This commit is contained in:
Namhyeon Go 2020-11-18 13:13:38 +09:00
parent 0014384539
commit a634f54400
9 changed files with 202 additions and 84 deletions

BIN
Default_HTA.reg Normal file

Binary file not shown.

26
app.js
View File

@ -32,6 +32,7 @@
// The appname argument causes <appname>.js to be loaded. The interface returned // The appname argument causes <appname>.js to be loaded. The interface returned
// must define main = function(args) {}, which is called once the module is // must define main = function(args) {}, which is called once the module is
// loaded. // loaded.
var exit = function(status) { var exit = function(status) {
if (typeof(WScript) !== "undefined") { if (typeof(WScript) !== "undefined") {
WScript.quit(status); WScript.quit(status);
@ -41,28 +42,27 @@ var exit = function(status) {
var console = { var console = {
_messages: [], _messages: [],
_echo: function(msg, type) { _echo: function(args, type) {
msg = (typeof(type) !== "undefined" ? type + ": " : "") + msg; msg = (typeof(type) !== "undefined" ? type + ": " : "") + args[0];
if (typeof(WScript) !== "undefined") { if (typeof(WScript) !== "undefined") {
WScript.echo(" * " + msg); WScript.echo(" * " + msg);
} }
this._messages.push(msg); this._messages.push(msg);
}, },
log: function(msg) { log: function() {
this._echo(msg); this._echo(arguments);
}, },
error: function(msg) { error: function() {
this._echo(msg, "error"); this._echo(arguments, "error");
}, },
info: function(msg) { info: function() {
this._echo(msg, "info"); this._echo(arguments, "info");
}, },
warn: function(msg) { warn: function() {
this._echo(msg, "warn"); this._echo(arguments, "warn");
}, },
debug: function(msg) { debug: function() {
this._echo(msg, "debug"); this._echo(arguments, "debug");
} }
}; };

View File

@ -134,7 +134,7 @@ var getLocalApplications = function() {
var getMyApplications = function() { var getMyApplications = function() {
var onSuccess = function(res) { var onSuccess = function(res) {
var xmlStrings = []; var xmlStrings = [];
xmlStrings.push('<?xml version="1.0" encoding="UTF-8"?>'); xmlStrings.push('<?xml version="1.0" encoding="UTF-8"?>');
xmlStrings.push("<StaticIP>"); xmlStrings.push("<StaticIP>");
for (var i = 0; i < res.data.length; i++) { for (var i = 0; i < res.data.length; i++) {
@ -258,6 +258,12 @@ if (typeof(token) !== "undefined") {
ev.preventDefault(); ev.preventDefault();
}; };
if (FILE.fileExists("credential.json")) {
var credential = JSON.parse(FILE.readFile("token.txt", "utf-8"));
document.getElementById("txt_email").value = credential.email;
document.getElementById("txt_password").value = credential.password;
}
document.getElementById("btn_submit").onclick = function() { document.getElementById("btn_submit").onclick = function() {
var credential = { var credential = {
"email": document.getElementById("txt_email").value, "email": document.getElementById("txt_email").value,
@ -272,6 +278,7 @@ if (typeof(token) !== "undefined") {
console.error(res.error.message); console.error(res.error.message);
} else if ("data" in res) { } else if ("data" in res) {
console.log("ok"); console.log("ok");
FILE.writeFile("credential.json", JSON.stringify(credential), "utf-8");
FILE.writeFile("token.txt", res.data.token, "utf-8"); FILE.writeFile("token.txt", res.data.token, "utf-8");
FILE.writeFile("userid.txt", res.data.user.id, "utf-8"); FILE.writeFile("userid.txt", res.data.user.id, "utf-8");
OldBrowser.reload(); OldBrowser.reload();

13
bootstrap.js vendored
View File

@ -28,8 +28,19 @@ exports.main = function(args) {
REG.write(REG.HKCR, appName + "\\DefaultIcon", "", SYS.getCurrentScriptDirectory() + "\\app\\favicon.ico,0", REG.STRING); REG.write(REG.HKCR, appName + "\\DefaultIcon", "", SYS.getCurrentScriptDirectory() + "\\app\\favicon.ico,0", REG.STRING);
REG.write(REG.HKCR, appName + "\\shell\\open\\command", "", "cmd.exe /c cscript " + SYS.getCurrentScriptDirectory() + "\\app.js uriloader \"%1\"", REG.STRING); REG.write(REG.HKCR, appName + "\\shell\\open\\command", "", "cmd.exe /c cscript " + SYS.getCurrentScriptDirectory() + "\\app.js uriloader \"%1\"", REG.STRING);
// open HTA file // open web application
console.log("Trying open GUI..."); console.log("Trying open GUI...");
// detect old process
var processList = SYS.getProcessList();
for (var i = 0; i < processList.length; i++) {
var process = processList[i];
if (process.Caption == "mshta.exe") {
SYS.killProcess(process.ProcessID);
}
}
// open web application
if (typeof(args) !== "undefined") { if (typeof(args) !== "undefined") {
SHELL.run(["app.hta"].concat(args)); SHELL.run(["app.hta"].concat(args));
} else { } else {

View File

@ -3,10 +3,10 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
var SHELL = require("lib/shell"); var SHELL = require("lib/shell");
var SYS = require("lib/system"); var SYS = require("lib/system");
var SB = require("lib/sandboxie");
var ChromeObject = function() { var ChromeObject = function() {
this.binPath = "%PROGRAMFILES%\\Google\\Chrome\\Application\\chrome.exe"; this.workingDirectory = SYS.getEnvString("PROGRAMFILES") + "\\Google\\:profileName\\Application";
this.binPath = this.workingDirectory + "\\chrome.exe";
this.processID = 0; this.processID = 0;
this.profileName = "Default"; this.profileName = "Default";
this.proxyPort = 1080; this.proxyPort = 1080;
@ -17,8 +17,10 @@ var ChromeObject = function() {
return this; return this;
}; };
this.setProfileName = function(s) { this.setProfileName = function(profileName) {
this.profileName = s; this.profileName = (profileName == "Default" ? "Chrome" : profileName);
this.workingDirectory = this.workingDirectory.replace(":profileName", this.profileName);
this.binPath = this.binPath.replace(":profileName", this.profileName);
return this; return this;
}; };
@ -32,18 +34,40 @@ var ChromeObject = function() {
}; };
this.open = function(url) { this.open = function(url) {
this.setProfileName(this.profileName);
var process; var process;
while (this.processID == 0) { while (this.processID == 0) {
try { try {
/*
process = SB.start(this.profileName, [ process = SB.start(this.profileName, [
this.binPath, this.binPath,
"--profile-directory=" + this.profileName, "--profile-directory=" + this.profileName,
"--proxy-server=socks5://127.0.0.1:" + this.proxyPort, "--proxy-server=socks5://127.0.0.1:" + this.proxyPort,
url url
]); ]);
*/
/*
process = SHELL.createProcess([
this.binPath,
"--profile-directory=" + this.profileName,
"--proxy-server=socks5://127.0.0.1:" + this.proxyPort,
url
], this.workingDirectory);
*/
var shell = SHELL.create().setWorkingDirectory(this.workingDirectory);
var process = shell.createProcess([
"\"" + this.binPath + "\"",
"--profile-directory=\"" + this.profileName + "\"",
"--proxy-server=\"socks5://127.0.0.1:" + this.proxyPort + "\"",
"--user-data-dir=\"" + this.workingDirectory + "\"",
"\"" + url + "\""
].join(" "));
sleep(1000);
this.processID = process.ProcessID; this.processID = process.ProcessID;
shell.release();
} catch (e) { } catch (e) {
console.error(e.message); console.error("ChromeObject.open() -> " + e.message);
} }
} }

View File

@ -168,3 +168,7 @@ exports.deleteFile = function(FN) {
}; };
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
exports.copyFolder = function(FN) {
};

View File

@ -17,7 +17,7 @@ var SandboxieObject = function() {
process = SHELL.createProcess([ process = SHELL.createProcess([
this.binPath, this.binPath,
"/box:" + this.sandboxName, "/box:" + this.sandboxName,
SHELL.buildCommand(cmd) SHELL.build(cmd)
].join(' ')); ].join(' '));
this.processID = process.ProcessID; this.processID = process.ProcessID;
} catch (e) { } catch (e) {

View File

@ -1,13 +1,8 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Shell API // Shell API
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
var FILE = require("lib/file"); var FILE = require("lib/file");
exports.VERSIONINFO = "Shell Lib (shell.js) version 0.1";
exports.global = global;
exports.require = global.require;
var addslashes = function(s) { var addslashes = function(s) {
return s.toString().replace(/\\/g, '\\\\'). return s.toString().replace(/\\/g, '\\\\').
replace(/\u0008/g, '\\b'). replace(/\u0008/g, '\\b').
@ -19,67 +14,140 @@ var addslashes = function(s) {
replace(/"/g, '\\"'); replace(/"/g, '\\"');
}; };
exports.buildCommand = function(cmd) { var ShellObject = function() {
if (typeof(cmd) === "string") { this.interface = null;
return cmd; this.currentDirectory = null;
} else if (typeof(cmd) === "object") { this.workingDirectory = null;
return cmd.map(function(s) { this.isElevated = false;
var regex = /[ "]/g; this.isFork = false;
if (!regex.test(s)) {
return s; this.create = function() {
} else { try {
return "\"" + addslashes(s) + "\""; this.interface = CreateObject("WScript.Shell");
} this.currentDirectory = this.interface.CurrentDirectory;
}).join(' '); } catch (e) {
} else { console.error("ShellObject.create() -> " + e.message);
return ""; }
} return this;
};
this.setWorkingDirectory = function(dirname) {
if (typeof(dirname) === "string") {
this.workingDirectory = dirname;
this.interface.CurrentDirectory = this.workingDirectory;
console.info("ShellObject.workingDirectory -> " + this.workingDirectory);
}
return this;
};
this.build = function(cmd) {
if (typeof(cmd) === "string") {
return cmd;
} else if (typeof(cmd) === "object") {
return cmd.map(function(s) {
var regex = /[ "]/g;
if (!regex.test(s)) {
return s;
} else {
return "\"" + addslashes(s) + "\"";
}
}).join(' ');
} else {
return "";
}
};
this.createProcess = function(cmd) {
try {
var c = this.build(cmd);
console.info("ShellObject.createProcess() -> " + c);
return this.interface.Exec(c);
} catch (e) {
console.error("ShellObject.createProcess() -> " + e.message);
}
};
this.exec = function(cmd, stdOutPath) {
var data;
if (typeof(stdOutPath) === "undefined") {
stdOutPath = "stdout.txt";
}
var c = "%comspec% /c (" + this.build(cmd) + ") 1> " + stdOutPath;
c += " 2>&1";
this.interface.Run(c, 0, true);
console.info("ShellObject.exec() -> " + c);
data = FILE.readFile(stdOutPath, "utf-8");
if (FILE.fileExists(stdOutPath)) {
FILE.deleteFile(stdOutPath);
}
return data;
};
this.run = function(cmd, fork) {
var fork = (typeof(fork) !== "undefined") ? fork : true;
var c = "%comspec% /q /c (" + this.build(cmd) + ")";
console.info("ShellObject.run() -> " + c);
this.interface.Run(c, 0, !fork);
};
this.runWindow = function(cmd, fork) {
var fork = (typeof(fork) !== "undefined") ? fork : true;
var c = "%comspec% /q /c (" + this.build(cmd) + ")";
console.info("ShellObject.runWindow() -> " + c);
this.interface.Run(c, 1, !fork);
};
this.runAs = function(FN, args) {
var c = FN + " " + args.join(' ');
var oShell = CreateObject("Shell.Application");
console.info("ShellObject.runAs() -> " + c);
oShell.shellExecute(FN, args, null, "runas", 0);
return oShell;
};
this.release = function() {
console.info("ShellObject.release() -> " + this.currentDirectory);
this.interface.CurrentDirectory = this.currentDirectory;
this.interface = null;
};
this.create();
};
exports.create = function() {
return new ShellObject();
};
exports.build = function(cmd) {
return (new ShellObject()).build(cmd);
}; };
exports.exec = function(cmd, stdOutPath) { exports.exec = function(cmd, stdOutPath) {
var WSH = CreateObject("WScript.Shell"), data; return (new ShellObject()).exec(cmd, stdOutPath);
if (typeof(stdOutPath) === "undefined") { };
stdOutPath = "stdout.txt";
}
var c = "%comspec% /c (" + exports.buildCommand(cmd) + ") 1> " + stdOutPath;
c += " 2>&1";
WSH.Run(c, 0, true);
console.info("exec() -> " + c);
data = FILE.readFile(stdOutPath, "utf-8");
if (FILE.fileExists(stdOutPath)) {
FILE.deleteFile(stdOutPath);
}
return data;
}
exports.run = function(cmd, fork) { exports.run = function(cmd, fork) {
var WSH = CreateObject("WScript.Shell"); return (new ShellObject()).run(cmd, fork);
var fork = (typeof(fork) !== "undefined") ? fork : true;
var c = "%comspec% /q /c (" + exports.buildCommand(cmd) + ")";
console.info("run() -> " + c);
WSH.Run(c, 0, !fork);
}; };
exports.runWindow = function(cmd, fork) { exports.runWindow = function(cmd, fork) {
var WSH = CreateObject("WScript.Shell"); return (new ShellObject()).runWindow(cmd, fork);
var fork = (typeof(fork) !== "undefined") ? fork : true;
var c = "%comspec% /q /c (" + exports.buildCommand(cmd) + ")";
console.info("run() -> " + c);
WSH.Run(c, 1, !fork);
} }
exports.createProcess = function(cmd) { exports.createProcess = function(cmd, workingDirectory) {
var c = exports.buildCommand(cmd); if (typeof(workingDirectory) !== "undefined") {
var WSH = CreateObject("WScript.Shell"); console.info("Working directory: " + workingDirectory);
console.info("createProcess() -> " + c); }
return WSH.Exec(c); return (new ShellObject()).setWorkingDirectory(workingDirectory).createProcess(cmd);
}; };
exports.elevatedRun = function(FN, args) { exports.runAs = function(FN, args) {
console.info("elevatedRun() -> " + FN + " " + args.join(' ')); return (new ShellObject()).runAs(FN, args);
var oShell = CreateObject("Shell.Application");
oShell.shellExecute(FN, args, null, "runas", 0);
return oShell;
}; };
exports.VERSIONINFO = "Shell Lib (shell.js) version 0.1";
exports.global = global;
exports.require = global.require;

View File

@ -57,14 +57,18 @@ var XMLObject = function(dom) {
return this.dom; return this.dom;
}; };
this.load = function(s) { this.load = function(filename) {
this.filename = s; this.filename = filename;
console.info("XMLObject.load() -> Opening XML file: " + filename)
if (FILE.fileExists(s)) { try {
this.getDOM().loadXML(FILE.readFile(this.filename, "utf-8")); if (FILE.fileExists(filename)) {
} else { this.getDOM().loadXML(FILE.readFile(this.filename, "utf-8"));
console.error("The file does not exists"); } else {
return; console.error("XMLObject.load() -> The file does not exists or access denied");
}
} catch (e) {
console.error("XMLObject.load() -> " + e.message);
} }
return this; return this;