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 ...