0
我做登录网站(在我的LAN)和密码的哈希值,我需要CSRF登录令牌。Visual Basic中如何获得<META NAME =“csrf_token” CONTENT =”从HTML字符串
此代码加载从网站和粘贴数据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。
我该如何设法做到这一点? 谢谢!