๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • Tried. Failed. Logged.
๐ŸดCTF/webhacking.kr

webhacking.kr - old-11(Challenge 11)

by Janger 2023. 2. 15.
728x90

 

 

view-source

 

<?php
  include "../../config.php";
  if($_GET['view_source']) view_source();
?><html>
<head>
<title>Challenge 11</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
</style>
</head>
<body>
<center>
<br><br>
<?php
  $pat="/[1-3][a-f]{5}_.*$_SERVER[REMOTE_ADDR].*\tp\ta\ts\ts/";
  if(preg_match($pat,$_GET['val'])){
    solve(11);
  }
  else echo("<h2>Wrong</h2>");
  echo("<br><br>");
?>
<a href=./?view_source=1>view-source</a>
</center>
</body>
</html>

 

์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ val์ด๋ผ๋Š” ์ด๋ฆ„์˜ GET ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค,

 

๋งŒ์•ฝ์— ์•„๋ž˜์˜ ์ •๊ทœํ‘œํ˜„์‹์— ์ฐธ์˜ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค๋ฉด ์ •๋‹ต์ฒ˜๋ฆฌ

/[1-3][a-f]{5}_.*$_SERVER[REMOTE_ADDR].*\tp\ta\ts\ts/ 

 

$_SERVER[REMOTE_ADDR]๋Š” ์ ‘์†์ž์˜ ์•„์ดํ”ผ๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ ๋•Œ๋ฌธ์— ์•„์ดํ”ผ ํ™•์ธ ์‚ฌ์ดํŠธ(https://ip.pe.kr/ )์—์„œ ์ž์‹ ์˜ ์ฃผ์†Œ๋ฅผ ์ฐพ๊ณ , ๋‚˜๋จธ์ง€ ์ •๊ทœํ‘œํ˜„์‹๋“ค์ด ๋งŒ์กฑํ•˜๊ฒŒ๋” ๊ฐ’์„ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค. 

 

 

์•„๋ž˜์˜ ์—ฐ์Šต ์‚ฌ์ดํŠธ์—์„œ ์ •๊ทœํ‘œํ˜„์‹ ์กฐ๊ฑด์„ ๋„ฃ์–ด์„œ ์ง์ ‘ ํ™•์ธํ•ด ๋ณด์•˜๋‹ค. 

https://regexr.com/

 

RegExr: Learn, Build, & Test RegEx

RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).

regexr.com

 

 

๋Œ€์ถฉ ๋‚ด ์•„์ดํ”ผ๊ฐ€ 192.168.0.1์ด๋ผ๊ณ  ๊ฐ€์ •์„ ํ•˜๊ณ  ๋‚˜๋จธ์ง€๋Š” ์•Œ์•„์„œ ์ฑ„์›Œ์ค€๋‹ค.

[1-3]: 1~3๊นŒ์ง€ ์•„๋ฌด ์ˆซ์ž

[a-f]{5}: a~f๊นŒ์ง€ ์•„๋ฌด ๋ฌธ์ž ๋‹ค์„ฏ ๊ฐœ ์—ฐ์†

_: _(์–ธ๋”๋ฐ”)

.*: ์ ์€ ์•„๋ฌด ๋ฌธ์ž๋ฅผ ๊ฐ€์ ธ์˜ค๋Š”๋ฐ ๋’ค์— *์ด ๋ถ™์œผ๋ฉด ๊ฐ’์ด ์—†์–ด๋„ ์ƒ๊ด€์ด ์—†๋‹ค. 

192.168.0.1: ์ด๊ณณ์„ ์ž์‹ ์˜ ์•„์ดํ”ผ๋กœ ๋Œ€์ฒด

\t: ํƒญ

 

๊ทธ๋ž˜์„œ ๋‚˜์˜จ ๊ฒฐ๊ณผ๋Š”"1aaaaa_192.168.0.1. p a s s"์ด๋‹ค. 

 

 

๋‹น์—ฐํžˆ ์ด๊ฑธ ๊ทธ๋Œ€๋กœ ๊ฑด๋„ค์ฃผ๋ฉด ์ •๋‹ต์ฒ˜๋ฆฌ๊ฐ€ ์•ˆ ๋๋‹ค. ์™œ๋ƒ๋ฉด  p a s s ์ด ๋ถ€๋ถ„์„ ํƒญ์„ ์ฃผ๊ณ  ๊ฑด๋„ค์ฃผ์—ˆ์ง€๋งŒ ์ž๋™์œผ๋กœ ์‚ฌ๋ผ์ง.

 

๊ทธ๋Ÿฌ๋ฏ€๋กœ URL-encoding์œผ๋กœ ํƒญ์„ ์ˆ˜์ •ํ•ด ์ค€๋‹ค. 

 

https://www.eso.org/~ndelmott/url_encode.html

 

URL-encoding Reference

 

www.eso.org

ํƒญ์€ %09์ด๋ผ ํ•˜๋ฏ€๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •

 

1aaaaa_192.168.0.1.%09p%09a%09s%09s

 

 

 

๋‹ค์‹œ ์ฃผ์†Œ ๋ถ€๋ถ„์— ์ž…๋ ฅ์„ ํ•˜๋ฉด, ์„ฑ๊ณต์ฒ˜๋ฆฌ๊ฐ€ ๋˜์—ˆ๋‹ค. 

728x90

'๐ŸดCTF > webhacking.kr' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

webhacking.kr - old-39  (0) 2023.05.31
webhacking.kr - old-04(Challenge 4)  (1) 2023.02.15
webhacking.kr - old-20(Challenge 20)  (0) 2023.02.15