-
Notifications
You must be signed in to change notification settings - Fork 0
/
ps-kovak.js
32 lines (25 loc) · 853 Bytes
/
ps-kovak.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express')
const router = express.Router()
const { Buffer } = require("buffer")
const helper = require("./helper")
router.post("/generate", (req, res) => {
try {
if (!req.files) {
res.status(500).send("file upload error")
return
}
const psCode = req.files.file.data.toString()
const { method, base64: isBase64 } = req.body
if (psCode.includes("\n")) {
res.status(500).send("multiline string found. single line needed")
return
}
let payload = helper[`${method}Method`](psCode)
if (isBase64) payload = `powershell -e ${Buffer.from(payload, "utf16le").toString("base64")}`
res.send(payload)
} catch (error) {
console.log(error);
res.sendStatus(500)
}
})
module.exports = router