Slashdot: News for Nerds


Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Book Review: Metasploit The Penetration Tester's Guide

samzenpus posted more than 2 years ago | from the read-all-about-it dept.

Programming 24

eldavojohn writes "The Metasploit Framework has come a long way and currently allows just about anyone to configure and execute exploits effortlessly. Metasploit: The Penetration Tester's Guide takes current documentation further and provides a valuable resource for people who are interested in security but don't have the time or money to take a training class on Metasploit. The highlights of the book rest on the examples provided to the reader as exercises in exploiting several older versions of operating systems like Windows XP and Ubuntu while at the same time avoiding triggering antivirus or detection. The only weak point of this book is that a couple chapters refer the reader to external texts (on stacks and registers) in order to meet requirements for crafting exploits. The book also gives the reader a brief warning on ethics as many of these exploits and techniques would most likely work on many sites and networks. If you're wondering how seemingly inexperienced groups like lulzsec constantly claim victims, this would be an excellent read." Keep reading for the rest of eldavojohn's review.In 2007, Metasploit was migrated from Perl to Ruby. The book opens with a brief history of the framework and mentions this but does not address any complaints of performance loss. Instead, the authors argues that this increased contributions and adoptions. As a result, all the code in this book (which the exception of some SQL payloads) is written in Ruby. If you don't know Ruby but you know many other languages, it's a fairly simple language to pick up.

The first chapter of this book clearly indicates that the objective is to empower white hat hackers and researchers. They lay down a predefined set of phases that one takes while pen testing a target. They are Pre-engagement Interactions, Intelligence Gathering, Threat Modeling, Vulnerability Analysis, Exploitation, Post Exploitation and Reporting. Chapter two covers the terminology that is used across the Metasploit Framework so if you're unfamiliar with concepts like 'shellcode' or 'payload' this chapter will set you straight. It also mentions a UI for Metasploit called Armitrage but my personal tastes kept me using the minimal MSFConsole and MSFcli.

Chapter three begins to cover intelligence gathering and covers everything from the basic whois tool to writing your own custom scanner. The chapter does a great job of carefully explaining in detail the difference between passive and active scanning. The stealth TCP scan that nmap provides was a new thing for me and the chapter also details how Metasploit can use several database technologies to record and store the results of your scans to be used later on. The chapter shows how to use Metasploit to scan ports, server message blocks, MS SQL servers, SSH servers, FTP and simple network management protocol sweeping. Most of these techniques are a few quick commands in Metasploit's console and with Ruby mixins the chapter illustrates how to write your own scanner for use in Metasploit in about 20 lines of code. But all of this is just to get a grasp of what's up and running on the server.

Chapter four starts to get interesting with actual vulnerability scanning. Banner grabbing is an important technique in pen testing and the book suggests using NeXpose community edition (also a Rapid7 tool). This is covered in more detail in the appendix but NeXpose is a web GUI interface for scanning, storing and managing site scans. This provides great reporting features, it's intuitive and reduces everything to point-and-click for the user. But luckily this tool can also be run from the console (something I preferred). The chapter also covers another popular scanner called Nessus and shows to import the results to Metasploit for use. The chapter also includes noisy options like SMB login scanning or just looking for open VNC or X11 servers. Mentioned here first (but also frequently later in the book) is Back|Track for connecting to such targets. Something neat about this chapter is that if you don't care that your target knows you're attacking them, you can just move from these results collected with NeXpose, Nessus or OpenVAS and drop them into the 'autopwn' tool in Metasploit. It's three commands on the console and apparently works more often than it should.

Chapter five familiarizes the reader with the MSFConsole and its basic commands like showing all the exploits, payloads and targets available in the Metasploit Framework installed. These are constantly updated and maintained so they often change. With that information, the chapter proceeds to step the reader through an exploit in a Windows XP SP2 (MS08-067) and then a Samba exploit in Ubuntu 9.04.

Chapter six spices things up by introducing Meterpreter that extends the Metasploit Framework to serve a shell to the exploited system and from there perform additional attacks. The chapter shows how to brute force an MS SQL server and use the stored procedure xp_cmdshell to gain remote access. Meterpreter has a lot of neat features like keystroke logging, capturing screenshots and dumping password hashes (including the pass-the-hash technique). Simple commands in meterpreter can allow the user to easily and effortlessly accomplish many things: privilege escalation, token impersonation, pivoting to another system, process migration, killing antivirus software, system scraping, the list goes on. The chapter finishes by briefly mentioning an intriguing tool called Railgun that I wish they had spent more time on.

Chapter seven covers avoiding antivirus detection through tools like msfencode (to avoid your exploit being fingerprinted). Even better is encoding it many many times. If you know what antivirus your target uses, you can simply run the antivirus on your encoded exploit on your local machine to see if it's picked up. The chapter also covers the basics on continuing normal execution of a backdoored executable and packers that compress an executable for you with decompression code built in.

