闲来无事听说12306验证码变了。据说还很高调的在微博公布。于是打开研究了一番。

打开登录界面还真是吓我一尿。高大上啊。

 

看了一下应该是依靠点击坐标识别的。打开firebug分析一下。

首先点击刷新或者开始验证。会触发一个get请求

GET /otn/passcodeNew/getPassCodeNew?module=login&rand=sjrand&0.3681193683748071 HTTP/1.1
Host: kyfw.12306.cn
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0 FirePHP/0.7.4
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: https://kyfw.12306.cn/otn/login/init
Cookie: JSESSIONID=38F9A61F0C63B193E1A0D36CA995781A; BIGipServerotn=149946890.38945.0000; current_captcha_type=Z
x-insight: activate
Connection: keep-alive

直接把https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew?module=login&rand=sjrand&0.3681193683748071放到浏览器打开

还真是验证码。

接着分析

 

 

POST /otn/passcodeNew/checkRandCodeAnsyn HTTP/1.1
Host: kyfw.12306.cn
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0 FirePHP/0.7.4
Accept: */*
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF