msfnode is a metasploit RPC client for nodejs
It make RPC calls using http/https webservices of msfrpcd daemon.
Metasploit API is really well done, it's not necessary to develop a wrapper for each API functions. Just RTMF : Metasploit Remote API Documentation
as usual ...
npm install msfnode
Note: do not forget to launch msfrpcd with this syntax if you want to run tests :
./msfrpcd -U myLogin -P myPassword -f
var metasploitClient = require('metasploitJSClient');
var onConnect = function(err,token) {
if (err) {
console.log(err.error_message);
process.exit(0);
}
metasploitVersion();
}
var metasploitVersion = function() {
// Do not care about token, it will automaticaly
// be added as the second arguments
//
// The first value of the array is the function
// you want to call. Full list is available
// in metasploit remote api documentation
var args = ['core.version'];
client.exec(args,function(err,r) {
if (err) return console.log('Error: '+err);
console.log('-> Version: '+r.version);
console.log('-> Api: '+r.api);
console.log('-> Ruby: '+r.ruby);
});
}
var client = new metasploitClient({
login:'myLogin',
password:'myPassword',
host:'localhost', // optional
port:55553, // optional
protocol:'https', // optional
apiVersion:'1.0', // optional
apiPath:'/api/' // optional
});
client.on('connected',onConnect);
The tests directory contains more examples.
Just by curiosity, if you are using this module, please star it !
Special thanks to authors of theses nodejs modules :
and dailyjs ;)