Untitled
unknown
python
a year ago
838 B
1
Indexable
Never
import http.client def execute_command(command): conn = http.client.HTTPConnection(host_ip, host_port) conn.request('GET', f'/execute?{command}') response = conn.getresponse() return response.read().decode() def session_handler(): while True: try: command = input('Enter command: ') if command == 'exit': execute_command('exit') print('[-] The server has terminated the session.') break else: response = execute_command(command) print(response) except KeyboardInterrupt: print('[+] Keyboard interrupt issued.') break except Exception as e: print('Error:', str(e)) break host_ip = '127.0.0.1' host_port = 8080 session_handler()