Building a simple Metasploit auxiliary module

Here we are, playing with Ruby once again. Although Ruby can be awkward at times, module building in Metasploit makes up for things by making the process very easy. If you can put together some basic Ruby and understand how the different methods work, you can build a module.

In this example, we're throwing together a basic HTTP server that will prompt any visitor for credentials. It accomplishes this by kicking back a 401 Unauthorized to any request, which should prompt just about any browser to ask the user for credentials. After the fake authentication is done, you can redirect the user to a URL of your choosing. Let's look at this module chunk by chunk, starting with the following code:

class ...

Get Hands-On Penetration Testing on Windows now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.