Skip to content

Commit 71a38af

Browse files
committed
Updates php/challenge-92.md
Auto commit by GitBook Editor
1 parent d400e13 commit 71a38af

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
* [Challenge 89](php/challenge-89.md)
9696
* [Challenge 90](php/challenge-90.md)
9797
* [Challenge 91](php/challenge-91.md)
98+
* [Challenge 92](php/challenge-92.md)
9899

99100
## RUBY
100101

php/challenge-92.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Challenge
2+
```php
3+
<?php
4+
error_reporting(0);
5+
ini_set('open_basedir', '/var/www/html');
6+
7+
function autoload($page) {
8+
if (stripos($_SERVER['QUERY_STRING'], 'flag') > 0) {
9+
die('no flag flag flag flag !');
10+
}
11+
12+
if (stripos($_SERVER['QUERY_STRING'], 'uploaded') > 0) {
13+
die('no uploaded uploaded uploaded uploaded !');
14+
}
15+
16+
if (stripos($_SERVER['QUERY_STRING'], '://f') > 0) {
17+
die('no ://f ://f ://f');
18+
}
19+
20+
if (stripos($_SERVER['QUERY_STRING'], 'ata') > 0) {
21+
die('no ata ata ata');
22+
}
23+
24+
if (stripos($_SERVER['QUERY_STRING'], '0') > 0) {
25+
die('no 0 0 0');
26+
}
27+
28+
if(file_exists("./includes/$page.php")) {
29+
include "./includes/$page.php";
30+
}
31+
elseif(file_exists("./includes/$page")) {
32+
include "./includes/$page";
33+
}else{
34+
echo "File is not exit ";
35+
}
36+
}
37+
38+
39+
function download($adfile, $file){
40+
//Only Administrators can download files .
41+
$cert = 'N';
42+
if(isset($adfile) && file_get_contents($adfile, 'r') === 'Yeah Everything Will Be Ok My Boss') {
43+
echo "Welcome ! You Are Administrator !";
44+
$cert = 'Y';
45+
}else{
46+
echo "error1";
47+
}
48+
if ($cert === 'Y'){
49+
if (stripos($file, 'file_list') != false) die('error4');
50+
if (stripos($file, 'file_list') >= 0) {
51+
header('Content-Description: File Transfer');
52+
header('Content-Type: application/octet-stream');
53+
header('Content-Disposition: attachment; filename='. basename($file));
54+
header('Content-Transfer-Encoding: binary');
55+
header('Expires: 0');
56+
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
57+
header('Pragma: public');
58+
header('Content-Length: ' . filesize($file));
59+
readfile($file);
60+
}else{
61+
die('error2');
62+
}
63+
}else{
64+
echo 'error3';
65+
}
66+
}
67+
68+
if(!isset($_GET['page'])) {
69+
$page = 'index';
70+
}
71+
else {
72+
$page = $_GET['page'];
73+
}
74+
if (stripos($page, './') > 0) {
75+
die('no ./ ./ ./ ./');
76+
}
77+
if (stripos($page, '://') > 0) {
78+
die('no :// :// ://');
79+
}
80+
autoload($page);
81+
82+
if (isset($_GET[admin]) && isset($_GET[file])) {
83+
84+
if (stripos($_GET[admin], 'flag') > 0 || stripos($_GET[file], 'flag') > 0) {
85+
die('not flag flag flag falg !');
86+
}
87+
88+
if (strlen($_GET[file]) >= 38) {
89+
die('too long');
90+
}
91+
92+
download($_GET[admin], $_GET[file]);
93+
}
94+
95+
96+
?>
97+
98+
```
99+
100+
# Refference
101+
+ 赛博地球杯工业互联网安全大赛 工控云管理系统客服中心期待您的反馈

0 commit comments

Comments
 (0)