sshChat-CLI/commands/exec.js

25 lines
705 B
JavaScript
Raw Normal View History

2023-01-11 15:48:57 -05:00
// exec.js
const unirest = require("unirest");
async function runCMD(key, cmd, pwd) {
let requestData = await unirest
.post('https://api.discord-linux.com/exec')
.headers({
'Accept': 'application/json', 'Content-Type': 'application/json',
'x-discord-linux-auth': key
})
.send({ "cmd": cmd, "pwd": pwd })
return requestData.body.stdout
}
2023-01-11 16:27:33 -05:00
async function execute(key, cmd, pwd, conns) {
2023-01-11 15:48:57 -05:00
const stdout = await runCMD(key, cmd, pwd)
console.log(stdout)
2023-01-11 16:27:33 -05:00
if (stdout.length > 1800) return console.log("I cannot send stdout to the swarm, its too large!")
for (const conn of conns)
conn.write(`${USERNAME}: ran ${cmd}\n${stdout}`)
2023-01-11 15:48:57 -05:00
}
2023-01-11 16:27:33 -05:00
2023-01-11 15:48:57 -05:00
module.exports = { execute, runCMD }