CVE-2017-1000443 (published 2018-01-02T14:29Z)

Eleix Openhacker version 0.1.47 is vulnerable to a XSS vulnerability in the bank transactions component resulting in arbitrary code execution in the browser.

Severity: MEDIUM
CVSS v2 base score: 4.3 (AV:N/AC:M/Au:N/C:N/I:P/A:N)
CVSS v3 base score: 6.1, MEDIUM (CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/Eleix/openhacker
commit_details: repo_url: https://github.com/Eleix/openhacker
author: Francis Booth
author_date: 2017-09-20 07:16:04-04:00
msg: Security Update 092017

conf/global.php -
          Increment version +1

cron/watchdog.php -
          Remove linking transaction ID's. With clan bank transfers (Hacker 2 Clan or Clan 2 Hacker) the original logic no longer works as there is now two seperate database and ID' are not one after (or below) the other.

game/guest/lgin.htm - 
           Added validation for IP addresses (see game/guest/reg.htm)

game/guest/rebuild.htm
          Alert that the site is down but link off to the bugtracking page on GitHub

game/guest/reg.htm -
           Added ip validation
           Use POST over REQUEST for username, password, and email checks.
            Added username validation and sanitation
            Fixed a known bug that if the user didn't create a bank account first then they did not recieve any money for small jobs done before visiting the bank page for the first time. (Bank registration was an unnecessary complication and should already be handled on account registration.)
               Fixes #4 (lgin.htm too)

game/main/user/bank.htm -
          Added a missing end tag for the Send Cash form.

game/main/user/banksend.htm -
          Added sanitation on extra details message for bank transactions
          Added validation to sent amount
          Added logic to send money from Hacker to Clan
          Fixes #5

game/main/user/clanbank.htm -
          Phased out old button
          Added the radio toggle between Hacker or Clan

game/main/clanbankin.htm -
          Sanitized clan password input 
          Fixes #6

game/main/user/clanbanksend.htm -
          Added sanitation on extra details message for bank transactions
          Added validation to sent amount
          Removed sameid limitation for C 2 H transactions
          Added display for C 2 C coming soon

game/main/user/clanroster.htm - 
          Added logic for clan member status (regular member or council member)

game/main/user/updateacc.htm -
         Added sanitization to bio. Utilized htmlpurifier to allow for minimal html to be added (user can format their bios)
         Note: htmlpurifier sits outside web root (SEE index.php)
         Fixed old redirect location url

index.php -
         Added additional header modification cases
         Require the HTMLPurifier (Seperate download not contained in this repository)

layout/guest/header.htm -
           Removed old starting html logic (no longer needed and handled inside index.php

layout/main/footer.htm -
           Formatting issue

layout/main/header.htm -
           Changed Cryptocurrenty to Crypto-Market (Planned feature)
repository: repo_url: https://github.com/Eleix/openhacker
repo_name: visit repo url
description: visit repo url
repo_language: visit repo url
owner: Eleix
file_changes: filename: global.php
change_type: ModificationType.MODIFY
diff: @@ -7,7 +7,7 @@ WARNING EDITING THIS DOCUMENT WITHOUT UNDERSTANDING WHAT EACH OPTION DOES CAN HA
 Each option allows for the manipulation of global values. These affect the game engine and should be tested prior to pushing to production.
 */
 
-$GAMEVERSION = "0.1.47"; // Game version
+$GAMEVERSION = "0.1.48"; // Game version
 $MAXEPCOUNT = 64000; // Max Experience allowed
 $MEP4LVL = 640; // Max experience per level
 

programming_language: PowerShell
filename: watchdog.php
change_type: ModificationType.MODIFY
diff: @@ -22,12 +22,6 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 				$senderid = $row['userid'];
 				$recieverid = $row['recvid'];
 				$amount = $row['amount'];
-				if($transactionid % 2 == 0){
-					$linkedtransid = $transactionid -1;
-				}
-				else {
-					$linkedtransid = $transactionid +1 ;
-				};
 				
 				$checkUserIp = "SELECT regip FROM accounts WHERE id = '$senderid' limit 1";
 				$chkipResult = $conn->query($checkUserIp);
@@ -46,25 +40,19 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 				if($senderid == $recieverid && $amount < 0 && $account1ip == $account2ip){
 					// Known bank transfer logic (A negative transaction charge is sent to the user to subtract out the dollar amount from their account.)
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);
 
 				};
 				if($senderid == $recieverid && $amount > 0 && $account1ip == $account2ip){
 					// Known bank transfer logic (Post the new balance to the user as if they deposited the money themselves.)
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);
 
 				};
 				if($senderid != $recieverid && $amount < 0 && $account1ip == $account2ip){
 					// ACCOUNT CAUGHT | User has created another account and sent the funds to alt account
 					$WD_DNY = "UPDATE bank_transactions SET watchdog_approve = '0', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_DNY);
-					$result = $conn->query($WD_LNK_TRNS);
 					
 					$sqlsearchuname = "SELECT username FROM accounts WHERE id = '$senderid' limit 1";
 					$result22 = $conn->query($sqlsearchuname);
@@ -77,9 +65,7 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 				if($senderid != $recieverid && $amount > 0 && $account1ip == $account2ip){
 					// ACCOUNT CAUGHT | User has created another account and sent the funds to alt account
 					$WD_DNY = "UPDATE bank_transactions SET watchdog_approve = '0' AND wd_scanned = '1' WHERE id = '$transactionid";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_DNY);
-					$result = $conn->query($WD_LNK_TRNS);
 					
 					$sqlsearchuname = "SELECT username FROM accounts WHERE id = '$senderid' limit 1";
 					$result22 = $conn->query($sqlsearchuname);
@@ -92,21 +78,15 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 				if($senderid != $recieverid && $amount > 0 && $account1ip != $account2ip){
 					// Known bank transfer logic ( Legit Transfer )
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
-					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);					
+					$result = $conn->query($WD_APP);				
 				};
 				if($senderid == $recieverid && $amount > 0 && $account1ip != $account2ip){
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
-					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);		
+					$result = $conn->query($WD_APP);		
 				};
 				if($senderid != $recieverid && $amount < 0 && $account1ip != $account2ip){
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);
 				};
 			}		
 		}

