HttpClient破解联通充值,验证码不正确

louisgarcia 2011-06-01 10:59:20
请问一下各位,我在使用HttpClient破解联通充值时,验证码已经破解成功,这个可以保证,而且使用HttpWatch已经查到了需要发送的参数,而且保证正确,关键代码如下:

public String doMobileCharge(String pTel, String pCardPwd, int pAmt) throws IOException
{
String ret = "";
try
{
String checkCode = null;
String imagePath = null;
String CheckCodeCookie = null;
//下载图片到指定路径
while(true)
{
imagePath = m_Mask + ".jpeg";
if(null == (CheckCodeCookie = doGetImage(imagePath)))
{
continue;
}
System.out.println("imagePath:" + imagePath);

//对图片进行识别
OCR ocr = new OCR();
checkCode = ocr.recognizeText(new File(imagePath), "bmp", m_Mask + ".bmp");

if(checkCode.contains("\r\n"))
{
checkCode = checkCode.replaceAll("\r\n", "");
}

checkCode = checkCode.trim();
checkCode = checkCode.replaceAll(" ", "");
checkCode = checkCode.replaceAll(",", "");
checkCode = checkCode.replaceAll("'", "");
checkCode = checkCode.replaceAll("-", "");
new File(imagePath).delete();

if(null == checkCode || checkCode.trim().length() != 4)
{
continue;
}
try
{
Integer.parseInt(checkCode.trim());
break;
}
catch(Exception e)
{
checkCode = null;
sleep(1000);
continue;
}

}

if(null == checkCode)
return "21002";


String pData = "numbean.userNumBean.userSelNum=1&cardPwd="+pCardPwd+"&numbean.userNumBean.otherNum="+pTel+"&numbean.userNumBean.serviceType=03&verifyCode="
+checkCode;
PostMethod post = new PostMethod("http://upay.10010.com/web/Recharge/rechargeConfirm"); post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
post.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; CIBA; Media Center PC 6.0; InfoPath.2)");
post.setRequestHeader("Accept-Language","zh-CN");
post.setRequestHeader("Referer", "http://upay.10010.com/web/Recharge/rechargeInit");
post.setRequestHeader("Cookie", CheckCodeCookie);

RequestEntity entity = new StringRequestEntity(pData);
post.setRequestEntity(entity);

//指定请求内容的类型
int result = m_Client.executeMethod(post);
if(result != HttpStatus.SC_OK)
{
System.err.println( "doMobileCharge() -> Method failed:" + post.getStatusLine());
ret = "20000";
return ret;
}
InputStream is = post.getResponseBodyAsStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
StringBuilder sb = new StringBuilder();
String temp = null ;
while((temp = br.readLine())!= null){
System.out.println(temp);
sb.append(temp);
}
String response = sb.toString();
post.releaseConnection();
/************************************确认充值****************************************/
PostMethod post1 = new PostMethod("http://upay.10010.com/web/Recharge/rechargeResult");

post1.setRequestHeader("Cookie", CheckCodeCookie);
post.setRequestHeader("Referer", "http://upay.10010.com/web/Recharge/rechargeConfirm");
post1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

//指定请求内容的类型
int result1 = m_Client.executeMethod(post1);
if(result1 != HttpStatus.SC_OK)
{
System.err.println( "doTelCharge() -> Method failed:" + post1.getStatusLine());
ret = "20000";
return ret;
}
String response1 = post1.getResponseBodyAsString();
CommMethod.LOG("response1:"+response1);
post1.releaseConnection();

if(response1.contains("成功"))
{
ret = "00000";
}
else
{
ret = "21002";
}

}
catch(Exception ex)
{
ex.printStackTrace();
ret = "20000";
}
return ret;
}


在网上查看了一些,有种说法是Session问题,不过也没有确实有效的解决方案
在此请问一下大家,是怎么回事,验证码始终都不正确

得到验证码的关键代码

SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
Calendar c = Calendar.getInstance();
String time = format.format(c.getTime());
URL url = new URL("http://upay.10010.com/web/EsfWeb/VerifyCode.action?timestamp="+time);
HttpURLConnection huc =(HttpURLConnection)url.openConnection();
huc.connect();
InputStream is = huc.getInputStream();
//取得sessionID.
String cookieVal = huc.getHeaderField("Set-Cookie");
String sessionId = "";
if(cookieVal != null)
{
sessionId = cookieVal.substring(0, cookieVal.indexOf(";"));
}
System.out.println("sessionId:" + sessionId);


DataInputStream in_check = new DataInputStream(is);
DataOutputStream out = new DataOutputStream(new FileOutputStream(imagePath));
byte[] buffer = new byte[4096];
int count = 0;
while ((count = in_check.read(buffer)) > 0)
{
out.write(buffer, 0, count);
}
out.close();
in_check.close();

...全文
831 28 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
9807146wang 2013-12-23
  • 打赏
  • 举报
回复
老兄,我也在做此类程序,能说下验证码怎么识别的吗??多谢了。。
tony_1201 2011-10-22
  • 打赏
  • 举报
回复
楼主:你告诉我验证码的识别方法,我给你解决问题。
tony_1201 2011-10-13
  • 打赏
  • 举报
回复
楼主出来了,请指教我一下,我也正在学习这些功能
ttfadai 2011-07-16
  • 打赏
  • 举报
