找回密码
 加入
搜索
查看: 4617|回复: 6

[网络通信] 请教如何查看网络连接状态或DDOS 攻击(已解决)

  [复制链接]
发表于 2010-1-19 15:30:26 | 显示全部楼层 |阅读模式
本帖最后由 ufw119 于 2012-6-5 15:12 编辑

AU3 可以检测到网卡的每秒发包量吗?借此判断电脑是不是中了流量攻击或DDOS攻击。谢谢!!
发表于 2010-1-19 17:29:18 | 显示全部楼层
本帖最后由 FBWOLF 于 2010-1-19 17:35 编辑

可以的
Opt("MustDeclareVars", 1)
 
Local Const $sIP = "192.168.1.70", $sMac = "00:20:21:22:CC:DD"
Local $aIfTable, $iIndex = 0,$FIRST0=0,$FIRST1=0
WHILE 1
$aIfTable = _GetIfTable()
For $i = 1 To $aIfTable[0][0]
        If $aIfTable[$i][2] = 6 Then
$FIRST0=$aIfTable[$i][15]
$FIRST1=$aIfTable[$i][9]
        EndIf
Next

SLEEP(1000)
$aIfTable = _GetIfTable()
For $i = 1 To $aIfTable[0][0]
        If $aIfTable[$i][2] = 6 Then
TOOLTIP(ROUND(($aIfTable[$i][15]-$FIRST0)/1024,1)&@CRLF&ROUND(($aIfTable[$i][9]-$FIRST1)/1024,1),0,0)
        EndIf
