【星海出品】前端和后端交互的python EEL小技巧

前端和后端的交互

前端基础功能主要分为两大类

展示上实现以下几个功能
1。【显示或隐藏 哪些id或者class或者自定义的域】
2。【哪些id或者class展示的背景板颜色】
3。【哪些id或者class展示的决定位置】
4。【图标对应的位置】
5。【高级功能,样式调整CSS等】

功能上实现
1。【ID与某个输入框绑定】
2。【触发按钮,触发后,获取某个输入框内的内容并下发到后端某个函数】
3。【获取一个远端的信息,并展示出来】

具体还有其他的比如生命周期,xml dom调整等。这里暂不展开。主要为基础功能的纪录文档

以下先展示一个开源项目的魔改demo

由开源项目改编

HTML

<html>
# 控制网页在移动设备上的布局。确保网页的宽度与设备的宽度相同,并且初始缩放比例为1(即不缩放)。
# 引入外部样式表。
# 用 eel 实现内外部的沟通。
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css/styles.css">
    <link rel="stylesheet" href="css/plugins.css">
    <link rel="icon" type="image/png" href="/logo.ico" />
    <script type="text/javascript" src="/eel.js"></script>
    <script type="text/javascript" src="js/scripts.js"></script>
    <title>GOD</title>
  </head>
 
 # 样式设置为锁死,没有鼠标滚动功能
 # 相对于浏览器窗口定位,而不是文档流中的其他元素。并将该部分文本透明。
 # 修改该部分文本参见 2.1功能文档
  <body>
    <div class="build-number" id="buildNumber" style="position: fixed;bottom: 10px;right: 10px;color: rgba(255, 255, 255, 0.1); /* Almost invisible color */font-size: 12px;user-select: none;"></div>
    <div id="notification-container" style="position:fixed;pointer-events:none;"></div>
    <div id="loading-spin">
      <div id="loading-spinner"></div>
    </div>
    
    <div class="loading-screen">
      <div class="loading-bar">
        <div class="loading-bar-fill"></div>
      </div>
      <div class="loading-message">Loading god...</div>
    </div>

