Skip to content

Commit

Permalink
2.11.22 Update web service
Browse files Browse the repository at this point in the history
  • Loading branch information
webpwnized committed Oct 8, 2024
1 parent eeaf6e7 commit a6b6270
Show file tree
Hide file tree
Showing 18 changed files with 146 additions and 146 deletions.
2 changes: 1 addition & 1 deletion src/add-to-your-blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
*/
$lEnableJavaScriptValidation = TRUE;
$lEnableHTMLControls = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
break;
}// end switch

Expand Down
2 changes: 1 addition & 1 deletion src/ajax/lookup-pen-test-tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
case "4":
case "5": // This code is fairly secure
$lUseServerSideValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
/*
* NOTE: Input validation is excellent but not enough. The output must be
* encoded per context. For example, if output is placed in HTML,
Expand Down
2 changes: 1 addition & 1 deletion src/conference-room-lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function encodeForLDAP(/*string*/ $pString) {
$lProtectAgainstLDAPInjection=TRUE;
$lEnableHTMLControls = TRUE;
$lEnableJavaScriptValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
break;
}// end switch

Expand Down
12 changes: 6 additions & 6 deletions src/content-security-policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
$lEnableJavaScriptValidation = FALSE;
$lEnableHTMLControls = FALSE;
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
break;

case "1": // This code is insecure. No input validation is performed.
$lEnableJavaScriptValidation = TRUE;
$lEnableHTMLControls = TRUE;
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
break;

case "2":
Expand All @@ -29,8 +29,8 @@
$lProtectAgainstCommandInjection=TRUE;
$lEnableHTMLControls = TRUE;
$lEnableJavaScriptValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstXSS = TRUE;
$lProtectAgainstMethodTampering = true;
$lProtectAgainstXSS = true;
break;
}// end switch

Expand Down
14 changes: 7 additions & 7 deletions src/dns-lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
$lEnableJavaScriptValidation = FALSE;
$lEnableHTMLControls = FALSE;
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
break;

case "1": // This code is insecure. No input validation is performed.
$lEnableJavaScriptValidation = TRUE;
$lEnableHTMLControls = TRUE;
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
break;

case "2":
Expand All @@ -29,8 +29,8 @@
$lProtectAgainstCommandInjection=TRUE;
$lEnableHTMLControls = TRUE;
$lEnableJavaScriptValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstXSS = TRUE;
$lProtectAgainstMethodTampering = true;
$lProtectAgainstXSS = true;
break;
}// end switch

Expand All @@ -48,7 +48,7 @@
* We validate that an IP is 4 octets, IPV6 fits the pattern, and that domain name is IANA format */
$lTargetHostValidated = preg_match(IPV4_REGEX_PATTERN, $lTargetHost) || preg_match(DOMAIN_NAME_REGEX_PATTERN, $lTargetHost) || preg_match(IPV6_REGEX_PATTERN, $lTargetHost);
}else{
$lTargetHostValidated=TRUE; // do not perform validation
$lTargetHostValidated = true; // do not perform validation
}// end if

if ($lProtectAgainstXSS) {
Expand Down
12 changes: 6 additions & 6 deletions src/echo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
$lEnableJavaScriptValidation = FALSE;
$lEnableHTMLControls = FALSE;
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
break;

case "1": // This code is insecure. No input validation is performed.
$lEnableJavaScriptValidation = TRUE;
$lEnableHTMLControls = TRUE;
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
break;

case "2":
Expand All @@ -29,8 +29,8 @@
$lProtectAgainstCommandInjection=TRUE;
$lEnableHTMLControls = TRUE;
$lEnableJavaScriptValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstXSS = TRUE;
$lProtectAgainstMethodTampering = true;
$lProtectAgainstXSS = true;
break;
}// end switch

