I've never really looked into packet sniffing, but I do know it shouldn't matter if you're on dial-up or not. All the packet work's done before it hits the hardware, be it a LAN port or a dial-up modem.
If you Google for packet sniffers you will find some hits on them and there are some that you can download the source code. Studying the source code can give you more answers than anyone here could explain it. I downloaded the source code for one some time back and was able to use that source to make my own custom packet sniffer in VB. If I can find where I stored all that stuff I will post the info here but it will take me awhile to find it since it has been a few years ago and I dont remember exactly the name or where I put all that stuff.
I can recommend the winpcap library, I dont know if its "directly" usable from VB6 or if you'd need to compile some kind of DLL yourself but...have a look at it, you might find something.
I can recommend the winpcap library, I dont know if its "directly" usable from VB6 or if you'd need to compile some kind of DLL yourself but...have a look at it, you might find something.
That's it. That is exactly what I downloaded and used it to make my own VB packet sniffers. And yes, it is in C so you will need to convert the code to DLL's and then use the DLL's in your VB program. Now if I can just remember where I put that stuff. Now since I know the name maybe I can find it sooner.
I found the PacketX thinggy off the winpcap FAQ. The only documentation for it is how to add it to your project; didn't see any information on its use, but it did come with a VB6.0 example that I'm trying to muddle my way through.
I have now have a working code as seen below. It seems to be displaying what seem to be hex numbers.
How do you convert a hex number to a string?
Code:
Dim WithEvents oPacketX As PacketX
Private Sub Form_Load()
Set oPacketX = New PacketX
'MsgBox oPacketX.Adapter.Description
oPacketX.Start
End Sub
Private Sub Form_Unload(Cancel As Integer) 'some cleanup
oPacketX.Stop
End Sub
Private Sub FileExit_Click() 'end program
End
End Sub
Private Sub oPacketX_OnPacket(ByVal pPacket As PacketXLib.IPktXPacket)
vnCounter = vnCounter + 1
Dim vByte As Variant
Dim sData As String
Dim nPosition, nColumns As Integer
nColumns = 16
For Each vByte In pPacket.Data
If nPosition = 8 Then
sData = sData + " "
End If
If vByte <= &HF Then
sData = sData + "0"
End If
sData = sData + Hex(vByte) + " "
Next
Text1.SelText = sData & vbCrLf & Text1.SelText
End Sub
debug.print Chr(Val("&H" & "6D")) returns m
but when I change a line in the code to
sData = sData + Chr(Val("&H" & Hex(vByte))) + " "
it dosent seem to come out right
Its not translating correctly, I keep getting a bunch of garbage and nothing that resembles what it *should* be. I'm trying to decode it into text, but im not getting any text from it.
Show me the original input data and also show me what you are getting (the garbage of what it *should be*) and show me the code that you are using. The examples I posted for you above gives you what you want so maybe you are not using them in the correct way or manner.
Your problem is that you are sending non-printable characters to the textbox.
Consider your hex string:
2C342000
This translates as ",4 "
2C = ,
34 = 4
20 = space
00 = non-printable character which causes the text box to terminate.
You need to examine each byte and if it is a non-printable character you need to subsitute a period (.) for that character. That's why you saw the hex dump as I posted it with a lot of periods in it.
Public Function ToStr(ByVal strString As String) As String
strString = Replace(strString, " ", "")
Dim A&, strOut$, strC$
strOut$ = ""
For A = 1 To Len(strString) Step 2
If Val("&H" & Mid(strString, A, 2)) < 32 Or Val("&H" & Mid(strString, A, 2)) > 126 Then
strOut = strOut & "."
Else
strOut = strOut & Chr(Val("&H" & Mid(strString, A, 2)))
End If
Next A
ToStr = strOut
End Function