Git Product home page Git Product logo

cksgf / servermanagement Goto Github PK

View Code? Open in Web Editor NEW
600.0 19.0 208.0 5.06 MB

服务器管理工具,目前有文件管理器、进程监控、计划任务、webSSH、多主机管理等,准备在自己服务器上用,后续会加入更多运维相关,本项目后端python+flask,前端使用layui+jquery,代码在线编辑使用codemirror,webSSH后端使用paramiko前端xterm

Python 87.24% Shell 11.77% PHP 0.63% C 0.36%

servermanagement's Introduction

ServerManagement Python3.4+

服务器管理工具,目前有文件管理器、进程监控、计划任务、webSSH、多主机管理、本地桌面、内网穿透等,后续会加入更多运维相关,本项目后端python+flask
更新日志

功能介绍

1.文件管理

兼容windows和linxu的文件管理器,目前有文件的批量压缩、下载、重命名、文件内容在线编辑等.
文件管理器中进行下载时,若下载的是文件,将会直接下载,若为目录,则会压缩为zip后下载
文件后缀为.zip,.gz,.tar的,可以在线解压
可对文件进行分享,提供一个类似简易网盘的功能
并提供一个批量文件操作的按钮,支持跨文件夹操作,后续可能会加入更多功能
其余界面 其余界面 其余界面 其余界面

2.进程监控

显示CPU、内存、磁盘状态,并实时显示网速
同时显示了进程以及网络进程,点击进程名可以查看进程详细信息
其余界面 其余界面

3.计划任务

可以设定以秒为单位的循环执行,也可以设定规则,如每周三的12:50:30,每月的23号15:30:00
其余界面

4.shell

一个是个比较low的webSSH,最近可能没时间去完善这一块
还有一个是多主机批量执行shell,支持root身份运行(目前很简陋,后续会添加更多功能)
其余界面 其余界面 其余界面 其余界面

5.资源监控

本质上就是一个定时储存服务器资源使用情况的定时任务,前端请求到储存的数据后解析,最后用echarts生成折线图,为了尽量少的占用服务器资源,解析操作都是在网页前端进行的。
其余界面

6.便捷操作

现在只有一个快捷按钮的功能,就是可以自行设定一个常用的shll,方便快速调用,执行前可以做出修改,未来会加入其他我的脑洞...
其余界面 其余界面 其余界面

7.本地桌面

此功能仅限windows可用 其余界面

8.内网穿透

选用功能,将项目下server.zip解压并在有外网IP的服务器上运行,在本地服务器管理工具运行时修改配置(外网服务器需要开启80端口,10000-20000端口,其中80端口为综合管理平台,可以查看所有的连接设备,可以查看其绑定的外网IP+端口,10000-20000端口为内网穿透的绑定端口),即可实现内网穿透,在有外网IP的服务端上一键查看所有连接设备,后续会加入查看所有服务器实时状态等功能 其余界面

9.软件管理

仅在LINUX可用,以添加nginx一键安装配置(支持ubuntu及centos,使用ubuntu的同学使用之前记得更新apt源,推荐使用中科大apt源) 其余界面 其余界面

使用说明

运行本项目需要自行pip安装flask,chardet,datetime, paramiko,pillow,psutil,pyautogui

或在目录下 python3 -m pip -r install requirements.txt

以Ubuntu为例: 先安装python环境
apt install python3
apt install python3-pip
然后安装依赖库
python3 -m pip install flask paramiko pillow datetime chardet pautil
最后进入项目运行就行了
python3 index.py
如果你是windows,记得还需要pip install pyautogui

本项目后端给前端传值全部使用json,前端用jq处理、发送请求并生成最终页面

其中的文件管理器部分前端给后端传值,大部分采用base64编码

使用前切记修改config/config

如果你觉得我做的还可以,请给我个star,它将支持我继续优化及添加更多功能

servermanagement's People

Contributors

cksgf avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

servermanagement's Issues

文件权限存在bug

修改文件权限时,一般情况下都是输入(777,666)等文件权限位,但这应该是用的8进制,后台用int进行转换变成了10进制,输入777后权限变成了411,因此需要把route/file.py第158行改为:
os.chmod(fileName,int(power, 8)),这样就可以达到预期权限。

[Security] Path Traversal Vulnerability found

A path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files. It should be noted that access to files is limited by system operational access control (such as in the case of locked or in-use files on the Microsoft Windows operating system).

This attack is also known as “dot-dot-slash”, “directory traversal”, “directory climbing” and “backtracking”.

Root Cause Analysis

In this case, the path traversal vulnerability can be blamed on incorrect usage of the send_from_directory Flask call. The vulnerability occurs due to the code snippet shown below

