From 84eb2955277634d1af01cdc0c1ca91f8f66b2c3e Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Wed, 24 May 2017 16:35:24 -0500 Subject: [PATCH] Added functionality to create Deepscan programs. Untested --- index.html | 10 +++++++++ src/CreateProgram.js | 37 ++++++++++++++++++++++++++------ src/Terminal.js | 50 ++++++++++++++++++++++---------------------- src/engine.js | 17 +++++++++++++++ 4 files changed, 83 insertions(+), 31 deletions(-) diff --git a/index.html b/index.html index ad77e36cd..21705c4fa 100644 --- a/index.html +++ b/index.html @@ -430,6 +430,16 @@ SQLInject.exe This virus opens SQL ports + + + DeepscanV1.exe + This program allows you to use the scan-analyze command with a depth up to 5 + + + + DeepscanV2.exe + This program allows you to use the scan-analyze command with a depth up to 10 + diff --git a/src/CreateProgram.js b/src/CreateProgram.js index c00012040..141cc5317 100644 --- a/src/CreateProgram.js +++ b/src/CreateProgram.js @@ -1,11 +1,13 @@ /* Create programs */ Programs = { - NukeProgram: "NUKE.exe", - BruteSSHProgram: "BruteSSH.exe", - FTPCrackProgram: "FTPCrack.exe", - RelaySMTPProgram: "relaySMTP.exe", - HTTPWormProgram: "HTTPWorm.exe", - SQLInjectProgram: "SQLInject.exe", + NukeProgram: "NUKE.exe", + BruteSSHProgram: "BruteSSH.exe", + FTPCrackProgram: "FTPCrack.exe", + RelaySMTPProgram: "relaySMTP.exe", + HTTPWormProgram: "HTTPWorm.exe", + SQLInjectProgram: "SQLInject.exe", + DeepscanV1: "DeepscanV1.exe", + DeepscanV2: "DeepscanV2.exe", } //TODO Right now the times needed to complete work are hard-coded... @@ -17,6 +19,8 @@ function displayCreateProgramContent() { var relaySmtpALink = document.getElementById("create-program-relaysmtp"); var httpWormALink = document.getElementById("create-program-httpworm"); var sqlInjectALink = document.getElementById("create-program-sqlinject"); + var deepscanv1ALink = document.getElementById("create-program-deepscanv1"); + var deepscanv2ALink = document.getElementById("create-program-deepscanv2"); nukeALink.style.display = "none"; bruteSshALink.style.display = "none"; @@ -24,6 +28,8 @@ function displayCreateProgramContent() { relaySmtpALink.style.display = "none"; httpWormALink.style.display = "none"; sqlInjectALink.style.display = "none"; + deepscanv1ALink.style.display = "none"; + deepscanv2ALink.style.display = "none"; //NUKE.exe (in case you delete it lol) if (Player.getHomeComputer().programs.indexOf(Programs.NukeProgram) == -1) { @@ -59,6 +65,15 @@ function displayCreateProgramContent() { Player.hacking_skill >= 750) { sqlInjectALink.style.display = "inline-block"; } + + //Deepscan V1 and V2 + if (!Player.hasProgram(Programs.DeepscanV1) && Player.hacking_skill >= 75) { + deepscanv1ALink.style.display = "inline-block"; + } + + if (!Player.hasProgram(Programs.DeepscanV2) && Player.hacking_skill >= 400) { + deepscanv2ALink.style.display = "inline-block"; + } } //Returns the number of programs that are currently available to be created @@ -99,5 +114,15 @@ function getNumAvailableCreateProgram() { Player.hacking_skill >= 750) { ++count; } + + //Deepscan V1 and V2 + if (!Player.hasProgram(Programs.DeepscanV1) && Player.hacking_skill >= 75) { + ++count; + } + + if (!Player.hasProgram(Programs.DeepscanV2) && Player.hacking_skill >= 400) { + ++count; + } + return count; } \ No newline at end of file diff --git a/src/Terminal.js b/src/Terminal.js index c4877b55f..5fca816a2 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -728,8 +728,19 @@ var Terminal = { Terminal.executeScanAnalyzeCommand(1); } else if (commandArray.length == 2) { var depth = Number(commandArray[1]); - if (isNaN(depth)) { - post("Incorrect usage of scan-analyze command. depth argument must be numeric"); + if (isNaN(depth) || depth < 0) { + post("Incorrect usage of scan-analyze command. depth argument must be positive numeric"); + return; + } + if (depth > 3 && !Player.hasProgram(Programs.DeepscanV1) && + !Player.hasProgram(Programs.DeepscanV2)) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 3"); + return; + } else if (depth > 5 && !Player.hasProgram(Programs.DeepscanV2)) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 5"); + return; + } else if (depth > 10) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 10"); return; } Terminal.executeScanAnalyzeCommand(depth); @@ -844,6 +855,9 @@ var Terminal = { //We'll use the AllServersToMoneyMap as a visited() array //TODO Later refactor this to a generic name //TODO Using array as stack for now, can make more efficient + post("~~~~~~~~~~ Beginning scan-analyze ~~~~~~~~~~"); + post(" "); + post(" "); var visited = new AllServersToMoneyMap(); var stack = []; var depthQueue = [0]; @@ -862,31 +876,17 @@ var Terminal = { depthQueue.push(d+1); } if (d == 0) {continue;} //Don't print current server - var titleNumDashes = Array((d-1) * 2 + 1).join("-"); - post("" + titleNumDashes + s.hostname + ""); - var numDashes = Array(d * 2 + 1).join("-"); - var c = "N"; - if (s.hasAdminRights) {c = "Y";} - post(numDashes + "Root Access: " + c); - post(numDashes + "Required hacking skill: " + s.requiredHackingSkill); - post(numDashes + "Number of open ports required to NUKE: " + s.numOpenPortsRequired); - post(numDashes + "RAM: " + s.maxRam); - } - /* - var currServ = Player.getCurrentServer(); - for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { - var serv = currServ.getServerOnNetwork(i); - if (serv == null) {continue;} - post("" + serv.hostname + ""); - var c = "N"; - if (serv.hasAdminRights) {c = "Y";} - post("--Root Access: " + c); - post("--Required hacking skill: " + serv.requiredHackingSkill); - post("--Number of open ports required to NUKE: " + serv.numOpenPortsRequired); - post("--RAM: " + serv.maxRam); + var titleDashes = Array((d-1) * 4 + 1).join("-"); + post("" + titleDashes + ">" + s.hostname + ""); + var dashes = titleDashes + "--"; + //var dashes = Array(d * 2 + 1).join("-"); + var c = "NO"; + if (s.hasAdminRights) {c = "YES";} + post(dashes + "Root Access: " + c + ", Required hacking skill: " + s.requiredHackingSkill); + post(dashes + "Number of open ports required to NUKE: " + s.numOpenPortsRequired); + post(dashes + "RAM: " + s.maxRam); post(" "); } - */ }, executeFreeCommand: function(commandArray) { diff --git a/src/engine.js b/src/engine.js index 8b3aa1e92..bb9289b6b 100644 --- a/src/engine.js +++ b/src/engine.js @@ -1005,23 +1005,40 @@ var Engine = { var relaySmtpALink = document.getElementById("create-program-relaysmtp"); var httpWormALink = document.getElementById("create-program-httpworm"); var sqlInjectALink = document.getElementById("create-program-sqlinject"); + var deepscanv1ALink = document.getElementById("create-program-deepscanv1"); + var deepscanv2ALink = document.getElementById("create-program-deepscanv2"); + nukeALink.addEventListener("click", function() { Player.startCreateProgramWork(Programs.NukeProgram, CONSTANTS.MillisecondsPerFiveMinutes, 1); + return false; }); bruteSshALink.addEventListener("click", function() { Player.startCreateProgramWork(Programs.BruteSSHProgram, CONSTANTS.MillisecondsPerFiveMinutes * 2, 50); + return false; }); ftpCrackALink.addEventListener("click", function() { Player.startCreateProgramWork(Programs.FTPCrackProgram, CONSTANTS.MillisecondsPerHalfHour, 100); + return false; }); relaySmtpALink.addEventListener("click", function() { Player.startCreateProgramWork(Programs.RelaySMTPProgram. CONSTANTS.MillisecondsPer2Hours, 250); + return false; }); httpWormALink.addEventListener("click", function() { Player.startCreateProgramWork(Programs.HTTPWormProgram, CONSTANTS.MillisecondsPer4Hours, 500); + return false; }); sqlInjectALink.addEventListener("click", function() { Player.startCreateProgramWork(Programs.SQLInjectProgram, CONSTANTS.MillisecondsPer8Hours, 750); + return false; + }); + deepscanv1ALink.addEventListener("click", function() { + Player.startCreateProgramWork(Programs.DeepscanV1, CONSTANTS.MillisecondsPerQuarterHour, 75); + return false; + }); + deepscanv2ALink.addEventListener("click", function() { + Player.startCreateProgramWork(Programs.DeepscanV2, CONSTANTS.MillisecondsPer2Hours, 400); + return false; }); //Message at the top of terminal