i do not want to get flamed for this because it might sound like i want to learn about DOS, which i do not
but
is there a way i can force multiple connections to a given port?
this is to test my VNC server and web server
Printable View
i do not want to get flamed for this because it might sound like i want to learn about DOS, which i do not
but
is there a way i can force multiple connections to a given port?
this is to test my VNC server and web server
Yeah, telnet to the port multiple times.
can i automate this or do i have to type in >: telnet xyz 5900 again and again?
Wouldn't it be more fun to try this yourself or learn how to do it yourself??? What's the point in it if you don't learn anything?Quote:
Originally posted here by yellowcat
can i automate this or do i have to type in >: telnet xyz 5900 again and again?
Regardless.. this can be done quite easily in python:
How do you run it... how does it work... what do you need... Well that's up to you... but there's a very simple script for you (Yes I realize I could have made it easier... but where's the fun in that)... Also I didn't incorporate any error checking... so you'll die on errors... but it'll still do what you want.Code:#!/usr/bin/env python
import threading
import socket
import sys
class threadedConnect ( threading.Thread ):
def __init__ ( self, host, port, timeout ) :
self.host = host # host to connect to
self.port = port # port to connnect to
self.timeout = timeout # 0 for no timeout
threading.Thread.__init__ ( self )
def run ( self ) :
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
self.sock.settimeout( self.timeout )
self.sock.connect ( ( self.host, self.port ) )
print self.sock.recv( 1024 )
#Init Variables
host = sys.argv[ 1 ]
port = int ( sys.argv[ 2 ] )
timeout = int ( sys.argv [ 3 ] )
connCount = int ( sys.argv [ 4 ] )
for x in xrange ( connCount ) : #Number of connections to make
threadedConnect( host, port, timeout).start()
Peace,
HT
well i should now take up programming!!
read a few books but they ALL start off with 'hello world' and do not get more exciting than that
will give it a go
cheers for the script
well i have run it and yes there are errors!!
no idea what IndexError means but having a look on web to see
does not like the import socket line or host = sys.argv [1]
You will need to learn how to walk before you're able to run ;)Quote:
Originally posted here by yellowcat
well i should now take up programming!!
read a few books but they ALL start off with 'hello world' and do not get more exciting than that
ok done some playing around with the code
to no avail
i changed this
host = sys.argv[ 1 ]
to this
host = int ( sys.argv[ 1 ] )
but that did not work
and IndexError seems to be a universal type of error in many programming languages
am i missing modules?
i have tried several pre written scripts with
import socket
but non of them work.......
Hey Hey
If you've got Python, you've got everything you need to run the script and there are no changes that have to be made... it works perfectly the way it is.
I'd suggest you go look up why sys.argv[] is used... That will be your clue...
Peace,
HT
will google for sys.argv[ 1 ]
but i keep getting this error
(am ru itnning it from the command prompt and running xp)
Traceback (most recent call last):
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 5, in ?
import socket
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 28, in ?
host = int (sys.argv[ 1 ] )
IndexError: list index out of range
IndexError: list index out of range
This is your key.... It's actually a very, very simply solution...
Try just sys.argv
In python [x] denotes the x+1 item in a list (because we start counting with 0)
so sys.argv[ 1 ] is looking for the 1 + 1 (2nd) item.. Compare that with the first google result for sys.argv
5.12. Handling command line arguments
So now we've got command line arguments and a list... well command line arguments are a list aren't they...
nmap -sV -P0 -O 192.168.1.1 (that's just a list of flags and arguments)
Perhaps then the script is looking for command lines to follow it... Looking at the script I see 4 variables with sys.argv assignments... I bet that means 4 items...
host = 1
Port = 2
timeout = 3
connCount = 4
I'll tell you that scriptname = 0
so perhaps it's python scriptname host port timeout connCount :)
Peace,
HT
now that was impressive
i am supposed to be a smart cookie too!!
did not understand much of it but am off googleing myself into the ground!!
adding and taking stuff away from the code to see what happens!
ok now i have more of an understanding
so i did this
C:\Documents and Settings\mhodgson\Desktop>socket.py 192.168.2.2 80 3 4
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
Exception in thread Thread-4:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
Exception in thread Thread-5:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
Exception in thread Thread-7:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\Documents and Settings\mhodgson\Desktop\socket.py", line 20, in r
self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
AttributeError: 'module' object has no attribute 'AF_INET'
(where it says r should be run!!)
so what the tom dick and harry does that mean?
i am all ears!
btw cheers for help so far
ok now i am thinking
so i typed
socket.py -198.162.2.2 -80 -3 -4
and this did not return any errors
so to see if anything was being sent i fired up etherial (wireshark!!)
ran the script and nothing seemed be sent?
how am i doing??
You shouldn't have the - in front of each one..Quote:
Originally posted here by yellowcat
ok now i am thinking
so i typed
socket.py -198.162.2.2 -80 -3 -4
and this did not return any errors
so to see if anything was being sent i fired up etherial (wireshark!!)
ran the script and nothing seemed be sent?
how am i doing??
As for the initial error.. Is this Python from Python.org or ActiveState Python (they have differences)...
python is from python.org green snakey icons all over my desktop
if i do not put in the -'s i get all those errors
have tried to do it by taking some out
and still getting all the errors
however have learnt a lot about what a sys.avgr s are!
hang on
with -'s in
C:\Documents and Settings\mhodgson\Desktop>socket.py -192.168.2.2 -80 -3 -4
C:\Documents and Settings\mhodgson\Desktop>
see no errors