Expand Down
2 changes: 1 addition & 1 deletion src/pen-test-tool-lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$lUseSafeJSONParser = TRUE;
$lUseJavaScriptValidation = TRUE;
$lUseServerSideValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
/*
* NOTE: Input validation is excellent but not enough. The output must be
* encoded per context. For example, if output is placed in HTML,
Expand Down
2 changes: 1 addition & 1 deletion src/styling-frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
case "3":
case "4":
case "5": // This code is fairly secure
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
$lEncodeOutput = TRUE;
break;
};//end switch
Expand Down
2 changes: 1 addition & 1 deletion src/styling.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
require_once ('./includes/constants.php');
require_once (__SITE_ROOT__.'/classes/EncodingHandler.php');
$Encoder = new EncodingHandler();
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
$lEncodeOutput = TRUE;
break;
};//end switch
Expand Down
12 changes: 6 additions & 6 deletions src/test-connectivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
switch ($_SESSION["security-level"]){
case "0": // This code is insecure. No input validation is performed.
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
$lProtectAgainstSSRF = FALSE;
break;

case "1": // This code is insecure. No input validation is performed.
$lProtectAgainstMethodTampering = FALSE;
$lProtectAgainstCommandInjection=FALSE;
$lProtectAgainstXSS = FALSE;
$lProtectAgainstCommandInjection=false;
$lProtectAgainstXSS = false;
$lProtectAgainstSSRF = FALSE;
break;

Expand All @@ -26,8 +26,8 @@
case "4":
case "5": // This code is fairly secure
$lProtectAgainstCommandInjection=TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstXSS = TRUE;
$lProtectAgainstMethodTampering = true;
$lProtectAgainstXSS = true;
$lProtectAgainstSSRF = TRUE;
break;
}// end switch
Expand Down
2 changes: 1 addition & 1 deletion src/text-file-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$lEnableHTMLControls = TRUE;
$lUseTokenization = TRUE;
$lEncodeOutput = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
break;
}// end switch ($_SESSION["security-level"])

Expand Down
2 changes: 1 addition & 1 deletion src/user-info-xpath.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$lEnableHTMLControls = TRUE;
$lFormMethod = "POST";
$lEnableJavaScriptValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
$lEncodeOutput = TRUE;
$lProtectAgainstXPathInjection = TRUE;
break;
Expand Down
74 changes: 37 additions & 37 deletions src/user-poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@
require_once (__SITE_ROOT__.'/classes/CSRFTokenHandler.php');
$lCSRFTokenHandler = new CSRFTokenHandler($_SESSION["security-level"], "register-user");

if (!isSet($logged_in_user)) {
throw new Exception("$logged_in_user is not set. Page add-to-your-blog.php requires this variable.");
}// end if
if (!isSet($logged_in_user)) {
throw new Exception("$logged_in_user is not set. Page add-to-your-blog.php requires this variable.");
}// end if

function isParameterPollutionDetected(/*String*/ $pQueryString){

try {
// Detect multiple params with same name (HTTP Parameter Pollution)
$lQueryString = explode('&', $pQueryString);
$lKeys = array();
$lPair = array();
// Detect multiple params with same name (HTTP Parameter Pollution)
$lQueryString = explode('&', $pQueryString);
$lKeys = array();
$lPair = array();
$lParameter = "";
$lCountUnique = 0;
$lCountTotal = 0;

foreach ($lQueryString as $lParameter){
$lPair = explode('=', $lParameter);
array_push($lKeys, $lPair[0]);
}//end for each

$lCountUnique = count(array_unique($lKeys));
$lCountTotal = count($lKeys);

$lCountTotal = 0;

foreach ($lQueryString as $lParameter){
$lPair = explode('=', $lParameter);
array_push($lKeys, $lPair[0]);
}//end for each

$lCountUnique = count(array_unique($lKeys));
$lCountTotal = count($lKeys);

return ($lCountUnique < $lCountTotal);


} catch (Exception $e) {
return FALSE;
}//end catch
return FALSE;
}//end catch

}//end function isParameterPollutionDetected()

Expand Down Expand Up @@ -67,7 +67,7 @@ function isParameterPollutionDetected(/*String*/ $pQueryString){
case "5": // This code is fairly secure
$lEnableHTMLControls = TRUE;
$lEncodeOutput = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
$lHTTPParameterPollutionDetected = isParameterPollutionDetected($_SERVER['QUERY_STRING']);
$lLoggedInUser = $MySQLHandler->escapeDangerousCharacters($logged_in_user);
break;
Expand Down Expand Up @@ -116,19 +116,19 @@ function isParameterPollutionDetected(/*String*/ $pQueryString){
$LogHandler->writeToLog("User voted for {$lUserChoice}");
}// end if

// Encode output to protect against cross site scripting
if ($lEncodeOutput){
$lUserInitials = $Encoder->encodeForHTML($lUserInitials);
// Encode output to protect against cross site scripting
if ($lEncodeOutput){
$lUserInitials = $Encoder->encodeForHTML($lUserInitials);
$lUserChoice = $Encoder->encodeForHTML($lUserChoice);
$lUserChoiceMessage = $Encoder->encodeForHTML($lUserChoiceMessage);
}// end if
$lUserChoiceMessage = $Encoder->encodeForHTML($lUserChoiceMessage);
}// end if

//Insert vote into database
try {
$SQLQueryHandler->insertVoteIntoUserPoll($lUserChoice, $lLoggedInUser);
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Error inserting user vote for " . $lLoggedInUser);
}//end try
try {
$SQLQueryHandler->insertVoteIntoUserPoll($lUserChoice, $lLoggedInUser);
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Error inserting user vote for " . $lLoggedInUser);
}//end try

} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Vote was not counted");
Expand Down Expand Up @@ -203,17 +203,17 @@ function isParameterPollutionDetected(/*String*/ $pQueryString){

<?php
try{// to draw table
//Get votes from database
try {
$lQueryResult = $SQLQueryHandler->getUserPollVotes();
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Error getting user votes");
//Get votes from database
try {
$lQueryResult = $SQLQueryHandler->getUserPollVotes();
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Error getting user votes");
}//end try

if($lQueryResult->num_rows > 0){

// we have rows. Begin drawing output.
echo '<br/>';
echo '<br/>';
echo '<fieldset>';
echo '<legend>Poll Results</legend>';
echo '<table style="width:50%;" class="results-table">';
Expand Down
2 changes: 1 addition & 1 deletion src/view-someones-blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
$lTokenizeAllowedMarkup = TRUE;

/* If we are in secure mode, we need to protect against SQLi */
$lProtectAgainstMethodTampering = TRUE;
$lProtectAgainstMethodTampering = true;
break;
}// end switch

Expand Down
Loading

0 comments on commit a6b6270

Please sign in to comment.