Hack Like a Pro: Exploring the Inner Architecture of Metasploit « Null Byte :: WonderHowTo

Welcome back, my novice hackers!We've done a number of tutorials using one of my favorite hacking tools,Metasploit. In each of them, we've used themsfconsole, which can be reached through either the menu system or through simply typing "msfconsole" from the terminal.This msfconsole puts us into an interactive mode command prompt with the Metasploit Framework. This is my favorite way to use Metasploit, but certainly not the only way that is available to us.Metasploit has multiple ways of accessing its power and tools including a command line (msfcli), a GUI (armitage), and a web-based (msfweb). In this tutorial, we're going on a tour of Metasploit to introduce you to the inner structure and some new capabilities of Metasploit.Step 1: Open a Terminal & Find the DirectoryIn each of my previous tutorials, we've started from the interactive mode of Metasploit (the msfconsole). This time, however, let's go to the Metasploit directory directly so that we can explore its structure. We can get there by typing:bt > cd /pentest/exploits/frameworkStep 2: Look Around Inside the FrameworkNow that we're in the Metasploit Framework directory, let's take a look around. First, let's do a listing on this directory.If you look to the top of this long listing, you will see a directory calledarmitage. This is a GUI for driving Metasploit that we'll return to in another tutorial.Also note near the bottom a directory calledscripts. This includes, among other things,meterpreter scriptssuch askey_scanthat enables us torun a keylogger on the victim's computer.Also note the following files—msfcli, the command line version of Metasploit, andmsfencode, the command we used previously tore-encode a payload to get past antivirus software.Step 3: Explore the ModulesLet's now explore the Metasploit modules. These are the blood and guts of Metasploit. We have, for instance, used "exploit" modules and "payload" modules. This is where they reside. Type in:cd modulesls -lAs you can see from the screenshot above, Metasploit contains multiple modules. These include:auxiliaryencodersexploitsnops (no operations)payloadspost (post exploitation)These are the key modules in Metasploit, and as you've already guessed, we haven't even begun to explore the auxiliary, nops, and post exploitation modules, although we have used the exploits, payloads, and encoders.Step 4: Open the Exploits Module & Look AroundThe module we're probably most familiar with are theexploits. This is the module that contains the exploits that take advantage of a vulnerability in an application or an operating system, which enables us to place our payload on the victim. Let's look inside. Type:cd exploitsls -lTheexploitsmodule is broken into sub-directories that are specific to the operating system we're attempting to exploit. For instance, you can see at the top the directory,aix, (IBM's proprietary UNIX operating system) exploits. As we scan down, we can see exploit directories for:freebsdhpuxirixlinuxnetwareosxsolarisunixwindowsIf you have done any of my Metasploit tutorials and hacks, you've likely used exploits in thewindowsexploits directory. Let's look around there. Type:cd windowsls -lNow, we can see that the windows exploits are broken down into types of windows exploits. It's important to note that exploits are very specific. Not only are they operating system specific, but also application or service specific, port specific, and sometimes even language specific. Recently, we looked atexploiting the Internet Explorer in Windows 7. Let's see if we can find it in the browser directory. Type:cd browserls -lAs you can see in the above screenshot, ourms10_046_shortcut_icon_dllloaderexploit is highlighted.If we wanted to, for instance, find an exploit in this directory to hack Adobe products from the browser, we could useour Linux skills and "grep" for it. Type:ls -l | grep adobeWhen we hit enter, the terminal filters (grep) the output and shows us only the windows browser exploits that take advantage of Adobe products.Step 5: Explore the Payloads ModuleNext, let's navigate to the payloads directory. Type:cd /pentest/exploits/framework/modules/payloadsThen we can do a long listing on that directory by typing:ls -lWe can see that payloads are broken down by types.singlesstagersstagesLet's open upsinglesto look around. Type:cd singlesOnce again, we can see that the Metasploit Framework categorizes the payloads by operating system. Let's move to the generic directory and see whether we can find the genericshell_reverse_tcppayload that we used toget a command prompt when hacking Windows XP. Type:cd genericls -lAs you can see in this screenshot, I have highlighted the generic reverse tcp shell that we used earlier.In the tutorial onencoding your payload to get past AV software, we created a payload that we re-encoded usingshikata_ga_nai. Once we have that payload re-encoded to be undetectable to AV software and we want to use it other exploits, we could save it here in this payloads directory to make it available again and again to get past antivirus softwareI'm hoping that this brief exploration of the structure of Metasploit was enlightening. I'll try to come back in the future and further elaborate on its structure including the post exploitation, auxiliary and nops modules, but don't wait for that. Start doing your own exploration to better understand this wonderful and powerful tool to make you a better and more effective hacker.Want to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicenseRelatedMac for Hackers:How to Install the Metasploit FrameworkHack Like a Pro:Metasploit for the Aspiring Hacker, Part 1 (Primer & Overview)Hack Like a Pro:How to Exploit and Gain Remote Access to PCs Running Windows XPHack Like a Pro:How Windows Can Be a Hacking Platform, Pt. 1 (Exploit Pack)How to Hack Like a Pro:Getting Started with MetasploitHack Like a Pro:Metasploit for the Aspiring Hacker, Part 14 (Creating Resource Script Files)Hack Like a Pro:Metasploit for the Aspiring Hacker, Part 4 (Armitage)Hack Like a Pro:Exploring Metasploit Auxiliary Modules (FTP Fuzzing)Hack Like a Pro:Metasploit for the Aspiring Hacker, Part 10 (Finding Deleted Webpages)Hack Like a Pro:How to Remotely Install a Keylogger onto Your Girlfriend's ComputerHack Like a Pro:Metasploit for the Aspiring Hacker, Part 8 (Setting Up a Fake SMB Server to Capture Domain Passwords)Hack Like a Pro:Metasploit for the Aspiring Hacker, Part 7 (Autopwn)Hack Like a Pro:How to Exploit IE8 to Get Root Access When People Visit Your WebsiteHack Like a Pro:The Ultimate Command Cheat Sheet for Metasploit's MeterpreterHack Like a Pro:How to Hack Windows Vista, 7, & 8 with the New Media Center ExploitHack Like a Pro:How to Use Hacking Team's Adobe Flash ExploitHack Like a Pro:How to Bypass Antivirus Software by Disguising an Exploit's SignatureHack Like a Pro:Metasploit for the Aspiring Hacker, Part 5 (Msfvenom)Hack Like a Pro:Metasploit for the Aspiring Hacker, Part 2 (Keywords)Hack Like a Pro:How to Secretly Hack Into, Switch On, & Watch Anyone's Webcam RemotelyHack Like a Pro:Reconnaissance with Recon-Ng, Part 1 (Getting Started)News:How to Study for the White Hat Hacker Associate Certification (CWA)How to Meterpreter:Interactive Ruby Shell (A Quick Introduction)Hack Like a Pro:How to Install BackTrack 5 (With Metasploit) as a Dual Boot Hacking SystemHack Like a Pro:How to Remotely Record & Listen to the Microphone on Anyone's ComputerNews:DIY Papercraft Architecture with LightingExplore Ancient France:QuimperHack Like a Pro:Hacking Samba on Ubuntu and Installing the MeterpreterNews:Organic Structures, PVC and Powder Printing, and ArchitectureNews:Minecraft World Weekly Workshop: Techniques in ArchitectureNews:Minecraft World's Weekly Workshop: Architecture and StyleNews:Inner City ArtsNews:Techniques for Creating Architecture in Minecraft