Jump to content

Port scanner


Infinitex0
 Share

Recommended Posts

Well, I said I would redo it and I did, here is the TCP in a good *cough* best *cough* form. its a bit sloppy, but thats because I don't ever plan on others seeing my work.

#include <guiconstants.au3>

GUICreate("Infinitex0's Port Scanner", 300, 175)
GUICtrlCreateGroup("Port Scan", 5, 5, 275, 160)
$IPLabel = GUICtrlCreateLabel("IP", 20, 17)
$PortIPAddress = GUICtrlCreateInput("127.0.0.1", 20, 33, 125)
GUICtrlCreateLabel("Start on Port", 20, 55)
$PortStartNumber = GUICtrlCreateInput("1", 20, 68, 125)
GUICtrlCreateLabel("End on Port", 20, 91)
$PortEndNumber = GUICtrlCreateInput("30", 20, 108, 125)
$StartScan = GUICtrlCreateButton("Start", 20, 135, 125)
GUICtrlSetFont($StartScan,15)
GUICtrlCreateGroup("Open Ports", 160, 17,105, 125)
$OpenPortList=GUICtrlCreateList("", 168, 30, 90, 109)
GUICtrlCreateGroup ("",-99,-99,1,1)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_ClOSE
            ExitLoop
        Case $msg = $StartScan
            MsgBox(0, "Scanning", "Now Scanning", 1)
            _StartScan()
    EndSelect
WEnd

Func _StartScan()
    $PortIP=GUICtrlRead($PortIPAddress)
    $PortEndNumberB=guictrlread($PortEndNumber)
    $PortStartNumberB=guictrlread($PortStartNumber)
    TCPStartup()
$timerstart = TimerInit()
For $PortStartNumberB = $PortStartNumberB To $PortEndNumberB + 1
$socket = TCPConnect($PortIP,$PortStartNumberB)
If $socket = -1 Then
    $PortStartNumberB = $PortStartNumberB + 1
Else
    GUICtrlSetData($OpenPortList,$PortStartNumberB)
    $PortStartNumberB = $PortStartNumberB + 1
EndIf
Next
    TCPShutdown()
    $timerend = TimerDiff($timerstart)
    MsgBox(0, "Port Scanner", "Done, Process took " & Round($timerend,-1)/1000 & " seconds")
EndFunc

EDIT: No Idea how the IP thing got like that, I remember getting rid of that altogether.

Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

Hi,

As a comment to all, if it returns an error that says the address is wrong, it simply means that it will give this error the next times too, so if it gives this error, you should break the loop as in my script earlier.

@Richard Robertson

Thanks!

@SkinnyWhiteGuy

add an exitloop after it gives a wrong address error and yours is just perfect

Arjan

Edited by arjan staring
Link to comment
Share on other sites

Hm, thats weird, I remember getting completely rid of that invalid IP thing a while ago. Oh well, its gone now.

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

Lol, as soon as I tried to start it my comp went crazy with antispy stuff stopping it.

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

oh, lol. but its not a virus, its just your anti virus is seeing strange activity.

Yea, thats why it was so funny. Kind of like how people started freaking out when Adult swim put up those ATHF LED posters and people thought it was a terrorist thing. Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

CRAP I MESSED UP GUYS SORRY! I messed up and 2.0 scanned every other port due to a math problem I didn't notice. This is 2.5 it has some tiny changes and the big change of scanning every port. Sorry once again I didn't notice this earlier.

#include <guiconstants.au3>

$PortScanner = GUICreate("Infinitex0's Port Scanner", 300, 175)
GUICtrlCreateGroup("Port Scan", 5, 5, 275, 160)
$IPLabel = GUICtrlCreateLabel("IP", 20, 17)
$PortIPAddress = GUICtrlCreateInput("127.0.0.1", 20, 33, 125)
GUICtrlCreateLabel("Start on Port", 20, 55)
$PortStartNumber = GUICtrlCreateInput("1", 20, 68, 125)
GUICtrlCreateLabel("End on Port", 20, 91)
$PortEndNumber = GUICtrlCreateInput("30", 20, 108, 125)
$StartScan = GUICtrlCreateButton("Start", 20, 135, 125)
GUICtrlSetFont($StartScan,15)
$OnPort = GUICtrlCreateLabel("Scanning Port:None", 150, 142)
GUICtrlCreateGroup("Open Ports", 160, 17,105, 125)
$OpenPortList=GUICtrlCreateList("", 168, 30, 90, 109)
GUICtrlCreateGroup ("",-99,-99,1,1)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_ClOSE
            ExitLoop
        Case $msg = $StartScan
            _StartScan()
    EndSelect
WEnd