# 这部分展示了背景板

    <div class="navbar" id="navbar" style="left: -310px;">
      <div onclick="navto('home')" class="btn sebtn" style="background-image: url('feather/home.svg');background-size: 24px 24px;background-repeat: no-repeat;background-position: 10px center;">Home</div>
      <div onclick="navto('pyshell')" class="btn" style="background-image: url('feather/terminal.svg');background-size: 24px 24px;background-repeat: no-repeat;background-position: 10px center;">PyShell</div>
      <div onclick="navto('setup')" class="btn" style="background-image: url('feather/info.svg');background-size: 24px 24px;background-repeat: no-repeat;background-position: 10px center;">Setup</div>
      <div onclick="navto('about')" class="btn" style="background-image: url('feather/info.svg');background-size: 24px 24px;background-repeat: no-repeat;background-position: 10px center;">About</div>
    </div>
    <div class="menulol-container" id="menulol" style="left: 20px;">
      <div class="menulol">&#9776;</div>
    </div>
    <div class="content-container">

      <section id="winAPIhooking" class="center hidden">
        <h1>Behavior Monitoring</h1>
        <div class="frame" style="position: absolute; top: 120px;left:500px; width:400px; height:360px;">
          <h1> Output: <button onclick="document.getElementById('outputwinapihooks').select(); document.execCommand('copy');createnotification('success', 'Copied');" style="margin-left: 150px;" class="btns">Copy Output</button></h1>
          <textarea class="scroll-box" id="outputwinapihooks" style="height:250px;width: 380px;font-family: 'Share Tech Mono', monospace; resize:none;outline: none;"></textarea>
        </div>
      <div style="position: absolute; top: 120px; left: 50px; width: 350px; height: 150px;">
        <div class="checkbox-container">
          <label for="MFBOX">Monitor Files:</label>
          <input type="checkbox" id="MFBOX">
        </div>
        <div class="checkbox-container">
          <label for="MPBOX">Monitor Processes:</label>
          <input type="checkbox" id="MPBOX">
        </div>
        <div class="checkbox-container">
          <label for="MCBOX">Monitor Connections:</label>
          <input type="checkbox" id="MCBOX">
          <label for="MCDUMPBOX">Dump Socket:</label>
          <input type="checkbox" id="MCDUMPBOX">
        </div>
        <div class="checkbox-container">
          <label for="SSL">Dump OpenSSL Encrypted traffic:</label>
          <input type="checkbox" id="SSLBOX">
        </div>
        <div class="checkbox-container">
          <label for="PYCDUMB">PYC dumper:</label>
          <input type="checkbox" id="PYCDUMB">
        </div>
        <br>
        <button class="btns" onclick="navto('pyshell')">Back to PyShell menu</button>
      </div>
      </section>

      <section id="home" class="center active">
        <h1>GOD home</h1>
        <div class="frame" style="position: absolute; top: 120px;left:100px; width:300px; ">
          <h1>Change LOG</h1>
          <div style="max-height:250px;" id="changeLog" class="scroll-box"></div>
        </div>
        <div class="frame" style="position: absolute; top: 120px;left:600px; width:300px; ">
          <h1>Environment info</h1>
          <ul>
            <li>Python version: <span id="pv">{NULL}</span>
            </li>
            <li>Arch: <span id="arch">{NULL}</span>
            </li>
            <li>Operating System: <span id="os">{NULL}</span>
            </li>
          </ul>
        </div>
        <div class="frame" style="position: absolute; top: 320px;left:600px; width:300px; ">
          <div class="clock-container">
            <div class="clock" id="clock">Loading...</div>
          </div>
        </div>
      </section>


      <section id="pyshell" class="center hidden">
        <h1>GOD pyshell</h1>
        <div class="frame" style="position: absolute; top: 120px; left: 50px; width: 350px; height: 85px;">
          <label for="pidinput">Target pid:</label>
          <input type="text" id="pidinput" class="custom-input">
          <div style="text-align: center;">
            <button style="margin-top: 15px; margin-left: 10px;" class="btns" onclick="injectpyshell('normal')">Inject</button>
            <button style="margin-top: 15px; margin-left: 10px;" class="btns" onclick="injectpyshell('stealth')">Stealth Inject</button>
        </div>
        </div>

        <div class="frame" style="position: absolute; top: 270px; left: 50px; width: 890px; height: 240px; padding:0px;">
          <h1 style="margin-left:390px;">Commands</h1>
          <div style="padding-left: 40px;">
            <button class="btns" onclick="exec_command('ExecPY')">exec py code</button>
          </div>
          <div style="padding-left: 40px;margin-top: 20px;">
            <button class="btns" onclick="exec_command('PyshellGUI')">Pyshell (tkinter GUI)</button>
          </div>
          <div style="padding-left: 40px;margin-top: 20px;">
            <button class="btns" onclick="exec_command('GetAnalyzerHandle')">Behavior Monitoring</button>
          </div>
        </div>

        <div class="frame" style="position: absolute; top: 120px;left:500px; width:400px; height:85px;">
          <h3>Output:</h3>
          <textarea class="scroll-box" id="outputPYSHELL" style="height:5px;width: 380px;font-family: 'Share Tech Mono', monospace; resize:none;outline: none;overflow:hidden;"></textarea>
        </div>
        <div id="IDKWHATSHOULDINAMEIT" style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;backdrop-filter: blur(5px);background-color: rgba(0, 0, 0, 0.5);z-index: 9999;display:none;">
          <div style="padding-left: 800px;margin-top: 50px;">
            <button class="btns" onclick="pid_widget(0)">X</button>
          </div>
          <div class="frame" style="position: absolute; top: 120px;left:300px; width:400px; height:100px">
            <label for="scpid">Target pid:</label>
            <input type="text" id="scpid" class="custom-input">
            <div style="padding-left: 100px;margin-top: 30px;">
              <button class="btns" onclick="exec_command('ShowConsole')">unhide console</button>
            </div>
          </div>
        </div>
      </section>


      <section id="setup" class="center hidden">
        <h1>SetUp</h1>
        <div class="frame" style="position: absolute; top: 120px;left:100px; width:300px; ">
          <div class="clock-container">
            <div id="display">Remote Host Window</div>
          </div>
        </div>

        <div class="frame" style="position: absolute; top: 240px;left:100px; width:300px; ">
          <h1>Input CMD</h1>
          <label for="pidinput">Target cmd:</label>
          <input type="text" id="inputcmd" class="custom-input">
          <div style="text-align: center;">
            <button style="margin-top: 15px; margin-left: 10px;" class="btns" onclick="injectpyshell('normal')">Submit</button>
            <button style="margin-top: 15px; margin-left: 10px;" class="btns" onclick="injectpyshell('stealth')">Recovery</button>
          </div>
        </div>

        <div class="frame" style="position: absolute; top: 120px;left:600px; width:300px; ">
          <h1>Change LOG</h1>
          <div style="max-height:250px;" id="watching" class="scroll-box"></div>
        </div>
      </section>

      <section id="about" class="center hidden">
        <div class="about-info frame">
          <h1>About</h1>
          <p>GitHub: <a href="https://github.com/fadi002" target="_blank">fadi002</a>
          <p>GitHub: <a href="https://github.com/AdvDebug" target="_blank">Advdebug</a>
          </p>
          <p>Discord: @0xmrpepe, @advdebug</p>
        </div>
      </section>
    </div>
  </body>
