找回密码
 加入
搜索
查看: 3279|回复: 8

关于自动登陆WEB路由器管理检查端口转发防止内网机器被攻击。

[复制链接]
发表于 2009-6-27 16:59:00 | 显示全部楼层 |阅读模式
本帖最后由 mnm001 于 2009-6-28 16:33 编辑

目的就是我想自动登陆一般家庭用路由器管理页面。 检查转发规则是否被篡改。 却发现在内嵌的对象里打不开页面。新开的窗口却无法继承对象。 导致点击转发规则时会跳到页面错误。
基本上这个验证窗口是用JS 写的。 本来是准备问下, 可是2天了都没高人来回答, 于是自己解决了。 还就是为什么内嵌IE 却打不开站点。

具体代码见 6楼。 代码适合 TP-LINK 的路由。

这是调试代码 ,有些难看, 大家勉强一下自己的眼睛。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2009-6-27 17:35:56 | 显示全部楼层
想了想发现使用 ControlSetText 发送文本可以登陆这个窗口。
 楼主| 发表于 2009-6-27 17:45:41 | 显示全部楼层
$url = "http://192.168.0.1"
        $oIE = _IECreate ($url, 0, 1, 0, 1)
        Sleep(1000)
        ControlSetText('[REGEXPTITLE:连接到.+]', '', 1003, 'admin')
        ControlSetText('[REGEXPTITLE:连接到.+]', '', 1005, 'xxxxxx')
        ControlClick('[REGEXPTITLE:连接到.+]', '', 1)
        MsgBox(64,"2222",20)
        $sHTML = _IEBodyReadHTML ($oIE)
        $sHTML=StringRegExpReplace ($sHTML, "\r\n", "")
        $oLinks = _IELinkGetCollection ($oIE)
        MsgBox(64,"3333",20)
        If (StringInStr($oIE,"转发规则",2) > 0 ) Then
                MsgBox(64,"1111",20)
                _IELinkClickByText($oIE,"转发规则")
                If (StringInStr($sHTML,"1435",2) > 0 ) Then
                        MsgBox(64,"警告","转发规则被篡改",200)
                EndIf
        
        EndIf
另外写了个, 发现点不了转发规则。囧。
 楼主| 发表于 2009-6-28 09:09:32 | 显示全部楼层
囧, 居然没人回, 高人啊。
 楼主| 发表于 2009-6-28 13:18:31 | 显示全部楼层
本帖最后由 mnm001 于 2009-6-28 13:24 编辑

