BBS的登陆——发帖——回帖
整体分析思路
1、首先手工熟悉一遍业务流程
2、录制脚本,选取协议,设置录制选项
1)Run-Time-Settings——Preferences——Options设置3个超时
2)Recording Options——Recording设置,选择HTML,web_url,web_submit_data
3、录制完成以后,优化一下脚本
1)将脚本里的函数都捋一遍,即函数对应的业务是什么,去掉无关的业务,保证脚本的简洁
2)做的事非整站的性能,可将EXTRARES里的脚本都删除掉
4、分析脚本
1)登陆
可将用户名参数化
2)发帖
a、将脚本回放,报错
b、发帖时会产生一个动态变化值,formhash
c、去网页源码里寻找formhash,在hidden域里找到formhash
<input type="hidden" name="mod" id="scbar_mod" value="search" /> <input type="hidden" name="formhash" value="b450c09e" /> <input type="hidden" name="srchtype" value="title" /> <input type="hidden" name="srhfid" value="2" id="dzsearchforumid" /> <input type="hidden" name="srhlocality" value="forum::post" /> <table cellspacing="0" cellpadding="0">
d、将formhash做关联,因为关联函数是预注册函数,需放在默认版块之前
//发帖、回帖均需要关联formhash值 //<input type="hidden" name="formhash" value="b450c09e" /> web_reg_save_param("formhash", "LB=name=\"formhash\" value=\"", "RB=\" />", LAST);
3)回帖
a、回帖时,tid是动态变化的值,需要做关联,(是对刚才新建的帖子进行回复,如不关联,如tid=4557,就会对编号是4557的帖子不断的回复)
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>发帖发帖 - 默认版块 - Discuz! Board - Powered by Discuz!</title> <link href="http://192.168.1.188/bbs/forum.php?mod=viewthread&tid=4587" rel="canonical" /> <meta name="keywords" content="发帖发帖" /> <meta name="description" content=" 发帖发帖 ,Discuz! Board" />
b、将tid做关联,关联函数是预注册的,需要发在发帖之前
//<link href="http://{ip}/bbs/forum.php?mod=viewthread&tid=4587" rel="canonical" /> //在对应的帖子下进行回复,需关联tid web_reg_save_param("tidnum", "LB=forum.php?mod=viewthread&tid=", "RB=\" rel=\"", LAST);
4、登陆——发帖——回帖(完整版)
Action() { //保存值函数 lr_save_string("192.168.1.188","ip"); //首页 web_url("forum.php", "URL=http://{ip}/bbs/forum.php", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t24.inf", "Mode=HTML", LAST); //登陆 web_submit_data("member.php", "Action=http://{ip}/bbs/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1", "Method=POST", "TargetFrame=", "RecContentType=text/xml", "Referer=http://{ip}/bbs/forum.php", "Snapshot=t25.inf", "Mode=HTML", ITEMDATA, "Name=fastloginfield", "Value=username", ENDITEM, "Name=username", "Value={uname}", ENDITEM, "Name=password", "Value=123123", ENDITEM, "Name=quickforward", "Value=yes", ENDITEM, "Name=handlekey", "Value=ls", ENDITEM, LAST); //<input type="hidden" name="formhash" value="b450c09e" /> //给发帖做关联 web_reg_save_param("formhash", "LB=type=\"hidden\" name=\"formhash\" value=\"", "RB=\" />", LAST); //进入默认版块 web_url("默认版块", "URL=http://{ip}/bbs/forum.php?mod=forumdisplay&fid=2", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://{ip}/bbs/forum.php", "Snapshot=t27.inf", "Mode=HTML", LAST); //给回帖做关联 //http://192.168.1.188/bbs/forum.php?mod=viewthread&tid=4580" rel="canonical" /> web_reg_save_param("tidno", "LB=forum.php?mod=viewthread&tid=", "RB=\" rel=", LAST); //发帖 web_submit_data("forum.php_4", "Action=http://{ip}/bbs/forum.php?mod=post&action=newthread&fid=2&extra=&topicsubmit=yes", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://{ip}/bbs/forum.php?mod=post&action=newthread&fid=2&referer=http%3A//{ip}/bbs/forum.php%3Fmod%3Dforumdisplay%26fid%3D2", "Snapshot=t29.inf", "Mode=HTML", ITEMDATA, "Name=formhash", "Value={formhash}", ENDITEM, //formhash是动态值 "Name=posttime", "Value=1439821219", ENDITEM, "Name=wysiwyg", "Value=1", ENDITEM, "Name=subject", "Value=艰苦学习", ENDITEM, "Name=message", "Value=成效卓越,加油", ENDITEM, "Name=replycredit_extcredits", "Value=0", ENDITEM, "Name=replycredit_times", "Value=1", ENDITEM, "Name=replycredit_membertimes", "Value=1", ENDITEM, "Name=replycredit_random", "Value=100", ENDITEM, "Name=readperm", "Value=", ENDITEM, "Name=price", "Value=", ENDITEM, "Name=tags", "Value=", ENDITEM, "Name=rushreplyfrom", "Value=", ENDITEM, "Name=rushreplyto", "Value=", ENDITEM, "Name=rewardfloor", "Value=", ENDITEM, "Name=stopfloor", "Value=", ENDITEM, "Name=save", "Value=", ENDITEM, "Name=usesig", "Value=1", ENDITEM, "Name=allownoticeauthor", "Value=1", ENDITEM, LAST); //回帖 web_submit_data("forum.php_5", "Action=http://{ip}/bbs/forum.php?mod=post&action=reply&fid=2&tid={tidno}&extra=&replysubmit=yes&infloat=yes&handlekey=fastpost&inajax=1", "Method=POST", "TargetFrame=", "RecContentType=text/xml", "Referer=http://{ip}/bbs/forum.php?mod=viewthread&tid={tidnum}&extra=", "Snapshot=t30.inf", "Mode=HTML", ITEMDATA, "Name=message", "Value=过来顶贴了", ENDITEM, "Name=posttime", "Value=1439821241", ENDITEM, "Name=formhash", "Value={formhash}", ENDITEM, "Name=subject", "Value=", ENDITEM, LAST); return 0; }