</html>

2.1功能文档

设置生命周期

document.addEventListener('DOMContentLoaded', async function() {
	document.getElementById("buildNumber").innerText = (await eel.get_config()()).__BUILD_NUM__;
});
生命周期设置为调度后进行加载
document.addEventListener('DOMContentLoaded', async function() {
    const menuToggle = document.getElementById('menulol');

    menuToggle.addEventListener('click', function() {
        navbar.style.left = (navbar.style.left === '0px' || navbar.style.left === '') ? '-310px' : '0px';
        menuToggle.style.left = (navbar.style.left === '0px') ? '220px' : '20px';
        contentContainer.classList.toggle('open');
    });
});
函数
function navto(id) {
    var sec = document.getElementsByTagName('section');
    for (var i = 0; i < sec.length; i++) {
        sec[i].classList.add('hidden');
        sec[i].classList.remove('active');
    }
    var as = document.getElementById(id);
    as.classList.remove('hidden');
    as.classList.add('active');
}
模组介绍
      <section id="analyzer" class="center hidden">
        <h1>Analyzer</h1>
        <div class="frame" style="position: absolute; top: 120px; left: 50px; width: 350px; height: 50px;">
          <input onclick="getpath(1)" type="button" id="fileinputa" style="display: none;">
          <label class="btns" for="fileinputa" style="cursor: pointer;">Select a file</label>
          <span class="frame" style="padding:10px" id="selectedFileName1">None</span>
        </div>
        <div class="frame" style="position: absolute; top: 120px;left:500px; width:400px; height:360px;">
          <h1> Output: <button onclick="document.getElementById('outputanalyzer').select(); document.execCommand('copy');createnotification('success', 'Copied');" style="margin-left: 150px;" class="btns">Copy Output</button></h1>
          <textarea class="scroll-box" id="outputanalyzer" style="height:250px;width: 380px ;font-family: 'Share Tech Mono', monospace; resize:none;outline: none;"></textarea>
        </div>
        <div class="frame" style="position: absolute; top: 230px; left: 50px; width: 390px; height: 290px; padding:0px;">
          <h1 style="margin-left:150px;">options</h1>
          <div>
            <button style="margin-bottom: 15px;" class="btns" onclick="analyzer_command('detect_packer')">exe packer detector</button>
            <button style="margin-bottom: 15px;" class="btns" onclick="analyzer_command('unpack_exe')">unpack exe</button>
            <button style="margin-bottom: 15px;" class="btns" onclick="analyzer_command('sus_strings_lookup')">sus strings lookup</button>
            <button style="margin-bottom: 15px;" class="btns" onclick="analyzer_command('all_strings_lookup')">all strings lookup</button>
            <button style="margin-bottom: 15px;" class="btns" onclick="analyzer_command('get_file_hashs')">get file hashs</button>
          </div>
        </div>
      </section>

注意:

analyzer_command

