저장소

[webhacking.kr] 34번 풀이 본문

IT/웹 해킹

[webhacking.kr] 34번 풀이

huiu 2021. 8. 12. 21:57

https://webhacking.kr/

 

Webhacking.kr

Index Welcome Stranger! Chatting Notice(en) [2021-04-16] Score of old challenges has been adjusted to 1/10. For a while now, new challenges will be added "without" notice. [2020-08-12] Replace chat feature with Discord. Please do not cause inconvenience to

webhacking.kr

34번 문제를 클릭했을 때 debug me 라는 메시지 창이 팝업되고 아무런 반응이 없다.

크롬 기준 단축키 F12(Ctrl+Shift+I)를 사용해 소스코드를 확인했다.

script 부분이 매우 복잡하다. 처음에 팝업창을 띄우기 위해 사용되었을 것으로 추측되는 alert 함수를 Ctrl+F로 찾아보았다.

if-else 문에 걸려있다. b 함수에 '0x1e', '14cN' 라는 값을 전달하면 처음에 봤던 메시지 창이 뜨는 것으로 추측된다.

콘솔탭으로 가서 자바스크립트를 실행해봤다. debug me 라는 메시지 창이 팝업된다.

b 함수를 찾기 전에 if문에 걸려있는 조건도 b(인자1, 인자2)인 형태를 띄고 있어 각각 콘솔탭에서 실행해보았다.

실행 결과 의미있는 구문이 출력되고 있었다.

// Script
if(location[b('0x19','iUmC')][b('0x1a','6]r1')](0x1)==b('0x1b','RLUb'))location[b('0x1c','4c%d')]=b('0x1d','llaF');
else alert(b('0x1e','14cN'));

// Console
if(location["hash"]["slice"](0x1)=="Passw0RRdd")location["href"]="./?Passw0RRdd=1";
else alert("debug me");

보기 편하도록 간단하게 치환해서 적어보았다.

링크와 관련된 것 같아 URL의 마지막 부분에 ?Passw0RRdd=1를 추가해보았다.

문제 풀이에 성공했다.

다른 풀이를 참고해보니 자바스크립트가 복잡하게 작성되어있을 때 편하게 볼 수 있도록 변경해주는 사이트(JavaScript Beautifier로 검색하면 다양한 사이트가 나옴)를 이용하는 방법도 있다고 한다.

 

https://beautifier.io/

 

Online JavaScript beautifier

 

beautifier.io

https://codebeautify.org/jsviewer

 

Best Javascript Beautifier tool work as JavaScript Formatter and JavaScript Viewer

Secure JavaScript Beautifier, Viewer, Editor, Minify, Formatter, Obfuscator - Convert JS/Javascript Strings to a Friendly Readable Format.

codebeautify.org

개인적으로 보기 편하다고 느낀 사이트

 

b 함수를 찾아본 결과 매우 복잡하게 생겼음을 알 수 있었다.

'IT > 웹 해킹' 카테고리의 다른 글

[webhacking.kr] 35번 풀이  (0) 2021.08.20
[webhacking.kr] 3번 풀이  (0) 2021.08.20
[webhacking.kr] 54번 풀이  (0) 2021.08.13
[webhacking.kr] 17번 풀이  (0) 2021.08.09
[webhacking.kr] 16번 풀이  (0) 2021.08.09
Comments