Monday, September 7, 2009

Obfuscating your IP using a Burp/Tor/Prixoy combination.

Approximately a year or so ago @jack_mannino and I were banging our heads against the desk trying to figure out a good way to obfuscate the source of our web traffic while maintaining the use of our intercepting proxy.

When we figured out a viable solution, we had some beer & pizza, talked for a bit and realized we should share this with somebody. Jack wrote a blog post about it Here. Then Mubix suggested we should make a video. I didn't have much time to go about editing the video so Mubix did that for me. Thanks again Mubix.

Burp through Privoxy and Tor from mubix on Vimeo.


I hope somebody gets some use out of it.

Happy Hacking!

BToD > Intruder & Dates

Tonight's Burp Suite tip is super basic. You have a parameter that is clearly a date. So you want to re-submit the same request iterating thru various dates ONLY.

For example, lets say a company is going to offer a special (kind of like that pizza company a few months back) but haven't released it yet. Well you may want to submit various dates, FUTURE dates, to see if a response with a coupon pops-up.

In the example below, I found a date parameter which did not fit into Burp Suite's preset list of date formats. In this case, its very easy to create your own custom date format.

Firstly, send the request containing the date parameter to fuzz over to the Intruder tab. Catch the request in the proxy (or use the proxy history), right click, and 'send to intruder'.


You now need to select your target or where your payload is to be set. Navigate to Intruder >  Positions and select your target. Add the variable symbol on either side of the target (the date) by clicking the 'add' button. Should look like this:



At the Intruder > Payloads tab you will notice the 'payload set'. Use the drop down menu that says "preset list" by default and select 'dates'.


Okay, here is where we want to do some customization. So to keep it short, I will only fuzz 3 different days. You can get the gist from the picture but the portion I want to touch on is 'format'. Click the radio button format where it does NOT have a drop down. This is where you can enter your date. So our parameter was 2009_9_7 which we can safely assume is year, month and date. So I will enter yyyy_M_d. If I was to enter yyyy_M_dd then the day would switch to 07 vice 7 which would be incorrect according to the format. So all in all it should look like this:

 
You are done! Now go to the very top, choose the drop down for Intruder and click start. 
Note: This is very customizable so ensure you play around a bit modifying the 'step' field from 1 day to 1 month, etc etc. A lot of functionality to toy with here so try it out.
Happy Hacking!

Sunday, September 6, 2009

Burp Suite Tip of the Day (BToD) Sequencer & Entropy Analysis

Back with another tip. As pointed out by @rybolov's comment on twitter, Burp Suite may be somewhat difficult for folks new to the Suite of tools. One thing that I find interesting is how folks that use the tool (like myself) can learn something new everyday. Sequencer is one of the tools included in Burp Suite that I think requies a bit of an introduction. Once understood, this tool along with Intruder can be a powerful session attack combination.

You will notice I define Burp Suite as a suite of tools and this is for good reason. It is truly my belief that this tool is fast becoming a one-stop shop for dynamic analysis of an application. The free version of the suite is excellent but for those who test professionally, tools such sequencer and intruder must be threaded otherwise valuable functionality might be lost. I say this because when breaking a session token sequence to hijack a session....... timing is critical. With that in mind, show @portswigger and yourself some love by purchasing the product at portswigger.net.

On with the tutorial. In our example, we have registered for access to the site. We have also identified a login submission form. After successful authentication with a limited access user account we are provided a cookie 'set-cookie'. The idea is here is since we can log into the site and are provided only one session value (the cookie) we might be able to submit another user's cookie value and access the site with their account. In other words, session hijacking!

For example, I'm given session value abcd1112 and using sequencer I've noticed that only the last four digits change. The response would be abcd1113 abcd1114 up to abcd1212. So I've evaluated this session value and noticed it has extremely weak entropy.

My next step would be to request a resource just beyond the login form such as welcome.php and do this in a threaded fashion manipulating my cookie value using Intruder. The responses might vary in byte length. For instance I've noticed a large byte return in one instance indicating more functionality returned so this might be an administrative account.

So the first thing we would do is send the request that triggered a cookie value to be set to sequencer like so:


At the Sequencer > live capture tab we want to select the cookie to evaluate which would be the value immediately following 'set-cookie: badentropy='.  The selection drop down is highlighted in red.

