前言
由于网站注册入口容易被呆板执行自动化步伐攻击,存在如下风险:
- 暴力破解暗码,造成用户信息泄漏,不符合国家品级保护的要求。
- 短信盗刷带来的拒绝服务风险 ,造成用户无法登陆、注册,大量收到垃圾短信的用户投诉导致短信通道被关停。
- 带来经济丧失,尤其是后付费客户,需要承担被盗刷造成的大额短信费 ,造成亏损无底洞。
所以大部分网站及App 都采取图形验证码或滑动验证码等交互解决方案, 但在呆板学习本领提高的当下,连百度这样的大厂都遭受攻击导致点名品评, 图形验证及交互验证方式的安全性到底怎样? 请看具体分析
一、 AI智能的发展给行为验证带来威胁
验证码本质上自带一层答案的语义,这本来是天然的区分人和自动步伐的地方,但在本日却未必,由于AI智能及CHATGPT等大模型的发展,呆板要识别也变得更加容易。
1、 目的识别框架
黑产破解者为了降低攻击本钱、提高破解效率,通常会利用收集的大量验证码图片样本,打码标注、构建模型网络、练习模型、测试模型,从而得到一个可持续识别图片答案的识别。目前,黑产针对验证码图片的破解最常用的主要是分类模型和相似模型。
2、 批量下载存储验证图片,共需要大数万张图片。
3、 黑产练习出一个高准确度的识别模型后,后续破解验证码时,通过识别模型就能直接获取答案坐标。
4、 借力大模型进行升级
俗话说:道高一尺,魔高一丈,在chatgpt大模型发展的今天,行为验证的方式无论怎么变格式,被破解只是时间而已,被伤害的反而是真实用户。
二、 智谱清言-会员注册入口
简介:北京智谱华章科技有限公司(简称“智谱”)致力于打造新一代认知智能大模型,专注于做大模型的中国创新。公司合作研发了中英双语千亿级超大规模预练习模型GLM-130B,并基于此推出对话模型ChatGLM,开源单卡版模型ChatGLM-6B。同时,团队还打造了AIGC模型及产品矩阵,包括AI提效助手智谱清言(chatglm.cn)、高效率代码模型CodeGeeX、多模态明白模型CogVLM和文生图模型CogView等。公司践行Model as a Service(MaaS)的市场理念,推出大模型MaaS开放平台(https://open.bigmodel.cn/),打造高效率、通用化的“模型即服务”AI开发新范式。通过认知大模型链接物理世界的亿级用户,智谱基于完整的模型生态和全流程技能支持,为千行百业带来持续创新与变革,加速迈向通用人工智能的期间。
智谱 AI 开放平台提供一系列具有不同功能和定价的大模型,包括通用大模型、超拟人大模型、图像大模型、向量大模型等,并且支持使用您的私有数据对模型进行微调。
三、 安全性分析陈诉:
采取数美的滑动验证码,容易被模拟器绕过头至逆向后暴力攻击,滑动拼图识别率在 95% 以上。
四、 测试方法:
前端界面分析,采取的是数美的滑动验证码, 网上有现成的逆向文章及视频参考,不过我们这次不消逆向, 只是采取模拟器的方式,关键点主要模拟器交互、距离识别和轨道算法3部分。
1. 模拟器交互部分
- private final String INDEX_URL = "https://chatglm.cn/main/alltoolsdetail?lang=zh";
- @Override
- public RetEntity send(WebDriver driver, String areaCode, String phone) {
- try {
- RetEntity retEntity = new RetEntity();
- driver.get(INDEX_URL);
- // 输入手机号
- WebElement phoneElement = ChromeDriverManager.waitElement(driver, By.xpath("//input[contains(@placeholder,'请输入手机号')]"), 10);
- phoneElement.sendKeys(phone);
- // 点击发送验证码按钮
- WebElement sendElemet = driver.findElement(By.xpath("//button/span[contains(text(),'获取验证码')]"));
- if (sendElemet == null) {
- return null;
- }
- boolean isRobot = false;
- if (isRobot) {
- RobotMove.click(947, 591);
- } else {
- sendElemet.click();
- }
- // 数美滑动按钮
- Thread.sleep(1000);
- WebElement tipsElement = ChromeDriverManager.waitElement(driver, By.className("shumei_captcha_slide_tips"), 10);
- String tips = (tipsElement != null) ? tipsElement.getText() : null;
- if (tips == null) {
- System.out.println("tips=" + tips);
- return null;
- }
- WebElement moveElement = driver.findElement(By.className("shumei_captcha_slide_btn"));
- Actions actions = new Actions(driver);
- actions.moveToElement(moveElement).perform();
- Thread.sleep(1000);
- String spCode = "autohome";
- long t = System.currentTimeMillis();
- String path = dataPath + "/" + spCode + "/" + t + "/";
- // 获取大图
- WebElement bigElement = driver.findElement(By.xpath("//img[@class='shumei_captcha_loaded_img_bg']"));
- String bgUrl = bigElement.getAttribute("src");
- if (bgUrl == null) {
- System.out.println("bgUrl=" + bgUrl);
- return retEntity;
- }
- File bFile = new File(path + "big.png");
- FileUtils.copyURLToFile(new URL(bgUrl), bFile);
- byte[] bigBytes = FileUtils.readFileToByteArray(bFile);
- // 获取小图
- WebElement smallElement = driver.findElement(By.xpath("//img[@class='shumei_captcha_loaded_img_fg']"));
- String smallUrl = smallElement.getAttribute("src");
- File smllFile = new File(path + "small.png");
- FileUtils.copyURLToFile(new URL(smallUrl), smllFile);
- byte[] smallBytes = FileUtils.readFileToByteArray(smllFile);
- if (smallUrl == null) {
- System.out.println("smallUrl=" + smallUrl);
- return retEntity;
- }
- String ckSum = GenChecksumUtil.genChecksum(bigBytes);
- Map<String, Double> outMap = cv2.getOpenCvDistance(ckSum, bigBytes, smallBytes, spCode, 2);
- // 计算距离
- BigDecimal openDistanceD = new BigDecimal(outMap.get("minX") * 0.5).setScale(0, BigDecimal.ROUND_HALF_UP);
- int distince = openDistanceD.intValue();
- System.out.println("distince=" + distince);
- ActionMove.move(driver, moveElement, distince);
- Thread.sleep(1000);
- WebElement msgElement = ChromeDriverManager.waitElement(driver, By.xpath("//button/span[contains(text(),'s')]"), 10);
- String msg = (msgElement != null && msgElement.isDisplayed()) ? msgElement.getText() : null;
- retEntity.setMsg("[" + tips + "->" + msg + "]");
- if (msg != null && msg.contains("s")) {
- retEntity.setRet(0);
- }
- return retEntity;
- } catch (Exception e) {
- System.out.println("phone=" + phone + ",e=" + e.toString());
- for (StackTraceElement ele : e.getStackTrace()) {
- System.out.println(ele.toString());
- }
- return null;
- } finally {
- driver.manage().deleteAllCookies();
- }
- }
-
复制代码
2. 距离识别
- /**
- *
- * @param ckSum
- * @param bigBytes
- * @param smallBytes
- * @param factory
- * @return { width, maxX }
- */
- public Map<String, Double> getOpenCvDistance(String ckSum, byte bigBytes[], byte smallBytes[], String factory, int border) {
- try {
- String basePath = ConstTable.codePath + factory + "/";
- File baseFile = new File(basePath);
- if (!baseFile.isDirectory()) {
- baseFile.mkdirs();
- }
- // 小图文件
- File smallFile = new File(basePath + ckSum + "_s.png");
- FileUtils.writeByteArrayToFile(smallFile, smallBytes);
- // 大图文件
- File bigFile = new File(basePath + ckSum + "_b.png");
- FileUtils.writeByteArrayToFile(bigFile, bigBytes);
- // 边框清理(去干扰)
- byte[] clearBoder = (border > 0) ? ImageIOHelper.clearBoder(smallBytes, border) : smallBytes;
- File tpFile = new File(basePath + ckSum + "_t.png");
- FileUtils.writeByteArrayToFile(tpFile, clearBoder);
- String resultFile = basePath + ckSum + "_o.png";
- return getWidth(tpFile.getAbsolutePath(), bigFile.getAbsolutePath(), resultFile);
- } catch (Throwable e) {
- logger.error("getMoveDistance() ckSum=" + ckSum + " " + e.toString());
- for (StackTraceElement elment : e.getStackTrace()) {
- logger.error(elment.toString());
- }
- return null;
- }
- }
- /**
- * Open Cv 图片模板匹配
- *
- * @param tpPath
- * 模板图片路径
- * @param bgPath
- * 目标图片路径
- * @return { width, maxX }
- */
- public Map<String, Double> getWidth(String tpPath, String bgPath, String resultFile) {
- try {
- Map<String, Integer> hlMap = new HashMap<String, Integer>();
- Rect rectCrop = clearWhite(tpPath, hlMap);
- Mat g_tem = Imgcodecs.imread(tpPath);
- Mat clearMat = g_tem.submat(rectCrop);
- Mat cvt = new Mat();
- Imgproc.cvtColor(clearMat, cvt, Imgproc.COLOR_RGB2GRAY);
- Mat edgesSlide = new Mat();
- Imgproc.Canny(cvt, edgesSlide, threshold1, threshold2);
- Mat cvtSlide = new Mat();
- Imgproc.cvtColor(edgesSlide, cvtSlide, Imgproc.COLOR_GRAY2RGB);
- Imgcodecs.imwrite(tpPath, cvtSlide);
- Mat bgOrign = Imgcodecs.imread(bgPath);
- int rowStart = hlMap.get("minY");
- int rowEnd = hlMap.get("maxY");
- // 当滑块的高度和背景图高度一致才做截取
- boolean isSub = (bgOrign.rows() == hlMap.get("rows"));
- Mat bgMat = (isSub) ? bgOrign.submat(rowStart, rowEnd, 0, bgOrign.cols()) : bgOrign;
- // 北京切割
- Mat edgesBg = new Mat();
- Imgproc.Canny(bgMat, edgesBg, threshold1, threshold2);
- Mat cvtBg = new Mat();
- Imgproc.cvtColor(edgesBg, cvtBg, Imgproc.COLOR_GRAY2RGB);
- int result_rows = cvtBg.rows() - cvtSlide.rows() + 1;
- int result_cols = cvtBg.cols() - cvtSlide.cols() + 1;
- Mat g_result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
- Imgproc.matchTemplate(cvtBg, cvtSlide, g_result, Imgproc.TM_CCOEFF_NORMED); // 归一化平方差匹配法
- // 归一化相关匹配法
- MinMaxLocResult minMaxLoc = Core.minMaxLoc(g_result);
- Point maxLoc = minMaxLoc.maxLoc;
- Imgproc.rectangle(cvtBg, maxLoc, new Point(maxLoc.x + cvtSlide.cols(), maxLoc.y + cvtSlide.rows()), new Scalar(0, 0, 255), 1);
- Imgcodecs.imwrite(resultFile, cvtBg);
- Map<String, Double> paramMap = new HashMap<String, Double>();
- paramMap.put("tpWidth", g_tem.cols() * 1.0);
- paramMap.put("bigWidth", cvtBg.cols() * 1.0);
- paramMap.put("width", cvtSlide.cols() * 1.0);
- paramMap.put("minX", maxLoc.x);
- paramMap.put("maxX", maxLoc.x + cvtSlide.cols());
- System.out.println("OpenCv2.getWidth() " + paramMap.toString());
- return paramMap;
- } catch (Throwable e) {
- System.out.println("getWidth() " + e.toString());
- logger.error("getWidth() " + e.toString());
- for (StackTraceElement elment : e.getStackTrace()) {
- logger.error(elment.toString());
- }
- return null;
- }
- }
- public Rect clearWhite(String smallPath, Map<String, Integer> hlMap) {
- try {
- Mat matrix = Imgcodecs.imread(smallPath);
- int rows = matrix.rows();// height -> y
- int cols = matrix.cols();// width -> x
- hlMap.put("rows", rows);
- hlMap.put("cols", cols);
- Double rgb;
- double[] arr;
- int minX = 255;
- int minY = 255;
- int maxX = 0;
- int maxY = 0;
- Color c;
- for (int x = 0; x < cols; x++) {
- for (int y = 0; y < rows; y++) {
- arr = matrix.get(y, x);
- rgb = 0.00;
- for (int i = 0; i < 3; i++) {
- rgb += arr[i];
- }
- c = new Color(rgb.intValue());
- int b = c.getBlue();
- int r = c.getRed();
- int g = c.getGreen();
- int sum = r + g + b;
- if (sum >= 5) {
- if (x <= minX)
- minX = x;
- else if (x >= maxX)
- maxX = x;
- if (y <= minY)
- minY = y;
- else if (y >= maxY)
- maxY = y;
- }
- }
- }
- int boder = 1;
- if (boder > 0) {
- minX = (minX > boder) ? minX - boder : 0;
- maxX = (maxX + boder < cols) ? maxX + boder : cols;
- minY = (minY > boder) ? minY - boder : 0;
- maxY = (maxY + boder < rows) ? maxY + boder : rows;
- }
- int width = (maxX - minX);
- int height = (maxY - minY);
- hlMap.put("minY", minY);
- hlMap.put("maxY", maxY);
- System.out.println("openCv2.clearWhite() [" + rows + ", " + cols + "],minX=" + minX + ",minY=" + minY + ",maxX=" + maxX + ",maxY=" + maxY + "->width=" + width + ",height=" + height);
- Rect rectCrop = new Rect(minX, minY, width, height);
- return rectCrop;
- } catch (Throwable e) {
- StringBuffer er = new StringBuffer("clearWrite() " + e.toString() + "\n");
- for (StackTraceElement elment : e.getStackTrace()) {
- er.append(elment.toString() + "\n");
- }
- logger.error(er.toString());
- System.out.println(er.toString());
- return null;
- }
- }
复制代码 3. 轨道天生及移动算法
- /**
- * 双轴轨道生成算法,主要实现平滑加速和减速
- *
- * @param distance
- * @return
- */
- public static List<Integer[]> getXyTrack(int distance) {
- boolean isPrn = false;
- List<Integer[]> track = new ArrayList<Integer[]>();// 移动轨迹
- try {
- int a = (int) (distance / 3.0) + random.nextInt(10);
- int h = 0, current = 0;// 已经移动的距离
- BigDecimal midRate = new BigDecimal(0.7 + (random.nextInt(10) / 100.00)).setScale(4, BigDecimal.ROUND_HALF_UP);
- BigDecimal mid = new BigDecimal(distance).multiply(midRate).setScale(0, BigDecimal.ROUND_HALF_UP);// 减速阈值
- BigDecimal move = null;// 每次循环移动的距离
- List<Integer[]> subList = new ArrayList<Integer[]>();// 移动轨迹
- boolean plus = true;
- Double t = 0.18, v = 0.00, v0;
- while (current <= distance) {
- h = random.nextInt(2);
- if (current > distance / 2) {
- h = h * -1;
- }
- v0 = v;
- v = v0 + a * t;
- move = new BigDecimal(v0 * t + 1 / 2 * a * t * t).setScale(4, BigDecimal.ROUND_HALF_UP);// 加速
- if (move.intValue() < 1)
- move = new BigDecimal(1L);
- if (plus) {
- track.add(new Integer[] { move.intValue(), h });
- } else {
- subList.add(0, new Integer[] { move.intValue(), h });
- }
- current += move.intValue();
- if (plus && current >= mid.intValue()) {
- plus = false;
- move = new BigDecimal(0L);
- v = 0.00;
- }
- }
- track.addAll(subList);
- int bk = current - distance;
- if (bk > 0) {
- for (int i = 0; i < bk; i++) {
- track.add(new Integer[] { -1, h });
- }
- }
- if (isPrn)
- System.out.println("getMoveTrack(" + midRate + ") a=" + a + ",distance=" + distance + " -> mid=" + mid.intValue() + " size=" + track.size());
- return track;
- } catch (Exception e) {
- System.out.print(e.toString());
- return null;
- }
- }
- /**
- * 模拟人工移动
- *
- * @param driver
- * @param element页面滑块
- * @param distance需要移动距离
- * @throws InterruptedException
- */
- public static void move(WebDriver driver, WebElement element, int distance) throws InterruptedException {
- List<Integer[]> track = getXyTrack(distance);
- if (track == null || track.size() < 1) {
- System.out.println("move() track=" + track);
- }
- int moveY, moveX;
- StringBuffer sb = new StringBuffer();
- try {
- Actions actions = new Actions(driver);
- actions.clickAndHold(element).perform();
- Thread.sleep(50);
- long begin, cost;
- Integer[] move;
- int sum = 0;
- for (int i = 0; i < track.size(); i++) {
- begin = System.currentTimeMillis();
- move = track.get(i);
- moveX = move[0];
- moveY = move[1];
- sum += moveX;
- if (moveX < 0) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- sb.append(moveX);
- }
- actions.moveByOffset(moveX, moveY).perform();
- cost = System.currentTimeMillis() - begin;
- if (cost < 5) {
- Thread.sleep(5 - cost);
- }
- }
- if (sb.length() > 0) {
- System.out.println("-----backspace[" + sb.toString() + "],sum=" + sum + ",distance=" + distance);
- }
- Thread.sleep(180);
- actions.release(element).perform();
- Thread.sleep(500);
- } catch (Exception e) {
- StringBuffer er = new StringBuffer("move() " + e.toString() + "\n");
- for (StackTraceElement elment : e.getStackTrace())
- er.append(elment.toString() + "\n");
- logger.error(er.toString());
- System.out.println(er.toString());
- }
- }
复制代码 4. OpenCv 表面匹配测试样例:
五丶结语
北京智谱华章科技有限公司(简称“智谱”)致力于打造新一代认知智能大模型,专注于做大模型的中国创新。公司合作研发了中英双语千亿级超大规模预练习模型GLM-130B,并基于此推出对话模型ChatGLM,开源单卡版模型ChatGLM-6B。同时,团队还打造了AIGC模型及产品矩阵,包括AI提效助手智谱清言(chatglm.cn)、高效率代码模型CodeGeeX、多模态明白模型CogVLM和文生图模型CogView等。公司践行Model as a Service(MaaS)的市场理念,推出大模型MaaS开放平台(https://open.bigmodel.cn/),打造高效率、通用化的“模型即服务”AI开发新范式。通过认知大模型链接物理世界的亿级用户,智谱基于完整的模型生态和全流程技能支持,为千行百业带来持续创新与变革,加速迈向通用人工智能的期间。
作为全球领先AI智能高科技企业,拥有雄厚的技能研发实力, 采取的却是普通的滑动验证产品, 该产品稳定并且市场占有率很高, 在肯定程度上提高了用户体验, 但安全性在呆板学习的今天, 已经无法应对攻击了,并且正是由于该产品普通, 所以在网上破解的文章和教学视频也是大量存在,并且经过验证滑动产品很容易被破解, 所以除了滑动验证方式, 格式百出的产品层出不穷,但本质就是捐躯用户体验来提高安全。
许多人在短信服务刚开始建立的阶段,大概不会在安全方面考虑太多,来由有许多。
比如:“ 需求这么赶,当然是先实现功能啊 ”,“ 业务量很小啦,体系就这么点人用,不怕的 ” , “ 我们怎么会被盯上呢,不大概的 ”等等。
有一些来由固然有道理,但是该来的总是会来的。前期欠下来的债,总是要还的。越早还,问题就越小,丧失就越低。
所以大家在安全方面还是要重视。(血淋淋的栗子!)#安全短信#
戳这里→康康你手机号在过多少网站注册过!!!
谷歌图形验证码在AI 眼前已经形同虚设,所以谷歌公布退出验证码服务, 那么当全部的图形验证码都被破解时,大家又该怎样做好防御呢?
>>相关阅读
《腾讯防水墙滑动拼图验证码》
《百度旋转图片验证码》
《网易易盾滑动拼图验证码》
《顶象区域面积点选验证码》
《顶象滑动拼图验证码》
《极验滑动拼图验证码》
《使用深度学习来破解 captcha 验证码》
《验证码闭幕者-基于CNN+BLSTM+CTC的练习摆设套件》
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |