Pastebin

Paste #3916: python netcat

< previous paste - next paste>

Pasted by tdn

Download View as text

import socket

def netcat(hostname, port, content):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((hostname, port))
    s.sendall(content)
    s.shutdown(socket.SHUT_WR)
    while 1:
        data = s.recv(1024)
        if data == "":
            break
        print "Received:", repr(data)
    print "Connection closed."
    s.close()

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.