.
After we've clicked 'start capture' in the lower right hand corner in the Intruder > live capture tab we've a screen will pop-up like so:
By default, 100 session values will be evaulated and only after this is completed can you analyse the entropy. Burp Suite analyzes this for you btw ;-). So after the 100 session token values have been generated we've clicked the 'analyse now' button at this screen and determined that the site only increments the last four digits by 1 and sequentially by viewing the summary tab in this screen. So this is extremely weak entropy. Lets try to exploit it!

Send the request for http://www.example.com/welcome.php to intruder like so:


Now because the last value provided at the sequencer BY the application was badentropy=abcd1212 we will start at abcd1213 when positioning our payload.

I've already provided a tutorial on my blog how to use Intruder > numbers so the rest of this can be referenced at intruder/numbers paylod.

The thing to remember here is that you are looking for items of interest like varying byte length and response code. Obviously if you are given a 302 response when incorrect credentials are given and you've observed this in some of the responses and not others this might be a sign that the cookie submitted is not a valid. If the 200 response received in the other cookie values are all approximately the same size in byte length except for one or two those might indicate privileged accounts.

Hope this tutorial helps someone and as always, happy hacking.

Thursday, September 3, 2009

Burp Suite Tip of the Day (BToD) Proxy > HTML Modifications/Match and Replace

Today's tip is just purely based on some experiences I've had during testing. The gist is that some developers choose to render the application in such a way where obfuscation IS the security. So I will explain the scenario and then how to modify proxy options to uncover the obfuscated data.

It is true that you will eventually, when performing manual dynamic analysis, review the source code of every response. However, in my case, directly after building my site map I simply take a look and annotate the interesting finds and input that I may want to test.

To keep track of these annotations I prefer Dradis 2.3 and if you have any questions on using this tool might I suggest one of three routes. The first is to join the community Here. The second is to contact etd, the creator, on irc at irc.freenode.net on the #dradis channel. Lastly, etd is on twitter twitter.com/etdsoft and I highly suggest following him anyways!

Anyways, on with the tutorial. So, both @jack_mannino and I observed a situation, where a site loaded content from another site they managed via iFrame. Now the trick is directly calling the site being loaded in the iFrame to try and gain unauthenticated access to MAYBE an exposed default directory. We were in luck, there was in fact a default directory exposed. When requesting this resource however we received a 200 but with a redirection occuring in the browser? The page rendered fully in the response. WTF? Well what controls said redirection? Ahhh, JavaScript! So what happens if we strip javascript? Fully functionality! Sweet.....

Okay, so on with viewing the site with JavaScript disabled. Lets use burp to strip the JavaScript!
NOTE: Personally, I recommend always viewing a site with JavaScript disabled AND cookies disabled.

Navigate to Burp > Proxy > Options. Scroll down until you see 'html modifications' and check remove all JavaScript. Its really that simple.

 
 
The next scenario is where full administrative functionality was provided in the response BUT it was commented out. Again, wtf.....seriously? Obfuscation = fail. So if you want to just automatically remove the characters that control comments so that everything is rendered do the following. On the same page, navigate down to 'match and replace'. Choose 'response body in the drop down bar' like so:


Now in the 'match' field enter in the 'match' field this time and in the 'replace' field just leave this blank. When you are finished it should look like:


Happy hacking!

Wednesday, September 2, 2009

Burp Suite Tip of the Day (BToD) Intruder > Using recurvsive grep for SQLi

This post was inspired by both @portswigger book entitled "The Web Application Hacker's Handbook" and reminded and reiterated to me by @jack_mannino. Portswigger is obviously a legend in the community and Jack is a just a really really experienced Appsec/Pen-test/SE so I encourage you to add/follow both on twitter!

Anyways, accolades aside, lets begin shall we?

So it is pretty simple. You have SQL Injection. Its in the USER_ID field. This value is actually a string value which equates to a user name. So for instance, the value might be 'jdoe' (first initial, last name). Your SQLi looks like: ‘ or 1 in (select min(username) from users where user_id > ‘j’)-- and this returns

Microsoft OLE DB Provider for ODBC Drivers error ‘80040e07’
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting
the varchar value 'jdoe’ to a column of data type int.

Okay, so we know we can do this alphabetically!

Essentially the next command you would inject would be

‘ or 1 in (select min(username) from users where user_id > ‘jdoe’)--

This returns

Microsoft OLE DB Provider for ODBC Drivers error ‘80040e07’
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting
the varchar value ‘jdos’ to a column of data type int.

Alrighty, we don't want to continue this process manually do we? It is like. we want to extract all of the user names in a beautifully automated fashion right? Okay, here we go.

Capture the SQLi request in the intercepting proxy of burp. Right click on it and send to intruder.


