Invoke-Webrequest asp登录表单

时间:2015-01-19 18:43:35

标签: forms powershell asp-classic

我试图从我的路由器中获取一些细节,特别是我的手机号码。我昨天有这个工作,然后我将这个块复制到一个更大的脚本并清除旧源。现在它不起作用,它让我疯狂。

$RtrMainPage = Invoke-WebRequest -Uri 'http://192.168.0.1'

$RtrLoginForm = $RtrMainPage.Forms
$RtrLoginForm.Fields["login_name"] = "admin"
$RtrLoginForm.Fields["login_pass"] = "password"

$LoginResp = Invoke-WebRequest -Uri 'http://192.168.0.1/login.cgi' -Method POST -Body $RtrLoginForm -SessionVariable RtrSes #-ContentType 'application/x-www-form-urlencoded'

$RtrIPReq = Invoke-WebRequest -Uri 'http://192.168.0.1/st_device.asp' -WebSession $RtrSes 

$RtrWANIp = $RtrIPReq.Forms[0].Fields.wan_current_ipaddr.split('/')[0]

这是响应标题

  

' HTTP / 1.0 200 Ok Pragma:no-cache   连接:关闭Cache-Control:no-cache Content-Type:text / html   日期:星期二,2013年7月23日20:45:35 GMT到期:0服务器:httpd

     

function redirect(){document.location.href =   '&#39 ;;} redirect();

以下是输入字段

innerHTML : 
innerText : 
outerHTML : <INPUT id=html_response_page type=hidden value=login.asp name=html_response_page>
outerText : 
tagName   : INPUT
id        : html_response_page
type      : hidden
value     : login.asp
name      : html_response_page

innerHTML : 
innerText : 
outerHTML : <INPUT id=login_name type=hidden name=login_name>
outerText : 
tagName   : INPUT
id        : login_name
type      : hidden
name      : login_name

innerHTML : 
innerText : 
outerHTML : <INPUT id=login_pass type=hidden name=login_pass>
outerText : 
tagName   : INPUT
id        : login_pass
type      : hidden
name      : login_pass

innerHTML : 
innerText : 
outerHTML : <INPUT id=graph_id type=hidden value=1c540 name=graph_id>
outerText : 
tagName   : INPUT
id        : graph_id
type      : hidden
value     : 1c540
name      : graph_id

innerHTML : 
innerText : 
outerHTML : <INPUT id=alert_id type=hidden value=0 name=alert_id>
outerText : 
tagName   : INPUT
id        : alert_id
type      : hidden
value     : 0
name      : alert_id

innerHTML : 
innerText : 
outerHTML : <INPUT tabIndex=120 onfocus=select(); id=log_pass type=password value="" name=log_pass>
outerText : 
tagName   : INPUT
tabIndex  : 120
onfocus   : select();
id        : log_pass
type      : password
value     : 
name      : log_pass

innerHTML : 
innerText : 
outerHTML : <INPUT onfocus=select(); id=graph_code maxLength=8 type=password value="" name=graph_code>
outerText : 
tagName   : INPUT
onfocus   : select();
id        : graph_code
maxLength : 8
type      : password
value     : 
name      : graph_code

innerHTML : 
innerText : 
outerHTML : <INPUT onclick="window.location.reload( true );" id=Refresh class=button_submit_padleft style="WIDTH: 120px" 
            type=button name=Refresh>
outerText : 
tagName   : INPUT
onclick   : window.location.reload( true );
id        : Refresh
class     : button_submit_padleft
style     : WIDTH: 120px
type      : button
name      : Refresh

innerHTML : 
innerText : 
outerHTML : <INPUT id=login class=button_submit_padleft style="WIDTH: 120px" type=submit name=login>
outerText : 
tagName   : INPUT
id        : login
class     : button_submit_padleft
style     : WIDTH: 120px
type      : submit
name      : login

我想也许我放弃了像

这样的领域
$RtrLoginForm.Fields["login"] = "submit"

但那并没有奏效。

无论如何,我的眼睛受伤,并会感激任何帮助。

0 个答案:

没有答案