Skip to content

Commit

Permalink
CheungSSH Web 2.2.2.4
Browse files Browse the repository at this point in the history
更新鲜内容:
1 脚本执行
2 界面优化
  • Loading branch information
zhangqichuan committed Nov 18, 2015
1 parent b2286c5 commit 2fef2b4
Show file tree
Hide file tree
Showing 15 changed files with 253 additions and 140 deletions.
55 changes: 55 additions & 0 deletions bin/auth.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
-- MySQL dump 10.13 Distrib 5.1.73, for redhat-linux-gnu (x86_64)
--
-- Host: localhost Database: cheungssh
-- ------------------------------------------------------
-- Server version 5.1.73-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `auth_permission`
--

DROP TABLE IF EXISTS `auth_permission`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `auth_permission` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`content_type_id` int(11) NOT NULL,
`codename` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `content_type_id` (`content_type_id`,`codename`),
KEY `auth_permission_e4470c6e` (`content_type_id`)
) ENGINE=MyISAM AUTO_INCREMENT=56 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `auth_permission`
--

LOCK TABLES `auth_permission` WRITE;
/*!40000 ALTER TABLE `auth_permission` DISABLE KEYS */;
INSERT INTO `auth_permission` VALUES (25,'可执行命令',8,'excute_cmd'),(26,'查看命令历史',8,'show_cmd_history'),(27,'查看操作记录',8,'show_access_page'),(28,'允许从PC上传文件和密钥',8,'local_file_upload'),(29,'允许PC下载文件',8,'local_file_download'),(30,'远程文件上传',8,'transfile_upload'),(31,'远程文件下载',8,'transfile_download'),(32,'查看文件传输记录',8,'transfile_history_show'),(33,'查看计划任务',8,'crond_show'),(34,'删除计划任务',8,'crond_del'),(35,'创建计划任务',8,'crond_create'),(36,'秘钥上传',8,'transfile_keyfile'),(37,'删除秘钥',8,'key_del'),(38,'查看秘钥',8,'key_list'),(39,'创建服务器',8,'config_add'),(40,'删除服务器',8,'config_del'),(41,'修改服务器',8,'config_modify'),(42,'查看脚本内容',8,'scriptfile_show'),(43,'创建脚本',8,'scriptfile_add'),(44,'删除脚本',8,'scriptfile_del'),(45,'显示脚本清单',8,'scriptfile_list'),(46,'批量从web创建服务器',8,'batchconfig_web'),(47,'添加命令黑名单',8,'addblackcmd'),(48,'删除命令黑名单 ',8,'delblackcmd'),(49,'查看命令黑名单',8,'listblackcmd');
/*!40000 ALTER TABLE `auth_permission` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2015-11-17 20:57:44
105 changes: 6 additions & 99 deletions bin/cheungssh.sql
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ CREATE TABLE `auth_permission` (
PRIMARY KEY (`id`),
UNIQUE KEY `content_type_id` (`content_type_id`,`codename`),
KEY `auth_permission_e4470c6e` (`content_type_id`)
) ENGINE=MyISAM AUTO_INCREMENT=63 DEFAULT CHARSET=utf8;
) ENGINE=MyISAM AUTO_INCREMENT=56 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
Expand All @@ -90,7 +90,7 @@ CREATE TABLE `auth_permission` (

LOCK TABLES `auth_permission` WRITE;
/*!40000 ALTER TABLE `auth_permission` DISABLE KEYS */;
INSERT INTO `auth_permission` VALUES (25,'可执行命令',8,'excute_cmd'),(26,'执行脚本',8,'excutescript'),(27,'查看命令历史',8,'show_cmd_history'),(28,'查看操作记录',8,'show_access_page'),(29,'允许从PC上传文件',8,'local_file_upload'),(30,'允许PC下载文件',8,'local_file_download'),(31,'远程文件上传',8,'transfile_upload'),(32,'远程文件下载',8,'transfile_download'),(33,'查看文件传输记录',8,'transfile_history_show'),(34,'查看计划任务',8,'crond_show'),(35,'删除计划任务',8,'crond_del'),(36,'创建命令任务',8,'crond_create_cmd'),(37,'创建远程文件下载任务',8,'crond_create_transfile_download'),(38,'创建远程文件上传任务',8,'crond_create_transfile_upload'),(39,'秘钥上传',8,'transfile_keyfile'),(40,'删除秘钥',8,'key_del'),(41,'创建服务器',8,'config_add'),(42,'删除服务器',8,'config_del'),(43,'修改服务器',8,'config_modify'),(44,'查看服务器配置',8,'config_show'),(45,'查看脚本内容',8,'scriptfile_show'),(46,'创建脚本',8,'scriptfile_add');
INSERT INTO `auth_permission` VALUES (25,'可执行命令',8,'excute_cmd'),(26,'查看命令历史',8,'show_cmd_history'),(27,'查看操作记录',8,'show_access_page'),(28,'允许从PC上传文件和密钥',8,'local_file_upload'),(29,'允许PC下载文件',8,'local_file_download'),(30,'远程文件上传',8,'transfile_upload'),(31,'远程文件下载',8,'transfile_download'),(32,'查看文件传输记录',8,'transfile_history_show'),(33,'查看计划任务',8,'crond_show'),(34,'删除计划任务',8,'crond_del'),(35,'创建计划任务',8,'crond_create'),(36,'秘钥上传',8,'transfile_keyfile'),(37,'删除秘钥',8,'key_del'),(38,'查看秘钥',8,'key_list'),(39,'创建服务器',8,'config_add'),(40,'删除服务器',8,'config_del'),(41,'修改服务器',8,'config_modify'),(42,'查看脚本内容',8,'scriptfile_show'),(43,'创建脚本',8,'scriptfile_add'),(44,'删除脚本',8,'scriptfile_del'),(45,'显示脚本清单',8,'scriptfile_list'),(46,'批量从web创建服务器',8,'batchconfig_web'),(47,'添加命令黑名单',8,'addblackcmd'),(48,'删除命令黑名单 ',8,'delblackcmd'),(49,'查看命令黑名单',8,'listblackcmd');
/*!40000 ALTER TABLE `auth_permission` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -124,7 +124,7 @@ CREATE TABLE `auth_user` (

LOCK TABLES `auth_user` WRITE;
/*!40000 ALTER TABLE `auth_user` DISABLE KEYS */;
INSERT INTO `auth_user` VALUES (1,'cheungssh','','','[email protected]','pbkdf2_sha256$10000$2obbA1GVker0$LWWHjMUhRz8AMiaL1hx4OrXsIMHmBxLaz5FctAnYz5U=',1,1,1,'2015-11-11 03:25:34','2015-11-11 02:10:38');
INSERT INTO `auth_user` VALUES (1,'cheungssh','','','[email protected]','pbkdf2_sha256$10000$7xYyP8wYDPue$HbY1e0r1cSKVNgTukPmrFSbtpFs7F5aTykgggxt5S98=',1,1,1,'2015-11-17 12:53:38','2015-11-17 12:53:38');
/*!40000 ALTER TABLE `auth_user` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -332,73 +332,6 @@ LOCK TABLES `django_admin_log` WRITE;
/*!40000 ALTER TABLE `django_admin_log` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `django_comment_flags`
--

DROP TABLE IF EXISTS `django_comment_flags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `django_comment_flags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`comment_id` int(11) NOT NULL,
`flag` varchar(30) NOT NULL,
`flag_date` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`,`comment_id`,`flag`),
KEY `django_comment_flags_fbfc09f1` (`user_id`),
KEY `django_comment_flags_9b3dc754` (`comment_id`),
KEY `django_comment_flags_111c90f9` (`flag`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `django_comment_flags`
--

LOCK TABLES `django_comment_flags` WRITE;
/*!40000 ALTER TABLE `django_comment_flags` DISABLE KEYS */;
/*!40000 ALTER TABLE `django_comment_flags` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `django_comments`
--

DROP TABLE IF EXISTS `django_comments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `django_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content_type_id` int(11) NOT NULL,
`object_pk` longtext NOT NULL,
`site_id` int(11) NOT NULL,
`user_id` int(11) DEFAULT NULL,
`user_name` varchar(50) NOT NULL,
`user_email` varchar(75) NOT NULL,
`user_url` varchar(200) NOT NULL,
`comment` longtext NOT NULL,
`submit_date` datetime NOT NULL,
`ip_address` char(15) DEFAULT NULL,
`is_public` tinyint(1) NOT NULL,
`is_removed` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `django_comments_e4470c6e` (`content_type_id`),
KEY `django_comments_6223029` (`site_id`),
KEY `django_comments_fbfc09f1` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `django_comments`
--

LOCK TABLES `django_comments` WRITE;
/*!40000 ALTER TABLE `django_comments` DISABLE KEYS */;
/*!40000 ALTER TABLE `django_comments` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `django_content_type`
--
Expand All @@ -413,7 +346,7 @@ CREATE TABLE `django_content_type` (
`model` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `app_label` (`app_label`,`model`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
Expand All @@ -422,7 +355,7 @@ CREATE TABLE `django_content_type` (

LOCK TABLES `django_content_type` WRITE;
/*!40000 ALTER TABLE `django_content_type` DISABLE KEYS */;
INSERT INTO `django_content_type` VALUES (1,'permission','auth','permission'),(2,'group','auth','group'),(3,'user','auth','user'),(4,'content type','contenttypes','contenttype'),(5,'session','sessions','session'),(6,'cors model','corsheaders','corsmodel'),(7,'main_ conf','cheungssh','main_conf'),(8,'server conf','cheungssh','serverconf'),(9,'server info','cheungssh','serverinfo'),(10,'comment','comments','comment'),(11,'comment flag','comments','commentflag'),(12,'site','sites','site'),(13,'log entry','admin','logentry');
INSERT INTO `django_content_type` VALUES (1,'permission','auth','permission'),(2,'group','auth','group'),(3,'user','auth','user'),(4,'content type','contenttypes','contenttype'),(5,'session','sessions','session'),(6,'cors model','corsheaders','corsmodel'),(7,'main_ conf','cheungssh','main_conf'),(8,'server conf','cheungssh','serverconf'),(9,'server info','cheungssh','serverinfo'),(10,'log entry','admin','logentry');
/*!40000 ALTER TABLE `django_content_type` ENABLE KEYS */;
UNLOCK TABLES;