async function analyzer_command(command) {
    if (!bin_path) {
        createnotification('warning', "Select a file first");
        return
    }
    if (command == "detect_packer") {
        if (bin_path.endsWith(".exe")) {
            document.getElementById('outputanalyzer').textContent = await eel.detect_packer(bin_path)();
            createnotification("success", "Command executed");
            return
        } else {
            createnotification("failure", "only exe files are supported")
            return
        }
    } else if (command == "unpack_exe") {
        if (bin_path.endsWith(".exe")) {
            document.getElementById('outputanalyzer').textContent = await eel.unpack_file(bin_path)();
            createnotification("success", "Command executed");
            return
        } else {
            createnotification("failure", "only exe files are supported")
            return
        }
    } else if (command == "sus_strings_lookup") {
        document.getElementById('outputanalyzer').textContent = JSON.stringify(JSON.parse(await eel.sus_strings_lookup(bin_path)()), null, 2);
        createnotification("success", "Command executed");
        return
    } else if (command == "all_strings_lookup") {
        document.getElementById('outputanalyzer').textContent = await eel.all_strings_lookup(bin_path)();
        createnotification("success", "Command executed");
        return
    } else if (command == "get_file_hashs") {
        document.getElementById('outputanalyzer').textContent = await eel.get_file_hashs(bin_path)();
        createnotification("success", "Command executed");
        return
    }
}

将信息显示:

获取ID为 outputanalyzer 的前端区域,然后将文本替换为异步得到的值
JS

var bin_path;
if (command == "get_file_hashs") {
  document.getElementById('outputanalyzer').textContent = await eel.get_file_hashs(bin_path)();
  createnotification("success", "Command executed");
  return
}

async function getpath(x) {
    var dosya_path = await eel.file_explorer()();
    if (dosya_path) {
        var filename = dosya_path.match(/\/([^\/]+)$/);
        if (filename && filename.length > 1) {
            if (x) {
                document.getElementById('selectedFileName1').textContent = filename[1];
                bin_path = dosya_path
            } else {
                document.getElementById('selectedFileName').textContent = filename[1];
                path = dosya_path
            }   
        }
    }
}

HTML点击触发getpath

<input onclick="getpath(1)" type="button" id="fileinputa" style="display: none;">

HTML中获取ID位

        <div class="frame" style="position: absolute; top: 120px;left:500px; width:400px; height:360px;">
          <h1> Output: <button onclick="document.getElementById('outputanalyzer').select(); document.execCommand('copy');createnotification('success', 'Copied');" style="margin-left: 150px;" class="btns">Copy Output</button></h1>
          <textarea class="scroll-box" id="outputanalyzer" style="height:250px;width: 380px ;font-family: 'Share Tech Mono', monospace; resize:none;outline: none;"></textarea>
        </div>

调度了python的函数并换返回值到JS函数

@eel.expose
def get_file_hashs(file_path: str) -> str:
    file = open(file_path, "rb").read()
    md5_hash = md5(file).hexdigest()
    sha1_hash = sha1(file).hexdigest()
    sha256_hash = sha256(file).hexdigest()
    return "MD5: "+md5_hash+"\n"+"SHA1: "+sha1_hash+"\n"+"SHA256: "+sha256_hash

点击

input按钮,调度JS的getpath函数

<div class="frame" style="position: absolute; top: 120px; left: 50px; width: 350px; height: 50px;">
          <input onclick="getpath(1)" type="button" id="fileinputa" style="display: none;">
          <label class="btns" for="fileinputa" style="cursor: pointer;">Select a file</label>
          <span class="frame" style="padding:10px" id="selectedFileName1">None</span>
</div>

JS获取信息,并使用eel调度到python脚本获取dosya_path

async function getpath(x) {
    var dosya_path = await eel.file_explorer()();
    if (dosya_path) {
        var filename = dosya_path.match(/\/([^\/]+)$/);
        if (filename && filename.length > 1) {
            if (x) {
                document.getElementById('selectedFileName1').textContent = filename[1];
                bin_path = dosya_path
            } else {
                document.getElementById('selectedFileName').textContent = filename[1];
                path = dosya_path
            }
        }
    }
}

python获取信息,返回file_path

