table of Contents
First, the learning content summary
Data type
| C declarations | the Intel data type | assembly code suffix | size (bytes) | bits |
| -------- |: ---------------- : |: ----------------: |: ---------------: |: -----: |
| target | 5000 rows | 30 Pian | 400 Xiaoshi | |
| week | 301/706 | 1/34 | 18/40 | |
- NOTE: use the assembly code "l" represents a 4 to 8-byte integer and double precision floating point byte. This does not cause ambiguity, because the floating point number is a completely different set of instructions and registers.
Number of operations
操作数可分为三种类型:
1. 立即数
2. 寄存器
3. 内存引用
Operation indicator
process
P call Q:
call Q
The instruction in P willcall Q
next instruction address A onto the stack, and the program counter is set to the start position Q code.retq
A pop-up will address the instruction from the stack, and assign A PC
gdb debugging
objdump -d mstore.o disassemble
Buffer overflow
Minimize buffer overflow vulnerabilities in three ways:
- Stack randomization: before the program starts, the size of the space allocated randomly between 0-n bytes are not being used on the stack, the stack such that a change in location has a program every time it runs.
- Tamper detection stack: the stack is stored in the frame buffer with the stack between any of the local state of a particular canary value, and restoring register state from before the function returns, canary value check whether an operation or function of the an operation a function of the function call is changed. In order to determine whether a buffer overflow.
- Limit executable code region: only save the code produced by the compiler portion of memory that only need to be enforceable, the other part can be restricted to only allow read and write. In order to eliminate the ability of the attacker to insert executable code into the system.
Second, the problem of teaching and learning in the process of resolving
- Problem 1: When the code 114 on the materials to verify, during the compilation of the time display
:错误:无效的选项参数'-Og'
.
解决方法1:将其改为
gcc -O1 -c mstore.c
,因为有的版本编译器不支持-Og
运行结果如下:
- 使用gdb对教材上的代码进行调试
- 使用
gcc -g week302.c -o week302
进行汇编 - 使用
b f
在f函数处设置一个断点 - 使用
run
运行至断点处 - 使用
disas
进行反汇编 - 使用
display /i $pc
查看每次执行的汇编语句 - 使用
stepi
每次运行一句汇编语句 - 使用
i r
查看每个寄存器的值 运行结果如下:
三、心得体会
本周学习内容较为繁杂,只要之前的汇编课认真听讲,理解起来也虽然不是很难。
四、学习进度条
代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | 重要成长 | |
---|---|---|---|---|
目标 | 5000行 | 30篇 | 400小时 | |
第三周 | 301/706 | 1/34 | 18/40 |
计划学习时间:20小时
实际学习时间:18小时
五、参考资料
- 在linux里面如何调试C语言程序
- GDB如何调试没有符号表(未加-g选项的编译)的程序
- GDB调试程序用法
- GDB调试汇编堆栈过程分析
- 程序的机器级表示(1)
- 程序的机器级表示(2)
- 程序的机器级表示(3)
- 《深入理解计算机系统》