Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sniffing the data you are sending?

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
Is there a way of using VB6 to monitor what my computer is actually sending to the internet ?
Particularly when I have a browser open doing nothing or when I click on an object on the screen such as a link.


 
Well, yes. But it can be complex.

Easiest way is to install WinPcap and then an ActiveX control such as PacketX, which simplifies things a lot

Then something like the following:

Code:
[blue]Option Explicit

Private Sub Form_Load()
    PacketXCtrl1.Adapter = PacketXCtrl1.Adapters(1) [green]' Assuming only one adapter, and that this is the one we want to monitor[/green]
    
    [green]' Following 4 lines from PacketX example code
    '// Capture buffer parameters[/green]
    PacketXCtrl1.Adapter.BuffSize = 256& * 1024 [green]'// 256 KB[/green]
    PacketXCtrl1.Adapter.BuffMinToCopy = 0
    [green]'// Hardware filter and capture mode[/green]
    PacketXCtrl1.Adapter.HWFilter = PktXPacketTypePromiscuous
    PacketXCtrl1.Adapter.Mode = PktXModeCapture

    [green]' Start monitoring[/green]
    PacketXCtrl1.Start
End Sub

Private Sub Form_Unload(Cancel As Integer)
    PacketXCtrl1.Stop
End Sub

Private Sub PacketXCtrl1_OnPacket(ByVal pPacket As PacketXLibCtl.IPktXPacket)
    [green]' if the source of the packet is our adapter[/green]
    If pPacket.SourceIpAddress = PacketXCtrl1.Adapter.NetIP Then
        Debug.Print pPacket.SourceIpAddress, pPacket.SourcePort, pPacket.DestPort
    End If
End Sub[/blue]
 
Thanks. Away on hols again. Will try when I get back
 
Yes but just spent a week in hospital with a foreign virus!
It might be some time before I get back to programming.
Thanks anyway
 
>hospital with a foreign virus!

Doesn't sound good. Hope you are on the road to recovery.
 
Recovered OK.
Damn foreigners! Probably arrived on a leaky boat?
 
Yes I'm still alive thanks!
As I am approaching my 80th birthday I have given programming a bit of a rest for a while - too busy with other things!
I will get back to it when the nights get longer (it's summer here).
My only problem now is to find out how the retire from retirement. Whoever said I'd be bored when I retire was crazy!
 
You can use wireshark application as sniffing tool it uses (winpcap sniffing tool), you can download it here: However, if you decided to implement it on VB6 you have to use dll and callbacks that is in Winpcap package.

for reliable solution it is highly recommended to use c++ as programming language, in this case you will find many Winpcap sample applications (with source code) to capture all traffic on your network

Wael
VoIP Expert
 
You need to understand Ted's history. He doesn't really want to packet capture, he doesn't want a 3rd party app; and he's not a C++ programmer

And it's only a year since he asked ...
 
My how time flies (when you get old) but then maybe it's just as well?
Retirement seems busier than when I was working for a living but it is possible I just think slower.
Sorry I haven't got back to following this up but the need for it is now not so evident.

I suppose I will give it a go as soon as I get motivated by a vicious internet bug (again)

Thank you all for your interest and help.
 
I was beginning to worry, Ted. Hadn't see you on here for a few months. Hope all is well in sunny Australia.
 
Yes, still alive. Thanks for your thoughts.
Just returned home from a 17,000 km three month round Australia trip towing our camper trailer with my 4wd.
Had a fantastic time only needing being rescued once by the State Emergency Service.
I had never visited the Aussie western desert areas before, the scenery equals anywhere else I have been (and that amounts to 33 different countries so far!). It is like being transported back in time 50,000 years to what the world would have been like BC (Before Computers).

I'll get back to this problem when I get a chance as I am still curious about how browsers actually work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top