개요
- SQL Injection 취약점을 찾아주는 툴이다. SQL Injection 탐지에 대해서는 아마도 가장 뛰어날 툴일 것이다.
- 탐지 뿐만 아니라 실제 공격까지 수행할 수 있으므로 해킹툴로도 사용될 수 있다.
설치
wget -O sqlmap.zip https://github.com/sqlmapproject/sqlmap/zipball/master
unzip sqlmap.zip
# 압축풀린 디렉토리로 이동
cd sqlmapproject-sqlmap-c5d7c54
python3 sqlmap.py
옵션
자주 사용하는 옵션
몇 가지 자주 사용하는 옵션을 정리해둔다.
-u : URL 지정
-v : verbose옵션.
--cookie: cookie를 설정해서 HTTP요청을 보낸다.
--tables: 테이블명을 조사한다.
--current-db: 동작중인 DB명를 조사한다.
--is-dba: DBA권한으로 동작중인지 확인한다.
-D : DB명을 지정한다
--columns: 컬럼명을 조사한다.
--dump: 데이터를 조사한다.
--level=LEVEL: 레벨을 지정한다. (1~5, 기본값은 1)
--risk=RISK: 리스크를 지정한다. (1~3, 기본값은 1)
--test-filter: 실시하고 싶은 테스트를 지정할 수 있다. 예를들어 "time-based blind"로 값을 줄 수 있다.
--dbs: 데이터베이스 목록을 조사한다.
--r: HTTP요청 파일을 지정 (HTTP요청 전체를 텍스트파일로 저장한 뒤에 -r옵션으로 지정할 수 있다. 해당 요청을 베이스로 테스트해준다.)
level에 대해서
- Level1: 가장 기본적인 디텍션을 수행 (아마도 HTTP 파라메터로 수행하는 것 같다.)
- Level2: HTTP 쿠키 헤더를 추가로 수행한다.
- Level3: HTTP User-Agent/Referer 헤더를 추가로 수행한다.
risk에 대해서
- Risk1: 가장 기본적인 SQL injection 테스트를 수행한다.
- Risk2: time-based SQL injection 테스트를 추가해서 수행한다.
- Risk3: OR-based SQL injection 테스트를 추가해서 수행한다.
그러나 Risk1로 지정해도 time-based나 OR-based 테스트가 수행되기도 한다.결국 Risk에 대해서는 아직 잘 모르겠다.
전체 옵션
옵션이 너무 많다. -h로도 전체옵션은 나오지 않는다. -hh 옵션으로 전체 옵션을 볼 수 있다.
python3 sqlmap.py -h
___
__H__
___ ___[(]_____ ___ ___ {1.7.2.8#dev}
|_ -| . [,] | .'| . |
|___|_ ["]_|_|_|__,| _|
|_|V... |_| https://sqlmap.org
Usage: python3 sqlmap.py [options]
Options:
-h, --help Show basic help message and exit
-hh Show advanced help message and exit
--version Show program's version number and exit
-v VERBOSE Verbosity level: 0-6 (default 1)
Target:
At least one of these options has to be provided to define the
target(s)
-u URL, --url=URL Target URL (e.g. "http://www.site.com/vuln.php?id=1")
-g GOOGLEDORK Process Google dork results as target URLs
Request:
These options can be used to specify how to connect to the target URL
--data=DATA Data string to be sent through POST (e.g. "id=1")
--cookie=COOKIE HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..")
--random-agent Use randomly selected HTTP User-Agent header value
--proxy=PROXY Use a proxy to connect to the target URL
--tor Use Tor anonymity network
--check-tor Check to see if Tor is used properly
Injection:
These options can be used to specify which parameters to test for,
provide custom injection payloads and optional tampering scripts
-p TESTPARAMETER Testable parameter(s)
--dbms=DBMS Force back-end DBMS to provided value
Detection:
These options can be used to customize the detection phase
--level=LEVEL Level of tests to perform (1-5, default 1)
--risk=RISK Risk of tests to perform (1-3, default 1)
Techniques:
These options can be used to tweak testing of specific SQL injection
techniques
--technique=TECH.. SQL injection techniques to use (default "BEUSTQ")
Enumeration:
These options can be used to enumerate the back-end database
management system information, structure and data contained in the
tables
-a, --all Retrieve everything
-b, --banner Retrieve DBMS banner
--current-user Retrieve DBMS current user
--current-db Retrieve DBMS current database
--passwords Enumerate DBMS users password hashes
--dbs Enumerate DBMS databases
--tables Enumerate DBMS database tables
--columns Enumerate DBMS database table columns
--schema Enumerate DBMS schema
--dump Dump DBMS database table entries
--dump-all Dump all DBMS databases tables entries
-D DB DBMS database to enumerate
-T TBL DBMS database table(s) to enumerate
-C COL DBMS database table column(s) to enumerate
Operating system access:
These options can be used to access the back-end database management
system underlying operating system
--os-shell Prompt for an interactive operating system shell
--os-pwn Prompt for an OOB shell, Meterpreter or VNC
General:
These options can be used to set some general working parameters
--batch Never ask for user input, use the default behavior
--flush-session Flush session files for current target
Miscellaneous:
These options do not fit into any other category
--wizard Simple wizard interface for beginner users
[!] to see full list of options run with '-hh'
참고 링크
- https://security.stackexchange.com/questions/162979/what-are-the-consequences-of-increasing-the-risk-option-of-sqlmap
- https://github.com/sqlmapproject/sqlmap/wiki/Usage