有些时候我们在渗透测试的时候需要提交一些假的http头信息或者一些post参数,这时候我们可以用nc来提交,命令是
nc -v www.test.com<abc.txt
其中www.test.com就是目标网站,abc.txt中就是需要提交的数据,比如我想往一个网页提交一个post参数的值。
页面代码是:
<?php $auth='0'; extract($_POST); if($auth == 1){ echo "private!"; } else{ echo "public"; } ?>
这段代码是我用来测试extract函数的变量覆盖漏洞的,原本是extract($_GET)的,这样的参数很好提交,只需在网址后面加上参数就可以,例如:http://www.test.com/lynx.php?auth=1,但是如果是extract($_POST)的呢?我想用nc提交POST请求是很帅的。
例如我提交的POST请求是:
POST /lynx.php HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/QVOD, application/QVOD, application/x-shockwave- flash, */* Referer: http://www.test.com/lynx.php Accept-Language: zh-cn Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; qihu theworld) Host: www.test.com Content-Length: 6 Connection: Keep-Alive Cache-Control: no-cache auth=1
其中的Content-Length:6,其中的6要根据“auth=1”这部分的数据长度变化,如果不正确,会得不到正确的处理。
如果不知道应该提交什么样的POST数据包,那么可以用WsockExpert抓下包,随便找个login页面,随便输入用户名和密码,然后看下POST数据包是什么样的,然后根据自己的需要修改一下就好。比如我抓的是:
POST http://run.keytrain.com/main/login.asp HTTP/1.0 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/QVOD, application/QVOD, application/x-shockwave-flash, */* Referer: http://run.keytrain.com/main/login.asp Accept-Language: zh-cn Content-Type: application/x-www-form-urlencoded Proxy-Connection: Keep-Alive User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; qihu theworld) Host: run.keytrain.com Content-Length: 71 Pragma: no-cache Cookie: ASPSESSIONIDCCDTBDBR=APMFAMPCFAJMFHNDNODLONFC login_state=retry&redirect=%2Fmain&userid=abc&password=adf&submit=Login
开始我没有修改Content-Length这部分的数据,导致得不到正确的结果。