@app.route('/DownFile',methods=['GET','POST'])
@cklogin()
def DownFile():
fileName = request.values.get('filename')
fileName = b64decode_(fileName)
if os.path.isdir(fileName):
result = zip_(fileList=[fileName],zipPath=os.path.split(fileName)[0])
if result[0] :
fileName = result[1]
else:
return json.dumps({'resultCode':1,'fileCode':str(e)})
response = make_response(send_from_directory(os.path.split(fileName)[0],os.path.split(fileName)[1],as_attachment=True))

Here, since the filename parameter is attacker controlled, the effective directory and filename passed to the send_from_directory call can be controlled by the attacker leading to a path traversal attack.

Proof of Concept

The bug can be verified using the proof of concept similar to the one shown below.

curl -i -s -k -X $'GET' \
    -H $'Host: 0.0.0.0:9001' -H $'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0' -H $'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H $'Accept-Language: en-US,en;q=0.5' -H $'Accept-Encoding: gzip, deflate' -H $'Connection: close' -H $'Upgrade-Insecure-Requests: 1' \
    -b $'session=eyJwYXNzd29yZCI6IndlbnJ1aSIsInNlY2VjdExpc3QiOiJbXSIsInVzZXJuYW1lIjoiYWRtaW4ifQ.FC1IVA.B3HWw42zgF_CltmVq0wm0N64vYQ' \
    $'http://0.0.0.0:9001/DownFile?filename=L2V0Yy9wYXNzd2Q='

Remediation

This can be easily fixed my restricting the value of file and path parameters by a fixed whitelist of possible values.

CVSS 3 Score

CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

This bug was found using CodeQL by Github

AttributeError: module 'gssapi' has no attribute 'GSSException'

[root@rcrai-devops-01 ServerManagement]# python3 index.py
Traceback (most recent call last):
File "index.py", line 9, in
from route.login import cklogin
File "/root/zbl/www/ServerManagement/route/init.py", line 7, in
from .webssh import *
File "/root/zbl/www/ServerManagement/route/webssh.py", line 1, in
from paramiko import *
File "/usr/local/lib/python3.6/site-packages/paramiko/init.py", line 22, in
from paramiko.transport import SecurityOptions, Transport
File "/usr/local/lib/python3.6/site-packages/paramiko/transport.py", line 38, in
from paramiko.auth_handler import AuthHandler
File "/usr/local/lib/python3.6/site-packages/paramiko/auth_handler.py", line 72, in
from paramiko.ssh_gss import GSSAuth, GSS_EXCEPTIONS
File "/usr/local/lib/python3.6/site-packages/paramiko/ssh_gss.py", line 55, in
GSS_EXCEPTIONS = (gssapi.GSSException,)

请教一下进程管理细节

自己分别弄了文件系统和进程管理平台 https://github.com/yddeng/amp https://github.com/yddeng/filecloud

主要是为了进程管理,现在项目有多种服务类型每个类型多个副本。想着弄一个管理平台方便一点。

  1. 新的程序怎么同步?多个版本怎么更新和回滚? 我现在是本地用脚本上传到每个服务器的指定目录直接覆盖了原有文件,没有上传功能和版本控制。之前单台服务器打算用文件系统上传但发现上传后的程序丢失执行权限,又服务器增多就还是自己写脚本上传的。
  2. 能不能控制程序使用的物理机资源? 研究了一段时间k8s,有这个功能。但是搭建环境太麻烦了,而且网络环境也复杂
  3. 查看进程的日志? 程序都有自定义的日志输出,怎么在平台上查看日志。

分享文件下载报错

你好,请问下分享文件下载报错nternal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
image
是什么yuany原因 还望解答

依赖库

有没有 安装版本的清单 或者怎么联系你

后台登录有验证码验证吗

你好 能来一个后台登录页面截图吗 还有首页截图
后台登录支持验证码验证吗?
我最近也在学习django 我能拿来二次开发吗

运行报错

Traceback (most recent call last):
File "/home/leo/桌面/ServerManagement/index.py", line 2, in
import flask
File "/home/leo/桌面/ServerManagement/venv/lib/python3.8/site-packages/flask/init.py", line 19, in
from jinja2 import Markup, escape
ImportError: cannot import name 'Markup' from 'jinja2' (/home/leo/桌面/ServerManagement/venv/lib/python3.8/site-packages/jinja2/init.py)

0.0.0.0怎么改

对于0.0.0.0怎么处理呢,需要自己买一个服务器吗

demo

能够提供一个demo网址吗

docker

add a Dockerfile to support
containerization

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.