如何做國外的電商網(wǎng)站設計廣告營銷的經(jīng)典案例
前言
由于網(wǎng)站注冊入口容易被黑客攻擊,存在如下安全問題:
- 暴力破解密碼,造成用戶信息泄露
- 短信盜刷的安全問題,影響業(yè)務及導致用戶投訴
- 帶來經(jīng)濟損失,尤其是后付費客戶,風險巨大,造成虧損無底洞
所以大部分網(wǎng)站及App 都采取圖形驗證碼或滑動驗證碼等交互解決方案, 但在機器學習能力提高的當下,連百度這樣的大廠都遭受攻擊導致點名批評, 圖形驗證及交互驗證方式的安全性到底如何?請看具體分析。
一、 PingPong PC端注冊入口
簡介:杭州乒乓智能技術有限公司(簡稱PingPong)成立于2015年,誕生于全球跨境電子交易蓬勃發(fā)展的浪潮中,是跨境行業(yè)的創(chuàng)新推動者。目前,PingPong在全球設有超30個分支機構,業(yè)務覆蓋超200個國家和地區(qū)。
以遍布全球的運營服務網(wǎng)絡、主流國家地區(qū)支付牌照和合規(guī)資質為依托, PingPong圍繞中小企業(yè)、科技企業(yè)、金融機構等出海的綜合需求,建立了涵蓋跨境收款、外貿B2B收付款、全球收單、全球分發(fā)、供應鏈融資、匯率風險中性解決方案、出口退稅、VAT稅務服務、企業(yè)費用管理、SaaS企業(yè)服務等多元化的產(chǎn)品矩陣,可為不同類型的客戶提供合規(guī)、安全、便捷的一站式數(shù)字化服務。
二、 安全性分析報告:
采用極驗的V2版本,容易被模擬器繞過甚至逆向后暴力攻擊,滑動拼圖識別率在 95% 以上。
三、 測試方法:
前端界面分析, 采用的是極驗2.0,最大特點就是將圖片做分割后,在前端再做合并,這就好辦了, 網(wǎng)上有大量現(xiàn)成的逆向文章及視頻參考,不過我們這次不用逆向, 只是采用模擬器的方式,關鍵點主要模擬器交互、距離識別和軌道算法3部分。
- 模擬器交互部分
public RetEntity send(WebDriver driver, String areaCode, String phone) {try {driver.get(INDEX_URL);// 輸入手機號WebElement phoneElement = driver.findElement(By.xpath("//input[@class='el-input__inner' and contains(@placeholder,'手機號')]"));phoneElement.click();for (int i = 0; i < phone.length(); i++) {phoneElement.sendKeys(String.valueOf(phone.charAt(i)));phoneElement.click();}// 點擊出現(xiàn)滑動圖WebElement clickElemet = ChromeDriverManager.waitElement(driver, By.className("position-right"), 10);clickElemet.click();Thread.sleep(2000);String msg = this.getText(driver);System.out.println("before msg=" + msg);if (msg == null || "獲取驗證碼".equals(msg)) {// 滑動結果boolean result = geetApi.getAndMove(driver, 6);if (result) {Thread.sleep(2000);msg = this.getText(driver);}System.out.println("after msg=" + msg + "->result=" + result);}RetEntity retEntity = new RetEntity();if (msg != null && msg.contains("再次發(fā)送")) {retEntity.setRet(0);retEntity.setMsg(msg);}return retEntity;} catch (Exception e) {System.out.println(e.toString());return null;} finally {driver.manage().deleteAllCookies();}}
- 獲取滑動圖片及調用移動交互
public boolean getAndMove(WebDriver driver, Integer offSet) {int distance = -1;try {WebElement moveElement = ChromeDriverManager.waitElement(driver, By.className("geetest_slider_button"), 1000);if (moveElement == null) {logger.error("getAndMove() moveElement=" + moveElement);return false;}// 下面的js代碼根據(jù)canvas文檔說明而來// 完整背景圖geetest_canvas_fullbg geetest_fade geetest_absoluteStringBuffer base64 = new StringBuffer();String fullName = "geetest_canvas_fullbg geetest_fade geetest_absolute";byte[] fullImg = GetImage.callJsByName(driver, fullName, base64);String bgName = "geetest_canvas_bg geetest_absolute";byte[] bgImg = GetImage.callJsByName(driver, bgName, base64);File fullFile = null, bgFile = null;if (fullImg != null && bgImg != null) {Long time = System.currentTimeMillis();fullFile = new File(dataPath + "geet/" + time + "full.png");FileUtils.writeByteArrayToFile(fullFile, fullImg);bgFile = new File(dataPath + "geet/" + time + "bg.png");FileUtils.writeByteArrayToFile(bgFile, bgImg);if (fullImg.length < 10000) {System.out.println("fullImg len=" + fullImg.length + " -> err[len<10000]");return false;}}// 獲取滑動距離并刪除圖片distance = (fullFile != null && bgFile != null) ? ActionMove.getMoveDistance(fullFile.getAbsolutePath(), bgFile.getAbsolutePath()) : -1;if (distance < 1) {logger.error("getAndMove distance=" + distance);return false;}if (offSet != null)ActionMove.move(driver, moveElement, distance - offSet);elseActionMove.move(driver, moveElement, distance);// 滑動結果Thread.sleep(1 * 1000);WebElement infoElement = ChromeDriverManager.getInstance().waitForLoad(By.className("geetest_result_content"), 10);String gtInfo = (infoElement != null) ? infoElement.getAttribute("innerText") : null;if (gtInfo != null) {System.out.println("gtInfo=" + gtInfo);if (gtInfo.contains("速度超過") || gtInfo.contains("通過驗證")) {return true;}} else {String msg = driver.findElement(By.className("geetest_panel_success_title")).getAttribute("innerText");System.out.println("msg=" + msg);}return false;} catch (Exception e) {System.out.println("getAndMove() " + e.toString());logger.error(e.toString());return false;}}
2. 距離識別
/*** 計算需要平移的距離* * @param fullImgPath* 完整背景圖片文件名* @param bgImgPath含有缺口背景圖片文件名* @return* @throws IOException*/public static int getMoveDistance(String fullImgPath, String bgImgPath) {System.out.println("fullImgPath=" + fullImgPath);File fullFile = new File(fullImgPath);File bgFile = new File(bgImgPath);boolean fullExists = fullFile.exists();boolean bgExists = bgFile.exists();if (fullExists && bgExists) {String abPath = bgFile.getAbsolutePath();int l = abPath.lastIndexOf(".");String out = abPath.substring(0, l) + "-o" + abPath.substring(l);return getComareImg(fullFile, bgFile, out);} else {System.out.println("fullExists(" + fullImgPath + ")=" + fullExists + "\nbgExists(" + bgImgPath + ")=" + bgExists);return -1;}}
/*** 計算需要平移的距離* * @param driver* @param fullImgPath完整背景圖片文件名* @param bgImgPath含有缺口背景圖片文件名* @return* @throws IOException*/private static int getComareImg(Object fullObj, Object bgObj, String out) {System.out.println("getComareImg() begin");try {if (fullObj == null || bgObj == null) {return -1;}BufferedImage fullBI = (fullObj instanceof File) ? ImageIO.read((File) fullObj) : ImageIO.read((ByteArrayInputStream) fullObj);BufferedImage bgBI = (bgObj instanceof File) ? ImageIO.read((File) bgObj) : ImageIO.read((ByteArrayInputStream) bgObj);List<Integer> list;Color ca, cb;Map<Integer, List<Integer>> xMap = new TreeMap<Integer, List<Integer>>();// 將頭35列的最大不同值取出, 作為右邊圖像的基礎差Long tifTotl = 0L;int tifLeft = 0;int tifCount = 0;for (int i = 0; i < bgBI.getWidth(); i++) {for (int j = 0; j < bgBI.getHeight(); j++) {ca = new Color(fullBI.getRGB(i, j));cb = new Color(bgBI.getRGB(i, j));int diff = diff(ca, cb);if (i <= 35 && tifLeft < diff) {tifLeft = (diff >= 255) ? 255 : diff;} else if (diff > tifLeft) {tifTotl += diff;tifCount++;}}}Long tifAvg = (tifCount > 0) ? (tifTotl / tifCount) : 0L;if (tifLeft <= 0 && tifAvg >= 2) {tifAvg = tifAvg / 2;}for (int i = 35; i < bgBI.getWidth(); i++) {for (int j = 0; j < bgBI.getHeight(); j++) {ca = new Color(fullBI.getRGB(i, j));cb = new Color(bgBI.getRGB(i, j));int diff = diff(ca, cb);if (diff >= tifAvg) {list = xMap.get(i);if (list == null) {list = new ArrayList<Integer>();xMap.put(i, list);}list.add(j);xMap.put(i, list);}}}System.out.println(" |--tifLeft=" + tifLeft + ",tifTotl=" + tifTotl + ",tifCount=" + tifCount + ",tifAvg=" + tifAvg + ",xMap.size=" + xMap.size());int minX = 0;int maxX = 0;for (Integer x : xMap.keySet()) {list = xMap.get(x);minX = (minX == 0) ? x : minX;maxX = x;for (int y : list) {cb = new Color(bgBI.getRGB(x, y));int gray = (int) (0.3 * cb.getRed() + 0.59 * cb.getGreen() + 0.11 * cb.getBlue());bgBI.setRGB(x, y, gray);}}// 標記直線位置for (int y = 0; y < bgBI.getHeight(); y++) {bgBI.setRGB(minX, y, Color.red.getRGB());}int width = maxX - minX;File destFile = new File(out);Thumbnails.of(bgBI).scale(1f).toFile(destFile);System.out.println(" |---xMap.size=" + xMap.size() + " minX=" + minX + ",maxX=" + maxX + ",width=" + width);return minX;} catch (Exception e) {System.out.println(e.toString());for (StackTraceElement elment : e.getStackTrace()) {System.out.println(elment.toString());}logger.error("getMoveDistance() err = " + e.toString());return 0;}}private static int diff(Color ca, Color cb) {int d = Math.abs(ca.getRed() - cb.getRed()) + Math.abs(ca.getGreen() - cb.getGreen()) + Math.abs(ca.getBlue() - ca.getBlue());return d;}
3. 軌道生成及移動算法
/*** 雙軸軌道生成算法,主要實現(xiàn)平滑加速和減速* * @param distance* @return*/public static List<Integer[]> getXyTrack(int distance) {List<Integer[]> track = new ArrayList<Integer[]>();// 移動軌跡try {int a = (int) (distance / 3.0) + random.nextInt(10);int h = 0, current = 0;// 已經(jīng)移動的距離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;// 每次循環(huán)移動的距離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 });}}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(20);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];sum += moveX;moveY = move[1];if (moveX < 0) {if (sb.length() > 0) {sb.append(",");}sb.append(moveX);}actions.moveByOffset(moveX, moveY).perform();cost = System.currentTimeMillis() - begin;if (cost < 3) {Thread.sleep(3 - 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());}}
- 圖片比對結果測試樣例:
四丶結語
PingPong 作為擁有支付牌照的支付公司, 跨境行業(yè)的創(chuàng)新推動者, 采用的是通俗的滑動驗證產(chǎn)品, 在一定程度上提高了用戶體驗, 不過隨著圖形識別技術及機器學習能力的提升,所以在網(wǎng)上破解的文章和教學視頻也是大量存在,并且經(jīng)過驗證的確有效, 所以除了滑動驗證方式, 花樣百出的產(chǎn)品層出不窮,但本質就是犧牲用戶體驗來提高安全。
很多人在短信服務剛開始建設的階段,可能不會在安全方面考慮太多,理由有很多。
比如:“ 需求這么趕,當然是先實現(xiàn)功能啊 ”,“ 業(yè)務量很小啦,系統(tǒng)就這么點人用,不怕的 ” , “ 我們怎么會被盯上呢,不可能的 ”等等。有一些理由雖然有道理,但是該來的總是會來的。前期欠下來的債,總是要還的。越早還,問題就越小,損失就越低。
所以大家在安全方面還是要重視。(血淋淋的栗子!)#安全短信#
戳這里→康康你手機號在過多少網(wǎng)站注冊過!!!
谷歌圖形驗證碼在AI 面前已經(jīng)形同虛設,所以谷歌宣布退出驗證碼服務, 那么當所有的圖形驗證碼都被破解時,大家又該如何做好防御呢?
>>相關閱讀
《騰訊防水墻滑動拼圖驗證碼》
《百度旋轉圖片驗證碼》
《網(wǎng)易易盾滑動拼圖驗證碼》
《頂象區(qū)域面積點選驗證碼》
《頂象滑動拼圖驗證碼》
《極驗滑動拼圖驗證碼》
《使用深度學習來破解 captcha 驗證碼》
《驗證碼終結者-基于CNN+BLSTM+CTC的訓練部署套件》