Now the next part is important. We are actually using the server RESPONSES as input for the payload. Pretty awesome right? Navigate over to Intruder > Options tab. You need to select the portion of the response that gives you valuable information as the input. So in our case, anything after the varchar value ' is what we will use. This will be where the username is extracted. We want to end the string at ' as well because the string is returned between two single quotations. This is how it should look for your options:


Now you just need to choose the payload. Navigate to Intruder > payloads. Choose the payload 'recursive grep' from the drop down list. I've created my first payload at 'j'. It looks something like this.


At this point you are almost ready. Just choose your position. I've shown you how in this pic (clicked 'add' and placed j as the position to use the payload)


Now you are set. Go to the very top of Burp Suite, drop down from Intruder and click 'start'.

Comments and suggestions for the next post are welcome.

As always, enjoy and happy hacking!

Tuesday, September 1, 2009

Burp Suite Tip of the Day (BTod) > Intercepting responses

Today's post will be short. Long day, lots of work. Intercepting requests TO the server using the Intercepting proxy within Burp is just as important as intercepting server responses.

To intercept server responses, navigate to Burp Suite Proxy > Options and scroll down to 'Intercept Server Responses'. Ensure 'intercept if' is checked and choose 'add' and choose the following options.
AND - HTTP METHOD - DOES NOT MATCH - "insert a string you wont see here" (I chose a bunch of 6s).
 
Happy H4xx0r1ng

Monday, August 31, 2009

Burp Suite Tip of the Day (Using intruder > 'number' payload)

Customers understand better when you actually show them the data that you can extract. Time and again I've observed a simple numerical value used as your USER ID and time and again its client side controllable. The easiest way to automate this attack and extract useful data, for me at least, has been to use the Burp Suite > Intruder 'number' payload along with the Intruder > 'grep' function all contained within the suite.

Lets go!

Step number one is to request the URI that points to your profile and intercept that request.


Now that the payload has been sent to intruder lets go over to the Intruder > positions tab. Clear the the current positions by selecting 'clear' button on the right. Then add the positions by selecting 'add' on either side of the numerical value. Ensure the attack type selected is 'Sniper.



After this has been accomplished move over to the Intruder > payloads tab. Scroll down at payload set to 'numbers'.


We are now ready to configure the numbers payload. We've selected from 0 to 1000 (Numerical representation of USER IDs). We've done this by adding 0 in the Intruder > payloads > range 'from' field and 1000 in the 'to' field. Since 1000 is four digits I've entered the number 4 in the 'Max Integer Digits' field. The 'Min Integer Digits' field is set at 1 since we need at least 1 integer. The 'step' field is set at 1 because I only want to increment 1 digit at a time. For example, 1 2 3 4, etc etc. Lastly, the 'sequential' radio button has been highlighted as well as the 'decimal' radio button for obvious reasons. These are decimal values incrementing sequentially.


Now lets say we want to grep a field named "dob" for the results. This represents a field named "dob" which contains customers dates of birth. We will later use this output to fill an excel sheet or whatever you prefer Navigate to Intruder > options and scroll down the page to 'grep'. Click the extract tab. So to extract the string in the response I added dob= (this is how it would look in the raw response) and chose to stop capturing at "> (this is where the field ends). I also chose 'simple pattern match' for simplicity's sake. NOTE: If the response containing this field comes only after a 302 response or "redirection" choose to follow redirects. If you follow redirects you probably want to process cookies. All depends on the behavior of the application.


So now that this is configured, its time to fire up intruder. Go to the very top of burp, drop down intruder and click 'start'. At this point you should see your intruder fill up with responses containing the dob value. Note: I'm not doing this on a real site, therfore you will see no results in my dob field. You get the point.

 

At this point you can save your results by choosing save > attack results but I believe this functionality is limited to users of the professional version found Here . I'm sure you can figure something out in the interim!

Sunday, August 30, 2009

Using Burp Intruder to brute force login

Inspired by a little tweet I saw from @carnal0wnage, I've decided to make today's "Burp Tip of the Day" about brute forcing a login with Burp Suite's Intruder. As always, this goes a lot faster if you purchase the professional version of Burp here. However, this also works for the free version but much slower.

So, lets get started!

First thing first, send a request to the target site entering a username and password combo. I chose pma_username=test and pma_password=test. Intercept that request, right click and send to intruder like so.


Once you have the request sent to burp 'Intruder' you need to choose your targets for the intruder payload. You can do this by clicking the 'add' button and putting the '$' symbol around the username and password as shown in the example. Also choose the 'cluster bomb' attack type (circled in the example).


