SecureString for managing passwords in memory

As the brush with 2-tier apps continues, the usual recommendations to manage the memory from leakage is to overwrite it quickly once its use is over. Although, it does not prevents the leakage completely, it reduces the attack surface by a considerable extent. Fortunately, for .Net application there's a method called SecureString. This class allows you to keep string data encrypted in memory. But a few things to keep in mind. Liked the below points from a discussion from stackoverflow post:
Do you know how many times I've seen such scenarios(answer is: many!):

1.A password appears in a log file accidentally.
2.A password is being shown at somewhere - once a GUI did show a command line of application that was being run, and the command line consisted of password.
3.Using memory profiler to profile software with your colleague. Colleague sees your password in memory. Sounds unreal? Not at all.
4.Some tools such as  RedGate software that could capture the "value" of lo…

Memory leakage in 2-tier applications

The 2-tier applications use front-end to directly communicate to DB. There's no separate business logic tier. All the business logic are at client side. Thick client applications (mostly) are classic examples of that. Applications developed in .Net and Java could be found in big nos. inside any organization. Sometimes it's difficult to straightaway move to 3-tier architecture. Businesses are reluctant to accept this approach due to: - Moving towards 3-tier involves a great amount of coding efforts and  money. - Sometimes the applications are almost end of life and are not being retired just because of there;s no good reason to do so.  - Most of the above applications are Intranet applications. Business claims that being an internal application, this is less susceptible to attack.
But they forget one very big risk under these claims- sensitive information in memory dumps. 
The application being 2-tier connects to DB while constructing the connection string using DB credentials…

File Upload through Null Byte Injection continued...

Just after writing the previous post, we came across a scenario where the application was expecting a pdf and back-end was php. But the application was not accepting the Null Byte injected files as described in last post.
We found that it was validating PDF magic no. and application types in headers.
So, we repeated the the exact steps of the last post and additionally we changed the signature and content type and the application uploaded it successfully.
So we renamed our file shell.php as shell.phpA.pdf and replaced A with Null, so the strings became shell.php[NULL] .pdf, which the interpreter read and created a file shell.php on the server. Only issue is that there's not code to execute since all the contents were pdf contents. But our aim was to bypass this and it was successful. This post concludes.

File Upload through Null Byte Injection

Sometimes, during file upload we come across situation wherein there would be check on the file extension at the client side as well as server side too. If the application does allow only .jpeg extension to be uploaded, the client side java script checks for the extension of the file before passing the request. We all know that how easily this can be defeated.
Some applications, checks for the extension at the server side also. That's not easy to bypass. However there are some ways with which it still can be bypassed. Most of server side scripts are written in high level languages such as Php, Java etc who still use some C/C++ libraries to read the file name and contents. That leads to the problem. In C/C++ a line ends with /00 or which is called Null Byte. So whenever the interpreter sees a null byte at the end of the a string, it stops reading thinking it has reached at the end of the string.
This can be used for the bypass. It works for many servers, specially php servers. Th…

Installing Burp cert in Android

I have seen many a times, even though there's already a Burp cert is installed on the Android device, the browser throws an error and Burp does not capture the request. This issue is mostly prevalent with Kitkat 4. As browser errors can be bypassed by clicking Proceed, but Banking apps keep throwing 'SSL Error' messages. Not sure what happens, but below works for me in such cases:

1. Download the Burp certificate. It'll be downloaded as 'cert.der'

2. Go to download folder, rename it as 'cert.cer' . Recommend to have a file explorer app which makes renaming easy.

3. Copy it to /storage/sdcard0 folder.

4. Go to Settings-> Security-> Trusted Credentials-> User. Remove the old Portswigger (Burp) certificates.

5. Go to Settings-> Security-> Install from device storage. Tap it and it installs your new certificate automatically. Now you are done. You'll notice all well now, the app communications being intercepted by Burp.

Maybe due to some…

jtool - an alternative to otool

jtool comes with a capability of running on Linux environment. Some ipa scanning tools are created to run on Linux environment where mac environment is not available. In such cases tools such as otool and class-dump-z will not work. So jtool can be an alternative to otool. For more information on jtool please refer to . It lists down various commands which have same output as otool or a equivalent. There are several commands mentioned in link.

But for our customized requirements and basis checks I have listed down the below ones after running on many binaries. The outputs are similar or equivalent to otool and class-dump-z:

Commands for checking PIE flag (ASLR) in jTool jtool -d -v -arch | grep stack
·Automatic Reference Counting (ARC) protection: jtool -d -v -arch | grep _objc_release
·To check if the device is jailbroken: jtool -d -v -arch | grep jail
·Dyldinfo compatible options: jtool -function_starts  -v -arch -d objc arm64 --- prin…

SQLi and Blind SQLi in search field

This continues from my earlier posts on SQLi in search fields:

I recently found one sqli which was both in nature- generic sqli and blind sqli. As I have already said, search boxes are always an unusual suspect and we tend to generally overlook them.

But the field was not vulnerable to simple queries like ' or ''=', would have missed it if would not have tried similar to ' or ''='' or ''='. I fired Burp intruder and got a couple of more payloads which worked. Still I am not able to understand the difference between these two queries, why they yield different results.

Anyways, the sqli got exploited and the app displayed all the records from the table.

Now turn for blind sqli:
The same field was also vulnerable to blind sqli. This became more important as the automated tools such as SQLmap, failed due to some errors or the apps being unstable. So it is purely man…