Skip to content

Commit

Permalink
Command Injection Vulnerability a better teaching example
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Fedosov committed May 10, 2024
1 parent 9eca6f3 commit 1e538f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vulnerabilities/exec/source/impossible.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
$octet = explode( ".", $target );

// Check IF each octet is an integer
if( ( is_numeric( $octet[0] ) ) && ( is_numeric( $octet[1] ) ) && ( is_numeric( $octet[2] ) ) && ( is_numeric( $octet[3] ) ) && ( sizeof( $octet ) == 4 ) ) {
if( $octet === array_filter( $octet, 'is_numeric' ) && ( sizeof( $octet ) === 4 ) ) {
// If all 4 octets are int's put the IP back together.
$target = $octet[0] . '.' . $octet[1] . '.' . $octet[2] . '.' . $octet[3];
$target = implode('.', $octet);

// Determine OS and execute the ping command.
if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
Expand Down

0 comments on commit 1e538f4

Please sign in to comment.