-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create jeff-high.php #34
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
if( isset( $_POST[ 'Submit' ] ) ) { | ||
// Get input | ||
$target = trim($_REQUEST[ 'ip' ]); | ||
|
||
// Set blacklist | ||
$substitutions = array( | ||
'&' => '', | ||
';' => '', | ||
'| ' => '', | ||
'-' => '', | ||
'$' => '', | ||
'(' => '', | ||
')' => '', | ||
'`' => '', | ||
'||' => '', | ||
); | ||
|
||
// Remove any of the characters in the array (blacklist). | ||
$target = str_replace( array_keys( $substitutions ), $substitutions, $target ); | ||
|
||
// Determine OS and execute the ping command. | ||
if( stristr( php_uname( 's' ), 'Windows NT' ) ) { | ||
// Windows | ||
$cmd = shell_exec( 'ping ' . escapeshellarg($target) ); | ||
} | ||
else { | ||
// *nix | ||
$cmd = shell_exec( 'ping -c 4 ' . escapeshellarg($target) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗Cycode: SAST violation: 'Unsanitized user input in OS command'. Severity: Critical DescriptionExecuting OS commands that include user-supplied data can lead to command injection vulnerabilities. This occurs when an application dynamically executes OS commands that an attacker can manipulate through user input. Cycode Remediation Guideline✅ Do
if ($_GET["action"] == "option1") {
$command = "command1";
} else {
$command = "command2";
}
exec($command); ❌ Don't
exec($_GET["command"]); // unsafe 📋 References |
||
} | ||
|
||
// Feedback for the end user | ||
$html .= "<pre>{$cmd}</pre>"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗Cycode: SAST violation: 'Unsanitized user input in raw HTML strings (XSS)'. Severity: High DescriptionIncluding unsanitized user input in HTML exposes your application to cross-site scripting (XSS) attacks. This vulnerability allows attackers to inject malicious scripts into web pages viewed by other users. Cycode Remediation Guideline✅ Do
$html = "<h1>${htmlspecialchars($_GET["title"])}</h1>"; ❌ Don't
$html = "<h1>{$_GET["title"]}</h1>"; // unsafe 📋 References |
||
} | ||
|
||
?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗Cycode: SAST violation: 'Unsanitized user input in OS command'.
Severity: Critical
Description
Executing OS commands that include user-supplied data can lead to command injection vulnerabilities. This occurs when an application dynamically executes OS commands that an attacker can manipulate through user input.
Cycode Remediation Guideline
✅ Do
❌ Don't
📋 References