npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

msfrpc

v1.0.2

Published

Metasploit Framework RPC api and command line interface

Downloads

13

Readme

MsfRpc logo

The Metasploit RPC api for Node.js

Getting started

Installing

This will install the cli in your system.

npm install -g msfrpc

This will add the msfrpc module to your Node.js project.

npm install --save msfrpc

Using the cli

msfrpc <URI>

URI example: https://msfUser:123456@localhost:55553

Using the api

All msfrpc methods are grouped in the following "method groups":

  • Auth
  • Base
  • Console
  • Core
  • Db
  • Job
  • Module
  • Plugin
  • Session

To call a msfrpc, use the following pattern:

msfrpc.<method group>.<method name (camel case)>([arguments]);

All methods returns Promises.

Please note that we don't pass tokens to the methods. Tokens are added automatically by MsfRpc.

Here is an example:

const MsfRpc = require('msfrpc');

const msfrpcUri = 'https://msfUser:123456@localhost:55553';
const msfrpc = new MsfRpc(msfrpcUri);

console.log(`Connecting to ${msfrpcUri}`);
msfrpc.connect().then(() => {
  return msfrpc.core.version().then((res) => {
    console.log(`Metasploit Framework version ${res.version}`);
  }).then(() => {
    const keyword = 'windows';
    console.log(`Search modules containing "${keyword}". This may take a few seconds...`);
    return msfrpc.module.search(keyword).then((modules) => {
      console.log(`Found the ${modules.length} modules for "${keyword}":`);
      modules.forEach((module) => {
        console.log('=========', module.fullname);
        console.log('  Name', module.name);
        console.log('  Type', module.type);
        console.log('  Rank', module.rank);
        if(module.disclosuredate) {
          console.log('  Date', module.disclosuredate);
        }
      });
    });
  });
});

In the example, we:

  • Connect to the msfrpc server
  • Obtain and print the Metasploit Version
  • Find and print all modules containing a given keyword

Api Reference

For a list and documentation of all available methods, visit the following links.

  • http://www.nothink.org/metasploit/documentation/RemoteAPI_4.1.pdf
  • https://help.rapid7.com/metasploit/Content/api/rpc/overview.html
  • https://help.rapid7.com/metasploit/Content/api/rpc/standard-reference.html
  • https://rapid7.github.io/metasploit-framework/api/Msf/RPC.html

Here are some examples of method calls:

Get version information:

msfrpc.core.version()

Get module stats:

msfrpc.core.moduleStats()

Search for a module:

msfrpc.module.search('keyword')

List payloads:

msfrpc.module.payloads()

Developing

Optional Prerequisites

This project includes a Dockerfile (and docker-compose.yml) so you dont have to build a testing environment yourself. To use docker, you need it installed in your system. For installation, follow the steps here.

Setting up Dev

Clone the repository and install dependencies.

git clone https://github.com/tomasgvivo/node-msfrpc.git
cd node-msfrpc/
npm install

Licensing

Copyright 2017 Tomas Gonzalez Vivo

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.