一个网络设备的web页面采用https登录抓包分析如下:
[HTML] 纯文本查看 复制代码 General
Remote Address:10.196.2.88:443
Request URL:https://10.196.2.88/login.cgi
Request Method:POST
Status Code:302 Found
Response Headers
view source
Content-Type:text/html
Date:Thu, 03 Apr 2014 21:04:28 GMT
Location:/index.cgi
Server:lighttpd/1.4.31
Set-cookie:show_security_warning=true
Set-cookie:ui_language=en_US; expires=Tuesday, 19-Jan-38 03:14:07 GMT
Transfer-Encoding:chunked
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4,zh-TW;q=0.2
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:332
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryr60VxcDvNBmAnJOB
Cookie:last_check=1450059028693; netCollapsed=%23headerIfaces%2C%23headerAliases%2C%23headerVlan%2C%23headerBridge%2C%23headerFirewall%2C%23headerRoutes%2C%23headerPortFwd%2C%23headerIgmp%2C%23headerTShaping; AIROS_SESSIONID=3a29cd933a8fbda0f7a44d00b7ff7a6d; show_security_warning=true; ui_language=en_US
Host:10.196.2.88
Origin:https://10.196.2.88
Referer:https://10.196.2.88/login.cgi
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Request Payload
------WebKitFormBoundaryr60VxcDvNBmAnJOB
Content-Disposition: form-data; name="uri"
------WebKitFormBoundaryr60VxcDvNBmAnJOB
Content-Disposition: form-data; name="username"
myusername
------WebKitFormBoundaryr60VxcDvNBmAnJOB
Content-Disposition: form-data; name="password"
mypassword
------WebKitFormBoundaryr60VxcDvNBmAnJOB--
我下载了证书,可以获取https页面内容,登录后有获取到cookie,但不知道这是不是登录成功了(因为密码写错,也能获取到cookie)。
帮忙看看,我的代码如下:
[C#] 纯文本查看 复制代码
HttpHelper http = new HttpHelper();
string p1 = null;
p1 = addpost(p1, "uri", "");
p1 = addpost(p1, "username", "myusername");
p1 = addpost(p1, "password", "mypassword");
HttpItem item = new HttpItem()
{
URL = "https://10.196.2.88/login.cgi",
Encoding = System.Text.Encoding.UTF8,
Method = "post",
Postdata = p1,
CerPath = "C:\\zhengshu.cer",
ContentType = "multipart/form-data; boundary=----WebKitFormBoundaryZ9IStEDwVADgmWWH",
Expect100Continue = false,
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
KeepAlive = true,
};
HttpResult result = http.GetHtml(item);
string html = result.Html;
string cookie = string.Empty;
foreach (CookieItem s in HttpCookieHelper.GetCookieList(result.Cookie))
{
if (s.Key.Contains("AIROS_SESSIONID"))
{
cookie += HttpCookieHelper.CookieFormat(s.Key, s.Value);
}
}
textBox1.Text = "cookie=" + cookie;
item = new HttpItem()
{
URL = "https://10.196.2.88/network.cgi",
Cookie = cookie,//==================这里直接写=result.cookie也不行
Referer = "",
Postdata = "",
Timeout = 100000,
ReadWriteTimeout = 30000,
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
ContentType = "application/x-www-form-urlencoded",
Allowautoredirect = true,
Expect100Continue = false,
};
result = http.GetHtml(item);
html = result.Html;
|