목록전체 글 (33)
D1N0's hacking blog
문제 풀이 코드를 보면 '를 필터링하고 있고, id를 전부 소문자로 바꾸고, "admin"을 ""으로 바꾼다 Troll문제에서 사용한 대소문자로 우회하는 것도 사용할 수 없다 때문에 str_replace에서의 취약점을 이용할 것이다 풀이 id=adadminmin 언뜻 보면 str_replace("admin","",$_GET[id]);에서 모든 admin이 지워져서 admin을 쓰지 못할 것 같지만, 문제는 admin을 한 번만 날린다는 것이다 id를 adadminmin처럼 쓰면 가운데의 admin이 사라지면서 양 끝의 ad와 min만 남아 admin이 된다
문제 풀이 코드를 보면 id가 admin이기만 하면 되는 것 같다 그러나 admin과 '를 필터링해서 우회를 해야 한다 풀이 id=Admin preg_match 구문을 잘 보면 /뒤에 i가 없는데, 이는 대소문자 구분을 한다는 것이다 SQL은 대소문자 구분을 하지 않기 때문에 id의 일부를 대문자로 쓰면 필터링에 걸리지 않으면서 admin취급을 받는다
문제 풀이 코드를 보니 or과 and를 필터링하고 있다 그리고 믿에서 pw를 직접 검사하기 때문에 Blind SQL injection을 통해 pw를 알아내야 한다 STEP 0 - SQL injection 취약점 확인 pw=' || id='admin' %26%26 1=1;%23 이렇게 쓰면 Hello admin이 뜬다 이를 이용해 Blind SQL injection을 한다 STEP 1 - pw 길이 구하기 pw=' || id='admin' %26%26 length(pw) = [길이 추측];%23 이를 이용해 길이를 구할 수 있다 직접 하기 귀찮으니 파이썬 코드를 짠다 import requests target = "https://los.rubiya.kr/chall/orge_bad2f25db233a7542be..