前言
由于網站注冊入口容易被黑客攻擊,存在如下安全問題:
- 暴力破解密碼,造成用戶信息泄露
- 短信盜刷的安全問題,影響業務及導致用戶投訴
- 帶來經濟損失,尤其是后付費客戶,風險巨大,造成虧損無底洞
所以大部分網站及App 都采取圖形驗證碼或滑動驗證碼等交互解決方案, 但在機器學習能力提高的當下,連百度這樣的大廠都遭受攻擊導致點名批評, 圖形驗證及交互驗證方式的安全性到底如何? 請看具體分析
一、 科學技術部政務服務平臺PC 注冊入口
簡介:科技部政務服務平臺是科學技術部深入推進科技領域“互聯網+政務服務”,整合共享科技政務信息資源,優化科技政務服務流程,更好發揮對科技創新的服務保障作用的綜合政務服務系統和信息技術應用體系,是全面推進科技部各類政務服務 “一網通辦”的一站式服務窗口。科技部政務服務平臺一方面承載科技部各類政務服務和信息資源,按照科技部政務服務事項統一對外開展政務服務;一方面與全國一體化在線政務服務平臺聯通,實現與國家各類政務數據資源的信息共享利用。
安全分析:
采用傳統的圖形驗證碼方式,具體為4個英文,ocr 識別率在 95% 以上。
?
測試方法:
采用模擬器+OCR識別
private OcrClientDddd ddddOcr = new OcrClientDddd();private static String INDEX_URL = "https://fuwu.most.gov.cn/mostreg/reg/zrr/step1";@Overridepublic RetEntity send(WebDriver driver, String areaCode, String phone) {RetEntity retEntity = new RetEntity();try {driver.get(INDEX_URL);Thread.sleep(1 * 1000);// 1 輸入手機號WebElement phoneElement = ChromeDriverManager.waitElement(driver, By.id("mobile"), 1);phoneElement.sendKeys(phone);Thread.sleep(1 * 1000);String imgCode, err;WebElement getCodeElement, alertElement, tipElement, confirmElement, inputElement;byte[] imgByte;for (int i = 0; i < 3; i++) {// 2 獲取圖形驗證碼imgByte = GetImage.callJsById(driver, "code2");int len = (imgByte != null) ? imgByte.length : 0;imgCode = (len > 0) ? ddddOcr.getImgCode(imgByte) : null;if (imgCode == null || imgCode.length() < 1) {System.out.println("len=" + len + ",imgCode=" + imgCode);return retEntity;}// 3 輸入識別出來的圖形驗證碼inputElement = driver.findElement(By.id("validateCode"));inputElement.clear();inputElement.sendKeys(imgCode);// 4 點擊獲取驗證碼Thread.sleep(1 * 1000);getCodeElement = driver.findElement(By.id("Submit3"));getCodeElement.click();Thread.sleep(1 * 1000);alertElement = ChromeDriverManager.waitElement(driver, By.id("layui-layer1"), 20);if (alertElement == null) {continue;}tipElement = alertElement.findElement(By.className("layui-layer-content"));err = (tipElement != null) ? tipElement.getText() : null;confirmElement = alertElement.findElement(By.tagName("a"));confirmElement.click();if (err != null && err.contains("手機驗證碼已發送")) {break;}}WebElement gtElement = driver.findElement(By.id("codetip"));String gtInfo = gtElement.getText();retEntity.setMsg(gtInfo);if (gtInfo.contains("秒后重新獲取")) {retEntity.setRet(0);return retEntity;} else {System.out.println("gtInfo=" + gtInfo);}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();}}
獲取圖形驗證碼
public String getImgCode(byte[] bigImage) {try {if (ddddUrl == null) {System.out.println("getImgCode() ddddUrl=" + ddddUrl);return null;}int len = (bigImage != null) ? bigImage.length : -1;if (len < 0) {System.out.println("getImgCode() len=" + len);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(10 * 1000);con.setReadTimeout(10 * 1000);con.setDoOutput(true);con.setDoInput(true);con.setUseCaches(true);con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);out = con.getOutputStream();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("getImgCode() ddddUrl=" + ddddUrl + ",len=" + len + "->ret=" + buffer.toString());}return buffer.toString();} catch (Throwable e) {logger.error("getImgCode() ddddUrl=" + ddddUrl + ",e=" + e.toString());return null;}}
測試返回結果:
測試報告 :
二丶結語
科技部政務服務平臺是科學技術部深入推進科技領域“互聯網+政務服務”,整合共享科技政務信息資源,優化科技政務服務流程,更好發揮對科技創新的服務保障作用的綜合政務服務系統和信息技術應用體系,是全面推進科技部各類政務服務 “一網通辦”的一站式服務窗口,作為中國最權威的權利機構, 采用的還是老一代的圖形驗證碼已經落伍了, 用戶體驗一般,容易被破解, 一旦被國際黑客發起攻擊,將會對老百姓形成騷擾,影響聲譽。
很多人在短信服務剛開始建設的階段,可能不會在安全方面考慮太多,理由有很多。
比如:“ 需求這么趕,當然是先實現功能啊 ”,“ 業務量很小啦,系統就這么點人用,不怕的 ” , “ 我們怎么會被盯上呢,不可能的 ”等等。有一些理由雖然有道理,但是該來的總是會來的。前期欠下來的債,總是要還的。越早還,問題就越小,損失就越低。
所以大家在安全方面還是要重視。(血淋淋的栗子!)#安全短信#
戳這里→康康你手機號在過多少網站注冊過!!!
谷歌圖形驗證碼在AI 面前已經形同虛設,所以谷歌宣布退出驗證碼服務, 那么當所有的圖形驗證碼都被破解時,大家又該如何做好防御呢?
>>相關閱讀
《騰訊防水墻滑動拼圖驗證碼》
《百度旋轉圖片驗證碼》
《網易易盾滑動拼圖驗證碼》
《頂象區域面積點選驗證碼》
《頂象滑動拼圖驗證碼》
《極驗滑動拼圖驗證碼》
《使用深度學習來破解 captcha 驗證碼》
《驗證碼終結者-基于CNN+BLSTM+CTC的訓練部署套件》