date: 2024/6/21
使用process monitor监听utools,当执行添加启动项时,会改写相关路径:C:\Users\xiaoyu\AppData\Roaming\uTools\database\default中的文件,查看目录下的文件,将该目录结构提交gpt,发现该目录格式与leveldb数据库操作相关的目录结构相似。
使用.net中的leveldb相关的库对其进行相关操作后,在第1次运行leveldb对该数据库进行修改时可以发现,数据库操作失败,通过调用leveldb的修复代码后,发现能够正常读取写入。
static void RepairDatabase()
{
    var repairOptions = new Options { CreateIfMissing = false };
    // 正确的参数顺序
    DB.Repair(repairOptions, dbPath);
}
通过打印数据库结构后发现,数据库中有一个key-value中包含的"files:[]"字符串,该字符串中包含的启动文件中路径与我在utools界面程序中添加的一致,所以考虑直接清空该数组,通过遍历我们自定义的文件夹下的所有启动项添加到该数组中。
仅简单添加会对数据库改写,但多次启动后,manifest文件与.log文件的版本号相差到3左右时会触发一定问题,导致这个数据库重置。根据仔细手动通过utools添加多次启动项并打印数据库的kev-value,对比后发现每次修改数据会对其他值也进行相应的修改。所以可以确定utools使用的数据库应该是基于leveldb的一种类型的数据库,所以不能简单的直接修改想要的数据。
对比调试后,对相应的所有key-value进行更新后能正常使用。
有时会出现卡住的bug,我将C:\Users\xiaoyu\AppData\Local\Programs\utools\resources\app-update.yml中的url与update的value都乱改了一下重启软件就正常了
level相关操作代码:
链接:https://pan.baidu.com/s/1_D2NId2Kt9BCx2ICa1ft6g 
提取码:1111 
--来自百度网盘超级会员V6的分享
2024/8/10 17:28:07
utools逆向,调用utools中添加本地文件启动的函数
环境:utools v5.0.0(
解决安装高版本后,utools强制更新。
C:\Users\xiaoyu\AppData\Local\Programs\utools\resources下
app.asar、app-update.yml将yml文件重命名为:原+.bak。同时替换app.asar为https://www.52pojie.cn/thread-1910115-1-1.html中博主评论区上传的asar。两文件属性,安全,高级,禁用继承;所有用户取消修改权限。
)
1.node.js官网下载node.js一键安装
2.npm install -g asar
3.解包:asar extract app.asar destination_folder
4.在destination_folder中对对应代码修改
5.打包:asar pack destination_folder app.asar
修改app.asar后调试流程:
C:\Users\xiaoyu\AppData\Local\Programs\utools\utools.exe --remote-debugging-port=9222
打开Chrome浏览器,输入URL chrome://inspect,点击 "Configure" 按钮,添加你的设备的IP地址和端口号(例如,127.0.0.1:9222)。之后,你应该能看到一个目标列表,其中包含你的Electron应用,点击 "inspect" 链接即可开始调试。
dist/plugins/ffffffff/index.html也就是管理界面需要,通过在inspect页面中点击这几个页面中操作,然后才能在目标列表看到管理界面目标。然后inspect这个链接,修改相关报错。
分析:
vscode打开destination_folder
1.addLocalOpen,drag搜索定位到dist>plugins>fffff>index.js中的 OV>constructor存在一个函数是用来处理拖拽到界面来添加本地启动的,如下:
Iv(this, "handleDrop", (e) => {
...
window.services.addLocalOpen
....
2.在这个文件中使用require就会报错,因为,这里通过main.js脚本将需要的 Node.js 功能或模块暴露给渲染进程,然后在渲染进程中通过全局变量访问这些方法(window.services.addLocalOpen)
3.定位到window.services.addLocalOpen这个访问的相当于main.js中mt>constrctor>addLocalOpen
4.在1中定位的地方查看addlocalopen调用传递参数为,一个字符串数组(Array<string>),添加console.log打印t发现,数组内容就会拖拽的文件的绝对路径
5.在3中mt的构造函数中添加:用来暴露 `addLocalOpen` 方法为一个 API 端点
	const http = require('http');
	class Mt {
        constructor() {
            // 服务器创建和路由配置
            this.server = http.createServer((req, res) => {
                if (req.url === '/api/addLocalOpen' && req.method === 'POST') {
                    this.handleAddLocalOpen(req, res);
                } else {
                    res.writeHead(404, { 'Content-Type': 'text/plain' });
                    res.end('Not Found');
                }
            });
            // 服务器监听在指定端口
            this.server.listen(3000, () => {
                console.log('Server is running on http://localhost:3000');
            });
            ..原本的代码..
        }
	async handleAddLocalOpen_jz(req, res) {
        let data = "";
        req.on('data', chunk => {
            data += chunk;
        });
        req.on('end', async () => {
            try {
                const datar = data;
                // 解析 JSON 数据为字符串数组
                main_log_jz(datar);
                const paths = JSON.parse(datar);
                main_log_jz(JSON.stringify(paths));
                if (!Array.isArray(paths)) {
                    throw new Error("Expected an array of strings");
                }
                // 假设 addLocalOpen 是一个处理数据并返回结果的异步方法
                const result = await this.addLocalOpen_jz(paths);
                main_log_jz(JSON.stringify(result));
                res.writeHead(200, { 'Content-Type': 'application/json' });
                res.end(JSON.stringify({ result }));
                main_log_jz("open end.\n");
            } catch (error) {
                res.writeHead(500, { 'Content-Type': 'application/json' });
                res.end(JSON.stringify({ error: error.message }));
            }
            });
    }
    async addLocalOpen_jz(data) {
        const userDataPath = path_jz.join(app_jz.getPath('userData'), 'debug.log');
        fs_jz.appendFileSync(userDataPath, `接受成功: ${data}\n`);
        const result = await this.addLocalOpen(data);
        return `Processed: ${result}`;
    }
    ...原本的代码
创建一个powershell脚本测试:
$dataArray = @("C:\Users\xiaoyu\Desktop", "C:\Users\xiaoyu")
$jsonData = $dataArray | ConvertTo-Json
$response = Invoke-WebRequest -Uri "http://localhost:3000/api/addLocalOpen" -Method POST -Body $jsonData -ContentType "application/json; charset=utf-8"
$response.Content
2024/8/12 16:21:43
这里下载的楼主的asar文件,楼主默认设置了utools搜索栏的文件显示,现在我要设置成自己想定义成的文字。
流程:
1.--remote-debugging-port=9222启动utools,chrome中定位到search栏的页面
2.检查页面元素,查看到这个文字显示的属性为 placeholder
3.vscode中搜索placeholder,分析关键词上下文,在设置页面中的设置显示文本那里,发现mainplaceholder这个属性在代码中是用来描述我们需要的。
4.观察到utools设置中可以设置这个属性,搜索hi,定位到控件相关方法
5.在主进程中打印输出到文件,渲染进程使用console.log打印内容,从第4步逆推最后找到配置属性在node_modules>configuration>index.js中