Hi please read more about "Error and Exception" and also "Sockets" in python.
I don't know what's write after it but "TimeoutError" mean the connection get over the default time to establish the connection.
This mean u have a problem on the listening program. Just be sure u're "server-side" program is listening on the correct port and on the correct address (loopback or localIP).
U use the "try:" statement code block when u are going to use a piece of code which will probably have an exception/s. U use the "except:" statement code block to manage that/those exception/s.
U should change ur code in: try: connect.connect((hostname, 21)) response = connect.recv(2000) print(response)
the script now will do the connection, then wait for an incoming message, then print it, then go over the except code block, send the "username" to other back-end, then wait for an incoming message, then print it.
If u get an error inside the try block the code will run the code inside the "except block".
Actually u are generating an exception inside another exception (1 exception when u try to connect, this execute the code inside the "except" code block which arise another exception because u try to read data-stream from a socket which isn't connected )
Oh also, this isn't an exploit but just a client for a TCP connection ^^
1 Response
Hi
please read more about "Error and Exception" and also "Sockets" in python.
I don't know what's write after it but "TimeoutError" mean the connection get over the default time to establish the connection.
This mean u have a problem on the listening program. Just be sure u're "server-side" program is listening on the correct port and on the correct address (loopback or localIP).
U use the "try:" statement code block when u are going to use a piece of code which will probably have an exception/s.
U use the "except:" statement code block to manage that/those exception/s.
U should change ur code in:
try:
connect.connect((hostname, 21))
response = connect.recv(2000)
print(response)
except:
print("- Connection Error")
sys.exit(1)
connect.send("user %s\r\n" %username)
response = connect.recv(2000)
print(response)
the script now will do the connection, then wait for an incoming message, then print it, then go over the except code block, send the "username" to other back-end, then wait for an incoming message, then print it.
If u get an error inside the try block the code will run the code inside the "except block".
Actually u are generating an exception inside another exception (1 exception when u try to connect, this execute the code inside the "except" code block which arise another exception because u try to read data-stream from a socket which isn't connected )
Oh also, this isn't an exploit but just a client for a TCP connection ^^
Share Your Thoughts