목록Web (18)
D1N0's hacking blog
보호되어 있는 글입니다.
문제 풀이 세상에... 따옴표를 필터링하고 있다 지금까지 사용했던 SQL 인젝션 기법으로는 풀 수 없어 보인다 유일하게 전과 다른 것은 쿼리문에서 =이 아니라 like를 사용한다는 것이다 like는 =과 비슷하게 작동하여 전에 =을 우회하기 위해서도 사용하였지만 한 가지 큰 차이점이 있는데, 바로 와일드카드를 사용할 수 있다는 점이다 STEP 0 - SQL injection 취약점 확인 like는 특정 문자를 모르더라도 검색할 수 있는 와일드카드 %와 _를 지원한다 %는 문자의 길이에 관계없이 어떤 문자가 오던 상관없이 가져오고, _는 딱 한 글자를 어떤 문자던지 상관없이 가져온다 예를 들어, A%B라면 ACB, A1234B, AB 등을 모두 가져오고, A_B라면 ACB는 가져올 수 있지만 AB, A12..
문제 풀이 코드를 보면 입력받는 쿼리는 shit 하나이다 shit의 길이가 1을 넘으면 No Hack이 뜨고, 띄어쓰기, 개행, 캐리지 리턴, 탭도 필터링한다 필터링만 봐도 공백을 우회하는 방법을 묻는 문제임을 알 수 있다 아마 정상적으로 우회했다면 from과 prob_giant가 떨어지면서 SQL 구문이 정상적으로 1234를 반환할 것이다 풀이 shit=%0b shit=%0c 전에도 공백을 우회하는 비슷한 문제가 있었다 Lord of SQL injection - Wolfman 문제 풀이 언뜻 보면 pw=' or id = 'admin';%23으로 풀 수 있을 것 같지만 코드를 보면 공백을 필터링하고 있다 불필요한 공백을 지우더라도 or과 id는 띄워야 한다 SQL에서 공백은 Tab, Line Feed, ..
문제 풀이 5번 파일에 플래그가 있다는데 5번 버튼이 없다 다 눌러봐도 Nop만 뜬다 그런데 이동한 페이지를 자세히 보면 ?id=[숫자] 형태가 붙어있다 ?[파라미터 이름]=[파라미터 값] 형태로 데이터를 넘겨주는 것을 GET방식이라 하는데, 문제에서 id에 번호를 GET방식으로 넘겨주는 듯 하다 실제로 소스를 보면 id에 GET방식으로 각각 1,2,3,4를 넘겨주는 것을 알 수 있다 5번 파일에 플래그가 있다고 했으므로 ?id=5로 넘겨주면 플래그가 나온다 FLAG : HackCTF{idx_is_so_s1m3le_ctf}
문제 풀이 들어가보면 Hidden Flag라는 문구와 로봇 사진만 있다 아마 저 로봇 사진이 힌트인듯 하다 로봇과 웹 하면 생각할 수 있는게 robots.txt이다 robots.txt는 크롤링 봇들이 사이트에 접근하지 않도록 하는 일종의 안내문이다 사이트에서 robots.txt에 들어가보면 User-agent: * Disallow: /robot_flag/ 이런 것을 볼 수 있다 모든 봇에 대해 /robot_flag/ 로의 접근을 막겠다는 건데, 너무 수상해보인다 /robot_flag/에 들어가보면 바로 플래그가 나온다 FLAG : HackCTF{w3lcome_to_s1mple_web_h3cking!}
문제 풀이 코드를 보면 ', substr, ascii, =, or, and, 공백, like, 0x를 필터링하고 있다 '는 no 부분에 '가 없기 때문에 우회 가능하고, substr은 mid, ascii는 char, or는 ||, and는 &&(%26%26)로 우회 가능하며, 공백은 tab이나 괄호 등으로 우회 가능하다 문제는 =과 like인데, 이와 비슷한 기능을 하는 instr을 이용하면 우회할 수 있다 STEP 0 - SQL injection 취약점 확인 no=1234||instr(id,char(97,100,109,105,110));%23 instr은 일치하는 문자열의 개수를 반환하는 함수인데, instr([문자열], [찾을 문자열])을 통해 =을 우회할 수 있다 STEP 1 - pw 길이 구하기 ..
문제 풀이 코드를 보면 pw를 직접 비교하기 때문에 pw를 구해야 한다 blind SQL injection을 쓰면 될 것 같은데 잘 보니 '를 필터링한다 그러나 no에 '가 없으니 Goblin문제처럼 SQL injection이 가능하다 substr, ascii, =를 필터링하는 것은 Golem문제처럼 각각 mid, ord, like로 우회 가능하다 STEP 0 - SQL injection 취약점 확인 no=1234 or id like char(97, 100, 109, 105, 110);%23 like와 char을 이용해 필터링을 우회하면 Hello admin을 띄울 수 있다 이제 pw를 찾아보자 STEP 1 - pw 길이 구하기 no=1234 or id like char(97, 100, 109, 105,..
문제 풀이 문제를 보면 pw를 직접 비교하기 때문에 Blind SQL injection으로 pw를 알아내야 한다 그러나 or, and, substr(, =을 필터링하고 있다 or과 and는 전처럼 ||, &&로 우회 가능하고, =은 like로 우회 가능하다 참고로 like는 부분적으로 일치하는 부분이 있는지 확인할 때 사용하는 구문이지만 특정기호 없이 글자만 넣으면 =과 같은 역할을 한다 substr을 우회할 수 있는건 많이 있지만 여기서는 mid를 이용했다 STEP 0 - SQL injection 취약점 확인 pw=' || id like 'admin';%23 or -> || , = -> like로 하면 Hello admin이 뜬다 이를 이용해 pw를 구해보자 STEP 1 - pw 길이 구하기 pw=' ..
문제 풀이 코드를 보면 id를 guest로 두고 심지어 뒤에 false구문까지 뒀다 그러나 다행히 '를 필터링하지 않기 때문에 전에 간단한 SQL injection으로 인증할 수 있다 첫 번째 풀이 pw=' or id='admin';%23 or을 사용해 id가 admin인 행을 가져오고 1=0 부분은 주석으로 날린다 두 번째 풀이 pw=' or id='admin' or ' 주석을 쓰지 않고 1=0 부분을 or로 처리할 수도 있다
문제 풀이 코드를 보면 '를 필터링하고 있고, id를 전부 소문자로 바꾸고, "admin"을 ""으로 바꾼다 Troll문제에서 사용한 대소문자로 우회하는 것도 사용할 수 없다 때문에 str_replace에서의 취약점을 이용할 것이다 풀이 id=adadminmin 언뜻 보면 str_replace("admin","",$_GET[id]);에서 모든 admin이 지워져서 admin을 쓰지 못할 것 같지만, 문제는 admin을 한 번만 날린다는 것이다 id를 adadminmin처럼 쓰면 가운데의 admin이 사라지면서 양 끝의 ad와 min만 남아 admin이 된다