
仓库地址 https://github.com/codehz/tjs
这是某天折腾 tcc 时突发奇想的的 idea,也就是用 js 做脚本,然后任何涉及系统的功能直接用 tcc 运行时编译出来调用(
查了查 node 方面有 node-ffi,但是显而易见都用了 nodejs 了,系统交互基本很多都能在纯 js 层做了,于是再搞这个
目前测试可以直接使用 windows api MessageBox 弹个框(暂时只支持 win,32 位+64 位)
特(que)色(xian):
示例代码:
import { Compiler } from "builtin:c"; const compiler = new Compiler("memory"); compiler.link("user32"); compiler.compile(` #include <windows.h> void msgbox(char const *text) { MessageBoxA(NULL, text, "from js", 0); } `); const obj = compiler.relocate({ msgbox: { arguments: ["string"] } }); obj.msgbox(`from ${import.meta.url}`); 1 azh7138m 2020-10-12 23:09:49 +08:00 可也太..... tql |
2 charten 2020-10-13 11:30:08 +08:00 刚开始没看清以为 windows api 指的是浏览器内的那一套,后面才发现是微软的 windows.h....流批啊,一起黑子下发恶意代码是通常是 vb,现在可以直接下发 c 代码搞破坏了 hhhhhhh |
3 codehz OP @charten #2 类似想法的恶意软件多了去了,不过不会这么 naive 直接下发 c 代码,通常是直接下发 shellcode,最多加上点重定位的操作,就可以跑了。 |
4 Themyth 2020-10-13 22:11:28 +08:00 我想问。。。 是不是把这个代码改成.js 放到 html 里面 然后访问就可以弹窗? |
7 codehz OP @sologgfun #6 不是 node,用 quickjs 做的一个很小的 js 运行时,压缩后<4MB,node 请直接用 node-ffi ( |
8 sarvatathagata 2021-01-24 18:00:57 +08:00 这和 wasm 相比有什么有点呢 |
9 codehz OP @sarvatathagata 为了调用系统 api 的(不是为了提高性能 |