Next step is to roll over to the Intruder > Payloads tab. You will have two separate payload sets. Set 1 and Set 2 (easy right?). So in payload Set 1 you choose "preset list" click 'load' and upload the user_name file (containing....ya you guessed it). It should look like so:


Next, click payload set 1 and drop down to payload set 2. You remain using a preset list and click 'load' to upload the password file. It should look like so:

At this point you are ready to rock. Just in case the password submission is using Basic Authorization (aka Base64) you can choose to base64 encode the data by choosing the option in the Intruder > payload section near the bottom. So go to the very top, drop down intruder, and click start. All in all the results should look something like this:


Generally when the length differs greatly or the response code differs you have a pretty good sign that you've hit the mark! Hope this helps someone.

Saturday, August 29, 2009

BurpSuite Intruder Tip (Creating a site map quickly!)

Until I have another program (qwick_request.rb) correctly coded to properly handle certain errors when requesting the output of DirSnatch (which is just a bunch of URIs) thru the proxy............I've been using BurpSuite v1.2 Intruder functionality instead to build an application map.

Note: If you are using the professional version of BurpSuite you can build an entire site map very very quickly even if it has thousands of resources and 404 errors, 500, etc etc (due to unauthed permissions). Visually it can be easier and also you may have unexpected results when requesting a resource you shouldn't have permissions to. This is why I do this.

Overview:

Basically I use the output of DirSnatch (minus the URL) as a payload for BurpSuite Intruder. I start intruder running that payload and because it is forwarding to the second instance of Burp, you will see the target tab fill up very quickly if you are using the professional version. Slower for the free version (not threaded).

So, I've already spidered a site and created a payload file (as an example). Here is what a payload for something like sourceforge.net would look like.

Then I send a request for simply http://sourceforge.net and intercept that request with burp. When the request is intercepted (in the proxy tab) Right click and choose "Send to Intruder".
 
Once the request is in the "Intruder tab", go to the Intruder tab (duh) and clear the payload selector. Add the variable you want to "fuzz" by clicking 'add' on either side of the "forward slash" on the first line. You can leave the "Sniper" attack type in place.

 At this point you want to move out of the Intruder > positions tab over to Intruder > payloads tab. Under payload set you will see "load". Once you click load you can load the payload file. It should look like this when you are done. (Notice: choose 'Do not URL encode these characters'). This is important., by default it is enabled and this will cause issues with what we are doing.

 We are almost good to go! So scroll over to the comms tab (newer version called options). Scroll down to 'use proxy server'. Enter the IP address (127.0.0.1) and enter the port number (i'm using 8081, cant have two instances of Burp on the SAME machine and BOTH running on port 8080 due to .......ummm....science?) and then DO NOT 'CLICK USE PROXY SERVER' yet anyways :).
Fire up that second BurpSuite instance. Under the Proxy tab > options you will see "Proxy Listeners". Highlight the entry that shows port 8080 and click 'edit'. When the local listener port is populated with 8080 change to 8081. (If you want to run the second burpsuite instance on another machine - uncheck 'listen on loopback interface only' and CHECK 'support invisible proxying for non-proxy-aware-clients') and then..........update. Also, make sure the 'running' column is checked. NOW you can go back to the first instance of BurpSuite and click 'use proxy server'. Should look like this:

Finally, we are ready to start. Back at your first instance of BurpSuite, at the VERY TOP of the BurpSuite program you will see 'Intruder' (not the tab, look even farther up). So, now that you are at the intruder drop down, click start. If you go back to your second burpsuite instance you will notice the target tab has filled up. Great success!

Tuesday, July 21, 2009

New Nmap Ping Sweep Defaults

(mirrored from carnal0wnage.attackresearch.com)

as a note to self (and anyone who reads the blog)

http://nmap.org/5/#changes

"The host discovery (ping probe) defaults have been enhanced to include twice as many probes. The default is now "-PE -PS443 -PA80 -PP". In exhaustive testing of 90 different probes, this emerged as the best four-probe combination, finding 14% more Internet hosts than the previous default, "-PE -PA80". The default for non-root users is -PS80,443, replacing the previous default of -PS80. In addition, ping probes are now sent in order of effectiveness (-PE first) so that less effective probes may not have to be sent. ARP ping is still the default on local ethernet networks."

The non-sudo/root versions of the -sP should be noted, it could be enough traffic/ports per second to have some firewalls throw a SYN flood alert if you were to scan several hosts (like a Class C).

wireshark captures: