2017-08-30 19:44:29 +02:00
|
|
|
import {Programs} from "./CreateProgram.js";
|
|
|
|
import {Player} from "./Player.js";
|
|
|
|
import {SpecialServerIps} from "./SpecialServerIps.js";
|
|
|
|
import {post} from "./Terminal.js";
|
|
|
|
|
|
|
|
import {formatNumber} from "../utils/StringHelperFunctions.js";
|
|
|
|
|
|
|
|
|
2017-04-14 19:20:57 +02:00
|
|
|
/* DarkWeb.js */
|
2017-05-05 17:50:55 +02:00
|
|
|
//Posts a "help" message if connected to DarkWeb
|
2017-08-30 19:44:29 +02:00
|
|
|
function checkIfConnectedToDarkweb() {
|
2017-05-05 17:50:55 +02:00
|
|
|
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
|
|
|
var darkwebIp = SpecialServerIps["Darkweb Server"];
|
2017-05-05 18:52:48 +02:00
|
|
|
if (!isValidIPAddress(darkwebIp)) {return;}
|
2017-05-05 17:50:55 +02:00
|
|
|
if (darkwebIp == Player.getCurrentServer().ip) {
|
|
|
|
post("You are now connected to the dark web. From the dark web you can purchase illegal items. " +
|
2017-07-27 04:56:14 +02:00
|
|
|
"Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
|
2017-05-05 17:50:55 +02:00
|
|
|
"to purchase an item");
|
|
|
|
}
|
|
|
|
}
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Handler for dark web commands. The terminal's executeCommand() function will pass
|
|
|
|
//dark web-specific commands into this. It will pass in the raw split command array
|
|
|
|
//rather than the command string
|
2017-08-30 19:44:29 +02:00
|
|
|
function executeDarkwebTerminalCommand(commandArray) {
|
2017-05-05 17:50:55 +02:00
|
|
|
if (commandArray.length == 0) {return;}
|
|
|
|
switch (commandArray[0]) {
|
|
|
|
case "buy":
|
|
|
|
if (commandArray.length != 2) {
|
|
|
|
post("Incorrect number of arguments. Usage: ");
|
|
|
|
post("buy -l");
|
|
|
|
post("buy [item name]");
|
2017-09-01 04:21:13 +02:00
|
|
|
return;
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
var arg = commandArray[1];
|
|
|
|
if (arg == "-l") {
|
|
|
|
listAllDarkwebItems();
|
|
|
|
} else {
|
|
|
|
buyDarkwebItem(arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
post("Command not found");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function listAllDarkwebItems() {
|
2017-05-05 17:50:55 +02:00
|
|
|
for (var item in DarkWebItems) {
|
|
|
|
if (DarkWebItems.hasOwnProperty(item)) {
|
2017-07-27 04:56:14 +02:00
|
|
|
var item = DarkWebItems[item];
|
|
|
|
//Convert string using toLocaleString
|
|
|
|
var split = item.split(" - ");
|
|
|
|
if (split.length == 3 && split[1].charAt(0) == '$') {
|
|
|
|
split[1] = split[1].slice(1);
|
|
|
|
split[1] = split[1].replace(/,/g, '');
|
|
|
|
var price = parseFloat(split[1]);
|
|
|
|
if (isNaN(price)) {
|
|
|
|
post(item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
price = formatNumber(price, 0);
|
|
|
|
split[1] = "$" + price.toString();
|
|
|
|
post(split.join(" - "));
|
|
|
|
} else {
|
|
|
|
post(item);
|
|
|
|
}
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
}
|
2017-07-27 04:56:14 +02:00
|
|
|
|
|
|
|
var priceString = split[1];
|
|
|
|
//Check for errors
|
|
|
|
if (priceString.length == 0 || priceString.charAt(0) != '$') {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
//Remove dollar sign and commas
|
|
|
|
priceString = priceString.slice(1);
|
|
|
|
priceString = priceString.replace(/,/g, '');
|
|
|
|
|
|
|
|
//Convert string to numeric
|
|
|
|
var price = parseFloat(priceString);
|
|
|
|
if (isNaN(price)) {return -1;}
|
|
|
|
else {return price;}
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function buyDarkwebItem(itemName) {
|
2017-06-08 01:35:56 +02:00
|
|
|
if (itemName.toLowerCase() == Programs.BruteSSHProgram.toLowerCase()) {
|
2017-05-05 17:50:55 +02:00
|
|
|
var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram);
|
2017-07-29 18:25:40 +02:00
|
|
|
if (price > 0 && Player.money.gt(price)) {
|
2017-05-05 17:50:55 +02:00
|
|
|
Player.loseMoney(price);
|
|
|
|
Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);
|
2017-07-27 04:56:14 +02:00
|
|
|
post("You have purchased the BruteSSH.exe program. The new program " +
|
2017-05-05 17:50:55 +02:00
|
|
|
"can be found on your home computer.");
|
|
|
|
} else {
|
|
|
|
post("Not enough money to purchase " + itemName);
|
|
|
|
}
|
2017-06-08 01:35:56 +02:00
|
|
|
} else if (itemName.toLowerCase() == Programs.FTPCrackProgram.toLowerCase()) {
|
2017-05-05 17:50:55 +02:00
|
|
|
var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram);
|
2017-07-29 18:25:40 +02:00
|
|
|
if (price > 0 && Player.money.gt(price)) {
|
2017-05-05 17:50:55 +02:00
|
|
|
Player.loseMoney(price);
|
|
|
|
Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);
|
2017-07-27 04:56:14 +02:00
|
|
|
post("You have purchased the FTPCrack.exe program. The new program " +
|
2017-05-05 17:50:55 +02:00
|
|
|
"can be found on your home computer.");
|
|
|
|
} else {
|
|
|
|
post("Not enough money to purchase " + itemName);
|
|
|
|
}
|
2017-06-08 01:35:56 +02:00
|
|
|
} else if (itemName.toLowerCase() == Programs.RelaySMTPProgram.toLowerCase()) {
|
2017-05-05 17:50:55 +02:00
|
|
|
var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram);
|
2017-07-29 18:25:40 +02:00
|
|
|
if (price > 0 && Player.money.gt(price)) {
|
2017-05-05 17:50:55 +02:00
|
|
|
Player.loseMoney(price);
|
|
|
|
Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);
|
2017-07-27 04:56:14 +02:00
|
|
|
post("You have purchased the relaySMTP.exe program. The new program " +
|
2017-05-05 17:50:55 +02:00
|
|
|
"can be found on your home computer.");
|
|
|
|
} else {
|
|
|
|
post("Not enough money to purchase " + itemName);
|
|
|
|
}
|
2017-06-08 01:35:56 +02:00
|
|
|
} else if (itemName.toLowerCase() == Programs.HTTPWormProgram.toLowerCase()) {
|
2017-05-05 17:50:55 +02:00
|
|
|
var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram);
|
2017-07-29 18:25:40 +02:00
|
|
|
if (price > 0 && Player.money.gt(price)) {
|
2017-05-05 17:50:55 +02:00
|
|
|
Player.loseMoney(price);
|
|
|
|
Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);
|
2017-07-27 04:56:14 +02:00
|
|
|
post("You have purchased the HTTPWorm.exe program. The new program " +
|
2017-05-05 17:50:55 +02:00
|
|
|
"can be found on your home computer.");
|
|
|
|
} else {
|
|
|
|
post("Not enough money to purchase " + itemName);
|
|
|
|
}
|
2017-06-08 01:35:56 +02:00
|
|
|
} else if (itemName.toLowerCase() == Programs.SQLInjectProgram.toLowerCase()) {
|
2017-05-05 17:50:55 +02:00
|
|
|
var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram);
|
2017-07-29 18:25:40 +02:00
|
|
|
if (price > 0 && Player.money.gt(price)) {
|
2017-05-05 17:50:55 +02:00
|
|
|
Player.loseMoney(price);
|
|
|
|
Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);
|
2017-07-27 04:56:14 +02:00
|
|
|
post("You have purchased the SQLInject.exe program. The new program " +
|
2017-05-05 17:50:55 +02:00
|
|
|
"can be found on your home computer.");
|
|
|
|
} else {
|
|
|
|
post("Not enough money to purchase " + itemName);
|
|
|
|
}
|
2017-06-08 01:35:56 +02:00
|
|
|
} else if (itemName.toLowerCase() == Programs.DeepscanV1.toLowerCase()) {
|
|
|
|
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program);
|
2017-07-29 18:25:40 +02:00
|
|
|
if (price > 0 && Player.money.gt(price)) {
|
2017-06-08 01:35:56 +02:00
|
|
|
Player.loseMoney(price);
|
|
|
|
Player.getHomeComputer().programs.push(Programs.DeepscanV1);
|
2017-07-27 04:56:14 +02:00
|
|
|
post("You have purchased the DeepscanV1.exe program. The new program " +
|
2017-06-08 01:35:56 +02:00
|
|
|
"can be found on your home computer.");
|
|
|
|
} else {
|
|
|
|
post("Not enough money to purchase " + itemName);
|
|
|
|
}
|
|
|
|
} else if (itemName.toLowerCase() == Programs.DeepscanV2.toLowerCase()) {
|
|
|
|
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program);
|
2017-07-29 18:25:40 +02:00
|
|
|
if (price > 0 && Player.money.gt(price)) {
|
2017-06-08 01:35:56 +02:00
|
|
|
Player.loseMoney(price);
|
|
|
|
Player.getHomeComputer().programs.push(Programs.DeepscanV2);
|
2017-07-27 04:56:14 +02:00
|
|
|
post("You have purchased the DeepscanV2.exe program. The new program " +
|
2017-06-08 01:35:56 +02:00
|
|
|
"can be found on your home computer.");
|
|
|
|
} else {
|
|
|
|
post("Not enough money to purchase " + itemName);
|
|
|
|
}
|
2017-05-05 17:50:55 +02:00
|
|
|
} else {
|
|
|
|
post("Unrecognized item");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function parseDarkwebItemPrice(itemDesc) {
|
2017-05-05 17:50:55 +02:00
|
|
|
var split = itemDesc.split(" - ");
|
|
|
|
if (split.length == 3) {
|
|
|
|
var priceString = split[1];
|
|
|
|
//Check for errors
|
|
|
|
if (priceString.length == 0 || priceString.charAt(0) != '$') {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
//Remove dollar sign and commas
|
|
|
|
priceString = priceString.slice(1);
|
|
|
|
priceString = priceString.replace(/,/g, '');
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-05-05 17:50:55 +02:00
|
|
|
//Convert string to numeric
|
|
|
|
var price = parseFloat(priceString);
|
|
|
|
if (isNaN(price)) {return -1;}
|
|
|
|
else {return price;}
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
let DarkWebItems = {
|
|
|
|
BruteSSHProgram: "BruteSSH.exe - $500,000 - Opens up SSH Ports",
|
|
|
|
FTPCrackProgram: "FTPCrack.exe - $1,500,000 - Opens up FTP Ports",
|
|
|
|
RelaySMTPProgram: "relaySMTP.exe - $5,000,000 - Opens up SMTP Ports",
|
|
|
|
HTTPWormProgram: "HTTPWorm.exe - $30,000,000 - Opens up HTTP Ports",
|
|
|
|
SQLInjectProgram: "SQLInject.exe - $250,000,000 - Opens up SQL Ports",
|
|
|
|
DeepScanV1Program: "DeepscanV1.exe - $500,000 - Enables 'scan-analyze' with a depth up to 5",
|
|
|
|
DeepScanV2Program: "DeepscanV2.exe - $25,000,000 - Enables 'scan-analyze' with a depth up to 10",
|
2017-07-27 04:56:14 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
export {checkIfConnectedToDarkweb, executeDarkwebTerminalCommand,
|
|
|
|
listAllDarkwebItems, buyDarkwebItem, parseDarkwebItemPrice,
|
|
|
|
DarkWebItems};
|