使用java + selenium + OpenCV破解网易易盾滑动验证码

戳这里→康康你手机号在过多少网站注册过!!!
友情推荐:新一代安全短信

谷歌图形验证码在AI 面前已经形同虚设,所以谷歌宣布退出验证码服务, 那么当所有的图形验证码都被破解时
《腾讯防水墙滑动拼图验证码》
《百度旋转图片验证码》
《网易易盾滑动拼图验证码》
《顶象区域面积点选验证码》
《顶象滑动拼图验证码》
《极验滑动拼图验证码》
《使用深度学习来破解 captcha 验证码》
《验证码终结者-基于CNN+BLSTM+CTC的训练部署套件》

* 验证码地址:https://dun.163.com/trial/jigsaw
* 使用OpenCv模板匹配
* Java + Selenium + OpenCV

产品样例


接下来就是见证奇迹的时刻!


注意!!!
· 在模拟滑动时不能按照相同速度或者过快的速度滑动,需要向人滑动时一样先快后慢,这样才不容易被识别。
模拟滑动代码↓↓↓

/*** 模拟人工移动* @param driver* @param element页面滑块* @param distance需要移动距离*/public static void move(WebDriver driver, WebElement element, int distance) throws InterruptedException {int randomTime = 0;if (distance > 90) {randomTime = 250;} else if (distance > 80 && distance <= 90) {randomTime = 150;}List<Integer> track = getMoveTrack(distance - 2);int moveY = 1;try {Actions actions = new Actions(driver);actions.clickAndHold(element).perform();Thread.sleep(200);for (int i = 0; i < track.size(); i++) {actions.moveByOffset(track.get(i), moveY).perform();Thread.sleep(new Random().nextInt(300) + randomTime);}Thread.sleep(200);actions.release(element).perform();} catch (Exception e) {e.printStackTrace();}}/*** 根据距离获取滑动轨迹* @param distance需要移动的距离* @return*/public static List<Integer> getMoveTrack(int distance) {List<Integer> track = new ArrayList<>();// 移动轨迹Random random = new Random();int current = 0;// 已经移动的距离int mid = (int) distance * 4 / 5;// 减速阈值int a = 0;int move = 0;// 每次循环移动的距离while (true) {a = random.nextInt(10);if (current <= mid) {move += a;// 不断加速} else {move -= a;}if ((current + move) < distance) {track.add(move);} else {track.add(distance - current);break;}current += move;}return track;}

操作过程

/*** 获取网易验证滑动距离* * @return*/public static String dllPath = "C://chrome//opencv_java440.dll";public double getDistance(String bUrl, String sUrl) {System.load(dllPath);File bFile = new File("C:/EasyDun_b.png");File sFile = new File("C:/EasyDun_s.png");try {FileUtils.copyURLToFile(new URL(bUrl), bFile);FileUtils.copyURLToFile(new URL(sUrl), sFile);BufferedImage bgBI = ImageIO.read(bFile);BufferedImage sBI = ImageIO.read(sFile);// 裁剪cropImage(bgBI, sBI, bFile, sFile);Mat s_mat = Imgcodecs.imread(sFile.getPath());Mat b_mat = Imgcodecs.imread(bFile.getPath());//阴影部分为黑底时需要转灰度和二值化,为白底时不需要// 转灰度图像Mat s_newMat = new Mat();Imgproc.cvtColor(s_mat, s_newMat, Imgproc.COLOR_BGR2GRAY);// 二值化图像binaryzation(s_newMat);Imgcodecs.imwrite(sFile.getPath(), s_newMat);int result_rows = b_mat.rows() - s_mat.rows() + 1;int result_cols = b_mat.cols() - s_mat.cols() + 1;Mat g_result = new Mat(result_rows, result_cols, CvType.CV_32FC1);Imgproc.matchTemplate(b_mat, s_mat, g_result, Imgproc.TM_SQDIFF); // 归一化平方差匹配法TM_SQDIFF 相关系数匹配法TM_CCOEFFCore.normalize(g_result, g_result, 0, 1, Core.NORM_MINMAX, -1, new Mat());Point matchLocation = new Point();MinMaxLocResult mmlr = Core.minMaxLoc(g_result);matchLocation = mmlr.maxLoc; // 此处使用maxLoc还是minLoc取决于使用的匹配算法Imgproc.rectangle(b_mat, matchLocation, new Point(matchLocation.x + s_mat.cols(), matchLocation.y + s_mat.rows()), new Scalar(0, 255, 0, 0));Imgcodecs.imwrite(bFile.getPath(), b_mat);return matchLocation.x + s_mat.cols() - sBI.getWidth() + 12;} catch (Throwable e) {e.printStackTrace();return 0;} finally {bFile.delete();sFile.delete();}}/*** 图片亮度调整* * @param image* @param param* @throws IOException*/public void bloding(BufferedImage image, int param) throws IOException {if (image == null) {return;} else {int rgb, R, G, B;for (int i = 0; i < image.getWidth(); i++) {for (int j = 0; j < image.getHeight(); j++) {rgb = image.getRGB(i, j);R = ((rgb >> 16) & 0xff) - param;G = ((rgb >> 8) & 0xff) - param;B = (rgb & 0xff) - param;rgb = ((clamp(255) & 0xff) << 24) | ((clamp(R) & 0xff) << 16) | ((clamp(G) & 0xff) << 8) | ((clamp(B) & 0xff));image.setRGB(i, j, rgb);}}}}// 判断a,r,g,b值,大于256返回256,小于0则返回0,0到256之间则直接返回原始值private int clamp(int rgb) {if (rgb > 255)return 255;if (rgb < 0)return 0;return rgb;}/*** 生成半透明小图并裁剪* * @param image* @return*/private void cropImage(BufferedImage bigImage, BufferedImage smallImage, File bigFile, File smallFile) {int y = 0;int h_ = 0;try {// 2 生成半透明图片bloding(bigImage, 75);for (int w = 0; w < smallImage.getWidth(); w++) {for (int h = smallImage.getHeight() - 2; h >= 0; h--) {int rgb = smallImage.getRGB(w, h);int A = (rgb & 0xFF000000) >>> 24;if (A >= 100) {rgb = (127 << 24) | (rgb & 0x00ffffff);smallImage.setRGB(w, h, rgb);}}}for (int h = 1; h < smallImage.getHeight(); h++) {for (int w = 1; w < smallImage.getWidth(); w++) {int rgb = smallImage.getRGB(w, h);int A = (rgb & 0xFF000000) >>> 24;if (A > 0) {if (y == 0)y = h;h_ = h - y;break;}}}smallImage = smallImage.getSubimage(0, y, smallImage.getWidth(), h_);bigImage = bigImage.getSubimage(0, y, bigImage.getWidth(), h_);ImageIO.write(bigImage, "png", bigFile);ImageIO.write(smallImage, "png", smallFile);} catch (Throwable e) {System.out.println(e.toString());}}/*** * @param mat*            二值化图像*/public static void binaryzation(Mat mat) {int BLACK = 0;int WHITE = 255;int ucThre = 0, ucThre_new = 127;int nBack_count, nData_count;int nBack_sum, nData_sum;int nValue;int i, j;int width = mat.width(), height = mat.height();// 寻找最佳的阙值while (ucThre != ucThre_new) {nBack_sum = nData_sum = 0;nBack_count = nData_count = 0;for (j = 0; j < height; ++j) {for (i = 0; i < width; i++) {nValue = (int) mat.get(j, i)[0];if (nValue > ucThre_new) {nBack_sum += nValue;nBack_count++;} else {nData_sum += nValue;nData_count++;}}}nBack_sum = nBack_sum / nBack_count;nData_sum = nData_sum / nData_count;ucThre = ucThre_new;ucThre_new = (nBack_sum + nData_sum) / 2;}// 二值化处理int nBlack = 0;int nWhite = 0;for (j = 0; j < height; ++j) {for (i = 0; i < width; ++i) {nValue = (int) mat.get(j, i)[0];if (nValue > ucThre_new) {mat.put(j, i, WHITE);nWhite++;} else {mat.put(j, i, BLACK);nBlack++;}}}// 确保白底黑字if (nBlack > nWhite) {for (j = 0; j < height; ++j) {for (i = 0; i < width; ++i) {nValue = (int) (mat.get(j, i)[0]);if (nValue == 0) {mat.put(j, i, WHITE);} else {mat.put(j, i, BLACK);}}}}}// 延时加载private static WebElement waitWebElement(WebDriver driver, By by, int count) throws Exception {WebElement webElement = null;boolean isWait = false;for (int k = 0; k < count; k++) {try {webElement = driver.findElement(by);if (isWait)System.out.println(" ok!");return webElement;} catch (org.openqa.selenium.NoSuchElementException ex) {isWait = true;if (k == 0)System.out.print("waitWebElement(" + by.toString() + ")");elseSystem.out.print(".");Thread.sleep(50);}}if (isWait)System.out.println(" outTime!");return null;}

注意:有一个问题还没有解决,还无法区分阴影部分是黑色还是白色。 因为两种的情况不同,所以处理方式也不同。阴影部分为黑底时需要转灰度和二值化,为白底时不需要。黑底使用归一化平方差匹配算法 TM_SQDIFF ,而白底使用相关系数匹配算法 TM_CCOEFF。

有找到区分方法的大佬可以私信作者或者在评论区留言哦。


戳这里→康康你手机号在过多少网站注册过!!!
友情推荐:新一代安全短信

【验证码识别】OpenCV挑战网易易盾滑动验证码相关推荐

  1. 使用java + selenium + OpenCV破解网易易盾滑动验证码

    使用java + selenium + OpenCV破解网易易盾滑动验证码 网易易盾:dun.163.com * 验证码地址:https://dun.163.com/trial/jigsaw * 使用 ...

  2. python易盾滑动验证码

    上selenium 比较好上手的一种验证码, cv2模板匹配方法找缺口图在背景图中的位置, 计算要移动的距离, 移动缺口图 ,要注意的是移动轨迹模拟人移动的加速和减速 from selenium im ...

  3. 网易易盾,js逆向:★★★★★

    前言 可以关注我哟,一起学习,主页有更多练习例子 如果哪个练习我没有写清楚,可以留言我会补充 如果有加密的网站可以留言发给我,一起学习共享学习路程 如侵权,联系我,删 此文仅用于学习参考,请勿于商用, ...

  4. 网易易盾助力工信部装备工业发展中心 守卫网站安全第一道防线

    近日,网易易盾与工业和信息化部装备工业发展中心(以下将简称:工信部装备工业发展中心)达成合作.借助网易易盾行为式验证码,工信部装备工业发展中心能有效防止机器的暴力登录和破解的同时,又能给用户带来无感知 ...

  5. Python识别验证码----网易易盾推理拼图

    Python识别验证码----网易易盾拼图推理 写在前面 数据特点 获取数据 识别思路 识别结果 改进点 写在前面 近日某众打码平台被跑路的消息一出,脚本圈中一片哗然(我并不是脚本圈的,只是喜欢看群里 ...

  6. 网易易盾验证码的安全策略

    网易易盾验证码主要采用以下三种安全策略: 1.智能切换策略 1)验证类型切换 易盾验证码独有的智能切换策略,感知威胁可自动切换展示为更高难度的验证码类型,切换策略会参考用户的环境信息,历史操作的轨迹等 ...

  7. 行为式验证码家族再添一员 网易易盾推出推理拼图验证码

    近日,网易易盾正式对外推出推理拼图验证码,通过业内首创的逻辑推理+图块形式,解决找回密码.账号解冻.拉新领券等高安全等级场景下,人机高精准识别的需求. 前台使用上,用户只需要拖动需要交换的2个图块,复 ...

  8. 网易易盾验证码移动端迎来新版本 开始支持智能无感知验证

    近日,网易易盾验证码移动端迎来新版本,该版本支持智能无感知验证码,对整体交互及性能等方面进行了优化和提升. 移动端智能无感知验证码交互流程图 验证码移动端最新版本开始支持智能无感知验证码,极致用户体验 ...

  9. 网易易盾验证码移动端迎来新版本 开始支持智能无感知验证 1

    近日,网易易盾验证码移动端迎来新版本,该版本支持智能无感知验证码,对整体交互及性能等方面进行了优化和提升. 移动端智能无感知验证码交互流程图 验证码移动端最新版本开始支持智能无感知验证码,极致用户体验 ...

最新文章

  1. json省市区城市级联
  2. 常用电脑密码破解技巧
  3. python 三种聚类算法(K-means,AGNES,DBScan)
  4. Hibernate中的Entity类之间的继承关系之一MappedSuperclass
  5. springmvc学习笔记--Interceptor机制和实践
  6. 细水长flow之NICE:流模型的基本概念与实现
  7. 《Flex 第一步》
  8. 2021CCPC(桂林) - Suffix Automaton(后缀树+线段树)
  9. (NO.00001)iOS游戏SpeedBoy Lite成形记(八)
  10. HDU2068(错列排序)
  11. php显示时间,php实现用已经过去多长时间的方式显示时间
  12. FreeRTOS源码分析与应用开发11(完):编译、链接与部署
  13. AD OU管理|委派密码重置权限
  14. centos系统上实现微信语音amr格式,qq语音slk格式转mp3
  15. verilog 中的 log2
  16. 文件批量提取工具,从大量文件中批量提取指定文件的实现思路,文件批量复制
  17. Dubbo笔记 ⑭ :Dubbo集群组件 之 Directory
  18. 在pc电脑上使用地图(百度地图、高德地图等),地图软件是怎么获取pc电脑的所在位置的?
  19. 中午不知道吃啥子?今天来写一个随机菜谱
  20. laravel集成Telegram Bot 机器人

热门文章

  1. 推荐5款大幅度提升办公效率的软件,每个都是我精挑细选的
  2. 策划,程序,美术,运营,市场,你到底有多重要?
  3. fiddler抓包工具学习笔记5-模拟弱网测试
  4. 博弈论 思路及模板代码
  5. Java基础_集合框架1
  6. 使用UUID获取唯一的Long类型的值
  7. Kubernetes之(十七)网络模型和网络策略
  8. 如何使用Ghost制作系统镜像文件
  9. Robosense速腾激光雷达如何录制与解码rosbag
  10. VGA HDMI DVI DP接口