Jump to content

Nnet

Members
  • Posts

    6
  • Joined

  • Last visited

Nnet's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Ok here its all code. All code works properly only func minuta works how i said. Im allready know it coz not all indexes are there so im tryed make corection witch dont work too #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <GUIListViewEx.au3> #include <Winpcap.au3> #include <Date.au3> Global $src=0 Global $time1=TimerInit() Global $radek =Number(0) $winpcap=_PcapSetup() If ($winpcap=-1) Then MsgBox(16,"Nebyl nalezen ovladač WinPAP!") exit EndIf $pcap_devices=_PcapGetDeviceList() If ($pcap_devices=-1) Then MsgBox(16,"Prostě chyba, nejsou žádné síťové adaptéry!",_PcapGetLastError()) exit EndIf GUICreate("Časovač Navision", 600, 500) $interface=GUICtrlCreateCombo("", 80, 15, 300,default,$CBS_DROPDOWNLIST) For $i = 0 to Ubound($pcap_devices)-1 GUICtrlSetData(-1, $pcap_devices[$i][1]) Next $filter=GUICtrlCreateInPut ("port 139", 500, 15, 90) $start=GUICtrlCreateButton ( "Start", 20, 460, 60) $stop=GUICtrlCreateButton ( "Stop", 110, 460,60) GUICtrlSetState (-1, $GUI_DISABLE ) $clear=GUICtrlCreateButton ( "Vymazat", 200, 460,60) GUICtrlSetState (-1, $GUI_DISABLE ) GUICtrlSetStyle(GUICtrlCreateLabel ( "Adaptér :", 8, 20, 60),$SS_RIGHT) GUICtrlSetStyle(GUICtrlCreateLabel ( "Filtr :", 430, 18, 60),$SS_RIGHT) $packetwindow = GUICtrlCreateListView("č.|Naposledy aktivní|Neaktivní|Délka|Packet", 10, 50, 580, 395) _GUICtrlListView_SetColumn($packetwindow,0,"číslo",40,1) _GUICtrlListView_SetColumnWidth($packetwindow, 1, 80) _GUICtrlListView_SetColumn($packetwindow,3,"Délka",40,1) _GUICtrlListView_SetColumnWidth($packetwindow, 3, 60) _GUICtrlListView_SetColumn($packetwindow,2,"Neaktivní",40,1) _GUICtrlListView_SetColumnWidth($packetwindow, 2, 60) _GUICtrlListView_SetColumnWidth($packetwindow, 4, 290) GUISetState() $i=0 $pcap=0 $packet=0 $pcapfile=0 Do $msg = GUIGetMsg() If ($msg=$start) Then $prom=0 $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,GUICtrlRead($filter),$prom) If ($pcap=-1) Then MsgBox(16,"Chyba čtení dat!",_PcapGetLastError()) ContinueLoop EndIf $linktype=_PcapGetLinkType($pcap) If ($linktype[1]<>"EN10MB") Then MsgBox(16,"Chyba, funguje jen pro Ethernet!") ContinueLoop Endif GUICtrlSetState ($stop, $GUI_ENABLE) GUICtrlSetState ($start, $GUI_DISABLE) EndIf If ($msg=$stop) Then If IsPtr($pcapfile) Then _PcapStopCaptureFile($pcapfile) $pcapfile=0 EndIf if Not IsInt($pcap) Then _PcapStopCapture($pcap) $pcap=0 GUICtrlSetState ($stop, $GUI_DISABLE) GUICtrlSetState ($start, $GUI_ENABLE) EndIf If ($msg=$clear) Then _PcapGetStats($pcap) _GUICtrlListView_DeleteAllItems($packetwindow) EndIf If IsPtr($pcap) Then ; If $pcap is a Ptr, then the capture is running $time0=TimerInit() While (TimerDiff($time0)<500) ; Retrieve packets from queue for maximum 500ms before returning to main loop, not to "hang" the window for user $packet=_PcapGetPacket($pcap) Call("Minuta") If IsInt($packet) Then ExitLoop Call("MyDissector", $packet[3]) ;ConsoleWrite($src & @CRLF) ;ConsoleWrite(MyDissector($packet[3]) & @CRLF) If MyDissector($packet[3]) <> "0" Then Local $textnajdi=_GUICtrlListView_FindText( $packetwindow, $ippart) If $textnajdi="-1" then GUICtrlCreateListViewItem($ippart&"|"&StringTrimRight($packet[0],7)&"|"&"0"&"|"&$packet[2]&"|"&MyDissector($packet[3]), $packetwindow) ;$data=$packet[3] _GUICtrlListView_EnsureVisible($packetwindow, $ippart) Else ;local $rozdil=_DateAdd ( $sType, $iNumber, $sDate ) if $packet[2]>="61" then _GUICtrlListView_SetItemText($packetwindow, $textnajdi, StringTrimRight($packet[0],7), 1) _GUICtrlListView_SetItemText($packetwindow, $textnajdi, "0", 2) _GUICtrlListView_EnsureVisible($packetwindow, $ippart) EndIf EndIf If IsPtr($pcapfile) Then _PcapWriteLastPacket($pcapfile) EndIf ;_GUICtrlListView_EnsureVisible($packetwindow, $ippart) Wend EndIf Until $msg=$GUI_EVENT_CLOSE If IsPtr($pcapfile) Then _PcapStopCaptureFile($pcapfile) ; A file is still open: close it if IsPtr($pcap) Then _PcapStopCapture($pcap) ; A capture is still running: close it _PcapFree() Exit Func Minuta () ;každou minutu přičte 1 k neaktivnimu času local $cas ;ConsoleWrite(TimerDiff($time1) & @CRLF) if (TimerDiff($time1)>1000) then While $radek<=255 $radek+=1 local $index=_GUICtrlListView_FindText( $packetwindow, $radek) ;najde text podle konce ip a dodá jeho adresu If $index="-1" then elseif $index<>"-1" then $cas=_GUICtrlListView_GetItemText($packetwindow,$index , 2) ;přečte na řádku hodnotu aktuálního neaktivního času local $cas2=Number($cas+1) _GUICtrlListView_SetItemText($packetwindow, $index, $cas2, 2) ;zapíše novou hodnotu zvětšenou o 1 if $cas>50 Then ConsoleWrite("XX" & $cas & @CRLF) ;Odpojit () EndIf EndIf Wend $radek = 0 $time1=TimerInit() endif EndFunc Func Odpojit () ;pošle odpojovací packet $broadcastmac="FFFFFFFFFFFF" ; broacast $mymac=@YEAR ; my mac address in hex $ethertype="0800" ; ethertype = IP $checkSum="1a35" ; Just manual for now... $mypacket="0x"&$broadcastmac&$mymac&$ethertype&"4500014800010000641155a500000000ffffffff004400430134" & $checkSum & "01010600ca1d0c4a0100000000000000000000000000000000000000" & $mymac & "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ; stick together to a binary string ! _PcapSendPacket($pcap,$mypacket) ; sends a valid ethernet broadcast ! EndFunc Func MyDissector ($data) ;třídič paketů Local $ethertype=BinaryMid ( $data, 13 ,2 ) If $ethertype="0x0800" Then Global $src=Number(BinaryMid ($data, 27 ,1))&"."&Number(BinaryMid ($data, 28 ,1))&"."&Number(BinaryMid ($data, 29 ,1))&"."&Number(BinaryMid ($data, 30 ,1)) Global $dst=Number(BinaryMid ($data, 31 ,1))&"."&Number(BinaryMid ($data, 32 ,1))&"."&Number(BinaryMid ($data, 33 ,1))&"."&Number(BinaryMid ($data, 34 ,1)) Global $ippart=Number(BinaryMid ($data, 30 ,1)) Switch BinaryMid ($data, 24 ,1) Case "0x01" return "0" Case "0x02" return "0" Case "0x06" Global $srcport=Number(BinaryMid ($data, 35 ,1))*256+Number(BinaryMid ($data, 36 ,1)) Global $dstport=Number(BinaryMid ($data, 37 ,1))*256+Number(BinaryMid ($data, 38 ,1)) Global $flags=BinaryMid ($data, 48 ,1) Local $f="" If BitAND($flags,0x01) Then $f="Fin " If BitAND($flags,0x02) Then $f&="Syn " If BitAND($flags,0x04) Then $f&="Rst " If BitAND($flags,0x08) Then $f&="Psh " If BitAND($flags,0x10) Then $f&="Ack " If BitAND($flags,0x20) Then $f&="Urg " If BitAND($flags,0x40) Then $f&="Ecn " If BitAND($flags,0x80) Then $f&="Cwr " $f=StringTrimRight(StringReplace($f," ",","),1) ;ConsoleWrite(BinaryMid ( $data, 13 ,2 ) & "TCP("&$f&") "&$src&":"&$srcport&" -> "&$dst&":"&$dstport &"..." &$ippart & @CRLF & BinaryMid($data,1,255) & @CRLF ) return "TCP("&$f&") "&$src&":"&$srcport&" -> "&$dst&":"&$dstport &"..." &$ippart Case "0x11" return "0" Case Else return "0" EndSwitch ;ElseIf $ethertype="0x060800" Then EndIf return "0" EndFunc
  2. Hello, i have this code Func Minuta () if (TimerDiff($time1)>1000) then While $radek<="255" local $index=_GUICtrlListView_FindText( $packetwindow, $radek) local $cas=_GUICtrlListView_GetItemText($packetwindow,$index , 2) _GUICtrlListView_SetItemText($packetwindow, $index, Abs($cas+"1"), 2) $radek+=1 _GUICtrlListView_EnsureVisible($packetwindow, $index) if $cas>"50" Then ConsoleWrite($cas & @CRLF) EndIf Wend $radek = "0" $time1=TimerInit() endif EndFunc I have 2 problems with this code. 1. Every cycle i want +1 to number but its make +2 or +3 have no idea why 2. I want write to concele numbers bigger than 50 but it write to console specificly numbers 6,7,8 than 50-99 than 500-999 O.o Have no idea why. Pls. do you know what happening here?
  3. Looks like it will be what im looking for. But have no idea how to make it work, didnt find any help page. So i have $packetwindow = GUICtrlCreateListView("No|Time|Len|Packet", 10, 90, 480, 200) _GUICtrlListView_SetColumn($packetwindow,0,"No",40,1) _GUICtrlListView_SetColumnWidth($packetwindow, 1, 80) _GUICtrlListView_SetColumn($packetwindow,2,"Len",40,1) _GUICtrlListView_SetColumnWidth($packetwindow, 3, 300) And what i need is when its when its ippart same i need just update it with actual data from packet. GUICtrlCreateListViewItem($ippart&"|"&StringTrimRight($packet[0],4)&"|"&$packet[2]&"|"&MyDissector($packet[3]), $packetwindow) When its ippart different make new Item.
  4. Hello, Im using GUICtrlCreateListView to make table with items. But when it is new item with same first column a want just update allready existing row. Its posible? I cant figure it, if its better use other funkcion pls. tell me. Thank
  5. Thank, Im trying to use it but still nothing. Script running on server. This is how first contact look in wireshark: 192.168.1.198 192.168.1.96 NBSS 126 Session request, to NAVI42-N300114<03><00> from <00><00><00><00><00><00><00><00><00><00><1c>oe<81><e4><60> So what to do in code? Local $aInfo = _Net_Share_SessionGetInfo( "NAVI42-N300114<03><00>", "<00><00><00><00><00><00><00><00><00><00><1c>oe<81>", @UserName ) I got absolutly nothing Im used IP, computer names, sesion name...
  6. Hello, i have DOS program with maximum 30 users online. Sometimes some people let program running and oter users cant connect. Its posible watch NTBBS communication? And when its not running for 30minutes, to disconect user (mb for 30sec disconect this pc from port 139(netbios)) Im trying to use TCPListen but it dont work :/ I dont get anything. Just trying to discover how it works. When i use Wireshark i cant see all comunikations. But Autoit dont see it. 192.168.1.250 192.168.1.96 TCP netbios-ssn > 51532 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1 192.168.1.96 192.168.1.250 TCP 51532 > netbios-ssn [FIN, ACK] Seq=73 Ack=7 Win=65692 Len=0 Func Example() TCPStartup() ; Start the TCP service. Local $sIPAddress = "192.168.1.96" ; This IP Address only works for testing on your own computer. Local $iPort = 139 ; Port used for the connection. While 1 Local $aInfo = _Net_Share_SessionGetInfo($sIPAddress, @ComputerName, @UserName) Local $iListenSocket = TCPListen($sIPAddress, $iPort, 200) local $iSocket = TCPAccept($iListenSocket) sleep(100) ConsoleWrite($aInfo[1] & $iListenSocket & $iSocket) sleep(50) WEnd EndFunc
×
×
  • Create New...