本帖最后由 caruko 于 2013-2-12 14:23 编辑
代码使用了几个第三方工具
curl.exe 强大的网页提交工具,可以去百度搜索下载;
gdi.exe 批处理显示图片(用于显示验证码,使用自动验证码识别的可以不用下载 ); 论坛-第三方工具 可以找到下载,本人编写的那个,记得更改文件名为 gdip.exe(系统本身有gdi.exe);
cut.exe 论坛第三方找到的,用于截取字符的工具;
conset 论坛中有的第三方工具,方便获取curl输出用。
Calendar 论坛第三方工具,方便日期加减;
iconv.exe UTF-8 转编码工具,论坛有
使用代码,记得更改代码前几行中的 手机号,生日等:
关于:自动验证码识别,测试过UUWISE平台的(包含了非API代码),所以目前只能识别4个字的验证码,5字识别会失败!(需要使用API才能准确识别); 另外该平台付费,一个码大约1分钱,大家可以手动输码,有全自动要求的可以联系本人QQ:195319013。
因为没有打开网页,如果刷到奖品,需要使用fidder更改响应,才能拿奖。
得奖信息存在 prize.txt 中; 经测:奖品ID 215,201 没有领取必要。
- @echo off
- setlocal ENABLEDELAYEDEXPANSION
- ::下面一行为本机代理,fidder调试用
- ::set "daili=-x 127.0.0.1:8888"
- ::下面2行为 UUWISE 自动输码账户
- ::set username=....
- ::set password=...
- set ag=-A "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)"
-
- ::填入手机号码
- set phone=手机号
- ::起始日期
- set Bday=1980-01-01
- ::循环多少次日期
- set max=10
- :loop
- set /a k+=1
- for /f "skip=2 tokens=1-3 delims=年月日 " %%a in ('Calendar /A !Bday! 00:00:00 1 00:00:00') do (
- set /a yy=%%a,mm=%%b+100,dd=%%c+100
- set "Bday=%%a-%%b-%%c"
- set "nday=!yy!!mm:~-2!!dd:~-2!"
- )
- if !k! geq !max! exit
-
- :main
- conset /d @ >nul
- conset /d _ >nul
- set "@phone=!phone!"
- set "@birth=!nday!"
- call :putUser
- ::call :search
- call :topic
- call :lottery
- echo,!nday!
- call :拿奖 && goto :loop
- echo,剩余抽奖次数:!@count!
- if !@count! geq 1 (
- goto :main
- ) else (
- goto :loop
- )
- goto :eof
-
-
- :putUser
- echo,验证用户...
- 2>nul curl !ag! !daili! -b cookies.txt -c cookies.txt -d "phone=!@phone!&birth=!@birth!&validcode=!@validcode!&valid=!@valid!&_r=0.7948380977831662" -e http://www.baidu.com/chunjie/show/welcome http://www.baidu.com/chunjie/submit/checkusr |iconv -f utf-8 -c|conset _rjson=
- for /f "tokens=2-7 delims={}:," %%a in ('conset /v _rjson') do (
- if %%b=="4001" echo,"生日错误!"
- if %%b=="4002" echo,"手机号错误!"
- if %%b=="4003" (
- echo,"验证码错误!";
- call :getCoed
- call :putUser
- )
- if %%b=="5001" echo,"unable"
- if %%b=="6001" echo,"系统繁忙,请稍后再试^_^"
- if %%b=="0" (
- set /a auto=0
- echo,验证成功,得到搜索字串..
- call :stv %%c %%d
- call :stv %%e %%f
- )
- )
- set "@cookie=CJKEY=!@key!;CJEGG=1;CJPHONE=!@phone!;CJBIRTH=!@birth!"
- goto :eof
-
-
-
- :getCoed
- echo,获取验证码...
- 2>nul curl !ag! !daili! --cookie "!@cookie!" -b cookies.txt "http://www.baidu.com/chunjie/data/valid?phone=!@phone!&birth=!@birth!&_r=0.2951152564330317" |conset _rjson=
- for /f "tokens=1-3 delims={}," %%a in ('conset /v _rjson') do (
- for /f "tokens=1,2 delims=:" %%A in ("%%a") do (
- call :stv %%A %%B
- )
- for /f "tokens=1,2 delims=:" %%A in ("%%b") do (
- call :stv %%A %%B
- )
- for /f "tokens=1* delims=:" %%A in ("%%c") do (
- call :stv %%A %%B
- )
- )
- 2>nul curl !ag! !daili! "!@validUrl!" >code.jpg
- gdip "/t:cmd /c" code.jpg*250*150
- set /p @valid=请输入验证码:
- goto :eof
-
-
- :search
- echo,开始搜索,取得cookie...
- for /f "delims=" %%a in ('echo,!@query!^|urlencode.bat') do set "@query_URL=%%a"
- 2>nul curl !ag! !daili! -I -c cookies.txt -e "http://www.baidu.com/chunjie/show/welcome" "http://www.baidu.com/s?bhjc=zl&wd=!@query!" |findstr "Set-Cookie"|conset @Set-Cookie=
- for /f "tokens=1* delims=:" %%a in ('conset /v @Set-Cookie') do (
- for /f "tokens=1 delims=; " %%A in ("%%b") do (
- set @%%A
- set "@cookie=!@cookie!;%%A"
- )
- )
- goto :eof
-
- :topic
- echo,获取KEY...
- 2>nul curl !daili! -H "Cookie: !@cookie!" --cookie "!@cookie!" -c cookies.txt -e "http://www.baidu.com/s?bhjc=zl&wd=!@query_URL!" http://www.baidu.com/chunjie/show/topic >topic.txt
- cut topic.txt {errNo });|conset @top=
- set @top=errNo!@top!
- for %%a in (!@top!) do (
- for /f "tokens=1,2 delims=:" %%A in ("%%a") do (
- call :stv top_%%A %%B
- )
- )
- goto :eof
-
-
- :lottery
- echo,获取礼品...
- set /a ff=0
- 2>nul curl !daili! -H "Cookie: !@cookie!" --cookie "!@cookie!" -c cookies.txt -d "key=!@top_nextKey!&key1=areyoucheating&_r=0.8628629175014569" -e http://www.baidu.com/chunjie/show/topic http://www.baidu.com/chunjie/submit/lottery|iconv -f utf-8 -c|conset @prize=
- set @prize=!@prize::{=!
- set @prize=!@prize:{=!
- set @prize=!@prize:}=!
- set @prize=!@prize: =!
- for %%D in (!@prize!) do (
- for /f "tokens=1,2 delims=:" %%a in ("%%D") do (
- call :stv %%a %%b
- )
- )
- goto :eof
-
- :拿奖
- if not "!@prizeid!"=="" (
- msg * "你中奖了!注意拿奖!"
- echo,================================>>prize.txt
- set @>>prize.txt
- echo,================================>>prize.txt
- exit /b 0
- )
- exit /b 1
-
-
- :stv
- set "@%~1=%~2"
- goto :eof
-
-
- :自动识别验证码
- echo,正在自动识别验证码...
- curl -F "__EVENTTARGET=" -F "__EVENTARGUMENT=" -F "__VIEWSTATE=/wEPDwUKLTE3NDE4NzE0NQ9kFgJmD2QWAgIDD2QWAgIBDxYCHgdlbmN0eXBlBRNtdWx0aXBhcnQvZm9ybS1kYXRhFgICCw8WAh4EVGV4dAVL5rWL6K+V56ev5YiG5Y+v5ZCR5a6i5pyN6aKG5Y+W44CCPGEgaHJlZj0nVXNlclJlZy5hc3B4Jz7njJvlh7vmiJHms6jlhow8L2E+ZGSzCjPNYUlhvk8bVKkIiv+SjYK/eQ==" -F "__EVENTVALIDATION=/wEWBAKKjaLKDgKlhNbxBQKqw6i0BAKyjrOQAs5tN9SZNKrbdIQmtQWmWarKLf/a" -F "ctl00$ContentPlaceHolder1$txtUser=!username!" -F "ctl00$ContentPlaceHolder1$txtPass=!password!" -F "ctl00$ContentPlaceHolder1$file1=@code.jpg;type=image/jpeg" -F "ctl00$ContentPlaceHolder1$btnRecognize=开始识别" http://www.uuwise.com/OnlineDemo.aspx |conset _rjson=
- for /f "tokens=2,4 delims=:,)" %%a in ('conset /v _rjson') do (
- set "@valid=%%a"
- set "codeid=%%b"
- set "codeid=!codeid:'=!"
- copy code.jpg log\%%a_%%b.jpg
- echo,%%a,%%b,!date!!time!>>yzm.log
- )
- exit /b 0
复制代码
|