Can anyone tell me how to build a VB program that would monitor ports I specify (preferably 25 & 110) and log the requests to a text file?
Printable View
Can anyone tell me how to build a VB program that would monitor ports I specify (preferably 25 & 110) and log the requests to a text file?
Make two winsock controls, set the local ports to 25/110 respectively.
In the connection request... close it, accept requestID, they've now established a connection. You can use the remoteip to get their IP.
Server End:
VB Code:
Dim strData as string Form_Load() sckWinsock.LocalPort = 25 sckWinsock.Listen 'Listen for connection requests End Sub sckWinsock_ConnectionRequest() 'Accept connection sckWinsock.Close sckWinsock.Accept RequestID End Sub sckWinsock_DataArrival 'Gets data sckWinsock.GetData strData 'Writes to file Open App.Path & "\log.txt" for Append as #1 Write #1, strdata Close #1 End Sub sckWinsock_Close MsgBox ("User has closed connection!")
Client End:
VB Code:
Form_Load sckWinsock.RemoteHostIP = 000.000.000.000 sckWinsock.RemotePort = 25 End Sub cmdConnect_Click() sckWinsock.Connect End Sub 'If you want to send data, send it using sckWinsock.SendData (Variable)
Simple, as long as you don't mess it up, which I probably did.
Thanks guys, that's exactly what I needed :D