当前位置:网站首页>Introduction to software vulnerability analysis (II)
Introduction to software vulnerability analysis (II)
2022-07-19 01:39:00 【Default user_ one hundred and fourteen thousand five hundred an】
Preliminary debugging of stack buffer
This experiment includes 64 Bit and 32 Bit disassembly analysis , The main content is to debug and verify the changes of stack data after stack buffer overflow 、 Change of execution process
The tools used in this experiment include
IDA proas well asx64dbgandx32dbg( uselessollydbgBecause of analysis x64 The disassembly of is too complicated )
Compile stack overflow experimental code
Here is a classic code that appears frequently in various software security textbooks
//stack_over_ret.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define PASSWORD "1234567"
int verify_password (char *password)
{
int authenticated;
char buffer[8];
authenticated=strcmp(password,PASSWORD);
strcpy(buffer,password);//over flowed here!
return authenticated;
}
main()
{
int valid_flag=0;
char password[1024];
FILE * fp;
if(!(fp=fopen("password.txt","r")))
{
exit(0);
}
fscanf(fp,"%s",password);
valid_flag = verify_password(password);
if(valid_flag)
{
printf("incorrect password!\n");
}
else
{
printf("Congratulation! You have passed the verification!\n");
}
fclose(fp);
system("pause");
}
IDA analysis
This code needs to have a password.txt File as input
Let's experiment first , If the correct password is in the file , The window prompt is correct ,

Compile the file , Drag onto IDA in reverse , The jump process of various functions is very clear
It is found that there is a branch of the judgment statement at the place of the arrow

Dynamic debugging
After finding the branch location , Go to x64dbg Internal debugging , Direct positioning to the positioning position



mov [rbp+6B0h+var_6AC], eax ;eax Save the return value of the password detection function
cmp [rbp+6B0h+var_6AC], 0 ; Sum the return value of the function with 0 Compare
jz short loc_140011AD8 ; If it is 0 Right , No 0 It's a mistake
After knowing the position of this judgment , You can dynamically modify the branch of judgment , Bypass this branch of judgment
So let's take this je Change to jne The wrong password can also be verified
We changed the password file to the wrong 5555555

Locate the je Command Division , hold je Machine code from 74 0E Edit as 75 0E namely jne

Successfully bypassed
Use stack overflow to control the execution process
take password.txt Change the content to 7777777, Easy to locate

Find the stack 7777777 The location of

We let password Overrun overflow , Execute the program and see what happens

The program just crashed

We can see , Transgressive “7” Directly back filled

Let's change the next part to x86,32 Bit program for analysis ( because 64 Bit program function calls are not like 32 Bit directly into the stack , The parameter exceeds )
Let's put it first IDA Inside

stay x64dbg Find the most critical verify_pasword Function entrance , Write a note

password.txt use 010 editor open , Later use nop namely 0x90 fill , Fill until near the return address

nop It's close to the return address

Then fill it back , Fill the return address with 00D81182


You can see that the return address has been changed to what you want 00D81182 了

Stack overflow protection mechanism
If the reader follows the operation steps of the notes step by step , You will find that in the end, no matter what, the experiment will not succeed , This is because the system and compiler will enable some protection mechanisms against stack overflow by default when compiling programs , The vulnerability of stack overflow is not so easy to exploit . About these protection mechanisms , We will continue to discuss in the next issue of notes .
边栏推荐
- 同学们 小组作业记得别抄哈 幸好只传了两道题 不要出事了
- Uni app wechat official account (4) - address management page
- How to modify the color of a line of text in the elemtnui table (elemtnui table modifies the color of a line of text)
- 列表懒加载和图片懒加载
- ES6 map extract array object
- 7 矩阵中战斗力最弱的 K 行
- 情况说明和感想
- computed和watch、watchEffect
- Deep copy and shallow copy
- 软件漏洞分析入门(三)
猜你喜欢

Uniapp development, upload pictures in the app and send them directly to OSS

Libtomcrypt密码库的使用

记一次用canvas做出腾讯云首页banner流光效果的经历

Deep copy and shallow copy

Express的使用方法,路由的匹配与使用

Red sun safety range 3

JSX compilation

JS replaces a character in the string, and JS modifies the specified character in the string

The applet is embedded in the web page, jumps to the applet and transmits parameters. The wechat applet realizes the authorization of official account to obtain openid

Page layout - three column layout solution
随机推荐
情况说明和感想
05_回顾Object.defineProperty
What is the QS module?
nmap和nikto扫描
01_ Template syntax
05_ Review object defineProperty
Cento7安装mysql5.5以及升级5.7
Red sun safety range 3
02_ Data binding
Uni app wechat applet - Mall (7) - Product Details
不好意思各位 最近在银行有点事情要处理 耽搁了
Determine whether the two timestamps are the same day
软件漏洞分析入门(四)
JS数组常用方法
uni-app微信公众号(1)——网页授权登录
今天的码农女孩学习了关于事件操作和ref属性的笔记并做了表单双向绑定的练习
Uni app wechat official account (1) - Web page authorization login
我已经妥协了 大家既然都要叫我yelin 那我也没办法了
2022年暑假ACM热身练习1(总结)
object-fit:cover; It doesn't work in the applet. How to deal with the deformation of the applet image