【发布时间】:2015-04-06 11:09:54
【问题描述】:
我正在登录一个站点(在我的局域网中),对于密码哈希,我需要 csrf 登录令牌。
此代码从站点加载 HTML 并将数据粘贴到 Richtextbox:
Dim tempcookies As New CookieContainer
Dim xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open("GET", "http://" & ipaddressbox.Text & "/html/home.html", False)
xmlhttp.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0")
xmlhttp.send()
If (xmlhttp.readyState = 4) Then
Dim XMLResponse As String = xmlhttp.responseText
tempcookies = xmlhttp.getResponseHeader("Set-Cookie")
logincookie = tempcookies
RichTextBox1.Text = XMLResponse + xmlhttp.getAllResponseHeaders()
End If
结果如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="csrf_token" content="bVH41vpXbsswSSfNt3Ifw1ZClIKf83Zg"/>
<meta name="csrf_token" content="586yr+JH0dwsLFWZcndPQpx4wGKErie6"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="../css/main.css" />
<script type="text/javascript" src="../lib/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../lib/log4javascript_lite.js"></script>
<script type="text/javascript" src="../lib/jquery.qtip.js"></script>
<script type="text/javascript" src="../js/changelang.js"></script>
<script type="text/javascript" src="../js/main.js"></script>
<script type="text/javascript" src="../js/redirect.js"></script>
<script type="text/javascript" src="../js/validation.js"></script>
<script type="text/javascript" src="../js/home.js"></script>
<title></title>
</head>
<body>
<div id="all_content" class="body_bg">
<div id="login_wrapper" class="login_wrapper_dim">
.....etc, continues....
我需要从以下位置获取字符串:meta name="csrf_token" content="THESTRING" 并从第二个 csrf_token 中得到具体说明。
我怎样才能做到这一点? 谢谢!
【问题讨论】:
标签: html vb.net parsing metadata token