Introduction to PyMetasploit

PyMetasploit is a msfrpc library for Python and allowus us to automate the exploitation tasks with Python. It is meant to interact with the msfrpcd daemon that comes with the latest versions of Metasploit. Therefore, before you can begin to use this library, you'll need to initialize msfrpcd and optionally (highly recommended) PostgreSQL: https://github.com/allfro/pyMetasploit.

We can install the module from the source code with the setup.py script install:

$ git clone https://github.com/allfro/pyMetasploit.git$ cd pyMetasploit$ python setup.py install

Once we have installed it , we can import the module in our scripts and establish a connection with the MsfRpcClient class:

>>> from Metasploit.msfrpc import ...

Get Mastering Python for Networking and Security 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.