|
-
Mar 9th, 2000, 04:20 AM
#1
Thread Starter
New Member
Hello,
I am still a newbie, but I was wondering if anybody knows how to use the winsock control to make some kind of a port scanner. Not for hacking, but just for fun.
Thanks.
-
Mar 10th, 2000, 01:39 AM
#2
Junior Member
Right... For fun... 
Winsock1.remotehost = [Address to scan]
Then you loop through the ports you want to scan:
for i = 1 to [MaxPort]
Winsock1.remoteport = i
loop
Don't forget to set the Error and Connect event. You must specify something like Winsock1.close in the Error & Connect Event so that when the socket connects, it closes itself so it can continue scanning.
In the Connect Event, you must also put code to specify that you connected successfully to the port.
And you're done.
Raggart
-
Mar 11th, 2000, 03:05 AM
#3
Thread Starter
New Member
I've come up with the following code:
Dim i As Integer
Private Sub Command1_Click()
For i = 1 To 9000
Winsock1.RemotePort = i
Text1.Text = i
Next i
End Sub
Private Sub Form_Load()
Winsock1.RemoteHost = "127.0.0.1"
End Sub
Private Sub Winsock1_Connect()
Winsock1.Close
MsgBox "Port :" & i
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock1.Close
Text1.Text = "Error"
End Sub
The problem is, it doesn't work. The For-Next loop loops fine, but it doesn't detect any open ports.
Could you tell me what's wrong with this code?
Thanks.
-
Mar 12th, 2000, 09:25 AM
#4
Member
Connect
In the For..Next loop you have to put in the Connect command.
For i = 1 To 65535
Winsock1.RemotePort = i
Text1.Text = i
Winsock1.Connect
Next i
And the highest port number is 65535.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|