Infinitex0 Posted July 27, 2007 Share Posted July 27, 2007 (edited) well, I recently downloaded a port scanner and thought "this doesn't look to hard to make" so I opened up scite and made this. Its pretty simple......I'll probably redo it. Heres the 2.0 version (much better) expandcollapse popup#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 EDIT: wow, somehow the script got messed up fixed now. NEW EDIT: wow, I totally fu....can I say that here..well I messed up and by a tiny math problem 2.0 scanned every other port, this is 2.5 which (besides a few small changes) fixes this so now all ports are scanned. Edited July 29, 2007 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 More sharing options...
Skizmata Posted July 27, 2007 Share Posted July 27, 2007 I don't really know enough to say if that is really doing much of anything but I played with it and learned about timerstart and timerend. Thank you! Good work! AutoIt changed my life. Link to comment Share on other sites More sharing options...
lokster Posted July 27, 2007 Share Posted July 27, 2007 Port scanners are sometimes usefull (if you are SysAdmin), but are also the easyest way to get AutoIt blacklisted in some Antivirus or Network security program... And also the easyest way to make your ISP or Network admin mad at you Link to comment Share on other sites More sharing options...
Infinitex0 Posted July 27, 2007 Author Share Posted July 27, 2007 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. 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 More sharing options...
lokster Posted July 27, 2007 Share Posted July 27, 2007 Well, I think this is just what I needed to bring myself back to Autoit. I forgot how much I loved it.True, true AutoIt is the best example of good balance between functionality and ease of use Link to comment Share on other sites More sharing options...
Fabry Posted July 27, 2007 Share Posted July 27, 2007 Does an UDP port scanner exist? A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center] Link to comment Share on other sites More sharing options...
Infinitex0 Posted July 27, 2007 Author Share Posted July 27, 2007 I dunno, I guess I could try making one 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 More sharing options...
lokster Posted July 27, 2007 Share Posted July 27, 2007 The UDP scanners DO exist, and I think doing one in AutoIt is not verry different from the TCP port scanner. Maybe just replace TCPConnect() with UDPOpen(), TCPStartup() and TCPShutdown() with UDPStartUp() and UDPShutdown()? Link to comment Share on other sites More sharing options...
Infinitex0 Posted July 27, 2007 Author Share Posted July 27, 2007 I'm making one right now and I think its slightly different. 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 More sharing options...
Infinitex0 Posted July 27, 2007 Author Share Posted July 27, 2007 hmmm, well I made a UDP one but the problem is its counting all the ports as open......hmmmmmmmm 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 More sharing options...
Fabry Posted July 27, 2007 Share Posted July 27, 2007 I'm too. The error doesn't exist. A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center] Link to comment Share on other sites More sharing options...
jvanegmond Posted July 27, 2007 Share Posted July 27, 2007 (edited) UDP is 'fire-and-forget'. That explains why the UDP functions do not return an error.Fire up Wikipedia and view what is the difference between UDP and TCP.Edit: Just found a nice bit on UDP port scanning.UDP ScanningPort scanning usually means scanning for TCP ports, which are connection-oriented and therefore give good feedback to the attacker. UDP responds in a different manner. In order to find UDP ports, the attacker generally sends empty UDP datagrams. If the port is listening, the service should send back an error message or ignore the incoming datagram. If the port is closed, then most operating systems send back an "ICMP Port Unreachable" message. Thus, you can find out if a port is NOT open, and by exclusion determine which ports are open. Neither UDP packets, nor the ICMP errors are guaranteed to arrive, so UDP scanners of this sort must also implement retransmission of packets that appear to be lost (or you will get a bunch of false positives).Also, this scanning technique is slow because of compensation for machines that implement the suggestions of RFC 1812 and limit ICMP error message rate. For example, a kernal may limit destination unreachable message generation to 80 per 4 seconds, with a 1/4 second penalty if that is exceeded.Some people think UDP scanning is pointless - not so. Sometimes for example, Rpcbind can be found hiding on an undocumented UDP port somewhere above 32770. So it doesn't matter that port 111 is blocked by the firewall. But can you find which of the more than 30,000 high ports it is listening on? With a UDP scanner you can. Edited July 27, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Infinitex0 Posted July 27, 2007 Author Share Posted July 27, 2007 I was considering the idea of exclusion instead of inclusion but as it says in the article it (and as I thought, but not to that extent) it takes a long time. O well, just settle for TCP........until I make UDP.....if I do. 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 More sharing options...
Richard Robertson Posted July 27, 2007 Share Posted July 27, 2007 UDP is what is called "unreliable." It is made for speed, so all the overhead of error checking, destination checking, etc, has been removed. As Manadar posted, you would need your own checking system. Link to comment Share on other sites More sharing options...
Pakku Posted July 27, 2007 Share Posted July 27, 2007 (edited) 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() As you can see, it can now easily run in Scite and give you all portnumbers and if they are open or not. And I replaced your loop with a i think better loop for this use. Edited November 16, 2010 by Pakku How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me Link to comment Share on other sites More sharing options...
Infinitex0 Posted July 27, 2007 Author Share Posted July 27, 2007 only problem with that is people may not want to scan every port. 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 More sharing options...
CoderDunn Posted July 27, 2007 Share Posted July 27, 2007 Wow that was alot easier than I thought! You should have a TCPCloseSocket() after the "Success" ... Hallman Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 27, 2007 Share Posted July 27, 2007 Wow, that is pretty nice looking code Arjan. Simple, and easy to understand without running it. Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted July 27, 2007 Share Posted July 27, 2007 (edited) Got to Playing with this, tried to make it a little faster, and found something out: TCPConnect returns -1 for Wrong Address and Port number as well, and it sets @error to 1 or 2, depending on the error. My Version (Still not that fast, mind you): Opt("TCPTimeout",1) $SocketIP = "" $socketportstart = 1 $socketportend = 65535 TCPStartup() For $port = $socketportstart To $socketportend $socket = TCPConnect($SocketIP,$port) Switch $socket Case -1 Switch @error Case 1 ConsoleWrite($port & " - Unable to connect - Wrong Address." & @CRLF) Case 2 ConsoleWrite($port & " - Unable to connect - Wrong Port." & @CRLF) Case Else ConsoleWrite($port & " - Unable to connect." & @CRLF) EndSwitch Case Else TCPCloseSocket($socket) ConsoleWrite($port & " - Success!" & @CRLF) EndSwitch Next TCPShutdown() Edited July 27, 2007 by SkinnyWhiteGuy Link to comment Share on other sites More sharing options...
jvanegmond Posted July 27, 2007 Share Posted July 27, 2007 UDP is what is called "unreliable." It is made for speed, so all the overhead of error checking, destination checking, etc, has been removed. As Manadar posted, you would need your own checking system.Unreliable Datagram Protocol. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now