vared
vared - Blog
vared
전체 방문자
오늘
어제
  • 분류 전체보기 (138)
    • Study (0)
    • Project (0)
    • Paper Review (0)
    • Tool (0)
    • WriteUp (124)
      • Root-me.org (44)
      • LOS_rubiya (32)
      • Webhacking.kr (21)
      • DreamHack (9)
      • XCZ.kr (8)
      • HackCTF (10)
    • Miscellaneous (0)
    • Forensic-CheatSheet (10)

블로그 메뉴

  • Category

공지사항

  • Forensic-CheatSheet 오픈

인기 글

태그

  • Digital Forensic
  • LNK FIile
  • forensic artifacts
  • iconcahce
  • shellbag
  • trim
  • Digital-Forensic
  • File Execution
  • Los
  • Windows Artifact
  • Thumbcache
  • digital-forensics
  • JavaScript
  • webhacking.kr
  • Artifacts
  • sql injection
  • forensic-cheatsheet
  • shellbag forensics
  • ssd

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
vared

vared - Blog

Challenge 18 (100pt)
WriteUp/Webhacking.kr

Challenge 18 (100pt)

2020. 5. 10. 12:05

sql injection 문제다. 제출링크가 있고 get 방식으로 no라는 변수에 넘겨준다는 것을 확인할 수 있다.

밑에줄에는 result 도 출력해준다. 소스를 한번 보자.

<?php
  include "../../config.php";
  if($_GET['view_source']) view_source();
?><html>
<head>
<title>Challenge 18</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
input { background:silver; }
a { color:lightgreen; }
</style>
</head>
<body>
<br><br>
<center><h1>SQL INJECTION</h1>
<form method=get action=index.php>
<table border=0 align=center cellpadding=10 cellspacing=0>
<tr><td><input type=text name=no></td><td><input type=submit></td></tr>
</table>
</form>
<a style=background:gray;color:black;width:100;font-size:9pt;><b>RESULT</b><br>
<?php
if($_GET['no']){
  $db = dbconnect();
  if(preg_match("/ |\/|\(|\)|\||&|select|from|0x/i",$_GET['no'])) exit("no hack");
  $result = mysqli_fetch_array(mysqli_query($db,"select id from chall18 where id='guest' and no=$_GET[no]")); // admin's no = 2

  if($result['id']=="guest") echo "hi guest";
  if($result['id']=="admin"){
    solve(18);
    echo "hi admin!";
  }
}
?>
</a>
<br><br><a href=?view_source=1>view-source</a>
</center>
</body>
</html>

우리가 잘 봐야할 부분은 php 태그 내부이므로, 한번 보자.

Get['no']는 / ( ) | & select from 0x 를 필터링 한다.

주석으로 친절하게 admin의 no가 2라는 것도 알려줬다. 

2를 넣어봤는데 물론 작동하지 않는다. -> 왜냐하면

select id from chall18 where id='guest' and no=$_GET[no]

이기 때문에, id 가 guest로 설정되어있다. 즉 or 문을 이용해서 no=2일때를 넣어주면 되겠다.

?no=0 or no=2

이렇게 넣어주니까 no hack 즉 필터링 당했다. 공백이 필터링되는 것 같다. 공백을 %0a로 넣어주자.

?no=0%0aor%0ano=2

 

Clear!

저작자표시 (새창열림)

'WriteUp > Webhacking.kr' 카테고리의 다른 글

webhacking.kr : challenge 4  (0) 2020.09.11
challenge 57 (600pt)  (0) 2020.08.15
Challenge 26 (100pt)  (0) 2020.05.10
Challenge 38 (100pt)  (0) 2020.05.08
Challenge 15 (old) _50pt  (0) 2020.05.07
    'WriteUp/Webhacking.kr' 카테고리의 다른 글
    • webhacking.kr : challenge 4
    • challenge 57 (600pt)
    • Challenge 26 (100pt)
    • Challenge 38 (100pt)
    vared
    vared

    티스토리툴바