请求:
[root@ test]$ telnet 51hired.com 80
Trying 67.23.27.187...
Connected to 51hired.com.
Escape character is '^]'.
POST /login.php HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 22
user=abcde&psw=1234567
(abcde/1234567需要相应更改)
然后服务器会返回这么一坨东西:
HTTP/1.1 302 Found
Date: Thu, 11 Aug 2011 08:29:41 GMT
Server: Apache/2.2.11 (Unix) PHP/5.2.8
X-Powered-By: PHP/5.2.8
Set-Cookie: PHPSESSID=r8d4bvgtiklkehjv5o12fhbqo6; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: fuid=179255; expires=Sat, 10-Sep-2011 08:29:55 GMT; path=/
Location: index.php
Vary: Accept-Encoding,User-Agent
Content-Length: 0
Connection: close
Content-Type: text/html
重要的是Set-Cookie: PHPSESSID=r8d4bvgtiklkehjv5o12fhbqo6; path=/,
你可以手动修改浏览器PHPSESSID的COOKIE值,这样就登陆了。或者telnet请求时头上带上这个COOKIE也是一样的。
更新
也可以使用HTTP/1.1,但是必须加上Host:
POST /login.php HTTP/1.0
Host: 51hired.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 22