How to do it...

Let's start with some of the basics of module building:

  1. In the first line, the require method specifies which libraries this module needs to load:
require 'msf/core/post/windows/powershell'
  1. The following line defines the class which inherits the properties of the post family. The post module can import several functionalities, such as accessing the filesystem, using the registry, WMI, LDAP, and so on:
class MetasploitModule < Msf::Post
  1. The include statement can be used to include a particular functionality of the framework into our own module. For example, if we are building a post module, we can include it as:
include Msf::Post::
  1. The following line will include PowerShell functionalities in the module:
include Msf::Post::Windows::Powershell ...

Get Metasploit Penetration Testing Cookbook - Third Edition 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.