Add OS Checks
This commit is contained in:
parent
5262138c94
commit
c4f6c66c6d
59
index.js
59
index.js
@ -4,48 +4,55 @@ const args = process.argv.slice(2).join(' ');
|
||||
const pongoOSDevice = usb.findByIds(0x05ac, 0x4141);
|
||||
|
||||
function log(message, type) {
|
||||
switch (type) {
|
||||
case 'success':
|
||||
console.log("[+] " + message)
|
||||
break;
|
||||
case 'error':
|
||||
console.error("[-] " + message)
|
||||
break;
|
||||
}
|
||||
switch (type) {
|
||||
case 'success':
|
||||
console.log("[+] " + message)
|
||||
break;
|
||||
case 'error':
|
||||
console.error("[-] " + message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform != 'darwin' && process.platform != 'linux') {
|
||||
log(`You can't run this script on (${process.platform}) only works on Darwin/Linux Platform.`, 'error');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function checkRoot() {
|
||||
return process.getuid && process.getuid() === 0
|
||||
return process.getuid && process.getuid() === 0
|
||||
};
|
||||
|
||||
log(`Running the script on ${process.platform} and arch ${process.arch}`, "success");
|
||||
|
||||
if (!checkRoot()) {
|
||||
log(`Please run ass root (Current UID = ${process.getuid()}, Need UID = 0)`, "error");
|
||||
process.exit(1);
|
||||
log(`Please run ass root (Current UID = ${process.getuid()}, Need UID = 0)`, "error");
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
if (!pongoOSDevice) {
|
||||
log("No device with pongoOS Booted has been found.", "error");
|
||||
process.exit(1);
|
||||
log("No device with pongoOS Booted has been found.", "error");
|
||||
process.exit(1);
|
||||
};
|
||||
if (!args) {
|
||||
log("No argumment has been provided.", "error");
|
||||
process.exit(1);
|
||||
log("No argumment has been provided.", "error");
|
||||
process.exit(1);
|
||||
};
|
||||
try {
|
||||
pongoOSDevice.open(true)
|
||||
pongoOSDevice.open(true)
|
||||
} catch (e) {
|
||||
log("An error as occured while i was opening the device.", "error");
|
||||
process.exit(1)
|
||||
log("An error as occured while i was opening the device.", "error");
|
||||
process.exit(1)
|
||||
};
|
||||
if (args.length > 510) {
|
||||
log("You reached the length of the argumment.", "error");
|
||||
process.exit(1)
|
||||
log("You reached the length of the argumment.", "error");
|
||||
process.exit(1)
|
||||
};
|
||||
pongoOSDevice.controlTransfer(0x21, 3, 0, 0, new Buffer.from(`${args} \n`), (error) => {
|
||||
if (error) {
|
||||
log(`An error as occured while sending cmd error: ${error}`, "error")
|
||||
process.exit(1);
|
||||
}
|
||||
log(`Success, command "${args}" has been sent.`, "success")
|
||||
process.exit(0);
|
||||
if (error) {
|
||||
log(`An error as occured while sending cmd error: ${error}`, "error")
|
||||
process.exit(1);
|
||||
}
|
||||
log(`Success, command "${args}" has been sent.`, "success")
|
||||
process.exit(0);
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user