Skip to content

mkrecny/bantu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bantu (an African 'talking drum') is an HTTP server that will simply execute any commands on the host machine specified by an authenticated client.

cURL usage example: (kill all python processes running on a server)

**NOTE: this example assumes a bantu server running at http://bantu.someurl.com

curl --user foo:bar \
--data run="ps -ef | grep python | grep -v grep | awk '{print \$2}' | xargs kill -9" \
http://bantu.someurl.com/execute

Node usage example: (kill all node processes running on a server)

**NOTE: this example boots up a Bantu server and makes a client request in the same process. Obviously you would never do this in a production situation.
**NOTE: see the test/ dir for a working example

// defined user and pass for basic auth
var auth_user = 'foo'; 
var auth_pwd = 'bar';

// create a bantu client
var client = bantu.createClient();

// create a bantu server, the server object will be passed in the callback
var server = bantu.createServer(auth_user, auth_pwd, 3000, function(server){

  // define request options
  var opts = {
    host : 'localhost',
    port : '3000',
    run : "ps -ef | grep node | grep -v grep | awk '{print $2}' | xargs kill -9 ", //kill all node procs
    username : auth_user,
    password : auth_pwd 
  };
  
  console.log("Client: making request with opts:", opts);
  client.exec(opts, function(response){
    console.log("Client: received response:", response);
    process.exit();
  });

});

About

A HTTP wrapper on node's child_process

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published