from tkinter import Tk, filedialog
@eel.expose
def file_explorer() -> str:
    root = Tk()
    root.withdraw()
    root.wm_attributes('-topmost', 1)
    file_path = filedialog.askopenfilename(filetypes=[("Python Files", "*.py"),("Python compiled Files", "*.pyc"),("exe Files", "*.exe"),("All Files", "*.*")])
    return file_path

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/583663.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Docker创建镜像之--------------基于Dockerfile创建

目录 一、在编写 Dockerfile 时&#xff0c;有严格的格式需要遵循 二、Dockerfile 操作常用的指令 2.1ENTRYPOINT和CMD共存的情形 2.2ENTRYPOINT和CMD的区别 2.3ADD 与COPY的区别 三、Dockerfile案例 3.1构建apache镜像 3.1.1 创建镜像目录方便管理 3.1.2创建编写dock…

0417GoodsImgTomCat项目 实现添加储存图片 分页查询图片

0417GoodsImgTomCat项目包-CSDN博客 数据库字段&#xff1a; 界面效果

Baidu comate智能编程助手评测

Baidu comate智能编程助手评测 作者&#xff1a;知孤云出岫 目录 一&#xff0e; 关于comate产品 二&#xff0e; 关于comate产品体验 三&#xff0e; 关于实际案例. 四&#xff0e; 关于baidu comate编程助手的实测体验感悟 五&#xff0e; …

【鸿蒙】通知

一、概要 Android的Notification。 说到通知&#xff0c;就想到了推送。 通知这块可以做到不像Android一样需要集成各家厂商的推送了&#xff0c;不知道是否有建立独立的推送系统 这是官网上介绍的跨APP进行的IPC通知。实际在Android开发过程中&#xff0c;可能这种场景会相对…

代码审计-PHP模型开发篇MVC层RCE执行文件对比法1day分析0day验证

知识点&#xff1a; 1、PHP审计-MVC开发-RCE&代码执行 2、PHP审计-MVC开发-RCE&命令执行 3、PHP审计-MVC开发-RCE&文件对比简要点 1、代码审计必备知识点&#xff1a; 环境搭建使用&#xff0c;工具插件安装使用&#xff0c;掌握各种漏洞原理及利用,代码开发类知…

《HCIP-openEuler实验指导手册》2.2 Nginx静态资源访问配置

知识点 配置步骤 新建静态资源文件 mkdir /data mkdir /data/nginx touch /data/nginx/index.html echo "this is /data/nginx/index.html" > /data/nginx/index.html touch /data/nginx/test.txt echo "this is /data/nginx/test.txt" > /data/ng…

复刻系列-绝区零官网「喧响测试」

复刻绝区零官网「喧响测试」 0. 视频 绝区零&#xff0c;妮慧事捉净&#xff01;&#xff01;&#xff01; 1. 基本信息 作者: GMCY系列: 复刻系列网站: 绝区零「喧响测试」- 复刻的仓库: GitHub | Gitee话题(GitHub): vue \ reprint \ mihoyo \ ZenlessZoneZero创建时间: 20…

设计模式六大原则详解

引言 对于设计模式&#xff0c;自己很早之前就看了好多本设计模式书籍&#xff0c;其中一些还看了好几遍&#xff0c;也一直希望自己能在编码的时候把这些设计模式用上去。可是&#xff0c;在日常的打码中&#xff0c;用的做多的就是单例&#xff0c;其次是观察者和建造者模式…

ASP.NET某企业信息管理系统的设计与实现

摘 要 信息管理系统就是我们常说的MIS(Management Information System),它是一个计算机软硬件资源以及数据库的人-机系统。经过对题目和内容的分析,选用了Microsoft公司的ASP.NET开发工具,由于它提供了用于从数据库中访问数据的强大工具集,使用它可以建立开发比较完善的数据库…

docker容器---docker-compose容器集群的快速编排

一、Docker-compose简介 Docker-Compose项目是基于Python开发的Docker官方开源项目&#xff0c;负责实现对Docker容器集群的快速编排。 Docker-Compose将所管理的容器分为三层&#xff0c;分别是 工程&#xff08;project&#xff09;&#xff0c;服务&#xff08;service&am…

使用vue3+elementplus的级联选择器实现省市区联动(三级到五级)

