import paramiko, sys, io, time sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8") JD_HOST = "111.228.37.165" JD_USER = "root" JD_PASS = "Liudecai110" LAB_HOST = "216.144.233.14" LAB_USER = "root" LAB_PASS = "Kt9V72Tx2c48ChikKU" # Fix script that modifies BOTH server blocks FIX_SCRIPT = r''' import shutil # Fix the "default" config (server_name: gfil-lab.com - this is the one that actually serves gfil-lab.com) src = "/etc/nginx/sites-enabled/default" bak = "/etc/nginx/sites-enabled/default.bak.before-robots" shutil.copy2(src, bak) with open(src, "r") as f: content = f.read() robots_block = " location = /robots.txt {\n alias /var/www/gfil-lab/robots.txt;\n default_type text/plain;\n }\n\n" if "robots.txt" not in content: content = content.replace(" location / {", robots_block + " location / {") with open(src, "w") as f: f.write(content) print("INSERTED into default") else: print("ALREADY in default") ''' script_path = r"C:\Users\thinkpad\AppData\Local\Temp\kilo\fix_default.py" with open(script_path, "w") as f: f.write(FIX_SCRIPT) jd = paramiko.SSHClient() jd.set_missing_host_key_policy(paramiko.AutoAddPolicy()) jd.connect(JD_HOST, port=22, username=JD_USER, password=JD_PASS, timeout=20, banner_timeout=60, allow_agent=False, look_for_keys=False) sftp = jd.open_sftp() sftp.put(script_path, "/tmp/fix_default.py") sftp.close() # SCP and run scp_cmd = "sshpass -p '" + LAB_PASS + "' scp -o StrictHostKeyChecking=no /tmp/fix_default.py " + LAB_USER + "@" + LAB_HOST + ":/tmp/fix_default.py" stdin, stdout, stderr = jd.exec_command(scp_cmd, timeout=15) stdout.channel.recv_exit_status() run_cmd = "sshpass -p '" + LAB_PASS + "' ssh -o StrictHostKeyChecking=no " + LAB_USER + "@" + LAB_HOST + " 'python3 /tmp/fix_default.py && echo --- && cat /etc/nginx/sites-enabled/default && echo --- && nginx -t 2>&1 && (systemctl reload nginx && echo NGINX_OK) || (cp /etc/nginx/sites-enabled/default.bak.before-robots /etc/nginx/sites-enabled/default && nginx -t && systemctl reload nginx && echo ROLLBACK_OK) && rm -f /tmp/fix_default.py'" stdin, stdout, stderr = jd.exec_command(run_cmd, timeout=30) print(stdout.read().decode()) jd.close() time.sleep(2) # === STEP 2: Code verification === print("\n=== STEP 2: CODE VERIFICATION ===") # 2a. External check import urllib.request all_pass = True for domain in ["gfil-lab.com", "gfil-intel.xyz"]: # Homepage try: req = urllib.request.Request("https://" + domain + "/", headers={"User-Agent": "Mozilla/5.0"}) r = urllib.request.urlopen(req, timeout=10) print(f" {domain} homepage: {r.status} OK") except Exception as e: print(f" {domain} homepage: ERROR {e}") all_pass = False # robots.txt try: req = urllib.request.Request("https://" + domain + "/robots.txt", headers={"User-Agent": "Mozilla/5.0"}) r = urllib.request.urlopen(req, timeout=10) content = r.read().decode() checks = { "GPTBot": "GPTBot" in content, "ClaudeBot": "ClaudeBot" in content, "PerplexityBot": "PerplexityBot" in content, "Sitemap": "Sitemap:" in content, "Size>500": len(content) > 500, } status = "PASS" if all(checks.values()) else "FAIL" if not all(checks.values()): all_pass = False print(f" {domain} robots.txt: [{status}] {dict(checks)}") except Exception as e: print(f" {domain} robots.txt: ERROR {e}") all_pass = False # Googlebot try: req = urllib.request.Request("https://gfil-lab.com/robots.txt", headers={"User-Agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"}) r = urllib.request.urlopen(req, timeout=10) content = r.read().decode() print(f" Googlebot -> gfil-lab.com/robots.txt: {r.status}, GPTBot={'GPTBot' in content}") except Exception as e: print(f" Googlebot check: ERROR {e}") all_pass = False print() if all_pass: print("ALL CODE CHECKS PASSED") else: print("SOME CHECKS FAILED") # === STEP 3: Human checklist === print("\n" + "=" * 60) print("STEP 3: HUMAN OBSERVATION CHECKLIST") print("=" * 60) print() print("Please manually verify:") print(" 1. https://gfil-lab.com/ -> loads normally") print(" 2. https://gfil-lab.com/robots.txt -> shows FULL version with GPTBot/ClaudeBot/PerplexityBot") print(" 3. https://gfil-intel.xyz/robots.txt -> shows robots.txt") print(" 4. https://gfil-lab.com/login -> login page works") print() print("Rollback if needed:") print(" ssh root@216.144.233.14") print(" cp /etc/nginx/sites-enabled/default.bak.before-robots /etc/nginx/sites-enabled/default") print(" cp /etc/nginx/sites-enabled/gfil.bak.before-robots /etc/nginx/sites-enabled/gfil") print(" systemctl reload nginx")