Skip to main content

Posts

Data leakage in JSON

A web application is sending data in this format: {"t":1,"p":1,"r":1,"rows":[{"i":0,"c":["n","H, C","A","5","T","n"]}]} this is a valid JSON, before moving on lets understand an important concept: 1. Javscript expression 2. javascript statement javscript expressions are not executed by javascript parser, but statements are: for ex: <script> {"t":1,"p":1,"r":1,"rows":[{"i":0,"c":["n","H, C","A","5","T","n"]}]} </script> this will not be executed, that is, objects won't be created. The above example is for a javascript expression. But now when it is converted into a statement as given below: <script> [{"t":1,"p":1,"r":1,"rows":[{"i":0,"c":[...

Setting default encoding to UTF-8 in Python

After a long struggle for fixing up an error thrown by my Python script, I finally figured out an easy way to do it. As we know, Python's default encoding is ASCII (0-127), anything beyond that , Non-ASCII characters throws UnicodeEncode exception. To fix it up, we need to use UTF-8 encoding, which suits most of the characters. The easiest way to do that is: Go to your Python setup directory and then go to lib: C:\Python27\lib Look for site.py file, used for site specific configuration Edit it: Go to 'setencoding()' function and change the line: encoding = "ascii" to encoding = "utf-8" That's it! I don't know other implications of editing it right in site.py file but it worked for me, and I found it the easiest way to change the encoding!

URL rewriting and CSRF

Is url rewriting a mitigation of CSRF? Though, almost sure it's not a foolproof solution, I put up this query before all security gurus out there on webappsec. The application in question was replacing all the urls with some randomized and unique long strings in this format: https://mysite.com/myportal/b1/04_SjzQ0NTYyNzS2MLTUj9CPykssy0xPLMnMz0vMAfGjzOJDfU19LNxMTQwsAoydDDyNXb0cnc2dDA2czfRzoxwVAVLe6h0!/ The url was long enough and sufficiently randomized. The argument in favor of randomized url as csrf mitigation is, even an attacker is able to grab the url, it won't be valid for next session. So, the attacker can't exploit it by sending/ embedding in link/ images etc as it would stand invalid. Thus csrf mitigated. But let's consider the scenario wherein an attacker goes to logged in victim's machine, applied his social engineering tricks and note down the url , convince user to click the forged link sent to him. If the user stays at the same page, he gets exploited...

SQL Injection in search field

Earlier I had written about performing SQL injection in search field and how to do a DoS attack and privilege escalation using 'Like' operators. Now another SQLi exploitation I came across recently. That too in the search field. This becomes important as lots of people don't pay much attention on the search forms/ fields in the application. My aim is to show that a search form can also be exploited with SQL Injection. The following queries are based on a real world exploitation. The steps and data are for just illustration purpose only. Suppose, the search form provides the details of users who have accessed the application some time and their login time details etc, we just need to provide their name in the search box provided. All the data were being going as Post request. So, to just fingerprint the database, I provide, 'nil'+'esh' in the search field and it successfully gives me the results. That means the database behind the application is conca...

Android Penetration Testing

Published in Hakin9 Extra Magazine.  " In this article we’ll discuss about steps involved in performing security assessment of an Android based application. We will see use of various tools and methodologies. There are various other methods and tools but steps are very common in nature..." It can be downloaded here .

Python script to mail merge with CC

Limitation of normal mail merge is that you can't insert Cc/Bcc fields into it. I have tried to overcome this by writing a small script. The script takes the recipients in To and recipients in Cc fields from an excel sheet . It reads the sheet one by one from both columns and send them emails reading on the contents from an external fields. Yes, it's simple, but what I was trying earlier was something else. I was trying to send 'personalized' emails with 'Cc' field in the mail. But the 'personalized' part is very difficult to implement, as I was not able to write the variable data to the body of the email. So, settled down with this fixed body contents being read from external file. Let me know if anybody is aware of how to send personalized body contents to respective users. I mean the some fields in the body of the mail should on user basis. In this case the body of the mail is general and fixed in nature. Code to read user lists from excel and s...

Nipper Download

The great open source Nipper tool, used for auditing infrastructure and network devices, has now become commercial. So visiting http://sourceforge.net/projects/nipper/ would give you the latest version (1.0) which is of little help, as it contains the stripped version. So, no use of it. Fortunately, my friends on Null suggested me few links from where still the older version (0.11-12) could be downloaded. One of such link is: http://tools.l0t3k.net/NETWORKutils/ , you can download  nipper-inone-0.12.6.zip. It's an exe and you can run it directly. Alternate method: Upgrade to BackTrack5 R2. The latest version includes the Nipper-ng tool. To update to the latest version: http://www.backtrack-linux.org/backtrack/upgrading-to-backtrack-5-r2/  Also, once upgraded you need to install Nipper on the new kernel: apt-get install nipper-ng Screenshot from BT5 R2: