-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
71 lines (62 loc) · 2.71 KB
/
index.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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Panel de Administración - Ejecución de Comandos</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container my-5">
<h1 class="text-center">Panel de Administración</h1>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="form-group">
<label for="command">Ingrese un comando de bash</label>
<input type="text" id="command" class="form-control" placeholder="ls -lh">
</div>
<button id="execute" class="btn btn-primary btn-block">Ejecutar</button>
</div>
</div>
<div class="row justify-content-center mt-5">
<div class="col-md-10">
<h3 class="text-center">Salida</h3>
<pre id="command-output" class="bg-dark text-white p-3 rounded"></pre>
</div>
</div>
</div>
<!-- Bootstrap JS and dependencies -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
document.getElementById('execute').addEventListener('click', function () {
const command = document.getElementById('command').value;
if (!command) {
alert('Por favor, introduce un comando.');
return;
}
const url = 'http://www.vh7.lan/controller.php'; // Asegúrate de que la URL esté correcta
const postData = { command: command };
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(postData)
})
.then(response => response.json())
.then(data => {
const outputElement = document.getElementById('command-output');
outputElement.innerHTML = data.output ? data.output.join('\n') : "Error ejecutando el comando";
if (data.status === 'error') {
outputElement.classList.add('bg-danger');
} else {
outputElement.classList.add('bg-success');
}
})
.catch(error => console.error('Error en la solicitud POST:', error));
});
</script>
</body>
</html>