发现转发规则里的端口列表是保存在一个JS 里面的
<html>
<head>
</head>
<frameset framespacing="0" frameborder="no" cols="*" rows="94,*" border="0">
<frameset framespacing="0" frameborder="no" cols="185,*" rows="*" border="0">
<frame scrolling="no" noresize="" src="/frames/logo.htm" name="topLeftFrame">
<html>
<head>
<title>Logo</title>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type"/>
<meta content="no-cache" http-equiv="pragma"/>
<script language="javascript">
1
2<!--
3var newWin;
4var url="http://www.tp-link.com.cn"; //弹出页面的url
5
6if(window.parent == window) //如果页面不在框架中,则跳转到url
7 window.location.href=url;
8function Click(){ window.event.returnValue=false;}
9document.oncontextmenu=Click;
10
11function NewW()
12{
13 if(newWin) newWin.close();
14 newWin=window.open(url,"","scrollbars=yes,resizable=yes,toolbar=yes,status=yes,menubar=yes,scrollbar=yes,location=yes");
15 return true;
16}
17function ShowUrl() { //v1.0
18 status=url;
19 return true;
20}
21function EraseUrl()
22{
23 status="";
24 return true;
25}
26
27var address;
28var errorFlag;
29function LoadPage(){
30 if(true == errorFlag)
31 parent.location.href = 'http://' + address;
32}
33function LoadNewIp(){
34 errorFlag = true;
35 setTimeout("LoadPage()",3000);
36}
37function stopLoad(){
38 errorFlag = false;
39}
40
41//-->
42
</script>
<style type="text/css">
1<!--
2a.tp:visited{COLOR: #ffffff; TEXT-DECORATION: none; underline: none}
3a.tp:hover {COLOR: #ff4000; TEXT-DECORATION: none}
4a.tp:link {COLOR: #ffffff; TEXT-DECORATION: none; underline: none}
5.font {font-family: "Times New Roman", "宋体"; font-size: 12px;color: #FFFFFF;}
6-->
</style>
<meta content="no-cache" http-equiv="pragma"/>
</head>
<body bgcolor="#006699" background="/images/bgColor.jpg" topmargin="0" leftmargin="0">
<table class="font" width="185" height="94" cellspacing="0" cellpadding="0" border="0">
</table>
</body>
</html>
</frame>
<frame scrolling="no" noresize="" src="/userRpm/BannerRpm.htm" name="topRightFrame">
</frame>
</frameset>
<frameset framespacing="0" frameborder="no" cols="158,30,*" rows="*" border="0">
<frame scrolling="no" noresize="" src="/userRpm/MenuRpm.htm?MainID=0&SubID=0" name="bottomLeftFrame">
</frame>
<frame scrolling="no" noresize="" src="/frames/arc.htm" name="arcFrame">
<html>
<head>
<title>arc</title>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type"/>
</head>
<body topmargin="0" leftmargin="0">
<table width="40" height="80" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td valign="top" height="40" align="left" colspan="2">
<img width="30" height="31" src="/images/arc.jpg"/>
</td>
</tr>
</tbody>
</table>
</body>
</html>
</frame>
<frame src="/userRpm/MainRpm.htm" name="mainFrame">
<html>
<head>
<title>VirtualServer</title>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type"/>
<meta content="no-cache" http-equiv="pragma"/>
<meta content="wed, 26 Feb 1997 08:21:57 GMT" http-equiv="expires"/>
<link href="/dynaform/r410.css" type="text/css" rel="stylesheet">
1body {
2 font-size: 75%;
3 color: #003399;
4 background-color: #FFFFFF;
5 padding-top: 10px;
6 padding-left: 10px;
7 font-family: "宋体", "Times New Roman";
8
9}
10td {
11 font-size: 12px;
12 line-height: 18px;
13 text-decoration: none;
14
15}
16input.button {
17 font-size: 12px;
18 font-style: normal;
19 font-weight: normal;
20 font-variant: normal;
21 border: 1px solid #183ead;
22 line-height: normal;
23 background-color: #ddddff;
24 color: #000000;
25 height: 18px;
26}
27input.text {
28 font-size: 12px;
29 font-style: normal;
30 line-height: normal;
31 font-weight: normal;
32 font-variant: normal;
33 height: 18px;
34 border: 1px solid #183ead;
35 color: #000000;
36 padding-right: 3px;
37 padding-left: 3px;
38}
39td.title {
40 font-size: 12px;
41 color: #FFFFFF;
42 background-color: #6699FF;
43 height: 24px;
44}
45td.tail {
46 font-size: 12px;
47 height: 25px;
48}
49td.hline {
50 background-color: #FF9933;
51 height: 1px;
52 color: #FF9933;
53}
54td.vline {
55 color: #FF9933;
56 background-color: #FF9933;
57 width: 1px;
58}
59.space {
60 margin-top: 10px;
61 margin-bottom: 10px;
62}
63table {
64 background-color: #F5F5F5;
65}
66select.list {
67 font-size: 12px;
68 font-style: normal;
69 line-height: normal;
70 font-weight: normal;
71 font-variant: normal;
72 height: 18px;
73 color: #000000;
74 border: 1px solid #183ead;
75}
76input.buttonface {
77 font-size: 12px;
78 font-style: normal;
79 font-weight: normal;
80 font-variant: normal;
81 border: 1px solid #183ead;
82 line-height: normal;
83 background-color: #ddddff;
84 color: #000000;
85 height: 18px;
86}
87td.top {
88 font-size: 12px;
89 line-height: 18px;
90 text-decoration: none;
91 vertical-align: top;
92
93}
94input.textspecial {
95 font-size: 12px;
96 font-style: normal;
97 line-height: normal;
98 font-weight: normal;
99 font-variant: normal;
100 height: 18px;
101 border: 1px solid #183ead;
102 color: #000000;
103}
104
</link>
<script language="Javascript">
1<!--
2if(window.parent == window){window.location.href="http://192.168.0.1";}
3function Click(){ window.event.returnValue=false;}
4document.oncontextmenu=Click;
5function doHelp(){location.href="/userRpm/VirtualServerHelpRpm.htm";}
6function doAll(val){if(val=="DelAll"){if(!confirm("确定删除所有条目?")) return;} location.href="/userRpm/VirtualServerRpm.htm?doAll="+val+"&Page="+curPage;}
7function doAdd(nPage){location.href="/userRpm/VirtualServerRpm.htm?Add=Add&Page="+nPage;}
8function doPage(nPage){location.href="VirtualServerRpm.htm?Page="+nPage;}
9function ResetStatus(strInfo){window.status=strInfo; return true;}
10var protocolList = new Array(
11"",
12"ALL",
13"TCP",
14"UDP"
15);
16//-->
</script>
<meta name="GENERATOR" content="MSHTML 6.00.2800.1106"/>
<script language="JavaScript">
1<!--
2var virServerListPara = new Array(
33389, 3389, "192.168.0.252", 1, 1,
480, 80, "192.168.1.252", 1, 1,
581, 81, "192.168.1.251", 1, 1,
61430, 1440, "192.168.1.251", 1, 0,
72500, 2510, "192.168.1.252", 1, 1,
85566, 5577, "192.168.1.247", 1, 1,
98000, 9010, "192.168.0.246", 1, 1,
102000, 2000, "192.168.1.252", 1, 1,
110,0 );
12var virServerPara = new Array(
131,
140,
158,
165,
178,
180,0 );
19//-->
</script>
<meta content="no-cache" http-equiv="pragma"/>
</head>
<body>
<center>
<form onsubmit="return doSubmit();" method="get" enctype="multipart/form-data" action="VirtualServerRpm.htm">
<table width="552" cellspacing="0" cellpadding="0" border="0">
</table>
<input type="hidden" value="1" name="curpage"/>
</form>
</center>
<br/>
<script language="JavaScript">
1
2var curPage = virServerPara[0];
3var prePage = (virServerPara[0] == 1)?1:virServerPara[0]-1;
4var NextPage = virServerPara[0]+1;
5document.forms[0].Page.value = curPage;
6document.forms[0].previous.disabled = (virServerPara[0] < 2)?true:false;
7document.forms[0].next.disabled = (virServerPara[1] > 0)?false:true;
8
</script>
</body>
</html>
</frame>
</frameset>
</frameset>
<noframes><BODY onLoad="doPop();">对不起,您的浏览器不支持框架!</BODY></noframes>
</html>

怎么读取他呢?
$oForm = _IEFormGetObjByName ($oIE, "mainFrame");
        msgbox(0,"Handle of frame",$oForm);
        $objs = _IEBodyReadHtml($oForm)
读不到里面的内容。用_iebodyreadtext也一样。
 楼主| 发表于 2009-6-28 16:26:58 | 显示全部楼层
弄了半天, 也没人解答, 算了。 已经弄出来了。 囧。

与大家分享一下。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <INet.au3>
#include <file.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Website check", 633, 454, 192, 114)
;$Label1 = GUICtrlCreateLabel("Webstie", 72, 32, 43, 17)
;$Input1 = GUICtrlCreateInput("", 128, 32, 257, 21)
;$Button1 = GUICtrlCreateButton("check", 416, 32, 65, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
        $url = "http://192.168.0.1"
        $oIE = _IECreate ($url, 0, 1, 0, 1)
        Sleep(1000)
        ControlSetText('[REGEXPTITLE:连接到.+]', '', 1003, 'admin')
        ControlSetText('[REGEXPTITLE:连接到.+]', '', 1005, 'xxxxx')
        ControlClick('[REGEXPTITLE:连接到.+]', '', 1)
        
        Sleep(2000)

        $oForm = _IEFormGetObjByName ($oIE, "mainFrame");
        $oFrames = _IEFrameGetCollection ($oIE)
        $iNumFrames = @extended
                
        If $iNumFrames > 0 Then
                If _IEIsFrameSet ($oIE) Then
                        $oFrame = _IEFrameGetObjByName ($oIE, "bottomLeftFrame")
                        _IELinkClickByText($oFrame,'转发规则')
                        ;$sHTML = _IEBodyReadHTML ($oFrame)
                        ;MsgBox(64,"demo",$sHTML,10)
                        Sleep(2000)
                        
                        $oFrame = _IEFrameGetObjByName ($oIE, "mainFrame")
                        $sHTML = _IEBodyReadHTML ($oFrame)
                        
                        
                        ;msgBox(64,"demo",$sHTML,100)
                        $nowstring = ''
                        $array = StringRegExp($sHTML, '<TR>[^<]*<TD align=middle>([\d]*)</TD>[^<]*<TD align=middle>([^<]*)</TD>[^<]*<TD align=middle>([^<]*)</TD>[^<]*<TD align=middle>([^<]*)</TD>[^<]*<TD align=middle>([^<]*)</TD>', 3)
                        ;msgBox(64,"demo",UBound($array),100)
                        for $i = 0 to UBound($array) - 1
                                ;msgbox(0, "RegExp Test with Option 3 - " & $i, $array[$i])
                                $nowstring  &= $array[$i]
                        Next
                        ;msgBox(64,"demo",$nowstring,100)
                        _FileWriteLog(@ScriptDir & "\baocun.log",$nowstring)
                        
                EndIf
        Else
                MsgBox(0, "Frame Info", "Page contains no frames")
        EndIf
        Sleep(5000)
发表于 2010-12-31 12:46:38 | 显示全部楼层
呵呵,顶一下,,兄弟,,这样也好,提高了自己的解决能力
发表于 2013-3-30 20:32:16 | 显示全部楼层
学习学习。。。。
发表于 2013-4-15 08:54:29 | 显示全部楼层
还是没有实现集成到GUI里面的啊……
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-29 07:16 , Processed in 0.086341 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表