The book gets progressively more technical with chapter eight focusing on client side attacks. The chapter covers the NOP slide technique and also introduces the Immunity Debugger. It covers the Internet Explorer Aurora Exploit (MS10.002) as an end of chapter exercise for the reader to do. Chapter nine takes a quite look at Metasploit's auxiliary modules that allow the user to do many other things than just exploits. They run through the source of a mischievous Foursquare Location Poster that can make you appear to be everywhere on Foursquare. They also cover heap spraying attacks in web browsers — a topic that was particularly discomforting for me considering how long I often leave my browser open for.

Chapter ten was probably one of the more boring for me but a very important tool for pen testers. It shows how to turn the Metasploit Framework into a social exploitation tool that can be used to send templated e-mails to distribution lists. The intent of this, of course, is to get one user in a large company to click on a site that looks like their company's homepage and perhaps enter their credentials. By just selecting from lists of options, you can create java applet exploits that appear to be legitimately signed, clone a website like gmail and harvest credentials, tabnabbing, webjacking, man-left-in-the-middle and finally mixing those all together in a multipronged attack. The next chapter is just more exploits via Fast-Track (an open source Python based tool that builds on top of Metasploit).

Chapter twelve covers Karmetasploit, a Metasploit implementation of the wireless security tool Karma. The strategy of this exploit is to present your machine as a wireless access point. When a user connects, you can use karmetasploit to host fake webpages and grab their credentials or even gain shell access through a client side attack. Knowing how frequently people attach to anything in coffee shops and airports, this sort of attack could be particularly brutal and extremely easy to execute given Metasploit's simplicity for users.

The final chapters do an okay job of showing you how to first build your own module for Metasploit in chapter thirteen. Then in fourteen, the book looks at building your own exploit and goes into detail about fuzzing applications on your local machine and using the Immunity Debugger to look at what's happening given the fuzzed input. What follows is a lengthy discussion of the Structured Exception Handler (SEH) and the Next SEH (NSEH) and how you can manipulate registers and utilize JMPs to hit a NOP slide into your shellcode. This is one of the longest and most complicated chapters with probably the most technically intensive writing. I would like to see further editions of this book expand on things like this as it was important for me as a software developer to understand how these attacks are manufactured.

Chapter fifteen was similar to fourteen but showed how to port exploits to the metasploit framework. This chapter covers more so the general guidelines for writing exploits for the metasploit framework and doing it so that you leverage metasploit's flexibility. Chapter sixteen covers the scripting abilities of meterpreter and customizing that to execute further exploits once you have access to a target machine with meterpreter.

The final chapter brings the key steps together for a simulated penetration testing of a preconfigured system with web server (the book lists the Pirate Bay as a source of this torrent). As you work through this chapter, the phases of pen testing are exercised with all the aforementioned strategies employed.

This book was a real eye opener to read for a software developer. I haven't done formal pen testing aside from testing my own code so a lot of these advanced concepts were new to me. I enjoyed how the code was laid out with circled numbers marking code (instead of every line being numbered) that were referenced later in the text. I hope future editions of this book provide progressively more and more material as there's clearly a lot of sections that are condensed into a few paragraphs but could be expanded upon almost endlessly. I'm glad this sort of tool didn't exist during my younger more mischievous years as this book demonstrates that it could be used for gaining access to just about anything (depending on how much free time and skill you have).

You can purchase Metasploit: The Penetration Tester's Guide from Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

cancel ×


The book is good (4, Interesting)

