-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathset_options.js
35 lines (26 loc) · 1.2 KB
/
set_options.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
33
34
35
const { Luraph } = require("luraph");
const apiKey = process.env.LPH_API_KEY; //replace with your api key
const luraph = new Luraph(apiKey);
const obfuscate = async (script, fileName) => {
console.log(`[*] file name: ${fileName}`);
const nodes = await luraph.getNodes();
console.log(`[*] recommended node: ${nodes.recommendedId}`);
const node = nodes.nodes[nodes.recommendedId];
console.log(`[*] cpu usage: ${node.cpuUsage}`);
const { jobId } = await luraph.createNewJob(nodes.recommendedId, script, fileName, {
"TARGET_VERSION": "Lua 5.2"
});
console.log(`[*] job id: ${jobId}`);
const { success, error } = await luraph.getJobStatus(jobId);
console.log(`[*] job status: ${success ? "success" : "error"}`);
if(success){
const {fileName: resultName, data} = await luraph.downloadResult(jobId);
console.log(`[*] result name: ${resultName}`);
return data;
}else{
throw error; //error is a string
}
};
obfuscate("print'Hello World!'", `luraph-node-${Date.now()}.lua`)
.then(result => console.log(`[*] obfuscation successful: ${result.split("\n")[0]}`))
.catch(error => console.error(`[*] obfuscation failed: ${error}`));