Refactor Netscript Interpreter

This commit is contained in:
Daniel Xie 2017-06-04 23:48:37 -05:00
parent beb770eaf9
commit bb24c017f1
4 changed files with 777 additions and 969 deletions

@ -33,6 +33,7 @@
<script src="src/NetscriptParser.js"></script>
<script src="src/NetscriptEvaluator.js"></script>
<script src="src/NetscriptEnvironment.js"></script>
<script src="src/NetscriptFunctions.js"></script>
<!-- Main game files -->
<script src="src/Constants.js"></script>

@ -34,7 +34,7 @@ CONSTANTS = {
/* Script related things */
//Time (ms) it takes to run one operation in Netscript.
CodeInstructionRunTime: 1500,
CodeInstructionRunTime: 750,
//RAM Costs for differenc commands
ScriptWhileRamCost: 0.4,
@ -488,61 +488,15 @@ CONSTANTS = {
"RAM Upgrades on your home computer",
Changelog:
"v0.15 <br>" +
"-Slightly reduced production multiplier for Hacknet Node RAM<br>" +
"-Faction pages now scroll<br>" +
"-Slightly increased amount of money gained from hacking<br>" +
"-Added 'alias' command<br>" +
"-Added 'scan-analyze' terminal command - used to get basic hacking info about all immediate network connections<br>" +
"-Fixed bugs with upgradeHacknetNode() and purchaseHacknetNode() commands<br>" +
"-Added getNumHacknetNodes() and hasRootAccess(hostname/ip) commands to Netscript<br>" +
"-Increased Cost of university classes/gym<br>" +
"-You can now see what an Augmentation does and its price even while its locked<br><br>" +
"v0.16<br>" +
"-New Script Editor interface <br>" +
"-Rebalanced hacknet node - Increased base production but halved the multiplier from additional cores. This should boost its early-game production but nerf its late-game production<br>" +
"-Player now starts with 8GB of RAM on home computer<br>" +
"-'scan-analyze' terminal command displays RAM on servers<br>" +
"-Slightly buffed the amount of money the player steals when hacking servers (by about ~8%)<br>" +
"-Time to execute grow() now depends on hacking skill and server security, rather than taking a flat 2 minutes.<br>" +
"-Clicking outside of a pop-up dialog box will now close it<br>" +
"-BruteSSH.exe takes 33% less time to create<br>" +
"-'iron-gym' and 'max-hardware' servers now have 2GB of RAM<br>" +
"-Buffed job salaries across the board<br>" +
"-Updated Tutorial<br>" +
"-Created a Hacknet Node API for Netscript that allows you to access and upgrade your Hacknet Nodes. See the Netscript documentation for more details. WARNING The old upgradeHacknetNode() and getNumHacknetNodes() functions waere removed so any script that has these will no longer work <br><br>" +
"v0.17<br>" +
"-Greatly increased amount of money gained for crimes (by about 400% for most crimes)<br>" +
"-Criminal factions require slightly less negative karma to get invited to<br>" +
"-Increased the percentage of money stolen from servers when hacking<br>" +
"-Increased the starting amount of money available on beginning servers (servers with <50 required hacking))<br>" +
"-Increased the growth rate of servers (both naturally and manually when using the grow() command in a script)<br>" +
"-Added getHostname() command in Netscript that returns the hostname of the server a script is running on<br>" +
"-jQuery preventDefault() called when pressing ctrl+b in script editor<br>" +
"-The Neuroflux Governor augmentation (the one that can be repeatedly leveled up) now increases ALL multipliers by 1%. To balance it out, it's price multiplier when it levels up was increased<br>" +
"-Hacknet Node base production decreased from $1.75/s to $1.65/s<br>" +
"-Fixed issue with nested for loops in Netscript (stupid Javascript references)<br>" +
"-Added 'scp' command to Terminal and Netscript<br>" +
"-Slightly nerfed Hacknet Node Kernel DNI and Hacknet Node Core DNI Augmentations<br>" +
"-Increased TOR Router cost to $200k<br><br>" +
"v0.17.1 <br>" +
"-Fixed issue with purchasing Augmentations that are 'upgrades' and require previous Augmentations to be installed<br>" +
"-Increased the percentage of money stolen from servers when hacking<br><br>" +
"v0.18<br>" +
"-Major rebalancing (sorry didn't record specifics. But in general hacking gives more money " +
"and hacknet nodes give less)<br>" +
"-Server growth rate (both natural and manual using grow()) doubled<br>" +
"-Added option to Soft Reset<br>" +
"-Cancelling a full time job early now only results in halved gains for reputation. Exp and money earnings are gained in full<br>" +
"-Added exec() Netscript command, used to run scripts on other servers. <br>" +
"-NEW HACKING MECHANICS: Whenever a server is hacked, its 'security level' is increased by a very small amount. " +
"The security level is denoted by a number between 1-100. A higher security level makes it harder " +
"to hack a server and also decreases the amount of money you steal from it. Two Netscript functions, " +
"weaken() and getServerSecurityLevel() level, were added. The weaken(server) function lowers a server's " +
"security level. See the Netscript documentation for more details<br>" +
"-When donating to factions, the base rate is now $1,000,000 for 1 reputation point. Before, it was " +
"$1,000 for 1 reputation point.<br>" +
"-Monetary costs for all Augmentations increased. They are now about ~3.3 - 3.75 times more expensive than before<br><br>" +
"v0.19.7<br>" +
"-Added changelog to Options menu<br>" +
"-Bug fix with autocompletion (wasn't working properly for capitalized filenames/programs<br><br>" +
"v0.19.6<br>" +
"-Script editor now saves its state even when you change tabs <br>" +
"-scp() command in Terminal/script will now overwrite files at the destination <br>" +
"-Terminal commands are no longer case-sensitive (only the commands themselves such as 'run' or 'nano'. Filenames are " +
"still case sensitive<br>" +
"-Tab automcompletion will now work on commands<br><br>" +
"v0.19<br>" +
"-Hacknet Nodes have slightly higher base production, and slightly increased RAM multiplier. " +
"But they are also a bit more expensive at higher levels<br>" +
@ -560,16 +514,61 @@ CONSTANTS = {
"-Gyms and classes are now significantly more expensive<br>" +
"-Doubled the amount by which a server's security increases when it is hacked. Now, it will " +
"increase by 0.002. Calling weaken() on a server will lower the security by 0.1.<br><br>" +
"v0.19.6<br>" +
"-Script editor now saves its state even when you change tabs <br>" +
"-scp() command in Terminal/script will now overwrite files at the destination <br>" +
"-Terminal commands are no longer case-sensitive (only the commands themselves such as 'run' or 'nano'. Filenames are " +
"still case sensitive<br>" +
"-Tab automcompletion will now work on commands<br><br>" +
"v0.19.7<br>" +
"-Added changelog to Options menu<br>" +
"-Bug fix with autocompletion (wasn't working properly for capitalized filenames/programs<br><br>" +
"",
"v0.18<br>" +
"-Major rebalancing (sorry didn't record specifics. But in general hacking gives more money " +
"and hacknet nodes give less)<br>" +
"-Server growth rate (both natural and manual using grow()) doubled<br>" +
"-Added option to Soft Reset<br>" +
"-Cancelling a full time job early now only results in halved gains for reputation. Exp and money earnings are gained in full<br>" +
"-Added exec() Netscript command, used to run scripts on other servers. <br>" +
"-NEW HACKING MECHANICS: Whenever a server is hacked, its 'security level' is increased by a very small amount. " +
"The security level is denoted by a number between 1-100. A higher security level makes it harder " +
"to hack a server and also decreases the amount of money you steal from it. Two Netscript functions, " +
"weaken() and getServerSecurityLevel() level, were added. The weaken(server) function lowers a server's " +
"security level. See the Netscript documentation for more details<br>" +
"-When donating to factions, the base rate is now $1,000,000 for 1 reputation point. Before, it was " +
"$1,000 for 1 reputation point.<br>" +
"-Monetary costs for all Augmentations increased. They are now about ~3.3 - 3.75 times more expensive than before<br><br>" +
"v0.17.1 <br>" +
"-Fixed issue with purchasing Augmentations that are 'upgrades' and require previous Augmentations to be installed<br>" +
"-Increased the percentage of money stolen from servers when hacking<br><br>" +
"v0.17<br>" +
"-Greatly increased amount of money gained for crimes (by about 400% for most crimes)<br>" +
"-Criminal factions require slightly less negative karma to get invited to<br>" +
"-Increased the percentage of money stolen from servers when hacking<br>" +
"-Increased the starting amount of money available on beginning servers (servers with <50 required hacking))<br>" +
"-Increased the growth rate of servers (both naturally and manually when using the grow() command in a script)<br>" +
"-Added getHostname() command in Netscript that returns the hostname of the server a script is running on<br>" +
"-jQuery preventDefault() called when pressing ctrl+b in script editor<br>" +
"-The Neuroflux Governor augmentation (the one that can be repeatedly leveled up) now increases ALL multipliers by 1%. To balance it out, it's price multiplier when it levels up was increased<br>" +
"-Hacknet Node base production decreased from $1.75/s to $1.65/s<br>" +
"-Fixed issue with nested for loops in Netscript (stupid Javascript references)<br>" +
"-Added 'scp' command to Terminal and Netscript<br>" +
"-Slightly nerfed Hacknet Node Kernel DNI and Hacknet Node Core DNI Augmentations<br>" +
"-Increased TOR Router cost to $200k<br><br>" +
"v0.16<br>" +
"-New Script Editor interface <br>" +
"-Rebalanced hacknet node - Increased base production but halved the multiplier from additional cores. This should boost its early-game production but nerf its late-game production<br>" +
"-Player now starts with 8GB of RAM on home computer<br>" +
"-'scan-analyze' terminal command displays RAM on servers<br>" +
"-Slightly buffed the amount of money the player steals when hacking servers (by about ~8%)<br>" +
"-Time to execute grow() now depends on hacking skill and server security, rather than taking a flat 2 minutes.<br>" +
"-Clicking outside of a pop-up dialog box will now close it<br>" +
"-BruteSSH.exe takes 33% less time to create<br>" +
"-'iron-gym' and 'max-hardware' servers now have 2GB of RAM<br>" +
"-Buffed job salaries across the board<br>" +
"-Updated Tutorial<br>" +
"-Created a Hacknet Node API for Netscript that allows you to access and upgrade your Hacknet Nodes. See the Netscript documentation for more details. WARNING The old upgradeHacknetNode() and getNumHacknetNodes() functions waere removed so any script that has these will no longer work <br><br>" +
"v0.15 <br>" +
"-Slightly reduced production multiplier for Hacknet Node RAM<br>" +
"-Faction pages now scroll<br>" +
"-Slightly increased amount of money gained from hacking<br>" +
"-Added 'alias' command<br>" +
"-Added 'scan-analyze' terminal command - used to get basic hacking info about all immediate network connections<br>" +
"-Fixed bugs with upgradeHacknetNode() and purchaseHacknetNode() commands<br>" +
"-Added getNumHacknetNodes() and hasRootAccess(hostname/ip) commands to Netscript<br>" +
"-Increased Cost of university classes/gym<br>" +
"-You can now see what an Augmentation does and its price even while its locked<br><br>",
LatestUpdate:
"",

File diff suppressed because it is too large Load Diff

341
src/NetscriptFunctions.js Normal file

@ -0,0 +1,341 @@
/* Netscript Functions
* Implementation for Netscript functions */
function netscriptAssign(exp, workerScript) {
var env = workerScript.env;
return new Promise(function(resolve, reject) {
if (env.stopFlag) {return reject(workerScript);}
if (exp.left.type != "var") {
return reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to " + JSON.stringify(exp.left)));
}
var expRightPromise = evaluate(exp.right, workerScript);
expRightPromise.then(function(expRight) {
try {
env.set(exp.left.value, expRight);
} catch (e) {
return reject(makeRuntimeRejectMsg(workerScript, "Failed to set environment variable: " + e.toString()));
}
resolve(false); //Return false so this doesnt cause conditionals to evaluate
}, function(e) {
reject(e);
});
});
}
function netscriptBinary(exp, workerScript) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
var opPromises = [evaluate(exp.left, workerScript), evaluate(exp.right, workerScript)];
return Promise.all(opPromises).then(function (ops) {
try {
var result = apply_op(exp.operator, ops[0], ops[1]);
return Promise.resolve(result);
} catch(e) {
return Promise.reject(e);
}
}).catch(function(e) {
return Promise.reject(e);
});
}
function netscriptHack(exp, workerScript) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
if (exp.args.length != 1) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument"));
}
var ipPromise = evaluate(exp.args[0], workerScript);
return ipPromise.then(function(ip) {
var server = getServer(ip);
if (server == null) {
workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid IP or hostname passed into hack() command"));
}
//Calculate the hacking time
var hackingTime = scriptCalculateHackingTime(server); //This is in seconds
//No root access or skill level too low
if (server.hasAdminRights == false) {
workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access");
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Script crashed because it did not have root access to " + server.hostname));
}
if (server.requiredHackingSkill > Player.hacking_skill) {
workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Script crashed because player's hacking skill is not high enough to hack " + server.hostname));
}
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds");
return Promise.resolve([server, hackingTime]);
}).then(function([server, hackingTime]) {
console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds.");
return netscriptDelay(hackingTime* 1000).then(function() {
if (env.stopFlag) {return Promise.reject(workerScript);}
var hackChance = scriptCalculateHackingChance(server);
var rand = Math.random();
var expGainedOnSuccess = scriptCalculateExpGain(server);
var expGainedOnFailure = (expGainedOnSuccess / 4);
if (rand < hackChance) { //Success!
var moneyGained = scriptCalculatePercentMoneyHacked(server);
moneyGained = Math.floor(server.moneyAvailable * moneyGained);
//Safety check
if (moneyGained <= 0) {moneyGained = 0;}
server.moneyAvailable -= moneyGained;
Player.gainMoney(moneyGained);
workerScript.scriptRef.onlineMoneyMade += moneyGained;
workerScript.scriptRef.recordHack(server.ip, moneyGained);
Player.gainHackingExp(expGainedOnSuccess);
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp");
workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp");
server.fortify(CONSTANTS.ServerFortifyAmount);
return Promise.resolve(true);
} else {
//Player only gains 25% exp for failure? TODO Can change this later to balance
Player.gainHackingExp(expGainedOnFailure);
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp");
workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp");
return Promise.resolve(false);
}
});
}).then(function(res) {
return Promise.resolve(res);
}).catch(function(e) {
return Promise.reject(e);
});
}
function netscriptGrow(exp, workerScript) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
if (exp.args.length != 1) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument"));
}
var ipPromise = evaluate(exp.args[0], workerScript);
return ipPromise.then(function(ip) {
if (env.stopFlag) {return Promise.reject(workerScript);}
var server = getServer(ip);
if (server == null) {
workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip);
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid IP or hostname passed into grow() command"));
}
//No root access or skill level too low
if (server.hasAdminRights == false) {
workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access");
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Script crashed because it did not have root access to " + server.hostname));
}
var growTime = scriptCalculateGrowTime(server);
console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds")
workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds");
return Promise.resolve([server, growTime]);
}).then(function([server, growTime]) {
if (env.stopFlag) {return Promise.reject(workerScript);}
return netscriptDelay(growTime).then(function() {
if (env.stopFlag) {return Promise.reject(workerScript);}
server.moneyAvailable += 1; //It can be grown even if it has no money
var growthPercentage = processSingleServerGrowth(server, 450);
workerScript.scriptRef.recordGrow(server.ip);
return Promise.resolve(growthPercentage);
});
}).then(function(res) {
return Promise.resolve(res);
}).catch(function(e) {
return Promise.reject(e);
})
}
function netscriptWeaken(exp, workerScript) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
if (exp.args.length != 1) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument"));
}
var ipPromise = evaluate(exp.args[0], workerScript);
return ipPromise.then(function(ip) {
if (env.stopFlag) {return Promise.reject(workerScript);}
var server = getServer(ip);
if (server == null) {
workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip);
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid IP or hostname passed into weaken() command"));
}
//No root access or skill level too low
if (server.hasAdminRights == false) {
workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access");
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Script crashed because it did not have root access to " + server.hostname));
}
var weakenTime = scriptCalculateWeakenTime(server);
console.log("Executing weaken() on server " + server.hostname + " in " + formatNumber(weakenTime/1000, 3) + " seconds")
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " + formatNumber(weakenTime/1000, 3) + " seconds");
return Promise.resolve([server, weakenTime]);
}).then(function([server, weakenTime]) {
if (env.stopFlag) {return Promise.reject(workerScript);}
return netscriptDelay(weakenTime).then(function() {
if (env.stopFlag) {return Promise.reject(workerScript);}
server.weaken(CONSTANTS.ServerWeakenAmount);
workerScript.scriptRef.recordWeaken(server.ip);
return Promise.resolve(CONSTANTS.ServerWeakenAmount);
});
}).then(function(res) {
return Promise.resolve(res);
}).catch(function(e) {
return Promise.reject(e);
});
}
function netscriptRunProgram(exp, workerScript, programName) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
if (exp.args.length != 1) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "nuke() call has incorrect number of arguments. Takes 1 argument"));
}
var ipPromise = evaluate(exp.args[0], workerScript);
return ipPromise.then(function(ip) {
if (env.stopFlag) {return Promise.reject(workerScript);}
var server = getServer(ip);
if (server == null) {
workerScript.scriptRef.log("Cannot call " + programName + ". Invalid IP or hostname passed in: " + ip);
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid IP or hostname passed into " + programName + " command"));
}
if (!Player.hasProgram(programName)) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Player does not have " + programName + " on home computer"));
}
switch(programName) {
case Programs.NukeProgram:
return netscriptRunNukeProgram(exp, workerScript, server);
break;
case Programs.BruteSSHProgram:
return netscriptRunBrutesshProgram(exp, workerScript, server);
break;
case Programs.FTPCrackProgram:
return netscriptRunFtpcrackProgram(exp, workerScript, server);
break;
case Programs.RelaySMTPProgram:
return netscriptRunRelaysmtpProgram(exp, workerScript, server);
break;
case Programs.HTTPWormProgram:
return netscriptRunHttpwormProgram(exp, workerScript, server);
break;
case Programs.SQLInjectProgram:
return netscriptRunSqlinjectProgram(exp, workerScript, server);
break;
default:
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid program. This is a bug please contact game dev"));
break;
}
}).then(function(res) {
return Promise.resolve(res);
}).catch(function(e) {
return Promise.reject(e);
});
}
function netscriptRunNukeProgram(exp, workerScript, server) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
if (server.openPortCount < server.numOpenPortsRequired) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Not enough ports opened to use NUKE.exe virus"));
}
workerScript.scriptRef.log("Running NUKE.exe on server " + server.hostname + " in 5 seconds");
setTimeout(function() {
if (server.hasAdminRights) {
workerScript.scriptRef.log("Already have root access to " + server.hostname);
} else {
server.hasAdminRights = true;
workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access");
}
return Promise.resolve(true);
}, 5 * 1000);
}
function netscriptRunBrutesshProgram(exp, workerScript, server) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
setTimeout(function() {
if (!server.sshPortOpen) {
workerScript.scriptRef.log("Executed BruteSSH.exe virus on " + server.hostname + " to open SSH port (22)");
server.sshPortOpen = true;
++server.openPortCount;
} else {
workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
}
return Promise.resolve(true);
}, 10 * 1000);
}
function netscriptRunFtpcrackProgram(exp, workerScript, server) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
setTimeout(function() {
if (!server.ftpPortOpen) {
workerScript.scriptRef.log("Executed FTPCrack.exe virus on " + server.hostname + " to open FTP port (21)");
server.ftpPortOpen = true;
++server.openPortCount;
} else {
workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
}
return Promise.resolve(true);
}, 15 * 1000);
}
function netscriptRunRelaysmtpProgram(exp, workerScript, server) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
setTimeout(function() {
if (!server.smtpPortOpen) {
workerScript.scriptRef.log("Executed relaySMTP.exe virus on " + server.hostname + " to open SMTP port (25)");
server.smtpPortOpen = true;
++server.openPortCount;
} else {
workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
}
return Promise.resolve(true);
}, 20 * 1000);
}
function netscriptRunHttpwormProgram(exp, workerScript, server) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
setTimeout(function() {
if (!server.httpPortOpen) {
workerScript.scriptRef.log("Executed HTTPWorm.exe virus on " + server.hostname + " to open HTTP port (25)");
server.httpPortOpen = true;
++server.openPortCount;
} else {
workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
}
return Promise.resolve(true);
}, 25 * 1000);
}
function netscriptRunSqlinjectProgram(exp, workerScript, server) {
var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);}
setTimeout(function() {
if (!server.sqlPortOpen) {
workerScript.scriptRef.log("Executed SQLInject.exe virus on " + server.hostname + " to open SQL port (1433)");
server.sqlPortOpen = true;
++server.openPortCount;
} else {
workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
}
return Promise.resolve(true);
}, 30 * 1000);
}