Friday, May 18, 2012

Bypassing XSS filter in alert msg box

Chintan, Ronnie and I were discussing about one issue regarding how to bypass a specific XSS filter in alert message box. We were unable to breakout.
Chintan's problem statement was:
I am running into one issue with XSS and was interested if there is any way I can bypass it.
Following the response code where user supplied input is embedded. Input is taken via a text box.
<script type="text/javascript">alert('No Information is found for the card 1');script>

User supplied input 1 is highlighted in red. I am trying to break out of this alert box, however when a single quote is given as input, the output is escaped using a backslash. It is as follows:

Input:     1'
Output: <script type="text/javascript">alert('No Information is found for the card 1\'');script>

I am using IE 8 and tried using back ticks just to check if I can get around this limitation, however it did not work.
Any suggestion on how to break out of this would be much helpful.

All characters except the single quote, <!-- and </script> are working.
I tried the following vector to escape out:

Input:     1`);alert(1);(`');
Output:
<script type="text/javascript">alert('No Information is found for the card 1`);alert(1);(`');script>

So, after a serires of discussion we came out with the solution:
;/\');alert(1);//  or   \');alert(\'XSS

And now this was successful bypass:
<script type="text/javascript">alert('No Information is found for the card ;/\\');alert("XSS");//');</script>
So, we successfully bypassed it

Thursday, May 17, 2012

Closing PPTP on 1723

To know about PPTP go to : http://en.wikipedia.org/wiki/Point-to-Point_Tunneling_Protocol 
Basically PPTP is used as method to connect and implement VPN (Virtual Private Networks). There have been other protocols as well for example, IPSec. PPTP has been often criticized for its well known vulnerabilities, like weak encryption etc. But I am not concerned with all these, my challenge was to explore the ways to close the PPTP(Port 1723) on a machine (Windows XP). I did a lot of googling around on the web for hours but was unable to find any satisfying solution. Most results were related to how to setup a VPN connection using PPTP on a Windows client machine. But my question was how to close port 1723 (PPTP), if already your machine is acting as VPN server?
So, I started other way round. I setup my machine as a VPN server. Steps are very simple:
1. Go to Network connections
2. Click on "Create a new connection" wizard
3. Select "Set up an advanced connection". Click Next.
4. Select "Accept Incoming connections". Click Next.
5. Select "Allow virtual private connections" Click Next.
6. Select the users for the list to grant permission. Click Next.
7. Click Next, and Finish.
You will see an Incoming Connection icon in network connections dialog.
 Simultaneously I started to scan my PC for port 1723, and I found it open:
 Now, right click on Incoming Connections icon in network connections dialog, choose properties, go to general tab and uncheck "Allow other users to make private connections on my computer......" under Virtual Private Network section.
Now again scan the port 1723:
This is the most suitable approach I have found to close the port 1723 on Win XP.
Still I don't know how to disable this service from Services.msc, so I shall continue to use above approach. If you know, any other ways to close it, it will be greatly appreciated, if you let me know.

Update: The 1723 can also be stopped by stopping "Routing and Remote Access" services under "Services.msc"



Tuesday, May 8, 2012

Breaking Excel password protection

If you came across an excel sheet asking for password for allowing to make any changes into it, you may want to unprotect it.
All we need to do is to edit the xml file which comes intrinsically packaged with Excel 2007 or 2010. But what about Excel 2003? For that, open the Excel 2003 file within Excel 2007, save it as xlsx file. So, keep in mind all the Excel files below 2007 version, you need to convert them as Excel 2007 with extension .xlsx.
Now here are the steps for doing that:
1. Open the Excel 2003 file (e.g. Secret.xlsx) and save it as .xlsx (Excel 2007) format. If you already have Excel 2007 file, then no need for any conversion.

2. Now change the extension of the above file to .zip and extract the zipped file. Browse through the file in the extracted folder and go to:
<LocalPath>\Secret\xl\worksheets.
 
3. Now open the sheet/ sheets you want to remove protection in any xml editor. Look for keywords such as 'sheetProtection' or 'workbookProtection' in the xml file.
Remove such lines entirely from the xml files above. Do this for all the sheets you want to remove the protection.

4. Now, copy all these edited and saved xml files to the original zip file under the same path. Now change the extension back to .xlsx from .zip. You are done!