Skip to content

Commit 91bc7a9

Browse files
committed
Updates php/challenge-57.md
Auto commit by GitBook Editor
1 parent f6e5d7c commit 91bc7a9

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* [Challenge 54](php/challenge-54.md)
6161
* [Challenge 55](php/challenge-55.md)
6262
* [Challenge 56](php/challenge-56.md)
63+
* [Challenge 57](php/challenge-57.md)
6364

6465
## PYTHON
6566

php/challenge-57.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Challenge
2+
```php
3+
<?php
4+
/*//设置open_basedir
5+
ini_set("open_basedir", "/home/shawn/www/index/");
6+
*/
7+
8+
if (isset($_GET['file'])) {
9+
$file = trim($_GET['file']);
10+
} else {
11+
$file = "main.html";
12+
}
13+
14+
// disallow ip
15+
if (preg_match('/^(http:\/\/)+([^\/]+)/i', $file, $domain)) {
16+
$domain = $domain[2];
17+
if (stripos($domain, ".") !== false) {
18+
die("Hacker");
19+
}
20+
}
21+
22+
if( @file_get_contents($file)!=''){
23+
echo file_get_contents($file);
24+
25+
}else{
26+
27+
$str=<<<EOF
28+
<html>
29+
<head><title>403 Forbidden</title></head>
30+
<body bgcolor="white">
31+
<center><h1>403 Forbidden</h1></center>
32+
<hr><center>nginx/1.13.5</center>
33+
</body>
34+
</html>
35+
<!-- a padding to disable MSIE and Chrome friendly error page -->
36+
<!-- a padding to disable MSIE and Chrome friendly error page -->
37+
<!-- a padding to disable MSIE and Chrome friendly error page -->
38+
<!-- a padding to disable MSIE and Chrome friendly error page -->
39+
<!-- a padding to disable MSIE and Chrome friendly error page -->
40+
<!-- a padding to disable MSIE and Chrome friendly error page -->
41+
EOF;
42+
echo $str;
43+
}
44+
```
45+
46+
# Refference
47+
+ 2017 XDCTF web3

0 commit comments

Comments
 (0)