php:// — 锟斤拷锟绞革拷锟斤拷锟斤拷锟斤拷/锟斤拷锟斤拷锟斤拷锟絀/O streams锟斤拷
PHP 锟结供锟斤拷一些锟斤拷锟斤拷锟斤拷锟斤拷/锟斤拷锟斤拷锟絀O锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� PHP 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟阶硷拷锟斤拷锟斤拷锟斤拷锟酵达拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 锟节达拷锟叫★拷锟斤拷锟教憋拷锟捷碉拷锟斤拷时锟侥硷拷锟斤拷锟皆硷拷锟斤拷锟皆诧拷锟斤拷锟斤拷锟斤拷锟斤拷取写锟斤拷锟侥硷拷锟斤拷源锟侥癸拷锟斤拷锟斤拷锟斤拷
php://stdin锟斤拷php://stdout 锟斤拷
php://stderr 锟斤拷锟斤拷直锟接凤拷锟斤拷 PHP 锟斤拷锟斤拷锟斤拷应锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟剿革拷锟狡碉拷锟侥硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 php://stdin 锟斤拷锟斤拷之锟斤拷锟斤拷锟斤拷锟斤拷锟�
锟斤拷锟角关憋拷锟剿革拷锟斤拷品锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫碉拷 STDIN
锟斤拷锟斤拷锟斤拷影锟届。
注锟斤拷 PHP 锟斤拷锟解方锟斤拷锟斤拷锟轿拷泻芏锟� BUG 直锟斤拷 PHP 5.2.1锟斤拷
锟狡硷拷锟斤拷锟绞癸拷贸锟斤拷锟� STDIN
锟斤拷
STDOUT
锟斤拷 STDERR
锟斤拷锟斤拷锟斤拷锟街癸拷锟斤拷锟斤拷些锟斤拷装锟斤拷锟斤拷
php://stdin 锟斤拷只锟斤拷锟侥o拷 php://stdout 锟斤拷 php://stderr 锟斤拷只写锟侥★拷
php://input 锟角革拷锟斤拷锟皆凤拷锟斤拷锟斤拷锟斤拷锟皆硷拷锟斤拷莸锟街伙拷锟斤拷锟斤拷锟� POST 锟斤拷锟斤拷锟斤拷锟斤拷锟铰o拷锟斤拷锟绞癸拷锟� php://input 锟斤拷锟斤拷锟斤拷 $HTTP_RAW_POST_DATA锟斤拷锟斤拷为锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟截讹拷锟斤拷 php.ini 指锟筋。 锟斤拷锟揭o拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� $HTTP_RAW_POST_DATA 默锟斤拷没锟斤拷锟斤拷洌� 锟饺硷拷锟斤拷 always_populate_raw_post_data 潜锟斤拷锟斤拷要锟斤拷锟劫碉拷锟节存。 enctype="multipart/form-data" 锟斤拷时锟斤拷 php://input 锟斤拷锟斤拷效锟侥★拷
Note: 锟斤拷 PHP 5.6 之前 php://input 锟津开碉拷锟斤拷锟斤拷锟斤拷只锟杰讹拷取一锟轿o拷 锟斤拷锟斤拷锟斤拷锟斤拷支锟斤拷 seek 锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 SAPI 锟斤拷实锟街o拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷憋拷锟斤拷锟斤拷锟绞憋拷锟� 锟斤拷锟斤拷锟皆达拷锟斤拷一锟斤拷 php://input 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟铰讹拷取锟斤拷 通锟斤拷锟斤拷锟斤拷拢锟斤拷锟斤拷锟斤拷锟斤拷只锟斤拷锟斤拷锟� POST 锟斤拷锟襟,讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷式锟斤拷锟斤拷锟斤拷 PUT 锟斤拷锟斤拷 PROPFIND锟斤拷
php://output 锟斤拷一锟斤拷只写锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷 print 锟斤拷 echo 一锟斤拷锟侥凤拷式 写锟诫到锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
php://fd 锟斤拷锟斤拷直锟接凤拷锟斤拷指锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷 php://fd/3 锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷锟斤拷 3锟斤拷
php://memory 锟斤拷 php://temp 锟斤拷一锟斤拷锟斤拷锟斤拷锟侥硷拷 锟斤拷装锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫达拷锟绞憋拷锟斤拷荨锟� 锟斤拷锟竭碉拷唯一锟斤拷锟斤拷锟斤拷 php://memory 锟斤拷锟角帮拷锟斤拷锟捷达拷锟斤拷锟斤拷锟节达拷锟叫o拷 锟斤拷 php://temp 锟斤拷锟斤拷锟节达拷锟斤拷锟斤到预锟斤拷锟斤拷锟斤拷锟斤拷坪锟侥拷锟斤拷锟� 2MB锟斤拷锟斤拷锟斤拷锟斤拷时锟侥硷拷锟叫★拷 锟斤拷时锟侥硷拷位锟矫的撅拷锟斤拷锟斤拷 sys_get_temp_dir() 锟侥凤拷式一锟铰★拷
php://temp 锟斤拷锟节达拷锟斤拷锟狡匡拷通锟斤拷锟斤拷锟� /maxmemory:NN 锟斤拷锟斤拷锟狡o拷NN 锟斤拷锟斤拷锟街斤拷为锟斤拷位锟斤拷锟斤拷锟斤拷锟斤拷锟节达拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷使锟斤拷锟斤拷时锟侥硷拷锟斤拷
php://filter 锟斤拷一锟斤拷元锟斤拷装锟斤拷锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟�筛选锟斤拷锟斤拷应锟矫★拷 锟斤拷锟斤拷锟揭伙拷锟绞斤拷锟絘ll-in-one锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷锟角筹拷锟斤拷锟矫o拷锟斤拷锟斤拷 readfile()锟斤拷 file() 锟斤拷 file_get_contents()锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷讹拷取之前没锟叫伙拷锟斤拷应锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
php://filter 目锟斤拷使锟斤拷锟斤拷锟铰的诧拷锟斤拷锟斤拷为锟斤拷路锟斤拷锟斤拷一锟斤拷锟街★拷 锟斤拷锟较癸拷锟斤拷锟斤拷锟杰癸拷锟斤拷一锟斤拷路锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷细使锟斤拷锟斤拷些锟斤拷锟斤拷锟斤拷锟皆参匡拷锟斤拷锟藉范锟斤拷锟斤拷
锟斤拷锟斤拷 | 锟斤拷锟斤拷 |
---|---|
resource=<要锟斤拷锟剿碉拷锟斤拷锟斤拷锟斤拷> | 锟斤拷锟斤拷锟斤拷锟斤拷潜锟斤拷锟侥★拷锟斤拷指锟斤拷锟斤拷锟斤拷要筛选锟斤拷锟剿碉拷锟斤拷锟斤拷锟斤拷锟斤拷 |
read=<锟斤拷锟斤拷锟斤拷筛选锟叫憋拷> | 锟矫诧拷锟斤拷锟斤拷选锟斤拷锟斤拷锟斤拷锟借定一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟狡o拷锟皆管碉拷锟斤拷锟斤拷|锟斤拷锟街革拷锟斤拷 |
write=<写锟斤拷锟斤拷筛选锟叫憋拷> | 锟矫诧拷锟斤拷锟斤拷选锟斤拷锟斤拷锟斤拷锟借定一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟狡o拷锟皆管碉拷锟斤拷锟斤拷|锟斤拷锟街革拷锟斤拷 |
<锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷筛选锟叫憋拷> | 锟轿猴拷没锟斤拷锟斤拷 read= 锟斤拷 write= 锟斤拷前缀 锟斤拷筛选锟斤拷锟叫憋拷锟斤拷锟斤拷锟斤拷应锟斤拷锟节讹拷锟斤拷写锟斤拷锟斤拷 |
锟芥本 | 说锟斤拷 |
---|---|
5.6.0 | php://input 锟缴凤拷锟斤拷使锟矫★拷 |
5.3.6 | 锟斤拷锟斤拷 php://fd锟斤拷 |
5.1.0 | 锟斤拷锟斤拷 php://memory 锟斤拷 php://temp锟斤拷 |
5.0.0 | 锟斤拷锟斤拷 php://filter锟斤拷 |
Example #1 php://temp/maxmemory
锟斤拷锟斤拷锟窖⊙★拷锟斤拷锟斤拷锟斤拷锟斤拷锟� php://temp 锟斤拷始使锟斤拷锟斤拷时锟侥硷拷前锟斤拷锟斤拷锟斤拷诖锟斤拷锟斤拷啤锟�
<?php
// Set the limit to 5 MB.
$fiveMBs = 5 * 1024 * 1024;
$fp = fopen("php://temp/maxmemory:$fiveMBs", 'r+');
fputs($fp, "hello\n");
// Read what we have written.
rewind($fp);
echo stream_get_contents($fp);
?>
Example #2 php://filter/resource=<锟斤拷锟斤拷锟剿碉拷锟斤拷锟斤拷锟斤拷>
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟轿伙拷锟� php://filter 锟斤拷末尾锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷要锟斤拷锟斤拷筛选锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
<?php
/* 锟斤拷虻サ锟酵拷冢锟�
readfile("http://www.example.com");
实锟斤拷锟斤拷没锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷 */
readfile("php://filter/resource=http://www.example.com");
?>
Example #3 php://filter/read=<锟斤拷锟斤拷锟斤拷要应锟矫的癸拷锟斤拷锟斤拷锟叫憋拷>
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷怨艿锟斤拷锟� | 锟街革拷锟侥讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷啤锟�
<?php
/* 锟斤拷锟斤拷源锟叫达拷锟侥革拷锟斤拷 www.example.com 锟斤拷全锟斤拷锟斤拷锟斤拷 */
readfile("php://filter/read=string.toupper/resource=http://www.example.com");
/* 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 ROT13 锟斤拷锟杰★拷 */
readfile("php://filter/read=string.toupper|string.rot13/resource=http://www.example.com");
?>
Example #4 php://filter/write=<写锟斤拷锟斤拷要应锟矫的癸拷锟斤拷锟斤拷锟叫憋拷>
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷锟斤拷怨艿锟斤拷锟� | 锟街革拷锟侥讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷啤锟�
<?php
/* 锟斤拷锟酵拷锟� rot13 锟斤拷锟斤拷锟斤拷筛选锟斤拷锟街凤拷 "Hello World"
然锟斤拷写锟诫当前目录锟铰碉拷 example.txt */
file_put_contents("php://filter/write=string.rot13/resource=example.txt","Hello World");
?>
Example #5 php://memory 锟斤拷 php://temp 锟斤拷一锟斤拷锟皆碉拷
php://memory 锟斤拷 php://temp 锟斤拷一锟斤拷锟皆的o拷锟斤拷锟界:stream 锟斤拷锟截闭后,撅拷锟睫凤拷锟劫次得碉拷锟斤拷前锟斤拷锟斤拷锟斤拷锟剿★拷
file_put_contents('php://memory', 'PHP');
echo file_get_contents('php://memory'); // 啥也没锟斤拷