sshChat-CLI/commands/exec.js

25 lines
715 B
JavaScript
Raw Normal View History

2023-01-11 20:48:57 +00: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
}
async function execute(key, cmd, pwd, conns, USERNAME) {
2023-01-11 20:48:57 +00:00
const stdout = await runCMD(key, cmd, pwd)
console.log(stdout)
2023-01-11 21:27:33 +00: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 20:48:57 +00:00
}
2023-01-11 21:27:33 +00:00
2023-01-11 20:48:57 +00:00
module.exports = { execute, runCMD }