웹해킹

webhacking.kr Challenge 44 풀이

Hoin.s 2023. 11. 22. 13:46
 

Challenge 44

 

webhacking.kr:10005

<?php
  if($_GET['view_source']){ highlight_file(__FILE__); exit; }
?><html>
<head>
<title>Challenge 44</title>
</head>
<body>
<?php
  if($_POST['id']){
    $id = $_POST['id'];
    $id = substr($id,0,5);
    system("echo 'hello! {$id}'"); // You just need to execute ls
  }
?>
<center>
<form method=post action=index.php name=htmlfrm>
name : <input name=id type=text maxlength=5><input type=submit value='submit'>
</form>
<a href=./?view_source=1>view-source</a>
</center>
</body>
</html>

POST방식으로 id 값을 받고 id의 길이는 5라는 걸 알  수 있다. 

 

system("echo 'hello! {$id}'");에서 ls를 실행하기 위해 ';'ls를 입력하면 system("echo 'hello! ';'ls'"); 구문이 작성되어 ls를 수행한 결과가 표시된다.

성공