Python programming language has a socket object, which you can use to build a network socket. To build a client that connects to a remote host and sends some arbitrary text, utilize the following code.
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 4242))
s.send('Some Arbitrary Text')
data = s.recv(1024)
s.close()
print 'Received', 'data'
Now you can connect to this with a netcat listener:
nc -l -p 4242
You should receive "Some Arbitrary Text" as the output. Can you start to see the practical applications? :-)
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 4242))
s.send('Some Arbitrary Text')
data = s.recv(1024)
s.close()
print 'Received', 'data'
Now you can connect to this with a netcat listener:
nc -l -p 4242
You should receive "Some Arbitrary Text" as the output. Can you start to see the practical applications? :-)
Leave a comment