回复
正确的验证码地址应该是:"http://upay.10010.com/web/EsfWeb/VerifyCode.action?timestamp="+当前的日期时间.
ttfadai 2011-07-16
  • 打赏
  • 举报
回复
这个验证码难度到是不大.关键是在确认页面,提交以后.数据返回不正确的.
skyapplezhao 2011-06-17
  • 打赏
  • 举报
回复
你好楼主还在吗 搞定了没有?
xiangfeidecainiao 2011-06-17
  • 打赏
  • 举报
回复
LZ.可以透露下 验证码 破解的exe吗?
louisgarcia 2011-06-02
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 metsys 的回复:]
提交的应该是

http://upay.10010.com/web/Recharge/rechargeConfirm.action

多个.action
[/Quote]
通过HttpWatch查看过了,url确实是/web/Recharge/rechargeConfirm
而且,如果是少了.action这个扩展名,也许会提示其他错误,数据根本就提交不过去,我已经确定手机号码和充值卡号是被提交了的,用错误的手机号码充值,提示手机号码不正确
qiaoqiao85 2011-06-02
  • 打赏
  • 举报
回复
看不懂,学习一下……
xj199850412 2011-06-02
  • 打赏
  • 举报
回复
看不懂啊··想学习下
metsys 2011-06-02
  • 打赏
  • 举报
回复
提交的应该是

http://upay.10010.com/web/Recharge/rechargeConfirm.action

多个.action
chenchenyangll 2011-06-02
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 louisgarcia 的回复:]

引用 10 楼 chenchenyangll 的回复:
很好奇要是真搞成了 LZ会干啥

哈哈哈,我们有这个充值业务,每次充值抽取佣金,以前的老程序是可以的,现在联通的充值页改版了,程序也要跟着变化

充值卡肯定是正规的
[/Quote]

哦 我想歪了 = =
louisgarcia 2011-06-02
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 rmouse_2005 的回复:]
HTTPANALYZER监听下数据包
[/Quote]
HttpWatch是差不多的功能
rmouse_2005 2011-06-02
  • 打赏
  • 举报
回复
HTTPANALYZER监听下数据包
louisgarcia 2011-06-02
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 chenchenyangll 的回复:]
很好奇要是真搞成了 LZ会干啥
[/Quote]
哈哈哈,我们有这个充值业务,每次充值抽取佣金,以前的老程序是可以的,现在联通的充值页改版了,程序也要跟着变化

充值卡肯定是正规的
24K純帥 2011-06-02
  • 打赏
  • 举报
回复
有没有这么犀利的。。
louisgarcia 2011-06-02
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 skyapplezhao 的回复:]
提交验证验证码手机号和密码的页面是 http://upay.10010.com/web/Recharge/rechargeConfirm 这个不会错
传递时的几个hidden变量 看看都传递了没有?
楼主能私下的发过来验证码的破解吗 哈哈 我也看看提交了手机和密码是不是会出验证码错误
[/Quote]
这个可以肯定,都传递了,先前用HttpWatch查看到了所有应该传递的参数,不如是有参数没传递,会提示相应的错误,但是这次就提示验证码不正确,不知道验证码是否会与Session或者Cookie之类的东西绑定

关于破解验证码的,目前功能很少,但是基本能够保证正确性,这个问题也是老程序留下的,每次把验证码图片下载到本地,通过java调用DOS命令

List<String> cmd = new ArrayList<String>();
// if (OS.isWindowsXP())
// {
// cmd.add(tessPath + "\\tesseract");
// }
// else if (OS.isLinux())
// {
// cmd.add("tesseract");
// }
// else {
// cmd.add(tessPath + "\\tesseract");
// }
//cmd.add("c:\\tesseract\\tesseract");
cmd.add("D:\\tesseract\\tesseract");
cmd.add("");
cmd.add(outputFile.getName());
cmd.add(LANG_OPTION);
cmd.add("eng");

ProcessBuilder pb = new ProcessBuilder();
pb.directory(f2.getParentFile());

cmd.set(1, tempImage.getName());
pb.command(cmd);
pb.redirectErrorStream(true);
Process process = pb.start();

本地有个.exe文件用于破解图片中的验证码
skyapplezhao 2011-06-02
  • 打赏
  • 举报
回复
提交验证验证码手机号和密码的页面是 http://upay.10010.com/web/Recharge/rechargeConfirm 这个不会错
传递时的几个hidden变量 看看都传递了没有?
楼主能私下的发过来验证码的破解吗 哈哈 我也看看提交了手机和密码是不是会出验证码错误
chenchenyangll 2011-06-01
  • 打赏
  • 举报
回复
很好奇要是真搞成了 LZ会干啥
rocketball 2011-06-01
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 louisgarcia 的回复:]

LS的兄弟,破解验证码我已经确定成功了,但是每次把手机号码,充值卡号和验证码一起提交时,都得到验证码不正确的,而且验证码是最后判断的,输入错误的手机号码或者充值卡号,就会返回相应的错误,所以我确定是验证码不通过,求救解决方案
[/Quote]
那就是你得道的验证码不是它真正的验证码。我们公司已经会有两个验证码,第二个验证码(真正的验证码)会很快覆盖第一个验证码,你通过HTTPClient的方式你只能获取到一个。不知道联通是不是也是这么搞的
加载更多回复(8)

62,634

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