smileygladhands (1909508) | more than 2 years ago | (#37404394)

However, the framework changes incredibly quickly. It will be outdated soon.

That's Always the Case with Tech Books (3, Insightful)

eldavojohn (898314) | more than 2 years ago | (#37404472)

However, the framework changes incredibly quickly. It will be outdated soon.

While this is true, the book shows you how to use help and how to search for new modules or existing ones. I think a lot of the basic stuff like LHOST/RHOST and basic setup. How Metasploit uses a database to store, how other scanners store stuff and a lot of the basic stuff will remain. I mean, a lot of these exploits that I explored required you to just set the variables to tell it where to hit ... those are pretty static I think.

Sure, they delve pretty deeply into a few exploits as they have you use them but it was really easy to write my own scanner, exploit, payload, etc. Well, I should say it was as easy as it was going to get. I admit the payload part took me a fair amount of time. I've been busy using this book to point this sucker at my own code ... heh, let's just say Metasploit works more often than you'd like it to :)

There's a lot of basic stuff in this book that isn't going to change and the fact is that if you're not taking the Penetration Testing training, I would get this book and dive into it.

Like I said in the review, I would love to see them take this book further and deeper -- maybe expand on the basics that I had to find in other resources they cited?

Re:That's Always the Case with Tech Books (1)

Hatta (162192) | more than 2 years ago | (#37404610)

It's not always the case with tech books. The slender lorises [] will never be obsolete.

Re:That's Always the Case with Tech Books (0)

Anonymous Coward | more than 2 years ago | (#37405314)

...Or TCP/IP Illustrated, Volume 1: The Protocols...

Re:That's Always the Case with Tech Books (2, Informative)

Anonymous Coward | more than 2 years ago | (#37405458)

We tried to teach the methodologies around the framework versus every nitty gritty. While things may change this shouldn't impact the book. We knew going into this that Metasploit was a huge moving target and we had to do something different by teaching you how to leverage the framework versus every syntax or the latest exploit.

Thank you very much for the awesome comments here and the review of the book eldavojohn, we really appreciate it.

-Dave Kennedy (ReL1K)

My only Perl book is from 1993? (0)

Anonymous Coward | more than 2 years ago | (#37415024)

The basics don't change that much. For the specifics, grep through libraries/modules or look online.

Re:The book is good (1)

NeverVotedBush (1041088) | more than 2 years ago | (#37409462)

Just don't upgrade and the book stay... ;-)

Should be a good seller among the Slashdot crowd (2, Funny)

Anonymous Coward | more than 2 years ago | (#37404620)

Sure, many of us "test", but how many of us actually get to "penetrate"?

Re:Should be a good seller among the Slashdot crow (2, Funny)

Frosty Piss (770223) | more than 2 years ago | (#37405002)

Sure, many of us "test", but how many of us actually get to "penetrate"?

What exactly are you trying to say?

Re:Should be a good seller among the Slashdot crow (2)

martin-boundary (547041) | more than 2 years ago | (#37405396)

Sure, many of us "test", but how many of us actually get to "penetrate"?

What exactly are you trying to say?

His automake script is broken.

Re:Should be a good seller among the Slashdot crow (0)

Anonymous Coward | more than 2 years ago | (#37405462)

... something about rimming versus anal buttsex

Re:Should be a good seller among the Slashdot crow (1)

Anonymous Coward | more than 2 years ago | (#37407040)

In this context, a lack of penetration means success.

Re:Should be a good seller among the Slashdot crow (1)

Kvasio (127200) | more than 2 years ago | (#37415828)

he is not likely to replicate (the problem)

Re:Should be a good seller among the Slashdot crow (0)

Anonymous Coward | more than 2 years ago | (#37412064)

I'm penetrating you now, you just don't know it.

I'm seeing double (0)

Anonymous Coward | more than 2 years ago | (#37405612)

Up article on THC-HYDRA v7.0

good to see (1)

chL1rch (2453466) | more than 2 years ago | (#37406042)

nice to see people (kennedy) who writes mods for metasploit also writing up info. cheers

Section on Slashvertisement? (2, Interesting)

Anonymous Coward | more than 2 years ago | (#37406048)

Does the book describe how to use a /. book review as free ad-space? :-P

Nice review (1)

phantomfive (622387) | more than 2 years ago | (#37406466)

It is a nice review, but there's not much to say about it!

like bangla book (-1, Offtopic)

Siraj-DBR (2461880) | more than 2 years ago | (#37407150)

i love always reading book, bangla book always my favorite. i download [] book daily from online. nice post thanks.

Re:like bangla book (2)

The MAZZTer (911996) | more than 2 years ago | (#37408386)

This post certainly isn't suspicious and not a spam bot. Nope.

Yet another 10/10 review (0)

Anonymous Coward | more than 2 years ago | (#37407436)

I'd been reading a different book on metasploit recently and it was so bad I threw it against the wall. Or at least I barely refrained from throwing my e-reader against the wall. It too starts out waxing on how moving to ruby was the bestest thing evar, so this review pointing out this book starts out exactly the same is not a plus. I'm not quite desperate enough to try again. Maybe you just need an unhealthy love for ruby to succeed as a pen tester?

Anyway, there's so many 10/10 reviews (surely anybody who knows this vaunted critical thinking rechnique thing can find spots on any old cow?) that there's no longer any real point to the rating system. Evrything is grate, yessirree.

Does "I'd hit it" become "I'd 'sploit it" ? (0)

Anonymous Coward | more than 2 years ago | (#37408642)

I mean, we're talking penetration, right?

Was so excited to buy this book ... and then (0)

Anonymous Coward | more than 2 years ago | (#37409926)

it was sadly already of of date after delivery.

The book was written for Metasploit 3 and Metasploit 4 came out right after release.

It really is a well written book and easy to follow (when accurate), just sadly out of date.

Re:Was so excited to buy this book ... and then (1)

Anonymous Coward | more than 2 years ago | (#37410278)

That couldn't be further from the truth. The differences between 3 and 4 are minimal. The building in release builds 3+ were all to the release of 4. Nothing has changed since then. There were a couple of commands that got changed but got fixed in the reprint. Please do not listen to this comment...very far from accurate

Check for New Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account