Skip to content

Instantly share code, notes, and snippets.

@shitchell
Created July 7, 2020 01:35
Show Gist options
  • Save shitchell/505d67eb5e063737179c7739387ff62e to your computer and use it in GitHub Desktop.
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
#!/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