Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NMAP support with Caterpillar Proxy #118

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/catproxy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// catproxy.js
// Caterpillar Proxy Integration for WelsonJS framework
// https://github.com/gnh1201/welsonjs
// https://github.com/gnh1201/caterpillar
var JSONRPC2 = require("lib/jsonrpc2");

function CatProxyClient(url) {
var env = {"target": url, "method": ""};
var env = {
"target": "http://localhost:5555/jsonrpc2", // Check this: https://github.com/gnh1201/caterpillar
"method": ""
};

this.set_env = function(k, v) {
env[k] = v || null;
Expand Down Expand Up @@ -54,6 +56,10 @@ function CatProxyClient(url) {

return result;
}

if (typeof url !== "undefined") {
this.set_env(url);
}
}

function create(url) {
Expand All @@ -63,7 +69,7 @@ function create(url) {
exports.create = create;
exports.CatProxyClient = CatProxyClient;

exports.VERSIONINFO = "Caterpillar Proxy Integration (caterpillar.js) version 0.1.4";
exports.VERSIONINFO = "Caterpillar Proxy Integration (caterpillar.js) version 0.1.5";
exports.AUTHOR = "[email protected]";
exports.global = global;
exports.require = global.require;
30 changes: 22 additions & 8 deletions lib/nmap.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
////////////////////////////////////////////////////////////////////////
// NMAP API
// NMAP interface API
////////////////////////////////////////////////////////////////////////

var NMAPObject = function() {
this.binPath = "bin\\32bit\\nmap-7.92\\nmap.exe";
var client = require("lib/catproxy");

this.start = function() {
var cmd = [];
// .. todo ..
};
var PortScanner = function(binpath, url) {
this.url = url;
this.binpath = binpath;

this.scan = function(hosts) {
var worker = client.create(url);
worker.set_method("scan_ports_by_hosts");

var result = worker.exec({
"binpath": this.binpath,
"hosts": hosts
});
return result;
}
};

exports.NMAPObject = NMAPObject;
exports.PortScanner = PortScanner;

exports.VERSIONINFO = "NMAP interface version 0.2";
exports.AUTHOR = "[email protected]";
exports.global = global;
exports.require = global.require;