Expand All @@ -448,34 +381,8 @@ CREATE TABLE `django_session` (

LOCK TABLES `django_session` WRITE;
/*!40000 ALTER TABLE `django_session` DISABLE KEYS */;
INSERT INTO `django_session` VALUES ('8e0a42f6090b2aa0b4c9cde5bb5b92b2','ZWUwZTllMGQ2NDkzYjcxMTVmNWRkZmI1MTg5YjVlOTE3NDQ4Y2NhNzqAAn1xAShVEl9hdXRoX3Vz\nZXJfYmFja2VuZHECVSlkamFuZ28uY29udHJpYi5hdXRoLmJhY2tlbmRzLk1vZGVsQmFja2VuZHED\nVQ1fYXV0aF91c2VyX2lkcQSKAQF1Lg==\n','2015-11-25 03:25:34');
/*!40000 ALTER TABLE `django_session` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `django_site`
--

DROP TABLE IF EXISTS `django_site`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `django_site` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain` varchar(100) NOT NULL,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `django_site`
--

LOCK TABLES `django_site` WRITE;
/*!40000 ALTER TABLE `django_site` DISABLE KEYS */;
INSERT INTO `django_site` VALUES (1,'example.com','example.com');
/*!40000 ALTER TABLE `django_site` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
Expand All @@ -486,4 +393,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2015-11-11 11:27:03
-- Dump completed on 2015-11-17 20:57:03
22 changes: 11 additions & 11 deletions bin/install-CheungSSH.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#coding:utf-8
V=2.0.1
#如果您在使用过程中,遇到了一点点的问题,我都真诚希望您能告诉我!为了改善这个软件, 方便您的工作#
#############################################################################

cat <<EOFshow
CheungSSH环境安装如下:
os: centos 5系列
Expand Down Expand Up @@ -33,7 +33,7 @@ pycrypto-on-pypi
mod_python
EOFshow
read -p '请知悉以上,然后按Enter继续...'
#############################################################################

export LANG=zh_CN.UTF-8
if [ `id -u` -ne 0 ]
then
Expand Down Expand Up @@ -230,7 +230,7 @@ EOFparamiko
###
##############安装redis
echo "正在安装redis服务器"
tar xvf /home/cheungssh/soft/redis-3.0.4.tar.gz -C /home/cheungssh/ &&
cd /home/cheungssh/redis-3.0.4 && make
Expand All @@ -239,7 +239,7 @@ EOFparamiko
echo "安装redis服务器失败了,请检查原因"
exit 1
fi
##############安装redis
read -p 'CheungSSH需要数据库支持, 您是否有可用的Mysql服务器? (yes/no) ' emysql
emysql=${emysql:-y}
Expand Down Expand Up @@ -330,7 +330,7 @@ EOF
else
echo "初始化数据库完成"
fi
########3
APXS=`which apxs`
APXS=${APXS:-/usr/sbin/apxs}
if [ ! -f $APXS ]
Expand All @@ -350,14 +350,14 @@ EOF
echo "安装mod_python失败,请检查原因"
exit 1
fi
##########
/bin/cp /home/cheungssh/conf/version.py $(dirname `find /usr/lib*/python*/site-packages/mod_python -type f -name version.py`)
if [ $? -ne 0 ]
then
echo "修改mod_python失败,请检查原因"
exit 1
fi
##########
/bin/cp /home/cheungssh/conf/httpd.conf /etc/httpd/conf/httpd.conf
if [ $? -ne 0 ]
then
Expand All @@ -371,7 +371,7 @@ EOF
echo "修改配置失败,请检查原因"
exit 1
fi
########3
chown -R root.cheungssh /etc/httpd/ 2>/dev/null
chown -R cheungssh.cheungssh /home/cheungssh
if [ $? -ne 0 ]
Expand All @@ -397,9 +397,9 @@ EOF
启动CheungSSH服务: /home/cheungssh/bin/cheungssh-service.sh start"
###
exit
###############################################yum安装
}
#####################
update(){
cp_file
Expand Down Expand Up @@ -446,7 +446,7 @@ EOF
echo "连接数据库错误,请检查原因,端口, 密码, IP是否正确?您是否已经有Mysql服务器?"
exit 1
fi
mysql -uroot -h${mip} -u${musername} -p${mpassword} -P${mp} cheungssh < /home/cheungssh/bin/cheungssh.sql
mysql -uroot -h${mip} -u${musername} -p${mpassword} -P${mp} cheungssh < /home/cheungssh/bin/auth.sql
if [ $? -ne 0 ]
then
echo "初始化数据库失败,请检查原因"
Expand Down
14 changes: 7 additions & 7 deletions bin/install-CheungSSH.sh.local
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ then
echo "安装失败,请检查原因或者联系CheungSSH"
exit 1
fi
tar xvf /home/cheungssh/soft/redis-3.0.4.tar.gz -C /home/cheungssh/ &&
cd /home/cheungssh/redis-3.0.4 && make
if [ $? -ne 0 ]
then
echo "安装redis服务器失败了,请检查原因"
exit 1
fi

cd /home/cheungssh/soft/ &&
tar xvf django-redis-cache-1.6.3.tar.gz &&
Expand Down Expand Up @@ -201,13 +208,6 @@ then
fi


tar xvf /home/cheungssh/soft/redis-3.0.4.tar.gz -C /home/cheungssh/ &&
cd /home/cheungssh/redis-3.0.4 && make
if [ $? -ne 0 ]
then
echo "安装redis服务器失败了,请检查原因"
exit 1
fi

while [ 1 ]
do
Expand Down
3 changes: 1 addition & 2 deletions mysite/mysite/cheungssh/FileTransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ def DownFile(dfile,sfile,username,password,ip,port,su,supassword,sudo,sudopasswo
cache_translog=cache.get("translog")
print "抓取到异常...",e
logline["result"]=msg
finally:
sftp.close()




Expand Down
14 changes: 7 additions & 7 deletions mysite/mysite/cheungssh/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#coding:utf-8
from django.contrib import admin
from mysite.cheungssh.models import * #到处数据库表
from mysite.cheungssh.models import *








class ServerConf_admin(admin.ModelAdmin):
list_display=('IP','Port','Group','Username','Password','Su')
class ServerInfo_admin(admin.ModelAdmin):
list_display=('IP','Description',)
admin.site.register(ServerConf,ServerConf_admin)
admin.site.register(ServerInfo,ServerInfo_admin)
25 changes: 25 additions & 0 deletions mysite/mysite/cheungssh/black_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#coding:utf-8
from django.core.cache import cache
from django.http import HttpResponse
import re,json
def black_cmd_check(func):
def wrapper_back_cmd(request,*args,**kws):
info={'msgtype':'ERR'}
servers=request.GET.get('cmd')
black_cmd_list=cache.get('black.cmd.list')
try:
servers=eval(servers)
cmd=servers['cmd']
except Exception,e:
cmd=''
if black_cmd_list is None:black_cmd_list=[]
t_cmd=re.sub('^ *| *$','',cmd)
t_cmd=re.sub(' +','_',t_cmd)
for c in black_cmd_list:
if re.search(c['cmd'],t_cmd) and not request.user.is_superuser:
info['content']='该命令已被阻止 并且被审计!'
info=json.dumps(info,encoding='utf-8',ensure_ascii=False)
return HttpResponse(info)
return func(request,*args,**kws)
return wrapper_back_cmd

Loading

0 comments on commit 2fef2b4

Please sign in to comment.