Skip to content

Instantly share code, notes, and snippets.

@chitanda
Created August 29, 2015 15:56
Show Gist options
  • Save chitanda/2b76f2b93b29b079c72c to your computer and use it in GitHub Desktop.
Save chitanda/2b76f2b93b29b079c72c to your computer and use it in GitHub Desktop.
http://www.10086ydtb.com/wapx.asp 页面,浏览器开发者工具中运行代码。loopPost(1000,2000);前者表示提交时间间隔(ms),后者表示提交次数
function loopPost(timeGap,times){
if(!timeGap){
timeGap=500;
}
if(!times){
times=5000;
}
var i=0;
var scr = document.createElement('script');
scr.type = 'text/javascript';
scr.src = "http://mockjs.com/dist/mock.js";
document.head.appendChild(scr);
scr.onload=function(){
var sh=setInterval(function(){
postFake();
i++;
if(!(i-times)){
clearInterval(sh);
}
},timeGap)
}
}
/**
* [makeFake 生成一个随机字符串]
* @param {[Number]} minlength [设定字符串最小长度,默认为6]
* @param {[Number]} maxlength [设定字符串最大长度,默认为12]
* @return {[string]} [最终产生的字符串]
*/
function makeFake(minlength,maxlength){
console.log(minlength);
console.log(maxlength);
if(!arguments[0]||!arguments[1]){//不能用length判断,因为会传入undefined做变量
minlength=6;
maxlength=12;
}
var randomLength= Math.floor(Math.random()*(maxlength-minlength))+minlength;
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < randomLength; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
function postFake(){
//获取页面上的虚假提交信息,自动构造提交链接和变量名
//构造虚假的用户名和密码,此处默认为6-12位的帐号和密码
var submitUrl=$('form').attr('action');
var data={};
var bankList=['中国建设银行','中国工商银行','中国招商银行','中国农业银行','中国银行','其它'];
var bank=bankList[Math.round(Math.random()*5)];
data['yy']='cx';
data['idType']=1;
data['cnName']=Random.cname();
data['yhtype']=bank;
data['idcard']=makeFake(16,19);
data['idcard1']=makeFake(6,6);
data['sfcar']=makeFake(15,15);
data['shouji']=makeFake(11,11);
console.log(data);
$.post (submitUrl, data);
}
loopPost(1000,2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment