<?php header('Content-Type: text/html; charset=utf...
Créé le : 7 juin 2025
Créé le : 7 juin 2025
Let's break down what's happening in this PHP script and understand the possible vulnerabilities or intended interactions.
1. Input Handling:
Number
.Number
contains any digit (\d
), the script immediately exits with a message "不行不行,不能这样"
.2. Integer Validation:
intval($inputNumber)
evaluates to true (meaning $inputNumber
when cast to an integer is non-zero), it continues.Important Note:
intval()
in PHP converts strings to integers by taking the numeric prefix (e.g., '123abc'
becomes 123
, and 'abc'
becomes 0
).intval($inputNumber)
is true), your input must not contain digits (to pass the first check) but still somehow convert to a non-zero integer. This seems tricky, as intval
will generally yield 0
for strings without digits.3. Command Execution:
cmd
.cmd
matches a very strict regular expression forbidding a long list of typical command injection attempts and dangerous commands.system($cmd)
.To exploit this script and run a command, you need to:
0
. However, certain special strings can behave peculiarly in PHP:
0xFF
is allowed in PHP and equals 255
, but contains digits.1e1
has digits.intval()
will always return 0
, making it impossible to proceed past that check as-is.0123
) or locale-specific numerals might pass the regex \d
check yet be treated by PHP as digits, depending on locale configuration or PHP version.cat
, grep
, less
, etc.), execute scripts (bash
, sh
, etc.), or manipulate files (cp
, mv
, tee
, etc.).whoami
, pwd
, or uname -a
might not match the forbidden pattern and thus would execute, provided you could bypass the numeric check initially.preg_match('/\d/', $inputNumber)
and intval($inputNumber)
), which at face value are secure.If you're attempting to exploit or solve this, you need a specially crafted PHP numeric input that behaves non-intuitively (perhaps using encoding or special PHP features) to pass the numeric checks, then run allowed commands for further exploration.