How to steal cookies via XSS using remote server !
Thehackingverse | Security Researcher @bugdetector
5/8/20243 min read


Hi everyone my name is thehackingverse and i am security researchers at bugdetectors. In this blog we will learn how to steal cookies via xss using your remote server.
Let's get started.
In this blog we are using a test web application to understand whole mechanism .
Go to https://demo.testfire.net/ and create login or do sign-in. Once you logged in your account this web application make cookies of your login.
What is Cookies ?
A cookie is a small piece of data that a web server sends to a user's browser to store information about the user and their website activity. Whenever you visit any website then website ask that this site is using cookie. That means your search will saved by your browser and next time you visit that website then cookie will display your information as "Your Favorites , Recommends for you" and etc. In modern web application developers use cookies in their application to store their session of users in their browser.
Attackers steals that cookies from victims browser to takeover their accounts. In above paragraph we created our account on https://demo.testfire.net/ . When you logged in this site this will store cookies in your browser. Now this application is vulnerable to xss that means you can steal cookies of any victims of this website using your remote server.
How attackers steal cookies via xss using remote server ?
To steal cookies via xss in any web application. First attacker starts finding security vulnerability name cross site scripting ( XSS).
What is XSS ?
XSS stands for cross site scripting and its security flaws in web application where attacker is able to execute their JavaScript code on any web application.
Now the question is raise how an attacker founds XSS flaw in any web application. Usually an attacker try to start crawling the functionality of the web application and try to find out fields like search or input fields where he/she can execute their JavaScript code.
Similarly in our above website we found xss flaw in search field on this web application https://demo.testfire.net/ and we are able to execute the xss like this.


Now create one php script like this to steal cookies and upload this script on your remote server.


This script will create a file named data.txt on your remote server whenever script receive request using GET method.
Go back to your website and execute this payload on your search field.


Now this payload will send the cookies of your web application on your remote server where you host your file and that script will create a file called data.txt on your remote server.


Thanks for reading this blog.
Happy Hacking !!




When you opened that file on your remote server you see the cookies of your web application.


Bug Detectors
You Build We Hack !
We are team of security researcher's where we are helping the industry via providing the security consultancy and training with the prior experience of our researcher's in order to keep them secure.
Connect with us
Join our academy
info@bugdetector.in
+91 8178925263
© 2025. All rights reserved.