Next
WEND

 
Exit
 
 

 
;===============================================================================
; 说明:   获取 MIB-II 接口表
; 语法:   _GetIfTable()
; 参数:   无
; 需要:   无
; 返回:   成功 - 二维数组, 结构:
;         $array[0][0] - 接口总数
;         $array[1][0] - 第一接口索引号
;         $array[1][1] - 第一接口名称
;         $array[1][2] - 第一接口类型
;         $array[1][3] - 第一接口MTU字节数
;         $array[1][4] - 第一接口连接速度
;         $array[1][5] - 第一接口物理地址
;         $array[1][6] - 第一接口管理状态
;         $array[1][7] - 第一接口操作状态
;         $array[1][8] - 第一接口持续时间
;         $array[1][9] - 第一接口接收字节数
;         $array[1][10] - 第一接口接收单播数据包
;         $array[1][11] - 第一接口接收广播和组播数据包
;         $array[1][12] - 第一接口接收数据包丢弃数
;         $array[1][13] - 第一接口接收数据包错误数
;         $array[1][14] - 第一接口接收未知协议数据包
;         $array[1][15] - 第一接口发送字节数
;         $array[1][16] - 第一接口发送单播数据包
;         $array[1][17] - 第一接口发送广播和组播数据包
;         $array[1][18] - 第一接口发送数据包丢弃数
;         $array[1][19] - 第一接口发送数据包错误数
;         $array[1][20] - 第一接口传输队列长度
;         $array[1][21] - 第一接口描述
;         ...
;         [n][0] 至 [n][21] - 第 n 接口信息
;         失败 - 空列表数组 [0][0] = 0, 并设置 @error 到 1, @extended 到API操作返回值
; 备注:   参考: [url]http://www.autoitx.com/forum.php?mod=viewthread&tid=7308[/url] 3#
;===============================================================================
Func _GetIfTable()
        Local $aResult, $sPhysAddr, $iPhysAddrLen, $sDescr, $iDescrLen, $iIndex = 0, $aIfTable[1][22] = [[0]]
        Local $tBuffer, $pBuffer, $tNum, $tagIfTable = "", $tIfTable
 
        $aResult = DllCall("iphlpapi.dll", "dword", "GetIfTable", _
                        "ptr", 0, "int*", 0, "int", 1)
        If $aResult[2] = 0 Then Return SetError(1, $aResult[0], $aIfTable)
 
        $tBuffer = DllStructCreate("ubyte[" & $aResult[2] & "]")
        $pBuffer = DllStructGetPtr($tBuffer)
        $aResult = DllCall("iphlpapi.dll", "dword", "GetIfTable", _
                        "ptr", $pBuffer, "int*", $aResult[2], "int", 1)
 
        $tNum = DllStructCreate("dword", $pBuffer)
        $aIfTable[0][0] = DllStructGetData($tNum, 1)
        For $i = 1 To $aIfTable[0][0]
                $tagIfTable &= ";wchar[256];dword[5];byte[8];dword[16];byte[256]"
        Next
        $tIfTable = DllStructCreate("dword" & $tagIfTable, $pBuffer)
 
        ReDim $aIfTable[$aIfTable[0][0] + 1][22]
        For $i = 2 To $aIfTable[0][0] * 5 Step 5
                $iPhysAddrLen = DllStructGetData($tIfTable, $i + 1, 5)
                $sPhysAddr = DllStructGetData($tIfTable, $i + 2)
                $sPhysAddr = StringLeft($sPhysAddr, 2 + $iPhysAddrLen * 2)
                $sPhysAddr = _FormatMac($sPhysAddr)
                $iDescrLen = DllStructGetData($tIfTable, $i + 3, 16)
                $sDescr = DllStructGetData($tIfTable, $i + 4)
                $sDescr = StringLeft($sDescr, $iDescrLen * 2)
                $sDescr = BinaryToString($sDescr)
 
                $iIndex += 1
                $aIfTable[$iIndex][0] = DllStructGetData($tIfTable, $i + 1, 1)
                $aIfTable[$iIndex][1] = DllStructGetData($tIfTable, $i)
                $aIfTable[$iIndex][2] = DllStructGetData($tIfTable, $i + 1, 2)
                $aIfTable[$iIndex][3] = DllStructGetData($tIfTable, $i + 1, 3)
                $aIfTable[$iIndex][4] = DllStructGetData($tIfTable, $i + 1, 4)
                $aIfTable[$iIndex][5] = $sPhysAddr
                $aIfTable[$iIndex][6] = DllStructGetData($tIfTable, $i + 3, 1)
                $aIfTable[$iIndex][7] = DllStructGetData($tIfTable, $i + 3, 2)
                $aIfTable[$iIndex][8] = DllStructGetData($tIfTable, $i + 3, 3)
                $aIfTable[$iIndex][9] = DllStructGetData($tIfTable, $i + 3, 4)
                $aIfTable[$iIndex][10] = DllStructGetData($tIfTable, $i + 3, 5)
                $aIfTable[$iIndex][11] = DllStructGetData($tIfTable, $i + 3, 6)
                $aIfTable[$iIndex][12] = DllStructGetData($tIfTable, $i + 3, 7)
                $aIfTable[$iIndex][13] = DllStructGetData($tIfTable, $i + 3, 8)
                $aIfTable[$iIndex][14] = DllStructGetData($tIfTable, $i + 3, 9)
                $aIfTable[$iIndex][15] = DllStructGetData($tIfTable, $i + 3, 10)
                $aIfTable[$iIndex][16] = DllStructGetData($tIfTable, $i + 3, 11)
                $aIfTable[$iIndex][17] = DllStructGetData($tIfTable, $i + 3, 12)
                $aIfTable[$iIndex][18] = DllStructGetData($tIfTable, $i + 3, 13)
                $aIfTable[$iIndex][19] = DllStructGetData($tIfTable, $i + 3, 14)
                $aIfTable[$iIndex][20] = DllStructGetData($tIfTable, $i + 3, 15)
                $aIfTable[$iIndex][21] = $sDescr
        Next
 
        Return SetError($aResult[0], 0, $aIfTable)
EndFunc   ;==>_GetIfTable
 

Func _FormatMac($sMac, $iString = True)
        If $iString Then
                $sMac = StringTrimLeft($sMac, 2)
                Return StringTrimRight(StringRegExpReplace($sMac, ".{2}", "\0:"), 1)
        Else
                Return "0x" & StringReplace($sMac, ":", "")
        EndIf
EndFunc   ;==>_FormatMac
代码是以前的,没做过错误调试!楼主自己看吧!
 楼主| 发表于 2010-1-22 15:37:26 | 显示全部楼层
没有调用成功。。后参考这里有点眉目http://www.autoitx.com/forum.php ... hlight=%B7%A2%B0%FC
欢迎再顶。。
发表于 2010-3-14 06:25:10 | 显示全部楼层
我跟着来学习
发表于 2010-3-14 08:02:10 | 显示全部楼层
来学习......
发表于 2010-3-14 12:23:05 | 显示全部楼层
呵呵,学习一下。。
发表于 2010-5-21 10:28:57 | 显示全部楼层
查看网络连接 还可以但是DDOS 就不行了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-11 04:46 , Processed in 0.082922 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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