duangsuse::Echo
#telegram 100 Members Thank U!
Old Pin <<<
duangsuse::Echo
pinned «我如何评价 @duangsuse: 「代码一行不写,废话一大堆」 — duangsuse»
This media is not supported in your browser
VIEW IN TELEGRAM
duangsuse::Echo
hello.S .section .rodata hello_world: .string "你好,世界!\n" .section .text .globl _start _start: call main # call assembly main mov $60, %rax # sys_exit mov $0, %rdi # exit status syscall # make call sysprintf: mov %rsp, %rbp # stdcall…
就是这个... 咳咳 #CS #PL #backend #sysadmin #os #system
嗯... 很抱歉花太多时间了没时间所以不能讲好,而且对于 x86 的执行栈维护我也有点懵懵懂懂的样子,感觉稍微好点了但还是比较弱鸡,大佬轻喷啊
刚才想尝试一下 intel 风格的汇编,结果是个大坑...(我还不习惯 intel 风格的汇编...) 气死,第一次尝试待会发图
x86 系列汇编语言简单文档
x86 CDECL C 语言函数调用约定(规范)
好耶,那么开始说,首先是问题所在
我们来 cosplay CPU 一行一行的执行指令序列:
现在有一个
start:
call main ; push rip, save ret_addr to [rsp..rsp - size]
main:
mov rbp = rsp
现在程序的执行栈是这样的
> rsp: 0x.......
> [rip @ start:2nd]
> rbp: rsp
mov rax = hello_world
rax: dword ptr to hello_world @ .rodata
; 我们 skip 掉 dec rax
push rax
; [rip @ start]
; [dword ptr to hello_world @ .rodata]
push 20
; [rip @ start]
; [dword ptr to hello_world @ .rodata]
; [imm number 20]
call sysprintf
; [rip @ main]
sysprintf:
mov rbp = rsp
rbp: rsp ; 注意,上一次的 rbp 值压根没有被保存!
mov rax = 1
mov rdi = 1
> rip @ _start
> dword ptr to hello_world @ .rodata
> imm number 20
> rip @ main
pop rsi ; ... 由于程序正常允运行(真的?),我们只能假设 ret_addr 被无视了
rsi: imm number 20
pop rdx
rdx: dword ptr to hello_world ; 意料之外?
syscall
ret
.... 我模拟不下去了,算了算了 x86 这个我目前也要花很多时间学习下次再说(逃跑
... 我真应该做个动画帮助理解,像 RednaxelaFX 同学一样
嗯... 很抱歉花太多时间了没时间所以不能讲好,而且对于 x86 的执行栈维护我也有点懵懵懂懂的样子,感觉稍微好点了但还是比较弱鸡,大佬轻喷啊
刚才想尝试一下 intel 风格的汇编,结果是个大坑...(我还不习惯 intel 风格的汇编...) 气死,第一次尝试待会发图
x86 系列汇编语言简单文档
x86 CDECL C 语言函数调用约定(规范)
好耶,那么开始说,首先是问题所在
我们来 cosplay CPU 一行一行的执行指令序列:
现在有一个
.rodata 节的 hello_world 符号大概 20 字节的零结字符串(asciz,或者 string \0)已经被映射好了start:
call main ; push rip, save ret_addr to [rsp..rsp - size]
main:
mov rbp = rsp
现在程序的执行栈是这样的
> rsp: 0x.......
> [rip @ start:2nd]
> rbp: rsp
mov rax = hello_world
rax: dword ptr to hello_world @ .rodata
; 我们 skip 掉 dec rax
push rax
; [rip @ start]
; [dword ptr to hello_world @ .rodata]
push 20
; [rip @ start]
; [dword ptr to hello_world @ .rodata]
; [imm number 20]
call sysprintf
; [rip @ main]
sysprintf:
mov rbp = rsp
rbp: rsp ; 注意,上一次的 rbp 值压根没有被保存!
mov rax = 1
mov rdi = 1
> rip @ _start
> dword ptr to hello_world @ .rodata
> imm number 20
> rip @ main
pop rsi ; ... 由于程序正常允运行(真的?),我们只能假设 ret_addr 被无视了
rsi: imm number 20
pop rdx
rdx: dword ptr to hello_world ; 意料之外?
syscall
ret
.... 我模拟不下去了,算了算了 x86 这个我目前也要花很多时间学习下次再说(逃跑
... 我真应该做个动画帮助理解,像 RednaxelaFX 同学一样
duangsuse::Echo
就是这个... 咳咳 #CS #PL #backend #sysadmin #os #system 嗯... 很抱歉花太多时间了没时间所以不能讲好,而且对于 x86 的执行栈维护我也有点懵懵懂懂的样子,感觉稍微好点了但还是比较弱鸡,大佬轻喷啊 刚才想尝试一下 intel 风格的汇编,结果是个大坑...(我还不习惯 intel 风格的汇编...) 气死,第一次尝试待会发图 x86 系列汇编语言简单文档 x86 CDECL C 语言函数调用约定(规范) 好耶,那么开始说,首先是问题所在 我们来 cosplay…
This media is not supported in your browser
VIEW IN TELEGRAM
... 就是这样,反正 cdecl 还是没理解嘛,不过要我写个不用调用函数单 syscall 的我会写...
cdecl 执行栈管理,反正 edb 调试就是出各种问题,指针都乱套了,想在 rsp 上
今天晚上不可能了
cdecl 执行栈管理,反正 edb 调试就是出各种问题,指针都乱套了,想在 rsp 上
add sub 总是出问题,该 pop 到好东西的时候永远 pop 到无效(没有内存页面分配到的)指针今天晚上不可能了
.section .rodata... 比较难受,总是 segv,上 edb 以后发现是
hello: .asciz "hello, world!"
.globl _start
_start:
mov %rsp, %rbp
call main
doPrint:
pop %rdx
pop %rsi
mov $1, %rax
mov $1, %rdi
syscall
ret
doExit:
mov $0, %rax
call _Exit
main:
push $10
push hello
call doPrint
jmp doExit
ret @ main 跳转到 0xa 这个地址去了,而这块内存根本还没有 map 到... call Push 到栈上的应该是根本不可能是无效 rip 地址啊...今天这个汇编的算了... 很扫兴,也块到明天了
Makefile:
ASM_LDFLAGS := -lc -I /usr/lib64/ld-2*.so
hello: hello.S
$(AS) $(ASFLAGS) $^ -o $@.o
$(LD) $(LDFLAGS) -o $@ $@.o $(ASM_LDFLAGS)
clean:
$(RM) hello hello.o
run: hello
@./hello
runclean: run clean
.PHONY: clean run runclean
#telegram #tech #lib
https://github.com/tdlib/td#using-json
using... json, to communicate with Telegram client library daemon
https://github.com/tdlib/td#using-json
using... json, to communicate with Telegram client library daemon
GitHub
GitHub - tdlib/td: Cross-platform library for building Telegram clients
Cross-platform library for building Telegram clients - tdlib/td
Forwarded from LWL 的基地台
发现 TDLib 非常有趣的样子,感谢 jsw 介绍(
duangsuse::Echo
今天讲之前那个 x86 汇编的 helloworld 为什么出问题吧... 讲完再写不影响的,我已经基本会简单的 Qt 了... 就是我还看不到内存泄漏溢出、悬垂指针(Use-after-free)和非线程安全的风险
相当影响啊,因为我现在居然还不知道那个程序到底有什么问题 2333333 🌝....
duangsuse::Echo
讲完再写个 ARMv7 glibc (arm_v7-unknown-linux-gnu) #llvm #sysadmin #recommended #binary #backend (arch_subarch-vendor-os-abi-objectfmt) where arch: CPU 解释器平台,如 ARM、x86、x86_64、SPARC 编译到原生代码的语言,诸如 C/C++ 需要程序员时刻考虑底层的实现细节,诸如硬件解释器平台 一般来说不同的硬件处理器((嵌入式)微控制器)平台有不同的 …
纠正一下,Java 没有 label 和 goto... 我老是记错这些
duangsuse::Echo
... 再附加上一个 DalvikVM 的 smali 汇编猜数游戏吧,然后教你们怎么用 enjarify、dex2jar 之类的(2333 jadx、jd-gui 什么的那种简单到爆炸的玩意就不教你们了,你用脚趾头都想得出来怎么用啊? 最后附上一句:我是擅长逆向工程的(迫真)(hhhh 开什么玩笑....
import java.lang.System;
import java.lang.Math;
import java.util.Scanner;
class Main {
static int getRand() { return (int) (Math.random() * 100); }
static void judge(int truth, int given) {
if (truth > given)
System.out.println("Too small");
else if (truth < given)
System.out.println("Too big");
else System.out.println("You win");
}
public static void main(final String... args) {
int rand, input;
final Scanner stdin = new Scanner(System.in);
loop: while (true) {
rand = getRand();
if (!stdin.hasNextInt()) break loop;
input = stdin.nextInt();
judge(rand, input);
continue loop;
}
}
}
duangsuse::Echo
import java.lang.System; import java.lang.Math; import java.util.Scanner; class Main { static int getRand() { return (int) (Math.random() * 100); } static void judge(int truth, int given) { if (truth > given) System.out.println("Too small");…
... 算了也没时间写了,写 Qt 去吧,感觉
这次三个都没安排好... x86 汇编、ARM 汇编、Dalvik Smali,原因是我自己也不熟悉的东西教别人...
judge() 里面那个 if 不是多好看似的... 反正是 Jawa 嘛这次三个都没安排好... x86 汇编、ARM 汇编、Dalvik Smali,原因是我自己也不熟悉的东西教别人...
This media is not supported in your browser
VIEW IN TELEGRAM
Forwarded from duangsuse Throws
#life 掐指一算,我居然从下午三点死坐电脑前到晚上 11:50... 我居然死磕了足足 8 个小时一动也不动... 😶
Forwarded from METO 的涂鸦板
DNSPod 又开始各种炸了,我还是用 8.8.8.8 让 ISP 劫持走算了(
Forwarded from METO 的涂鸦板
内部章程明确规定周五不做变更,而且今天还是司庆日,完全没信心对外推荐腾讯云的服务。