Narrowed down conditions for CGI execution for security reasons
This commit is contained in:
parent
b4de66359d
commit
9381b3dec0
1 changed files with 11 additions and 7 deletions
18
index.js
18
index.js
|
@ -56,14 +56,15 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
||||||
".sh": ["bash"],
|
".sh": ["bash"],
|
||||||
".ksh": ["ksh"],
|
".ksh": ["ksh"],
|
||||||
".csh": ["csh"],
|
".csh": ["csh"],
|
||||||
".bat": ["cmd", "/c"],
|
|
||||||
".cmd": ["cmd", "/c"],
|
|
||||||
".vbs": ["cscript"],
|
|
||||||
".jar": ["java"],
|
|
||||||
".pyw": ["python"],
|
|
||||||
".rb": ["ruby"],
|
".rb": ["ruby"],
|
||||||
".php": ["php-cgi"]
|
".php": ["php-cgi"]
|
||||||
};
|
};
|
||||||
|
if(os.platform() == "win32") {
|
||||||
|
exttointerpreter[".exe"] = [];
|
||||||
|
exttointerpreter[".bat"] = ["cmd", "/c"];
|
||||||
|
exttointerpreter[".cmd"] = ["cmd", "/c"];
|
||||||
|
exttointerpreter[".vbs"] = ["cscript"];
|
||||||
|
}
|
||||||
var exttointerpreteruser = {};
|
var exttointerpreteruser = {};
|
||||||
fs.readFile(__dirname + "/../../../redbrick-interpreters.json", function (err, data) {
|
fs.readFile(__dirname + "/../../../redbrick-interpreters.json", function (err, data) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
@ -115,7 +116,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
||||||
return arg.replace(/"/g, "");
|
return arg.replace(/"/g, "");
|
||||||
});
|
});
|
||||||
afterShebangCallback(args);
|
afterShebangCallback(args);
|
||||||
} else if (line.substr(0, 2) == "MZ" || line.substr(0, 4) == "\x7fELF") {
|
} else if (os.platform() != "win32" && line.substr(0, 4) == "\x7fELF") {
|
||||||
afterShebangCallback("binary");
|
afterShebangCallback("binary");
|
||||||
} else {
|
} else {
|
||||||
afterShebangCallback(false);
|
afterShebangCallback(false);
|
||||||
|
@ -146,7 +147,10 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
args = exttointerpreteruser[ext];
|
args = exttointerpreteruser[ext];
|
||||||
if (!args) {
|
if (args === null) {
|
||||||
|
elseCallback();
|
||||||
|
return;
|
||||||
|
} else if (!args) {
|
||||||
args = exttointerpreter[ext];
|
args = exttointerpreter[ext];
|
||||||
if (!args) {
|
if (!args) {
|
||||||
elseCallback();
|
elseCallback();
|
||||||
|
|
Loading…
Reference in a new issue