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";
|
|
|
|
|
2017-09-03 19:44:20 +02:00
|
|
|
import {isValidIPAddress} from "../utils/IPAddress.js";
|
2018-06-22 23:30:24 +02:00
|
|
|
import {formatNumber} from "../utils/StringHelperFunctions";
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//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() {
|
2018-06-01 23:05:05 +02:00
|
|
|
for(const key in DarkWebItems) {
|
|
|
|
const item = DarkWebItems[key];
|
|
|
|
post(item.toString());
|
2017-07-27 04:56:14 +02:00
|
|
|
}
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function buyDarkwebItem(itemName) {
|
2018-06-01 23:05:05 +02:00
|
|
|
itemName = itemName.toLowerCase();
|
|
|
|
|
|
|
|
// find the program that matches, if any
|
|
|
|
let item = null;
|
|
|
|
for(const key in DarkWebItems) {
|
|
|
|
const i = DarkWebItems[key];
|
|
|
|
if(i.program.toLowerCase() == itemName) {
|
|
|
|
item = i;
|
2017-06-08 01:35:56 +02:00
|
|
|
}
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
2018-06-01 23:05:05 +02:00
|
|
|
// return if invalid
|
|
|
|
if(item === null) {
|
|
|
|
post("Unrecognized item: "+itemName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return if the player already has it.
|
|
|
|
if(Player.hasProgram(item.program)) {
|
|
|
|
post('You already have the '+item.program+' program');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return if the player doesn't have enough money
|
|
|
|
if(Player.money.lt(item.price)) {
|
|
|
|
post("Not enough money to purchase " + item.program);
|
|
|
|
return;
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
2018-06-01 23:05:05 +02:00
|
|
|
|
|
|
|
// buy and push
|
|
|
|
Player.loseMoney(item.price);
|
|
|
|
Player.getHomeComputer().programs.push(item.program);
|
|
|
|
post('You have purchased the '+item.program+' program. The new program can be found on your home computer.');
|
|
|
|
}
|
|
|
|
|
|
|
|
function DarkWebItem(program, price, description) {
|
|
|
|
this.program = program;
|
|
|
|
this.price = price;
|
|
|
|
this.description = description;
|
2017-05-05 17:50:55 +02:00
|
|
|
}
|
|
|
|
|
2018-06-01 23:05:05 +02:00
|
|
|
// formats the item for the terminal (eg. "BruteSSH.exe - $500,000 - Opens up SSH Ports")
|
|
|
|
DarkWebItem.prototype.toString = function() {
|
|
|
|
return [this.program, "$"+formatNumber(this.price), this.description].join(' - ');
|
2017-07-27 04:56:14 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2018-06-01 23:05:05 +02:00
|
|
|
const DarkWebItems = {
|
2018-06-26 16:49:28 +02:00
|
|
|
BruteSSHProgram: new DarkWebItem(Programs.BruteSSHProgram.name, 500000, "Opens up SSH Ports"),
|
|
|
|
FTPCrackProgram: new DarkWebItem(Programs.FTPCrackProgram.name, 1500000, "Opens up FTP Ports"),
|
|
|
|
RelaySMTPProgram: new DarkWebItem(Programs.RelaySMTPProgram.name, 5000000, "Opens up SMTP Ports"),
|
|
|
|
HTTPWormProgram: new DarkWebItem(Programs.HTTPWormProgram.name, 30000000, "Opens up HTTP Ports"),
|
|
|
|
SQLInjectProgram: new DarkWebItem(Programs.SQLInjectProgram.name, 250000000, "Opens up SQL Ports"),
|
|
|
|
DeepscanV1: new DarkWebItem(Programs.DeepscanV1.name, 500000, "Enables 'scan-analyze' with a depth up to 5"),
|
|
|
|
DeepscanV2: new DarkWebItem(Programs.DeepscanV2.name, 25000000, "Enables 'scan-analyze' with a depth up to 10"),
|
|
|
|
AutolinkProgram: new DarkWebItem(Programs.AutoLink.name, 1000000, "Enables direct connect via 'scan-analyze'"),
|
2018-06-01 23:05:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export {checkIfConnectedToDarkweb, executeDarkwebTerminalCommand, DarkWebItems};
|