当前位置:网站首页>Introduction to software vulnerability analysis (I)
Introduction to software vulnerability analysis (I)
2022-07-27 11:10:00 【Default user_ one hundred and fourteen thousand five hundred an】
Mixed assembly and inline assembly
Prepare to take notes of some knowledge points about software security from this article , Make a series , I hope I can stick to it . Limited ability , The knowledge point is also relatively simple , If there are omissions in your notes, please forgive me .
Because the notes focus on the analysis and practical operation of software vulnerabilities , Some basic knowledge of compilation is not included in this series , By default, you already have a certain assembly foundation , Therefore, the author will not add comments next to all sentences .
adopt VS2022 Conduct C and x86 Assembly mixed programming
Why not use more convenient
VS2010Well , One is that many software security textbooks are relatively old , Can't keep up with the new era , And if you areVS2022The latest version can be debugged successfully , Then many previous versions can be debugged successfully in this way
;func.asm
.model flat ; Pseudo instruction Determine the working mode
PUBLIC _TestDemo ;extern int TestDemo();
_TEXT SEGMENT ; Code segment
_TestDemo PROC
MOV EAX, 2222 ;
RET
_TestDemo ENDP
_TEXT ENDS
END
//main.c
#include <stdio.h>
int TestDemo(void);
int main()
{
int c = TestDemo();
printf("%d\n",c);
}
You can see , In the project file main.c Inside , It's not TestDemo The definition of function , TestDemo Is defined in another func.asm In the assembly statement , In order for the main code to know TestDemo The content of , You need a linker to link and compile the two files to generate an executable program
Add two files to VS2022 In the project , Because it needs links asm Assembly files , Therefore, the following settings are required:
Right click project --> Generation dependency --> Generate custom

Check masm

Right click func.asm choice attribute , Item type selection Microsoft Macro Assembler Give Way IDE distinguish

Item properties , The subsystem setting under the linker should be changed to console

Because the experiment is x86 assembly , Therefore, the generated compiled file must be x86 Format

Compile operation

adopt VS2022 Conduct X86 Embedded assembly programming
Now we embed the assembly code main.c Inline execution
Compared with the above code , This is a small improvement , Added the input part , Make it a normal adder
Compared with hybrid assembly , This inline assembly does not require link compilation , Because the assembled code is main.c Inside , As long as it contains dependencies that recognize assembly , You can directly compile and run
//main.c
#include <stdio.h>
#include <stdlib.h>
int TestDemo(int a, int b)
{
// Assembly part
__asm{
mov eax, a ; Get first argument
mov ecx, b ; Get second argument
add eax, ecx ; take eax,ecx Value added to eax On
};
}
int main()
{
int a,b,c;
scanf("%d %d",&a,&b);
c = TestDemo(a,b);
printf("%d\n",c);
system("pause");
}
In order to make the code work properly , It also needs to be set
Same as before , You also need to add dependencies masm

subsystem The setting should also be changed to console

Compile operation

The above two are the most common assembly code calls , After completing the compilation and generation of a program , You can start to disassemble and analyze its executable file
边栏推荐
- The permission problem of Oracle operating openldap
- A verification test of the relationship between iteration number and entropy
- 最短移动距离和形态复合体的熵
- IO流_数据输入输出流的概述和讲解
- Non progressive phenomena of entropy and morphology
- Take you hand-in-hand to develop a complete classic game [Tetris] from scratch, with less than 200 lines of logic.
- Analysis of C language pointer function and function pointer
- 11 wrong set
- The difference between scalar, vector, matrix and tensor in deep learning
- 4 search insertion location
猜你喜欢

Sort th in antd table to prevent hovering color change +table hovering row color change +table header color change

发动机悬置系统冲击仿真-瞬时模态动态分析与响应谱分析

Delete in MySQL: the difference between delete, drop and truncate

Recruit top talents! The "megeagle creator program" of Kuangshi technology was officially launched

FAQs of "relay chain" and "dot" in Poka ecosystem

Derive the detailed expansion of STO double center kinetic energy integral

Antd table+checkbox default value display

parsel的使用

荒野觅踪---寻找迭代次数

迭代次数和熵之间关系的一个验证试验
随机推荐
洛谷P1896 互不侵犯
Iptables prevent nmap scanning and binlog explanation
C语言 2:求三数字最大值,求三数字中间值,编写程序步骤
Review and Prospect of encrypted traffic identification based on deep learning
如何组装一个注册中心
How to build a data index system is the most effective. It will take you a quick start from 0 to 1
What changes will metauniverse bring to the music industry in the trillion market?
A measurement method of 5g air interface one-way delay and its reliability
Tdengine helps Siemens' lightweight digital solution simicas simplify data processing process
Error: image clipToBoundsAndScale, argument 'input'
How to modify the strict mode under MySQL so that adding new users by inserting user table is successful
Shock simulation of engine mounting system transient modal dynamic analysis and response spectrum analysis
antd table+checkbox 默认值显示
Use of pyquery
The permission problem of Oracle operating openldap
IO stream_ Character stream, IO stream summary, IO stream case summary
荒野觅踪---寻找迭代次数
OpenAtom OpenHarmony分论坛,今天14:00见!附大事记精彩发布
【FPGA教程案例40】通信案例10——基于FPGA的简易OFDM系统verilog实现
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?