krzychu12350/phpmetasploit

This plugin allows to interact with Metasploit framework either through msfrpcd deamon or the msgrpc plugin running in msfconsole.

1.0.0 2023-03-27 05:53 UTC

README

The PHP library whose code is automatically generated based on the Metasploit framework documentation.

Table of Contents

Documentation of standard methods

Owner dashboard view

Link to documentation

Class diagram

Owner dashboard view

Library class structure

Prerequisites

  1. PHP 8.1.2 minimum
  2. Composer 2.5.5 minimum

Installing and running the library

1. Metasploit RPC server initialization

- via msgrpc plugin

To start the server through the msgrpc plugin, execute the following command in the Metasploit framework default console:

  load msgrpc 

The command has the following parameters:

  • ServerHost - hostname on which the server is listening,
  • ServerPort - port number on which the server is listening,
  • User - user name that allows access to the server,
  • Pass – server access password. It is required that the password is enclosed in quotation marks,
  • SSL – enable or place SSL on the RPC socket. Select true enable SSL and false disable SSL.

An example command might be as follows:

  load msgrpc ServerHost=192.168.1.0 ServerPort=55553 User=user Pass='pass123'

- via msfrpcd demon

To start the RPC server through the msfrpcd daemon, launch the system terminal and then execute the following command:

  msfrpcd -P <password>

where is the defined password for access to the server, this parameter is required

The above command has the following parameters:

  • -a – name of the host on which the server is listening,
  • -p – port number on which the server is listening,
  • -U – username that allows access to the server,
  • -P – access password to the server. The password must be enclosed in single quotes,
  • -S – enable or disable SSL on the RPC socket. True enables SSL and false disables SSL,
  • -f – adding this parameter starts the msfrpcd daemon in the background.

In each of the parameters, means that the value of the parameter must be provided.

An example command might be as follows:

  ./msfrpcd -U user -P pass123 -a 127.0.0.1 -u /api/1.0 -p 55553 -f

2. Library installation

Before installation, make sure that the Composer package manager is installed in the operating system.

Then run the following command to install the library:

  composer require krzychu12350/phpmetasploit

During the library installation process, allow the library to dynamically generate the code by pressing the y key and then the key confirming the selection of this option.

Owner dashboard view

3. Launching the library

To start using the library, initialize the MsfRpcClient class object, and then call the msfAuth method to obtain the authentication token. As a result, you get a token that allow you to execute all functions available in the library.

Owner dashboard view

Owner dashboard view

Run unit tests

To run unit tests launch the system terminal and go to root directory of the library and type in following command:

  composer tests

License

All Rights Reserved

Copyright (c) 2022 Krzysztof Karaś

Created by Krzysztof Karaś