1 Star 0 Fork 10

Ya-haha/migration-tools-src

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
100-CVE-2024-24892.patch 2.75 KB
一键复制 编辑 原始数据 按行查看 历史
From 27f65f5c5e38b6d0cee28db3591784266a47de9e Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Tue, 12 Mar 2024 10:42:07 +0800
Subject: [PATCH] CVE-2024-24892
---
index.py | 50 ++++++++++++++++++++++++++++++++------------------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/index.py b/index.py
index 239148e..f604fc2 100644
--- a/index.py
+++ b/index.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: MulanPubL-2.0-or-later
import os
import json
+import paramiko
from func import share
from urls import server_mods
from flask import Flask, render_template, request, Response
@@ -202,29 +203,42 @@ def export_migration_reports():
:return:
"""
mod = check_methods()
- f = open("/usr/lib/migration-tools-server/.passwd.txt", "r")
- password = f.read()
- f.close()
if mod:
data = request.get_data()
json_data = json.loads(data)
- mkdir_log_pwd = "/var/uos-migration/"
- isExists=os.path.exists(mkdir_log_pwd)
- if not isExists:
- try:
- os.makedirs(mkdir_log_pwd)
- print(mkdir_log_pwd)
- except:
- print("export report mkdir error:%s" % mkdir_log_pwd)
-
+ user = json_data.get('info').split("|")[0]
info = mod.split(',')
- scp_log = "sshpass -p '%s'" % password + " scp -r %s" % json_data.get('info').split("|")[0] + "@%s" % info[1] \
- + ":/var/tmp/uos-migration/UOS*.tar.gz /var/uos-migration/"
+ ip = info[1].strip('"')
+ port = 22
+
+ with open("/usr/lib/migration-tools-server/.passwd.txt", "r") as f:
+ password = f.read()
+
+ remote_dir = local_dir = "/var/tmp/uos-migration"
+ if not os.path.exists(local_dir):
+ os.makedirs(local_dir)
+
+ client = paramiko.SSHClient()
+ client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
- os.system(scp_log)
- print(scp_log)
- except:
- print('export report scp error:%s' % scp_log)
+ client.connect(ip, port, user, password)
+ sftp = client.open_sftp()
+
+ remote_files = sftp.listdir(remote_dir)
+ # 遍历远程文件列表
+ for filename in remote_files:
+ if filename.endswith('.tar.gz'):
+ remote_file_path = os.path.join(remote_dir, filename)
+ local_file_path = os.path.join(local_dir, filename)
+ sftp.get(remote_file_path, local_file_path)
+
+ except Exception as e:
+ print(f"Error: {e}")
+
+ finally:
+ # 关闭连接
+ if client:
+ client.close()
return Response(mod, content_type='application/json')
--
2.41.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xuezhizone/migration-tools-src.git
git@gitee.com:xuezhizone/migration-tools-src.git
xuezhizone
migration-tools-src
migration-tools-src
master

搜索帮助