#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_outfile=ipjs.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <ComboConstants.au3>
#include 'Winpcap.au3'
$winpcap = _PcapSetup()
If ($winpcap = -1) Then
MsgBox(16, "错误!", "WinPcap 没有安装")
Exit
EndIf
$pcap_devices = _PcapGetDeviceList()
If ($pcap_devices = -1) Then
MsgBox(16, "网卡错误!", _PcapGetLastError())
Exit
EndIf
GUICreate("数据包监听", 640, 800)
$interface = GUICtrlCreateCombo("", 80, 15, 400, Default, $CBS_DROPDOWNLIST)
For $i = 0 To UBound($pcap_devices) - 1
GUICtrlSetData(-1, $pcap_devices[$i][1])
Next
$start = GUICtrlCreateButton("开始", 120, 660, 80, 80)
$stop = GUICtrlCreateButton("停止", 410, 660, 80, 80)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetStyle(GUICtrlCreateLabel("选择网卡 :", 10, 20, 60), $SS_RIGHT)
$packetwindow = GUICtrlCreateListView("编号|时间|长度|数据流向", 10, 40, 620, 600)
_GUICtrlListView_SetColumn($packetwindow, 0, "编号", 60, 1)
_GUICtrlListView_SetColumnWidth($packetwindow, 1, 80)
_GUICtrlListView_SetColumn($packetwindow, 2, "长度", 60, 1)
_GUICtrlListView_SetColumnWidth($packetwindow, 3, 400)
GUISetState()
$i = 0
$pcap = 0
$packet = 0
Do
$msg = GUIGetMsg()
If ($msg = $start) Then
$int = ""
For $n = 0 To UBound($pcap_devices) - 1
If $pcap_devices[$n][1] = GUICtrlRead($interface) Then
$int = $pcap_devices[$n][0]
ExitLoop
EndIf
Next
$pcap = _PcapStartCapture($int, "", 0)
$linktype = _PcapGetLinkType($pcap)
GUICtrlSetState($stop, $GUI_ENABLE)
GUICtrlSetState($start, $GUI_DISABLE)
EndIf
If ($msg = $stop) Then
If Not IsInt($pcap) Then _PcapStopCapture($pcap)
$pcap = 0
GUICtrlSetState($stop, $GUI_DISABLE)
GUICtrlSetState($start, $GUI_ENABLE)
EndIf
If IsPtr($pcap) Then
$time0 = TimerInit()
While (TimerDiff($time0) < 500)
$packet = _PcapGetPacket($pcap)
If IsInt($packet) Then ExitLoop
GUICtrlCreateListViewItem($i & "|" & StringTrimRight($packet[0], 4) & "|" & $packet[2] & "|" & mdata($packet[3]), $packetwindow)
$data = $packet[3]
_GUICtrlListView_EnsureVisible($packetwindow, $i)
$i += 1
WEnd
EndIf
Until $msg = $GUI_EVENT_CLOSE
Func mdata($data)
Local $src = Number(BinaryMid($data, 27, 1)) & "." & Number(BinaryMid($data, 28, 1)) & "." & Number(BinaryMid($data, 29, 1)) & "." & Number(BinaryMid($data, 30, 1))
Local $dst = Number(BinaryMid($data, 31, 1)) & "." & Number(BinaryMid($data, 32, 1)) & "." & Number(BinaryMid($data, 33, 1)) & "." & Number(BinaryMid($data, 34, 1))
Local $srcport = Number(BinaryMid($data, 35, 1)) * 256 + Number(BinaryMid($data, 36, 1))
Local $dstport = Number(BinaryMid($data, 37, 1)) * 256 + Number(BinaryMid($data, 38, 1))
Return "流向 " & $src & ":" & $srcport & " -> " & $dst & ":" & $dstport
EndFunc
给钱,走人.