programming_language: PHP
filename: lgin.htm
change_type: ModificationType.MODIFY
diff: @@ -3,6 +3,9 @@
 if (empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
 	if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
+		// Check if IP is valid
+		if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+		else{$ip = $_SERVER['REMOTE_ADDR'];};		
 	}
 	else{
 	$ip = $_SERVER['REMOTE_ADDR'];
@@ -10,6 +13,9 @@ if (empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
 }
 else {
 	$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
+	// Check if IP is valid
+	if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+	else{$ip = $_SERVER['REMOTE_ADDR'];};	
 };
 
 $error=''; // Variable To Store Error Message

programming_language: PHP
filename: rebuild.htm
change_type: ModificationType.MODIFY
diff: @@ -1,17 +1,9 @@
 <div id='content'>
 <h2>Site Offline</h2>
 
-<h4>LiteCity is currently offline for maintenance </h4>
-
-<h5>Whats to come</h5>
-
-<ul>
-
-	<li>Anti-cheat system</li>
-	<li>Live Events</li>
-	<li>CLI game program</li>
-	<li>Redesigned UI</li>
-	<li>... and much more</li>
+<h4>HackerCity is currently offline for maintenance </h4>
 
+<p>Keep up to date on the latest bugs on our Github!</p>
+<a style="font-size:20px;color:cyan;" href="https://github.com/Eleix/openhacker/issues">HackerCity Github Issues Page</a>
 </ul>
-</div>
\ No newline at end of file
+</div>

programming_language: HTML
filename: reg.htm
change_type: ModificationType.MODIFY
diff: @@ -8,6 +8,9 @@ else {
 if (empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
 	if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
+		// Check if IP is valid
+		if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+		else{$ip = $_SERVER['REMOTE_ADDR'];};		
 	}
 	else{
 	$ip = $_SERVER['REMOTE_ADDR'];
@@ -15,7 +18,11 @@ if (empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
 }
 else {
 	$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
+	// Check if IP is valid
+	if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+	else{$ip = $_SERVER['REMOTE_ADDR'];};	
 };
+
 $salt = substr(str_replace('+','.',base64_encode(md5(mt_rand(), true))),0,16);
 $rounds = 10000;
 $encpass = crypt($_POST['password'], sprintf('$6$rounds=%d$%s$', $rounds, $salt));
@@ -52,23 +59,30 @@ if ($_POST["g-recaptcha-response"]) {
 
 if ($response != null && $response->success) {
 
-
 //if submit is not blanked i.e. it is clicked.
 if(isset($_REQUEST['submit'])!='')
 {
-if($_REQUEST['username']=='' || $_REQUEST['email']=='' || $_REQUEST['password']=='')
+if($_POST['username']=='' || $_POST['email']=='' || $_POST['password']=='')
 {
 echo "please fill the empty field.";
 }
 else
 {
-$sql = "INSERT INTO accounts(username,email,password,regip,reghash) VALUES('".$_REQUEST['username']."', '".$_REQUEST['email']."', '$encpass', '$ip', '$reghash')";
+
+// Validate and Sanitize Username
+
+$username = $_POST['username'];
+$safeusername = (filter_var($username, FILTER_SANITIZE_STRING));
+if(@preg_match(''/^[a-zA-Z0-9]{3,}$/', $safeusername)) { // invalid username
+	echo "Your username is not allowed. Allowed values are a-z, A-Z, 0-9 and must be at least 3 characters";
+}
+else { // valid username
+
+$sql = "INSERT INTO accounts(username,email,password,regip,reghash) VALUES('$safeusername', '$email', '$encpass', '$ip', '$reghash')";
 $result = $conn->query($sql);
 if($result)
 {
 
-$username = $_POST['username'];
-
 $to      = $email; // Send email to our user
 $subject = "Hacker City Signup | Verification"; // Give the email a subject 
 $message = "
@@ -79,7 +93,7 @@ Your account has been created and the final step is to activate your account.
 We use activation emails as a way to prevent bots and trouble users from abusing the system and flooding the site with fake users.
  
 ------------------------
-Username: $username
+Username: $safeusername
 Password: Not sent via email for security 
 ------------------------
  
@@ -91,9 +105,7 @@ https://boothlabs.me/verify.php?email=$email&reghash=$reghash
 $headers = 'From:noreply@boothlabs.me' . "\r\n"; // Set from headers
 mail($to, $subject, $message, $headers); // Send our email
 
-$username = $_REQUEST['username'];
-
-$sql9 = "SELECT id FROM accounts WHERE username = '$username';";
+$sql9 = "SELECT id FROM accounts WHERE username = '$safeusername';";
 $result9 = $conn->query($sql9);
 while ($row9 = $result9->fetch_assoc()){
 $userid = $row9['id'];
@@ -102,6 +114,11 @@ $userid = $row9['id'];
 $sql10 = "INSERT INTO `usersystems` (`userid`, `cpu`, `motherboard`, `ram`, `os`, `hddtype`, `hddhealth`, `size`, `spaceused`, `spacefree`, `logs`, `securitypack`, `firewall`, `sphealth`, `firewallhealth`, `connectedto`, `connectiontype`, `ipaddress`, `gatewayip`, `gatewaystatus`, `systemstatus`) VALUES ('$userid', '486', 'Simple Motherboard', '256MB', 'DOS', '10GB', '100', '10GB', '0', '10', 'Not Installed', 'Not Installed', 'Not Installed', '0', '0', 'n00bnet', 'Loopback', '127.0.0.1', '', 'Offline', 'online');";
 $result10 = $conn->query($sql10);
 
+// Create bank account
+
+$sql11 = "INSERT INTO 'economy' ('userid') VALUES ('$userid');"
+$result11 = $conn->query($sql11);
+
 echo "Account Created Successfully, Check your email for instructions on activating your account .";
 }
 else {
@@ -109,7 +126,7 @@ echo "There is some problem creating your account, please contact an administrat
 echo "<br>";
 echo $sql;
 };
-}
+};
 }
 }
 else {

programming_language: PHP
filename: bank.htm
change_type: ModificationType.MODIFY
diff: @@ -63,6 +63,7 @@ if (isset($_SESSION['bank_login'])){
     echo "<br>";
 
 	echo "<button class='btn waves-effect waves-light' type='submit' name='action'>Send Cash<i class='material-icons center'></i></button>";
+	echo "</form>";
 
 	echo "<br>";
 	echo "<br>";

programming_language: PHP
filename: banksend.htm
change_type: ModificationType.MODIFY
diff: @@ -6,14 +6,30 @@ $SendUser=$userid;
 $SendUserName = $_SESSION['login_user'];
 $RecUser=$_POST['recvusername'];
 $type=$_POST['type'];
+$amount = $_POST['amount'];
+$details = $_POST['details'];
+
+//Sanitize details input
+
+$safedetails = (filter_var($details, FILTER_SANITIZE_STRING));
+
+if($amount < 0 ){ 
+	echo "Amount sent cannot be a negative number.";
+	echo "<br>";
+	echo "Transaction cancelled";
+
+echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+}
+else{
 
 if($type == 'hacker'){
 
 $details = "sent by $SendUserName reason: ";
-$details .= $_POST['details']; 
+$details .= $safedetails; 
 $details2 = "sent to $RecUser reason: ";
-$details2 .= $_POST['details'];
-$amount = $_POST['amount'];
+$details2 .= $safedetails;
+
+	
 $amountnegative = $amount * -1;
 
 //Check to see if RecUser has an account with the bank
@@ -96,9 +112,92 @@ else {
 };
 }
 else{ //type is clan
-echo "Money Transfers to clan banks are unavailable at this time";
+
+$clanname = $RecUser; //Used in the error message
+
+// Convert clan name to ID
+$sqlConv2ID = "SELECT id FROM clans WHERE clanname = '$RecUser'";
+$resultConv2ID = $conn->query($sqlConv2ID);
+while($rowConvID = $resultConv2ID->fetch_assoc()){
+  $RecUser = $rowConvID['id'];
 };
 
+$details = "sent by $SendUserName reason: ";
+$details .= $safedetails; 
+$details2 = "sent to $clanname reason: ";
+$details2 .= $safedetails;
+$amount = $_POST['amount'];
+$amountnegative = $amount * -1;
+
+//Check to see if RecUser has an account with the bank
+
+$sql = "SELECT clanid FROM claneconomy WHERE clanid = '$RecUser'";
+$result = $conn->query($sql);
+
+while($row = $result->fetch_assoc()){
+$recvuser = $row['clanid']; // Clan ID return
+};
+
+$sql = "SELECT clanid FROM claneconomy WHERE clanid = '$recvuser'";
+$result = $conn->query($sql);
+
+if ($result->num_rows > 0) {
+
+$sql = "SELECT cash FROM economy WHERE userid = '$SendUser'";
+$result = $conn->query($sql);
+
+while($row = $result->fetch_assoc()){
+$oldBal = $row['cash'];
+}
+
+$newBalUs1 = $oldBal - $amount;
+
+if ($newBalUs1 < 0)
+{
+   echo "<h1>Transaction Failed</h1>";
+   echo "<br>";
+   echo "You can't send more money than you actually have.";
+   echo "<br>";
+   echo "<br>";
+   echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+} else {
+
+$sql = "SELECT cash FROM claneconomy WHERE clanid = '$recvuser'";  //fetch the recieving clan's current bank balance
+$result = $conn->query($sql);
+
+while($row = $result->fetch_assoc()){
+$oldBalUs2 = $row['cash'];   // export the returned value to a variable
+}
+
+$newBalUs2 = $oldBalUs2 + $amount;
+
+$sql = "UPDATE claneconomy SET cash='$newBalUs2' WHERE clanid = '$recvuser'";
+$result = $conn->query($sql);
+
+$sql = "UPDATE economy SET cash='$newBalUs1' WHERE userid= '$SendUser'";
+$result = $conn->query($sql);
+
+$sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
+$result = $conn->query($sql);
+
+$sql = "INSERT INTO clanbank_transactions(clanid,clanrecvid,details,amount,transactionuserid) VALUES('$recvuser', '$recvuser', '$details', '$amount', '$SendUserName')";
+$result = $conn->query($sql);
+
+   echo "Transaction Complete";
+   echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+
+}
+} 
+else {
+	echo "<h1>Transaction Failed</h1>";
+	echo "<br>";
+	echo "<p>We are sorry. Our database failed to find the clan "; echo $clanname; echo " in our banking database.</p>";
+	echo "<p>Your previous transaction has been canceled.</p>";
+	echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+
+};
+};
+};
 
 ?>
-</div>
\ No newline at end of file
+</div>

programming_language: PHP
filename: clanbank.htm
change_type: ModificationType.MODIFY
diff: @@ -21,7 +21,7 @@ if(!isset($_SESSION['clanbank_login'])){
 		echo "<br>";
 		echo 'Password:  <input type="password" name="password" value=""><br>';
 		echo "<br>";
-		echo '<input style="width:70px;" type="submit" name="submit" value="Login">';
+		echo "<button class='btn waves-effect waves-light' type='submit' name='submit'>Login<i class='material-icons center'></i></button>";
 		echo "<br>";
 		echo "<br>";
 		echo "</form>";
@@ -62,9 +62,19 @@ $resultGetName = $conn->query($sqlGetName);
 	echo "<br>";
 	echo "Details:"; echo '<input type="text" name="details" value="">';
 	echo "<br>";
+
+    echo "<input type='radio' value='hacker' id='hacker' name='type'>";
+    echo "<label for='hacker'>Hacker</label>";
+    echo "<div class='check'><div class='inside'></div></div>";
+
+    echo "<input type='radio' value='clan' id='clan' name='type'>";
+    echo "<label for='clan'>Clan</label>";   
+    echo "<div class='check'><div class='inside'></div></div>";
+
     echo "<br>";
 
 	echo "<button class='btn waves-effect waves-light' type='submit' name='action'>Send Cash<i class='material-icons center'></i></button>";
+	echo "</form>";
 
 	echo "<br>";
 	echo "<br>";

programming_language: PHP
filename: clanbankin.htm
change_type: ModificationType.MODIFY
diff: @@ -21,8 +21,9 @@ $result = $conn->query($sql);
 // Set Clan bank password
 
 $password = $_POST['password'];
+$safepassword = mysqli_real_escape_string($conn, $password);
 
-$sqlSetCBP = "UPDATE clans SET bankpassword = '$password' WHERE id = '$clanid'";
+$sqlSetCBP = "UPDATE clans SET bankpassword = '$safepassword' WHERE id = '$clanid'";
 $resultSetCBP = $conn->query($sqlSetCBP);
 
 header("location: ?a=bank"); // Redirecting To Other Page

programming_language: PHP
filename: clanbanksend.htm
change_type: ModificationType.MODIFY
diff: @@ -2,13 +2,40 @@
 
 <?php
 
+	$username = $_SESSION['login_user'];
+
+	$sqlGetClanID = "SELECT clan FROM accounts WHERE username = '$username'";
+	$resultGetCID = $conn->query($sqlGetClanID);
+	while($rowCID = $resultGetCID->fetch_assoc()) {
+		$clanid = $rowCID['clan'];
+	};
+
+
 $SendUser=$clanid;
 $RecUser=$_POST['recvusername'];
+$type=$_POST['type'];
+$amount = $_POST['amount'];
+$details = $_POST['details'];
+
+//Sanitize details input
+
+$safedetails = (filter_var($details, FILTER_SANITIZE_STRING));
+
+if($amount < 0 ){ 
+	echo "Amount sent cannot be a negative number.";
+	echo "<br>";
+	echo "Transaction cancelled";
+
+echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+}
+else{
+
+if($type == 'hacker'){
 
 $details = "sent by $SendUserName reason: ";
-$details .= $_POST['details']; 
+$details .= $safedetails; 
 $details2 = "sent to $RecUser reason: ";
-$details2 .= $_POST['details'];
+$details2 .= $safedetails;
 $amount = $_POST['amount'];
 $amountnegative = $amount * -1;
 
@@ -27,7 +54,7 @@ $result = $conn->query($sql);
 if ($result->num_rows > 0) {
 
 
-$sql = "SELECT cash FROM economy WHERE userid = '$SendUser'";
+$sql = "SELECT cash FROM claneconomy WHERE clanid = '$SendUser'";
 $result = $conn->query($sql);
 
 while($row = $result->fetch_assoc()){
@@ -36,15 +63,6 @@ $oldBal = $row['cash'];
 
 $newBalUs1 = $oldBal - $amount;
 
-if ($recvuser == $SendUser) {
-echo "<h1>Transaction Failed</h1>";
-echo "<br>";
-echo "You can't send money to yourself!"; 
-echo "<br>";
-echo "<br>";
-echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
-} else {
-
 if ($newBalUs1 < 0)
 {
    echo "<h1>Transaction Failed</h1>";
@@ -67,10 +85,10 @@ $newBalUs2 = $oldBalUs2 + $amount;
 $sql = "UPDATE economy SET cash='$newBalUs2' WHERE userid = '$recvuser'";
 $result = $conn->query($sql);
 
-$sql = "UPDATE economy SET cash='$newBalUs1' WHERE userid= '$SendUser'";
+$sql = "UPDATE claneconomy SET cash='$newBalUs1' WHERE clanid= '$SendUser'";
 $result = $conn->query($sql);
 
-$sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
+$sql = "INSERT INTO clanbank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
 $result = $conn->query($sql);
 
 $sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$recvuser', '$recvuser', '$details', '$amount')";
@@ -79,7 +97,6 @@ $result = $conn->query($sql);
    echo "Transaction Complete";
    echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
 
-}
 }
 } 
 else {
@@ -90,7 +107,10 @@ else {
 	echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
 
 };
-
-
+}
+else {
+echo "Clan to Clan coming soon";
+};
+};
 ?>
-</div>
\ No newline at end of file
+</div>

programming_language: PHP
filename: clanroster.htm
change_type: ModificationType.MODIFY
diff: @@ -20,14 +20,15 @@ function checkDelete(){
 		$clanid = $rowCID['clan'];
 	};
 
-$sql = "SELECT id, username FROM accounts WHERE clan = '$clanid'";
+$sql = "SELECT id, username, clancouncil FROM accounts WHERE clan = '$clanid'";
 $result = $conn->query($sql);
 
 if ($result->num_rows > 0) {
      echo "<div id=admintable><table><tr><th>Username</th><th>Role</th><th>Bank Balance</th><th>Action</th>";
+
      // output data of each row
      while($row = $result->fetch_assoc()) {
-    	 echo "<tr><td><a href=?a=profile&id=" . $row["id"]. ">" . $row["username"]. "</td><td>" . $row["email"]. "</td><td>" . $row["role"]. "</td><td>" . $row["lastip"]. "</td><td>" . $row["lastlogindate"]. "</td><td>" . $row["regdate"]. "";
+    	 echo "<tr><td><a href=?a=profile&id=" . $row["id"]. ">" . $row["username"]. "</td><td>" . $row["clancouncil"]. "</td><td>" . $row["role"]. "</td><td>" . $row["lastip"]. "</td><td>" . $row["lastlogindate"]. "</td><td>" . $row["regdate"]. "";
 		 echo "<td><a href=?a=profile&id=" . $row["id"]. "><button type='submit' name='action'><i class='material-icons center'>edit</i></button></a>";
 		 echo "<input type='hidden' name='tempId' value='".$row["id"]."'/><form action='?m=deluser' method='POST'><button type='submit' name='action' action=''><i class='material-icons center'>delete</i></button></form>";
 		 echo "<input type='hidden' name='tempId' value='".$row["id"]."'/><form action='?m=banuser' method='POST'><button type='submit' name='action'><i class='material-icons center'>block</i></button></form></td>";

programming_language: PHP
filename: updateacc.htm
change_type: ModificationType.MODIFY
diff: @@ -1,11 +1,13 @@
 <?php
 $bio = $_POST['bio'];
-$_safebio = mysqli_real_escape_string($conn, $bio);
 
-$sql = "UPDATE accounts SET bio='$_safebio' WHERE username='$username'";
+// Sanitize bio but allow for a minimal amount of HTML so the user can style their bio thir way.
+$safebio = $purifier->purify($_safebio);
+
+$sql = "UPDATE accounts SET bio='$safebio' WHERE username='$username'";
 
 $result = $conn->query($sql);
 
-header("location: /game/main/index.php?a=accountdetails");
+header("location: ?a=accountdetails");
 
 ?>
\ No newline at end of file

programming_language: PHP
filename: index.php
change_type: ModificationType.MODIFY
diff: @@ -37,6 +37,9 @@ if (empty($_GET['m'])){
 			case "clanbank": echo "Clan Bank";break;
 			case "clanroster": echo "Clan Roster";break;
 			case "profile": echo "Player Profile";break;
+			case "guest": echo "Guest";break;
+			case "login": echo "Login";break;
+			case "register": echo "Register";break;
 		};
 	};
 }
@@ -68,6 +71,9 @@ else {
 
 <?php
 
+require_once '../htmlpurifier/library/HTMLPurifier.auto.php';
+$purifier = new HTMLPurifier();
+
 $mem = new Memcache();
 $mem->addServer("127.0.0.1", 11211);
 require 'sql/connect.php';

programming_language: PHP
filename: footer.htm
change_type: ModificationType.MODIFY
diff: @@ -22,7 +22,6 @@
 </div>
 <h6>Gameserver: <?php echo gethostname(); ?> </h6>
 
-
 <div style="clear: both"></div>
 
 <script type="text/javascript">

programming_language: PHP
filename: header.htm
change_type: ModificationType.MODIFY
diff: @@ -1,21 +1,3 @@
-<html>
-	<head>
-		<title>Hacker City | Index</title>
-		<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Ek+Mukta">
-		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
-		<link type="text/css" rel="stylesheet" href="/css/style.css">
-		<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
-		<link type="text/css" rel="stylesheet" href="/css/materialize.css">
-		<link type="text/css" rel="stylesheet" href="/css/burn.css">
-		<link rel="shortcut icon" href="/usr/share/nginx/html/images/favicon.ico" type="image/x-icon">
-		<link rel="icon" href="/usr/share/nginx/html/images/favicon.ico" type="image/x-icon">
-		<script src="/js/materialize.js"></script>
-		<script src='https://www.google.com/recaptcha/api.js'></script>
-		<script async src="/js/spanize.js"></script>
-	</head>
-	
-<body>
-
 <?php
 	include 'layout/guest/nav.htm';
 ?>	

programming_language: PHP
filename: footer.htm
change_type: ModificationType.MODIFY
diff: @@ -17,8 +17,7 @@
 </div>
 
 <div class="bottomright">
-<h6>Version <?php echo $GAMEVERSION; ?>
-</h6>
+<h6>Version <?php echo $GAMEVERSION; ?></h6>
 <h6>Developed by Francis Booth</h6>
 </div>
 <h6>Gameserver: <?php echo gethostname(); ?> </h6>

programming_language: PHP
filename: header.htm
change_type: ModificationType.MODIFY
diff: @@ -101,7 +101,7 @@
             		<li><a href="?a=hardwareshop">Hardware Shop</a></li>
             		<li><a href="?a=isp">Internet Provider</a></li>
             		<li><a href="?a=h4h">Hacker for Hire</a></li>
-            		<li><a href="?a=cryptocurrency">Cryptocurrency</a></li>
+            		<li><a href="?a=cryptomarket">Crypto-Market</a></li>
             	</ul>
             </li>
             <li>

programming_language: PHP