import os
import sys
import time
import shutil
def replicate(): # 1 usage
current_file = os.path.abspath(sys.argv[0])
current_dir = os.path.dirname(current_file)
print(f"[*] Starting process: {os.path.basename(current_file)}")
max_copies = 10
existing_copies = len(
[f for f in os.listdir(current_dir) if f.startswith("copy_")]
)
if existing_copies >= max_copies:
print("[*] Ending process")
return
for i in range(1, max_copies - existing_copies + 1):
new_name = f"copy_{existing_copies + i}.py"
new_path = os.path.join(current_dir, new_name)
if not os.path.exists(new_path):
try:
shutil.copy2(current_file, new_path)
print(f"[+] Copying {new_name}")
os.system(
f"python {new_path} &"
if os.name != "nt"
else f"start /B python {new_path}"
)
except Exception as e:
print(f"[-] Copying {new_name}")
time.sleep(0.5)
print("[+] Copying success")
if __name__ == "__main__":
replicate()