中华人民共和国行政区划代码 github地址&#xff1a;https://github.com/uiwjs/province-city-china 中华人民共和国行政区划&#xff08;五级&#xff09;&#xff1a;省级、地级、县级、乡级和村级。来自中华人民共和国民政部&#xff0c;用于查询中国省&#xff0c;市和区数…

linux远程访问及控制

一、SSH远程管理 1.SSH的简介 SSH远程管理是一种通过 SSH 协议安全地管理远程计算机的方法。允许管理员通过加密的连接从本地计算机或其他远程位置连接到远程计算机&#xff0c;并执行管理任务、配置设置、故障排除等操作。 远程链接的两种方法&#xff1a;SSH 、Telnet S…

函数定义域和值域

定义域和值域 1. 函数的定义 函数的定义&#xff1a;一般的&#xff0c;在一个变化过程中&#xff0c;假设有两个变量 x x x&#xff0c; y y y&#xff0c;如果对于任意一个 x x x 都有唯一确定的一个 y y y 和它对应&#xff0c;那么就称 x x x 是自变量&#xff0c; y…

C++初阶学习第四弹——类与对象(中)——刨析类与对象的核心点

类与对象&#xff08;上&#xff09;&#xff1a;C初阶学习第三弹——类与对象&#xff08;上&#xff09;——初始类与对象-CSDN博客 前言&#xff1a; 在前面文章中&#xff0c;我们已经讲了类与对象的思想和类与对象的一些基本操作&#xff0c;接下来这篇文章我们将讲解以下…

会计稳健性Cscore模型(2000-2022年)

01、数据介绍 会计稳健性是指在财务报告中&#xff0c;对损失和收益的确认存在不对称的延迟。具体来说&#xff0c;对于损失或坏消息&#xff0c;企业应尽早确认&#xff1b;而对于收益或好消息&#xff0c;企业应延迟确认。这种稳健的会计处理方式有助于提高财务报告的质量&a…

人工原生动物优化器(APO)-2024年SCI一区新算法-公式原理详解与性能测评 Matlab代码免费获取

声明&#xff1a;文章是从本人公众号中复制而来&#xff0c;因此&#xff0c;想最新最快了解各类智能优化算法及其改进的朋友&#xff0c;可关注我的公众号&#xff1a;强盛机器学习&#xff0c;不定期会有很多免费代码分享~ 目录 原理简介 一、觅食行为 (1)自养模式 (2)异…

[CUDA 学习笔记] GEMM 优化: 双缓冲 (Prefetch) 和 Bank Conflict 解决

GEMM 优化: 双缓冲 (Prefetch) 和 Bank Conflict 解决 前言 本文主要是对 深入浅出GPU优化系列&#xff1a;GEMM优化&#xff08;一&#xff09; - 知乎, 深入浅出GPU优化系列&#xff1a;GEMM优化&#xff08;二&#xff09; - 知乎 以及 深入浅出GPU优化系列&#xff1a;GE…

Git工具的使用

文章目录 Git概述本地仓库命令远程仓库命令分支操作标签操作 IDEA上执行Git Git概述 一般工作流程如下&#xff1a; 从远程仓库中克隆 Git 资源作为本地仓库&#xff1b; 从本地仓库中checkout代码然后进行代码修改&#xff1b; 在提交本地仓库前先将代码提交到暂存区&#xff…

上市公司-双重差分模型手动匹配绿色企业数据及参考资料

01、数据简介 双重差分模型&#xff08;DID&#xff0c;Differences-in-Differences&#xff09;是一种用于估计某个政策或处理效果的经济计量学模型。通过双重差分模型&#xff0c;可以控制一些不易观察的个体特征和时间趋势&#xff0c;以更准确地估计政策的效应。将绿色企业…

OmniReader Pro for Mac:强大且全面的阅读工具

OmniReader Pro for Mac是一款专为Mac用户设计的强大且全面的阅读工具&#xff0c;它集阅读、编辑、管理等多种功能于一身&#xff0c;为用户提供了卓越的阅读体验。 OmniReader Pro for Mac v2.9.5激活版下载 该软件支持多种文件格式的阅读&#xff0c;包括PDF、Word、Excel、…
最新文章