当前位置:网站首页>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
边栏推荐
- [QNX hypervisor 2.2 user manual]9.9 logger
- antd中table hover上去的背景色样式修改
- Using skills of word
- 基于FPGA的ECG信号采集,存储以及传输系统verilog实现
- 涌现与形态的局部差异和整体差异
- 计算重叠积分的第二种方法
- No identifier specified for entity solution
- Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
- Antd table+checkbox default value display
- I've compromised. Since everyone wants to call me Yelin, there's nothing I can do
猜你喜欢

DNS principle and resolution process

Play with the cluster configuration center and learn about the Taier console

How to build a data index system is the most effective. It will take you a quick start from 0 to 1

Record of a cross domain problem

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

Tdengine business ecosystem partner recruitment starts

华硕无双,这可能是屏幕最好的平价高刷轻薄笔记本

Kangaroo cloud stack based on CBO in spark SQL optimization

Shortest moving distance and entropy of morphological complex

Influence of black and white pixel distribution on iteration times
随机推荐
YonBuilder赋能创新,用友第四届开发者大赛“金键盘奖”开启竞逐!
迭代次数和熵之间关系的一个验证试验
MySQL installation (RPM package)
Why is the data service API the standard configuration of the data midrange when we take the last mile of the data midrange?
十年架构五年生活-07 年轻气盛的蜕变
神经网络学习笔记
NFT leaderboard -nft real offer latest address: NFT leaderboard.com
Sorry, you guys have something to deal with in the bank recently, which has been delayed
Study notes Minio
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
Pyqt5 rapid development and practice 4.2 QWidget
Research on synaesthesia integration and its challenges
计算重叠积分的第二种方法
Error: image clipToBoundsAndScale, argument 'input'
解决 ImportError: cannot import name 'abs' 导入tensorflow报错
学习笔记-微信支付
Regular form form judgment
Shortest moving distance and entropy of morphological complex
洛谷 P3052 [USACO12MAR]Cows in a Skyscraper G
Record of a cross domain problem