duangsues.is_a? SaltedFish
60 subscribers
609 photos
6 videos
91 files
562 links
🌶🐔🐟 duangsuse 的日常
尤其喜欢发些奇奇怪怪的东西
和转载别人的东西
Download Telegram
retdec 看感觉反编译结果特别好看,几乎都能直接拿去重新编译了
This media is not supported in your browser
VIEW IN TELEGRAM
基于 LLVM
能想像吗... 基于 LLVM IR
正在把输出重定向至 “wget-log”。
Verfifying archive's checksum ...
Unpacking archive ...

下好了 🌚

RetDec support directory downloaded OK
-- Installing: /home/dse/rd/lib
-- Installing: /home/dse/rd/lib/libretdec-libdwarf.so
-- Installing: /home/dse/rd/lib/libretdec-libelf.so
compiling yara signatures...
signatures compiled successfully
-- Installing: /home/dse/rd/bin/retdec-color-c.py
-- Installing: /home/dse/rd/bin/retdec-config.sh
-- Installing: /home/dse/rd/bin/retdec-archive-decompiler.sh
-- Installing: /home/dse/rd/bin/retdec-decompiler.sh
-- Installing: /home/dse/rd/bin/retdec-fileinfo.sh
-- Installing: /home/dse/rd/bin/retdec-signature-from-library-creator.sh
-- Installing: /home/dse/rd/bin/retdec-unpacker.sh
-- Installing: /home/dse/rd/bin/retdec-utils.sh
-- Installing: /home/dse/rd/bin/retdec-ar-extractor
-- Set runtime path of "/home/dse/rd/bin/retdec-ar-extractor" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-bin2llvmir
-- Set runtime path of "/home/dse/rd/bin/retdec-bin2llvmir" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-bin2pat
-- Set runtime path of "/home/dse/rd/bin/retdec-bin2pat" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-config
-- Set runtime path of "/home/dse/rd/bin/retdec-config" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-fileinfo
-- Set runtime path of "/home/dse/rd/bin/retdec-fileinfo" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-idr2pat
-- Set runtime path of "/home/dse/rd/bin/retdec-idr2pat" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-llvmir2hll
-- Set runtime path of "/home/dse/rd/bin/retdec-llvmir2hll" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-macho-extractor
-- Set runtime path of "/home/dse/rd/bin/retdec-macho-extractor" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-pat2yara
-- Set runtime path of "/home/dse/rd/bin/retdec-pat2yara" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-stacofin
-- Set runtime path of "/home/dse/rd/bin/retdec-stacofin" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-unpacker
-- Set runtime path of "/home/dse/rd/bin/retdec-unpacker" to "$ORIGIN/../lib"
-- Installing: /home/dse/rd/bin/retdec-getsig
-- Set runtime path of "/home/dse/rd/bin/retdec-getsig" to "$ORIGIN/../lib"

[1]+ 已完成 make install
##### Gathering file information...
RUN: /home/dse/rd/bin/retdec-fileinfo -c /home/dse/liba.so.c.json --similarity /home/dse/liba.so --no-hashes=all --crypto /home/dse/rd/bin/../share/retdec/support/generic/yara_patterns/signsrch/signsrch.yara --max-memory-half-ram
Input file : /home/dse/liba.so
File format : ELF
File class : 32-bit
File type : DLL
Architecture : x86 (or later and compatible)
Endianness : Little endian
Detected tool : gold (1.11) (linker), .note section heuristic
Detected tool : GCC (4.8) (compiler), .comment section heuristic
Detected tool : GCC (4.9) (compiler), .comment section heuristic
Original language : C++

