ディレクトリトラバーサル 05 - yujitounai/helloworld GitHub Wiki
Webページ印刷画面のfileのディレクトリトラバーサル
<?php
$url = @$_GET["url"];
$filename = str_replace( "http://bogus.jp" , "." , $url);
//print $filename;
$temp = array();
foreach ( file( $filename ) as $line ) {
//画面用CSSを印刷用CSSに置換
$line = str_replace( "_p.css" , "_p.css" , $line);
//</body>削除
if ( strpos( $line, "</body>" ) === false ) $line = $line;
//</html>削除
if ( strpos( $line, "</html>" ) === false ) $line = $line;
$temp[] = $line;
}
//書き出し
print implode( '', $temp ) ;
?>
<script type="text/javascript">
<!--
if (window.onload){
if (window.attachEvent){
window.attachEvent('onload', print_page);
}else if (window.addEventListener){
window.addEventListener('load', print_page, true);
}else{
window.onload = print_page;
}
}else{
window.onload = print_page;
}
function print_page(){
if (window.print){
window.print();
}
}
//-->
</script>
</body>
</html>
<script type="text/javascript">
<!--
if (window.onload){
if (window.attachEvent){
window.attachEvent('onload', print_page);
}else if (window.addEventListener){
window.addEventListener('load', print_page, true);
}else{
window.onload = print_page;
}
}else{
window.onload = print_page;
}
function print_page(){
if (window.print){
window.print();
}
}
//-->
</script>
</body>
</html>
?url=//etc/hosts