duangsuse::Echo
717 subscribers
4.26K photos
130 videos
583 files
6.48K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
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 一行一行的执行指令序列:

现在有一个 .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 同学一样
... 就是这样,反正 cdecl 还是没理解嘛,不过要我写个不用调用函数单 syscall 的我会写...

cdecl 执行栈管理,反正 edb 调试就是出各种问题,指针都乱套了,想在 rsp 上 add sub 总是出问题,该 pop 到好东西的时候永远 pop 到无效(没有内存页面分配到的)指针
今天晚上不可能了
.section .rodata
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

... 比较难受,总是 segv,上 edb 以后发现是 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
Forwarded from LWL 的基地台
发现 TDLib 非常有趣的样子,感谢 jsw 介绍(
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 去吧,感觉 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 的涂鸦板
内部章程明确规定周五不做变更,而且今天还是司庆日,完全没信心对外推荐腾讯云的服务。