真好用
这次就到这里了(
想给 Lite 写个 LV(Lite VM)
或者给 Java 创建 bc 的绑定(binding)
或者 Wren...
不过 reveng 方便的话就算了
This media is not supported in your browser
VIEW IN TELEGRAM
看了某宝上的 GBA 就没兴趣了(内存算
接下来总结 Lite 的功能,准备写 LV 🌚
- LV 要成为 stack-based machine
- LV 要拥有一个 call-stack 和一个 stack 和一个 global table,gtable 必须是线程安全的
- LV 使用词法作用域和 lazy-init 优化(不是替换绑定)
- LV 要能支持 block
- LV 要能实现 Lite 的所有功能
- LV 要支持这些字面量:
- true / false
- null
- number ( byte, short, int, long, float, double, BigInteger, BigDecimal )
- string / char
- symbol
- range

- 要能创建一定维度的数组
- [] 能索引 数组、Map、List、Object(getXXXX property or field)、subclass、static member
- []= 能新建索引 数组、Map、List、Object(setXXXX property or field)、static member
- :: 是快速版本的 [] (语法糖),在虚拟机层面上不存在的
- -> 能修改 数组、Map、List、Object(setXXXX property or field)、static member(语法糖)

- 块内 return、break、next


- LV 要支持行注释: ;

- LV 要能进行动态链接
- LV 要支持调试信息 (文件名、行号)

- LV 暂时只使用代码文本表示
- LV 支持指令插件

- Lite 支持这些东西:
- vararg(在虚拟机层面不存在)
- block
- while、if、for、def、call、assign、
- | or in & and < > <= >= != == !== === << to + - * / % ** :: as
- unary - ! ++ —
-
- 要能调用对象的方法
- 要能调用类方法
- 要能调用 Lite 方法
- 要能调用 constructor
- 能创建 proc
指令列表:
- nop 啥都不做
- push [object] 往栈上放置一个对象
- pushnull 放置 null
- pushtrue 放置 true
- pushfalse 放置 false
- pushlv 往栈上放置虚拟机引用
- scope 进入作用域
- leave 离开作用域
- sget 读取本地变量
- sput 设置本地变量
- fun [sym] 定义函数符号
- call [sym] 调用函数
- ret 返回
- jump [ip] 跳转到 ip 处执行
- branchif [ip] if
- branchunless [ip] unless
- get 读取全局变量
- put 设置全局变量

- newary [n] 创建 n 维度的数组
- index []
- newindex []=
- file [fname] 在文件中
- line [line] 在行中

- send 调用对象方法和类方法
- new 创建对象

- block [range] 创建块对象,它打包所有引用到的本地变量的绑定
- yield 调用块对象

- or
- in?
- and
- op<
- op>
- op<=
- op>=
- noteq
- eq
- fulleq
- shl
- newrange
- add
- sub
- mul
- div
- mod
- pwr
- cast
- not
- inc
- dec

- len
我们来整理一下,顺便彻底解释所有指令语义和 stack-based 化指令( 把所有参数放在堆栈里)

- LV 拥有 call-stack(带有 ret_addr 和 lazy 的 locals HashMap )、stack(LinkedList<Object>) 和 global table(Hashtable)
- LV 是基于堆栈的虚拟机,LV 只有全局表要求线程安全
- LV 支持自己的 exception 系统
- LV 支持 block,会在创建 block 时自动打包 block 的所有符号本地变量引用
- LV 使用可扩展的指令系统,支持指令插件
- LV 支持的字面量有 boolean/null/number ( byte, short, int, long, float, double, BigInteger, BigDecimal )/char/string/symbol/range

- LV 支持注释和动态链接(允许在需要的时候创建新数组来容纳更多指令并注册函数符号表)、调试信息(file name, line number)
- LV 暂时使用代码文本表示
- LV 支持循环和分支逻辑、子过程调用、赋值运算

词法:
; 到行末尾是注释,除非是在字符串出现这个
true 是真 false 是假
null 是空
支持 0x 0b 0o 数字(Hex 数位字符只支持小写),自动删除下划线,类型依次以 `B S I L F D N P` 结尾,默认类型为 I
'c' 单字符的 single-quoted 为 char
"str" 'str' 非单字符的为 string,其中 "" 会处理 escape \b\t\n\r\"\\
ssss 是 symbol
0..9 是 range,不过这不是在词法扫描的时候创建的...
\t\f\r\13\v\u000C 是空格

语法:
单纯的汇编指令式,一行为一条指令,可能是 symbol 或 Object,如果是 Object,向堆栈上压入这个对象,如果是 symbol 则尝试执行 OpCode

指令列表:
nop
啥都不做

压入参数
(任何非 symbol 类型的词条)
向堆栈上压入一个对象

pushnull
向堆栈上压入 null
pushtrue
向堆栈上压入 true
pushfalse
向堆栈上压入 false
pushlv
向堆栈上压入当前 LV 虚拟机引用
newary
弹出栈顶的值,转换为 Integer,创建指定大小的新的 Array<Object> 对象并压入堆栈
newrange
弹出栈顶的两个值,转换为 Integer,创建 range v2..v1
newsymbol
弹出栈顶的值,检查其是否是 String 的实例,如果不是,抛出内部错误,否则创建新 Symbol 对象并压入堆栈

流程控制

FFI

作用域

子过程

特殊操作

数学运算

堆栈机标配指令