4.PHP-wrappers
Key Takeaways:
From LFI to RCE:
The section transitions from reading local files to executing commands.
Enumerating credentials and SSH keys is mentioned, but the focus is on direct RCE.
PHP Wrappers for RCE:
data://,input://, andexpect://wrappers are covered.allow_url_includesetting is crucial fordata://andinput://.
Checking PHP Configurations:
Reading
php.inito checkallow_url_includeandexpectstatus.Using
base64encoding and decoding forphp.inicontent.Using grep to find the needed configuration values.
data://Wrapper:Allows including external data, including PHP code.
Requires
allow_url_includeto be enabled.Base64 encoding is used to pass PHP code.
Example:
data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWyJjbWQiXSk7ID8+Cg==
input://Wrapper:Includes external input from POST requests.
Requires
allow_url_includeto be enabled.PHP code is passed as POST data.
Commands are passed as GET parameters.
Demonstrates how to use curl to send post data.
expect://Wrapper:Allows direct command execution.
Requires the
expectextension to be installed and enabled.Example:
expect://idVery simple syntax.
Further Exploitation:
Mention of
phar://andzip://wrappers for file upload scenarios.Reinforces that this is not the only way to gain RCE.
Additional Considerations:
allow_url_includeImportance:This setting is a major security risk when enabled.
It should be disabled in production environments.
expectExtension Security:The
expectextension can also be a security risk.It should be used with caution.
Real-World Scenarios:
Attackers often combine these techniques with other vulnerabilities.
WAFs and other security measures can hinder these attacks.
Defense in Depth:
Proper input validation and sanitization are crucial.
Principle of least privilege should be followed.
Keep php updated.
Error Messages:
As with all web attacks, error messages can give an attacker valuable information. Proper error handling is very important.
Curl usage:
The examples provided, show very good usage of the curl command line tool. This is a very useful tool for web penetration testing.
Last updated