Created
July 7, 2020 01:35
-
-
Save shitchell/505d67eb5e063737179c7739387ff62e to your computer and use it in GitHub Desktop.
Python script resembling ncat that allows you to send invisible characters using their unicode values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import time | |
import socket | |
import _thread | |
import readline | |
if len(sys.argv) < 3: | |
print('usage: pysock [options] server port') | |
quit() | |
# Go through options | |
if "-u" in sys.argv: | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
else: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
server = sys.argv[-2] | |
port = int(sys.argv[-1]) | |
s.connect((server, port)) | |
def listener(sock): | |
global keepgoing | |
while 1: | |
res = sock.recv(1024) | |
if res == b'': | |
keepgoing = False | |
break | |
res = str(res)[2:-1] | |
print(res) | |
_thread.start_new_thread(listener, (s,)) | |
keepgoing = True | |
try: | |
while 1: | |
tosend = input() | |
tosend = eval("b'" + tosend.replace("'", "\\'") + "'") | |
s.send(tosend) | |
except KeyboardInterrupt: | |
print() | |
quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment