Jump to content
Sign in to follow this  

WinPcap And AutoIT

Recommended Posts


Iam trying to get all network devices with WinPcap dll. But iam confuse with AU3 code. First here is the Function to show devlist (from winpcap.dll)

int pcap_findalldevs_ex  ( char *  source,  
  struct pcap_rmtauth *  auth,  
  pcap_if_t **  alldevs,  
  char *  errbuf   

Well the first parameter (SOURCE) can be 'rpcap://' to show all local adapters.

The 2 parameter (auth) can be null (since we dont need user and pass to see local adapters).

3 parameter is a pcap_if type and here is the problem: how i can create a dllstrute for this:

pcap_if *  next 
  if not NULL, a pointer to the next element in the list; NULL for the last element of the list 
char *  name 
  a pointer to a string giving a name for the device to pass to pcap_open_live() 
char *  description 
  if not NULL, a pointer to a string giving a human-readable description of the device 
pcap_addr *  addresses 
  a pointer to the first element of a list of addresses for the interface 
u_int  flags 
  PCAP_IF_ interface flags. Currently the only possible flag is PCAP_IF_LOOPBACK, that is set if the interface is a loopback interface.

The 4 parameter is easy, since is only a ptr.

Like we can see, we have a pcap_addr strutur inside of the pcap_if struture. My question is: how can I made it?

Edited by JustANoob

Share this post

Link to post
Share on other sites

I got it. But i have problem to encode/decode packets. I dont know why, but some chars just disapears.... I need some advice about how manipulate Binary array to Ansi to Hex (thats is the way to get what i want).

PS: This is a bot to read/log/alert a chat game. All chat msg start with C1xx00 (where xx is the id for the msg). I alredy decode all others packets too and find a way to got my chat log using winpcap but in AutoIt i just cant translate the Data from winpcap in hexdump format. Someone can help me (i dont want use .net). Thanks.

Share this post

Link to post
Share on other sites

#include <Array.au3>
#include <GuiListView.au3>
#include <GUIConstants.au3>
#include <String.au3>
#include <StrToHex.au3>
dim $list = ""
dim $PacketX = ObjCreate("PktX.PacketX")
dim $ondate = ObjEvent($PacketX,"PacketX_")
dim $adaptador = 1
dim $comecar = ""
dim $rodando = 0
Dim $GOOEY = GUICreate("Lista de Devices (adaptadores):",600,200)
Dim $edit = GUICtrlCreateListView("Device|Adaptador",10,10,280,160)
dim $pacotes = GUICtrlCreateListView("Pacotes", 300, 10)

For $i = 1 To $PacketX.Adapters.Count
    If $PacketX.Adapters($i).IsGood Then
    GUICtrlCreateListViewItem($PacketX.Adapters($i).device & "|" &  $PacketX.Adapters($i).Description & "|",$edit)

$comecar = GUICtrlCreateButton("Iniciar",10, 170)
$file = FileOpen("C:\test\Packt.txt", 1)


Func PacketX_OnPacket($oPacket);<<---- every  packet on network device selected.
if IsArray($oPacket.data) Then
$novastring = ""
$stronlyC1 = ""
$teste = $oPacket.data
;here i need translate from data to hex.

if IsArray ($teste) Then
    for $i = 0 to UBound($teste)-1
; here is each packet from data in this OnPacket event. 
    FileWrite($file,$novastring);<--- i write on a file and show the same string on ListView just to compare.
    GUICtrlCreateListViewItem($novastring & "|", $pacotes)

While 1
   $msg = GUIGetMsg()
   if $msg = $comecar Then
       $PacketX.Adapter = $PacketX.Adapters(Number(_GUICtrlListViewGetCurSel($edit))+1)
       $PacketX.Adapter.BPFilter = ""; filter, will use later.
       $rodando = 1

Func exi1()

Well here is the code, works fine, iam just little confused about DATA TYPE. This is a binary array and i cant see the value. I need change it to HEX, but I try __StrToHex from Jarvis, i try _StringToHex for Strings.au3 and try my own functio AscToHex....

Have another way to get binary array to hex? Maybe some API function?

PS:PacketX is a ActiveX to works with Winpcap (http://www.beesync.com/packetx/index.html).

PS2: I must be crazy.... Iam replying my own topic.... "Talk to my hand" lol...

Edited by JustANoob

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this