5 mark > tom
# explored a lot of stuff
# reusing password
# connecting mongo failed with mark creds
# looking at processes running as tom
mark@node:/opt$ ps fuaxwww | grep tom
mark 23909 0.0 0.1 14228 940 pts/0 S+ 19:15 0:00 \_ grep --color=auto tom
tom 1225 5.5 5.7 1045320 43720 ? Ssl 18:20 3:01 /usr/bin/node /var/www/myplace/app.js
tom 1229 0.0 4.0 1074616 30708 ? Ssl 18:20 0:01 /usr/bin/node /var/scheduler/app.jsmark@node:/opt$ cat /var/scheduler/app.js
const exec = require('child_process').exec;
const MongoClient = require('mongodb').MongoClient;
const ObjectID = require('mongodb').ObjectID;
const url = 'mongodb://mark:5AYRft73VtFpc84k@localhost:27017/scheduler?authMechanism=DEFAULT&authSource=scheduler';
MongoClient.connect(url, function(error, db) {
if (error || !db) {
console.log('[!] Failed to connect to mongodb');
return;
}
setInterval(function () {
db.collection('tasks').find().toArray(function (error, docs) {
if (!error && docs) {
docs.forEach(function (doc) {
if (doc) {
console.log('Executing task ' + doc._id + '...');
exec(doc.cmd);
db.collection('tasks').deleteOne({ _id: new ObjectID(doc._id) });
}
});
}
else if (error) {
console.log('Something went wrong: ' + error);
}
});
}, 30000);
});Last updated