Func _StartScan()
    $PortIP=GUICtrlRead($PortIPAddress)
    $PortEndNumberB=guictrlread($PortEndNumber)
    $PortStartNumberB=guictrlread($PortStartNumber)
    TCPStartup()
$timerstart = TimerInit()
For $LetsGo = $PortStartNumberB To $PortEndNumberB
$socket = TCPConnect($PortIP,$PortStartNumberB)
ControlSetText("", "", $OnPort, "Scanning Port:" & $PortStartNumberB & "")
If $socket = -1 Then
    $PortStartNumberB = $PortStartNumberB + 1
Else
    GUICtrlSetData($OpenPortList,$PortStartNumberB)
    $PortStartNumberB = $PortStartNumberB + 1
EndIf
Next
    TCPShutdown()
    $timerend = TimerDiff($timerstart)
    TrayTip("Port Scanner", "Done Process took " & Round($timerend,-1)/1000 & " seconds", 7, 1)
EndFunc

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

  • 2 weeks later...

yea, I did know that these are used to check your own ports so you know if any are open to hackers (or crackers). One of the reasons I never put up the keylogger I made with autoit (besides the fact that its extremely easy), don't worry, I've never used it on anyone. I put in the timer thing so that I could see how fast it is. I think the max number of ports is like 65535. but even testing on your own comp it would take a while (almost a day) to do, with any scanner. Well, I think this is just what I needed to bring myself back to Autoit. I forgot how much I loved it.

I believe I made a portscanner awhile back, So I could use it to check proxies.

I made one before using autoit, But the tcp's timeout, was way too long. So, I made one using winsock, Goes 10x faster. x3

I could post the source, But I wont. Because I dont have it, Its one of the many things I didnt backup when I formatted.

EDIT::

I just recreated the source.

Here you go :3

Keeping in mind, You would need winsock control to be on your system already.

$WinSock = ObjCreate("MSWinsock.Winsock.1")
$Next = False

$StartPort = 1
$EndPort = 65534
$Timeout = 100

For $i = $StartPort To $EndPort
    $WinSock.RemoteHost = "127.0.0.1"
    $WinSock.RemotePort = $i
    $WinSock.Connect
    AdlibEnable("Timeout", 1)
    $oTimer = TimerInit()
    
    While 1
        If $Next = True Then
            AdlibDisable()
            $Next = False
            ExitLoop
        EndIf
    WEnd
    
    If $WinSock.State = 7 Then
        ConsoleWrite("[" & $i & "] Open" & @CRLF)
    Else
        ConsoleWrite("[" & $i & "] Closed" & @CRLF)
    EndIf
    $WinSock.Close
Next

Func Timeout()
    If TimerDiff($oTimer) > $Timeout Then
        $Next = True
        $oTimer = ""
    EndIf
EndFunc

Enjoy ;D

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Extract that to system32 folder, Then Start > Run > Regsvr32 MSWINSCK.ocx

Then, run the script.

My friend said doing that didnt work for him, But, Who knows, might work for you.

MSWINSCK.rar

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Hi,

I rewrote your code:

$SocketIP = ""
$socketportstart = 1
$socketportend = 65535

TCPStartup()

For $port = $socketportstart To $socketportend
    $socket = TCPConnect($SocketIP,$port)
        
    If $socket = -1 Then
        ConsoleWrite($port & " - Unable to connect." & @CRLF)
    ElseIf $socket = 1 Then
        ConsoleWrite($port & " - Wrong Address" & @CRLF)
        ExitLoop
    ElseIf $socket = 2 Then
        ConsoleWrite($port & " - Wrong Port" & @CRLF)
    Else
        ConsoleWrite($port & " - Success!" & @CRLF)
    EndIf
Next

TCPShutdown()oÝ÷ Ø2¢çÇ×z0y«"*î)Òr+^jw`÷²¢æ¥+¶{¦mêìjwb~Ø^ɪޢ§¢¹è´  Ý"·©§w*.®Z(§­¨­)ämëmz¹h¢è®Øb²ë¸Úú®¢×)nëfk&Þjëh×6$SocketIP = ""
$socketportstart = 1
$socketportend = 65535

TCPStartup()

For $port = $socketportstart To $socketportend
    $socket = TCPConnect($SocketIP,$port)
        
    If $socket = -1 Then
        ConsoleWrite($port & " - Unable to connect." & @CRLF)
    ElseIf $socket = 1 Then
        ConsoleWrite($port & " - Wrong Address" & @CRLF)
        ExitLoop
    ElseIf $socket = 2 Then
        ConsoleWrite($port & " - Wrong Port" & @CRLF)
    Else
        ConsoleWrite($port & " - Success!" & @CRLF)
        FileWrite("Successful Ports.txt" , $port & " - Success!" & @CRLF)
    EndIf
Next

TCPShutdown()
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...