SlideShare une entreprise Scribd logo
1  sur  34
Disclaimer
The Content, Demonstration, Source Code and Programs presented here
is "AS IS" without any warranty or conditions of any kind. Also the
views/ideas/knowledge expressed here are solely of the trainer’s only and
nothing to do with the company or the organization in which the trainer is
currently working.
However in no circumstances neither the trainer nor Cysinfo is
responsible for any damage or loss caused due to use or misuse of the
information presented here.
Acknowledgement
 Special thanks to null & Garage4Hackers community for their extended
support and cooperation.
 Thanks to all the Trainers who have devoted their precious time and
countless hours to make it happen.
www.SecurityXploded.com
Reversing & Malware Analysis Training
This presentation is part of our Reverse Engineering & Malware
Analysis Training program. Currently it is delivered only during our local
meet for FREE of cost.
Who am I #1
Amit Malik (sometimes DouBle_Zer0,DZZ)
 Member Cysinfo
 Security Researcher
 RE, Exploit Analysis/Development, Malware Analysis
 Email: m.amit30@gmail.com
Who am I #2
Swapnil Pathak
 Member SecurityXploded
 Security Researcher
 RE, Malware Analysis, Network Security
 Email: swapnilpathak101@gmail.com
 Intro to x86-32
 Assembly Language
 Instructions
 Stack Operations
 Calling conventions
 Demo
 32 bit instruction set architectures based on Intel 8086 CPU
 Address a linear address space up to 4GB
 8, 32 bit General Purpose Registers (GPR)
 6,16 bit Segment Registers
 EFLAGS and EIP register
 Control Registers (CR0-CR4) (16 bits)
 Memory Management Registers Descriptor Table Registers (GDTR, IDTR,
LDTR)
 Debug Registers ( DR0-DR7)
 Register
◦ Storage Locations.
◦ Much faster access compare to memory locations.
 EAX: Accumulator , mostly stores return values from functions (APIs)
 EBX: Base index (for use with arrays)
 ECX: Counter
 EDX: Data/general
 ESI: Source index for string operations.
 EDI: Destination index for string operations.
 ESP: Stack pointer for top address of the stack.
 EBP: Stack base pointer for holding the address of the current stack frame.
 EIP: Instruction pointer. Holds the program counter, the next instruction
address.
 Segment registers:
◦ Used to address particular segments of memory ( code, data, stack )
!) CS: Code !!) SS: Stack
!!!) ES: Extra !V) DS: Data V) FS, GS
 Bit field of states
 Status Flags
◦ Carrry (CF) : set when an arithmetic carry/borrow has been generated out of
the MSB.
◦ Zero (ZF) : set when an arithmetic operation result is zero and reset otherwise.
◦ Sign (SF) : set when an arithmetic operation set the MSB i.e. the result value
was negative.
◦ Trap (TF ) : when set permits operation of processor in single-step. Mostly used
by debuggers.
◦ Interrupt (IF) : determines whether the CPU should handle maskable hardware
interrupts.
◦ Direction (DF) : determines the direction (left-to-right or right-to-left) of string
processing.
◦ Overflow (OF) : indicates arithmetic overflow.
 Low level programming language
 Symbolic representation of machine codes, constants.
 Assembly language program consist of sequence of process instructions
and meta statements
 Assembler translates them to executable instructions that are loaded into
memory and executed.
 Basic Structure
[label] : opcode operand1, operand2
opcode – mnemonic that symbolize instructions
 Example.
◦ MOV AL, 61h => 10110000 01100001
ADD dst, src
- Adds the values of src and dst and stores the result into dst.
- For example ADD EAX, 1
SUB dst, src
- Subtracts src value from dst and stores the result in dst.
- For example SUB EAX, 1
CMP dst, src
- Subtracts src value from dst but does store the result in dst
- Mostly used to set/reset decision making bits in EFLAGS register such as
ZF
- For example CMP EAX, EBX
MOV dst, src
- Moves data from src (left operand) to destination (right operand)
- For example mov EDI, ESI
Note :
- Both operands cannot be memory locations.
- Both the operands must be of the same size
LEA dst, src
- Stands for Load Effective Address.
- Computes the effective address of src operand and stores it in dst operand.
- For example LEA ECX,[EBX + 5]
Note:
- Generally brackets denote value at memory locations.
- In case of LEA it does simple arithmetic and stores it in dst
XOR dst, src
- Performs a bitwise exclusive OR operation on the dst and src and stores the
result in dst.
- Each bit of the result is 1 if the corresponding bits of the operands are
different, 0 if the corresponding bit are same
Note :
- When used with same register clears the contents of the register
- Optimized way to clear the register. Better than MOV EAX, 0
REP
- Used with string operations
- Repeats a string instruction until ECX (counter register) value is equal to
zero.
- For example REP MOVS byte ptr DS:[EDI], DS:[ESI]
LOOP
- Similar to loops in high level languages
- Used to execute sequence of instructions multiple times.
- For example
MOV ECX, 10
Test : INC EBX
INC EAX
LOOP Test
TEST dst, src
- Performs bitwise logical and between dst and src
- Updates the Zero flag bit of the EFLAGS register
- Mostly used to check if the return value of the function is not zero
- For example TEST EAX, EAX
INT 3h
- Breakpoint instruction
- Used by debuggers to stop execution of the program at particular
instruction
CALL address
- Performs two functions
- Push address of the next instruction on stack (return address)
- Jump to the address specified by the instruction
- For example CALL dword ptr [EAX+4]
RET
- Transfers the control to the address previously pushed on the stack by
CALL instruction
- Mostly denotes the end of the function
Jump instructions
- Categorized as conditional and unconditional
- Unconditional jump instructions
- JMP (Far Jump) – E9 – (Cross segments)
- JMP ( Short Jump ) – EB – (-127 to 128 bytes)
- JMP ( Near Jump ) – E9 – (in a segment)
- For example JMP EAX
- Conditional jump instructions
- Jumps according to bit flags set in the EFLAGS register
- JC, JNC, JZ, JNZ, JS, JNS, JO, JNO
- Unsigned comparisons JA, JAE, JB, JBE
- Signed comparisons JG, JGE, JL, JLE
- Usually followed by CMP instruction
PUSH operand
- Pushes operand on the stack
- Decrements the stack pointer register by operand size
- For example PUSH EAX
POP operand
- Stores the value pointed by the stack pointer in operand
- Increments the stack pointer register by operand size
- For example POP EAX
Note: POP/PUSH EIP is an invalid instruction
PUSHF, POPF
 Describes how the arguments are passed and values returned by functions.
 Steps performed when a function is called
◦ Arguments are passed to the called function
◦ Program execution is transferred to the address of the called function
◦ Called function starts with lines of code that prepare stack and registers for use within
the function. Also known as function prologue.
 For e.g.
push ebp
mov ebp, esp
or with enter instruction
◦ Called function ends with lines of code that restore stack and registers set initially. Also
known as function epilogue.
 For e.g.
mov esp, ebp
pop ebp
ret
or with leave instruction
◦ Passed arguments are removed from the stack, known as stack cleanup. Can be performed
by both calling function or called function depending on the calling convention used.
 __cdecl (C calling convention)
◦ Arguments are passed from right to left and placed on the stack
◦ Stack cleanup is performed by the caller
◦ Return values are stored in EAX register
◦ Standard calling convention used by C compilers
 __stdcall (Standard calling convention)
◦ Arguments are passed from right to left and placed on the stack
◦ Stack cleanup is performed by the called function
◦ Return values are stored in EAX register
◦ Standard calling convention for Microsoft Win32 API
 __fastcall (Fast calling convention)
◦ Arguments passed are stored in registers for faster access
 Thiscall
◦ Arguments are passed from right to left and placed on the stack. this pointer placed in
ECX
- Standard calling convention for calling member functions of C++ classes
 Stack is a LIFO (Last In First Out) type data structure
 Stacks grows downward in memory, from higher memory address to
lower memory address
 PUSH decrement the stack pointer i.e ESP
 POP Increment the stack pointer i.e ESP
 Each function has its own stack frame
 Function prologue setup the stack frame for each function
 Local variable of a function are stored into its stack frame
 Each function creates its own stack.
 Caller function stack: known as parent stack.
 Called function stack: known as child stack.
For e.g.
main(){ ASM Pseudo:
sum(); _main:
} 123: push ebp
124: mov ebp,esp
125: sub esp,val
126: call _sum
127: mov esp,ebp
128: pop ebp
129: ret
 #include <stdio.h>
 /*
 Author: Amit Malik
 http://www.securityxploded.com - Compile in Dev C++
 */
 int mysum(int,int);
 int main()
 {
 int a,b,s;
 a = 5;
 b = 6;
 s = mysum(a,b); // call mysum function
 printf("sum is: %d",s);
 getchar();
 }
 int mysum(int l, int m) // mysum function
 {
 int c;
 c = l + m;
 return c;
 }
 64 bit instruction set architectures based on Intel 8086 CPU
 Address a linear address space up to 16TB
 16, 64 bit General Purpose Registers (GPR)
 6, 16 bit Segment Registers
 RFLAGS and RIP register
 Control Registers (CR0-CR4) and CR8 (16 bits)
 Memory Management Registers Descriptor Table Registers (GDTR,
IDTR, LDTR) size expanded to 10 bytes
 Debug Registers ( DR0-DR7)
Thank You !

Contenu connexe

Tendances

SEH based buffer overflow vulnerability exploitation
SEH based buffer overflow vulnerability exploitationSEH based buffer overflow vulnerability exploitation
SEH based buffer overflow vulnerability exploitationPayampardaz
 
Basic buffer overflow part1
Basic buffer overflow part1Basic buffer overflow part1
Basic buffer overflow part1Payampardaz
 
Reversing & malware analysis training part 3 windows pe file format basics
Reversing & malware analysis training part 3   windows pe file format basicsReversing & malware analysis training part 3   windows pe file format basics
Reversing & malware analysis training part 3 windows pe file format basicssecurityxploded
 
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1  Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1 securityxploded
 
Advanced malware analysis training session 7 malware memory forensics
Advanced malware analysis training session 7 malware memory forensicsAdvanced malware analysis training session 7 malware memory forensics
Advanced malware analysis training session 7 malware memory forensicsCysinfo Cyber Security Community
 
Stack-Based Buffer Overflows
Stack-Based Buffer OverflowsStack-Based Buffer Overflows
Stack-Based Buffer OverflowsDaniel Tumser
 
Reversing & malware analysis training part 2 introduction to windows internals
Reversing & malware analysis training part 2   introduction to windows internalsReversing & malware analysis training part 2   introduction to windows internals
Reversing & malware analysis training part 2 introduction to windows internalssecurityxploded
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automationsecurityxploded
 
Advanced malware analysis training session4 anti-analysis techniques
Advanced malware analysis training session4 anti-analysis techniquesAdvanced malware analysis training session4 anti-analysis techniques
Advanced malware analysis training session4 anti-analysis techniquesCysinfo Cyber Security Community
 
Buffer overflow explained
Buffer overflow explainedBuffer overflow explained
Buffer overflow explainedTeja Babu
 
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...securityxploded
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacksSandun Perera
 
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 1   lab setup guideReversing & malware analysis training part 1   lab setup guide
Reversing & malware analysis training part 1 lab setup guidesecurityxploded
 
JProfiler / an introduction
JProfiler / an introductionJProfiler / an introduction
JProfiler / an introductionTommaso Torti
 
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]securityxploded
 
Reversing malware analysis trainingpart9 advanced malware analysis
Reversing malware analysis trainingpart9 advanced malware analysisReversing malware analysis trainingpart9 advanced malware analysis
Reversing malware analysis trainingpart9 advanced malware analysisCysinfo Cyber Security Community
 

Tendances (20)

Dynamic Binary Instrumentation
Dynamic Binary Instrumentation	Dynamic Binary Instrumentation
Dynamic Binary Instrumentation
 
SEH based buffer overflow vulnerability exploitation
SEH based buffer overflow vulnerability exploitationSEH based buffer overflow vulnerability exploitation
SEH based buffer overflow vulnerability exploitation
 
Basic buffer overflow part1
Basic buffer overflow part1Basic buffer overflow part1
Basic buffer overflow part1
 
Reversing & malware analysis training part 3 windows pe file format basics
Reversing & malware analysis training part 3   windows pe file format basicsReversing & malware analysis training part 3   windows pe file format basics
Reversing & malware analysis training part 3 windows pe file format basics
 
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1  Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 
Advanced malware analysis training session 7 malware memory forensics
Advanced malware analysis training session 7 malware memory forensicsAdvanced malware analysis training session 7 malware memory forensics
Advanced malware analysis training session 7 malware memory forensics
 
Stack-Based Buffer Overflows
Stack-Based Buffer OverflowsStack-Based Buffer Overflows
Stack-Based Buffer Overflows
 
Anti-Virus Evasion Techniques and Countermeasures
Anti-Virus Evasion Techniques and CountermeasuresAnti-Virus Evasion Techniques and Countermeasures
Anti-Virus Evasion Techniques and Countermeasures
 
Reversing & malware analysis training part 2 introduction to windows internals
Reversing & malware analysis training part 2   introduction to windows internalsReversing & malware analysis training part 2   introduction to windows internals
Reversing & malware analysis training part 2 introduction to windows internals
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automation
 
Advanced malware analysis training session4 anti-analysis techniques
Advanced malware analysis training session4 anti-analysis techniquesAdvanced malware analysis training session4 anti-analysis techniques
Advanced malware analysis training session4 anti-analysis techniques
 
Buffer overflow explained
Buffer overflow explainedBuffer overflow explained
Buffer overflow explained
 
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 1   lab setup guideReversing & malware analysis training part 1   lab setup guide
Reversing & malware analysis training part 1 lab setup guide
 
JProfiler / an introduction
JProfiler / an introductionJProfiler / an introduction
JProfiler / an introduction
 
Perl Modules
Perl ModulesPerl Modules
Perl Modules
 
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
 
Reversing malware analysis trainingpart9 advanced malware analysis
Reversing malware analysis trainingpart9 advanced malware analysisReversing malware analysis trainingpart9 advanced malware analysis
Reversing malware analysis trainingpart9 advanced malware analysis
 

En vedette

Reversing malware analysis training part2 introduction to windows internals
Reversing malware analysis training part2 introduction to windows internalsReversing malware analysis training part2 introduction to windows internals
Reversing malware analysis training part2 introduction to windows internalsCysinfo Cyber Security Community
 
Advanced malware analysis training session1 detection and removal of malwares
Advanced malware analysis training session1 detection and removal of malwaresAdvanced malware analysis training session1 detection and removal of malwares
Advanced malware analysis training session1 detection and removal of malwaresCysinfo Cyber Security Community
 
Advanced malware analysis training session3 botnet analysis part2
Advanced malware analysis training session3 botnet analysis part2Advanced malware analysis training session3 botnet analysis part2
Advanced malware analysis training session3 botnet analysis part2Cysinfo Cyber Security Community
 
Reversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basicsReversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basicsCysinfo Cyber Security Community
 
Advanced malware analysis training session11 part2 dissecting the heart beat ...
Advanced malware analysis training session11 part2 dissecting the heart beat ...Advanced malware analysis training session11 part2 dissecting the heart beat ...
Advanced malware analysis training session11 part2 dissecting the heart beat ...Cysinfo Cyber Security Community
 
Advanced malware analysis training session6 malware sandbox analysis
Advanced malware analysis training session6 malware sandbox analysisAdvanced malware analysis training session6 malware sandbox analysis
Advanced malware analysis training session6 malware sandbox analysisCysinfo Cyber Security Community
 
Advanced malware analysis training session8 introduction to android
Advanced malware analysis training session8 introduction to androidAdvanced malware analysis training session8 introduction to android
Advanced malware analysis training session8 introduction to androidCysinfo Cyber Security Community
 
Reversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedReversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedCysinfo Cyber Security Community
 

En vedette (20)

Reversing malware analysis training part2 introduction to windows internals
Reversing malware analysis training part2 introduction to windows internalsReversing malware analysis training part2 introduction to windows internals
Reversing malware analysis training part2 introduction to windows internals
 
Reversing malware analysis training part1 lab setup guide
Reversing malware analysis training part1 lab setup guideReversing malware analysis training part1 lab setup guide
Reversing malware analysis training part1 lab setup guide
 
Security Analytics using ELK stack
Security Analytics using ELK stack	Security Analytics using ELK stack
Security Analytics using ELK stack
 
Reversing malware analysis training part7 unpackingupx
Reversing malware analysis training part7 unpackingupxReversing malware analysis training part7 unpackingupx
Reversing malware analysis training part7 unpackingupx
 
Advanced malware analysis training session1 detection and removal of malwares
Advanced malware analysis training session1 detection and removal of malwaresAdvanced malware analysis training session1 detection and removal of malwares
Advanced malware analysis training session1 detection and removal of malwares
 
Advanced malware analysis training session3 botnet analysis part2
Advanced malware analysis training session3 botnet analysis part2Advanced malware analysis training session3 botnet analysis part2
Advanced malware analysis training session3 botnet analysis part2
 
Reversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basicsReversing malware analysis training part10 exploit development basics
Reversing malware analysis training part10 exploit development basics
 
Linux Malware Analysis
Linux Malware Analysis	Linux Malware Analysis
Linux Malware Analysis
 
Advanced malware analysis training session11 part2 dissecting the heart beat ...
Advanced malware analysis training session11 part2 dissecting the heart beat ...Advanced malware analysis training session11 part2 dissecting the heart beat ...
Advanced malware analysis training session11 part2 dissecting the heart beat ...
 
Advanced malware analysis training session6 malware sandbox analysis
Advanced malware analysis training session6 malware sandbox analysisAdvanced malware analysis training session6 malware sandbox analysis
Advanced malware analysis training session6 malware sandbox analysis
 
Advanced malware analysis training session8 introduction to android
Advanced malware analysis training session8 introduction to androidAdvanced malware analysis training session8 introduction to android
Advanced malware analysis training session8 introduction to android
 
Reversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedReversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advanced
 
Introduction to Binary Exploitation
Introduction to Binary Exploitation	Introduction to Binary Exploitation
Introduction to Binary Exploitation
 
Advanced malware analysis training session10 part1
Advanced malware analysis training session10 part1Advanced malware analysis training session10 part1
Advanced malware analysis training session10 part1
 
XXE - XML External Entity Attack
XXE - XML External Entity Attack	XXE - XML External Entity Attack
XXE - XML External Entity Attack
 
ATM Malware: Understanding the threat
ATM Malware: Understanding the threat	ATM Malware: Understanding the threat
ATM Malware: Understanding the threat
 
Image (PNG) Forensic Analysis
Image (PNG) Forensic Analysis	Image (PNG) Forensic Analysis
Image (PNG) Forensic Analysis
 
Malware Detection using Machine Learning
Malware Detection using Machine Learning	Malware Detection using Machine Learning
Malware Detection using Machine Learning
 
Automating malware analysis
Automating malware analysis Automating malware analysis
Automating malware analysis
 
Malicious Client Detection using Machine learning
Malicious Client Detection using Machine learningMalicious Client Detection using Machine learning
Malicious Client Detection using Machine learning
 

Similaire à Reversing malware analysis training part4 assembly programming basics

Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics Abdulrahman Bassam
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applicationscommiebstrd
 
Assembly language
Assembly languageAssembly language
Assembly languagePiyush Jain
 
Introduction to Assembly Language
Introduction to Assembly Language Introduction to Assembly Language
Introduction to Assembly Language ApekshaShinde6
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptMuhammad Sikandar Mustafa
 
Exploit techniques - a quick review
Exploit techniques - a quick reviewExploit techniques - a quick review
Exploit techniques - a quick reviewCe.Se.N.A. Security
 
02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stack02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stackAlexandre Moneger
 
Malware Analysis - x86 Disassembly
Malware Analysis - x86 DisassemblyMalware Analysis - x86 Disassembly
Malware Analysis - x86 DisassemblyNatraj G
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Elvin Gentiles
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacksJapneet Singh
 
Buffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly RequiredBuffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly RequiredKory Kyzar
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Akhila Rahul
 

Similaire à Reversing malware analysis training part4 assembly programming basics (20)

Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applications
 
[ASM]Lab6
[ASM]Lab6[ASM]Lab6
[ASM]Lab6
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Advance ROP Attacks
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacks
 
Introduction to Assembly Language
Introduction to Assembly Language Introduction to Assembly Language
Introduction to Assembly Language
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 
Coal (1)
Coal (1)Coal (1)
Coal (1)
 
Exploit techniques - a quick review
Exploit techniques - a quick reviewExploit techniques - a quick review
Exploit techniques - a quick review
 
02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stack02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stack
 
Malware Analysis - x86 Disassembly
Malware Analysis - x86 DisassemblyMalware Analysis - x86 Disassembly
Malware Analysis - x86 Disassembly
 
Exploitation Crash Course
Exploitation Crash CourseExploitation Crash Course
Exploitation Crash Course
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
 
Software Exploitation Techniques by Amit Malik
Software Exploitation Techniques by Amit MalikSoftware Exploitation Techniques by Amit Malik
Software Exploitation Techniques by Amit Malik
 
Buffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly RequiredBuffer Overflows 101: Some Assembly Required
Buffer Overflows 101: Some Assembly Required
 
Theperlreview
TheperlreviewTheperlreview
Theperlreview
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
ISA.pptx
ISA.pptxISA.pptx
ISA.pptx
 

Plus de Cysinfo Cyber Security Community

Understanding Malware Persistence Techniques by Monnappa K A
Understanding Malware Persistence Techniques by Monnappa K AUnderstanding Malware Persistence Techniques by Monnappa K A
Understanding Malware Persistence Techniques by Monnappa K ACysinfo Cyber Security Community
 
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviUnderstanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviCysinfo Cyber Security Community
 
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TK
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TKGetting started with cybersecurity through CTFs by Shruti Dixit & Geethna TK
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TKCysinfo Cyber Security Community
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiCysinfo Cyber Security Community
 
Reversing and Decrypting Malware Communications by Monnappa
Reversing and Decrypting Malware Communications by MonnappaReversing and Decrypting Malware Communications by Monnappa
Reversing and Decrypting Malware Communications by MonnappaCysinfo Cyber Security Community
 
Understanding evasive hollow process injection techniques monnappa k a
Understanding evasive hollow process injection techniques   	monnappa k aUnderstanding evasive hollow process injection techniques   	monnappa k a
Understanding evasive hollow process injection techniques monnappa k aCysinfo Cyber Security Community
 
Security challenges in d2d communication by ajithkumar vyasarao
Security challenges in d2d communication  by ajithkumar vyasaraoSecurity challenges in d2d communication  by ajithkumar vyasarao
Security challenges in d2d communication by ajithkumar vyasaraoCysinfo Cyber Security Community
 

Plus de Cysinfo Cyber Security Community (20)

Understanding Malware Persistence Techniques by Monnappa K A
Understanding Malware Persistence Techniques by Monnappa K AUnderstanding Malware Persistence Techniques by Monnappa K A
Understanding Malware Persistence Techniques by Monnappa K A
 
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviUnderstanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
 
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TK
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TKGetting started with cybersecurity through CTFs by Shruti Dixit & Geethna TK
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TK
 
Emerging Trends in Cybersecurity by Amar Prusty
Emerging Trends in Cybersecurity by Amar PrustyEmerging Trends in Cybersecurity by Amar Prusty
Emerging Trends in Cybersecurity by Amar Prusty
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
 
Closer look at PHP Unserialization by Ashwin Shenoi
Closer look at PHP Unserialization by Ashwin ShenoiCloser look at PHP Unserialization by Ashwin Shenoi
Closer look at PHP Unserialization by Ashwin Shenoi
 
Unicorn: The Ultimate CPU Emulator by Akshay Ajayan
Unicorn: The Ultimate CPU Emulator by Akshay AjayanUnicorn: The Ultimate CPU Emulator by Akshay Ajayan
Unicorn: The Ultimate CPU Emulator by Akshay Ajayan
 
The Art of Executing JavaScript by Akhil Mahendra
The Art of Executing JavaScript by Akhil MahendraThe Art of Executing JavaScript by Akhil Mahendra
The Art of Executing JavaScript by Akhil Mahendra
 
Reversing and Decrypting Malware Communications by Monnappa
Reversing and Decrypting Malware Communications by MonnappaReversing and Decrypting Malware Communications by Monnappa
Reversing and Decrypting Malware Communications by Monnappa
 
DeViL - Detect Virtual Machine in Linux by Sreelakshmi
DeViL - Detect Virtual Machine in Linux by SreelakshmiDeViL - Detect Virtual Machine in Linux by Sreelakshmi
DeViL - Detect Virtual Machine in Linux by Sreelakshmi
 
Analysis of android apk using adhrit by Abhishek J.M
 Analysis of android apk using adhrit by Abhishek J.M Analysis of android apk using adhrit by Abhishek J.M
Analysis of android apk using adhrit by Abhishek J.M
 
Understanding evasive hollow process injection techniques monnappa k a
Understanding evasive hollow process injection techniques   	monnappa k aUnderstanding evasive hollow process injection techniques   	monnappa k a
Understanding evasive hollow process injection techniques monnappa k a
 
Security challenges in d2d communication by ajithkumar vyasarao
Security challenges in d2d communication  by ajithkumar vyasaraoSecurity challenges in d2d communication  by ajithkumar vyasarao
Security challenges in d2d communication by ajithkumar vyasarao
 
S2 e (selective symbolic execution) -shivkrishna a
S2 e (selective symbolic execution) -shivkrishna aS2 e (selective symbolic execution) -shivkrishna a
S2 e (selective symbolic execution) -shivkrishna a
 
Dynamic binary analysis using angr siddharth muralee
Dynamic binary analysis using angr   siddharth muraleeDynamic binary analysis using angr   siddharth muralee
Dynamic binary analysis using angr siddharth muralee
 
Bit flipping attack on aes cbc - ashutosh ahelleya
Bit flipping attack on aes cbc -	ashutosh ahelleyaBit flipping attack on aes cbc -	ashutosh ahelleya
Bit flipping attack on aes cbc - ashutosh ahelleya
 
POS Malware: Is your Debit/Credit Transcations Secure?
POS Malware: Is your Debit/Credit Transcations Secure?POS Malware: Is your Debit/Credit Transcations Secure?
POS Malware: Is your Debit/Credit Transcations Secure?
 
Introduction to ICS/SCADA security
Introduction to ICS/SCADA securityIntroduction to ICS/SCADA security
Introduction to ICS/SCADA security
 
Format string vunerability
Format string vunerabilityFormat string vunerability
Format string vunerability
 
Deep Web - what to do and what not to do
Deep Web - what to do and what not to do	Deep Web - what to do and what not to do
Deep Web - what to do and what not to do
 

Dernier

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Reversing malware analysis training part4 assembly programming basics

  • 1.
  • 2. Disclaimer The Content, Demonstration, Source Code and Programs presented here is "AS IS" without any warranty or conditions of any kind. Also the views/ideas/knowledge expressed here are solely of the trainer’s only and nothing to do with the company or the organization in which the trainer is currently working. However in no circumstances neither the trainer nor Cysinfo is responsible for any damage or loss caused due to use or misuse of the information presented here.
  • 3. Acknowledgement  Special thanks to null & Garage4Hackers community for their extended support and cooperation.  Thanks to all the Trainers who have devoted their precious time and countless hours to make it happen. www.SecurityXploded.com
  • 4. Reversing & Malware Analysis Training This presentation is part of our Reverse Engineering & Malware Analysis Training program. Currently it is delivered only during our local meet for FREE of cost.
  • 5. Who am I #1 Amit Malik (sometimes DouBle_Zer0,DZZ)  Member Cysinfo  Security Researcher  RE, Exploit Analysis/Development, Malware Analysis  Email: m.amit30@gmail.com
  • 6. Who am I #2 Swapnil Pathak  Member SecurityXploded  Security Researcher  RE, Malware Analysis, Network Security  Email: swapnilpathak101@gmail.com
  • 7.  Intro to x86-32  Assembly Language  Instructions  Stack Operations  Calling conventions  Demo
  • 8.  32 bit instruction set architectures based on Intel 8086 CPU  Address a linear address space up to 4GB  8, 32 bit General Purpose Registers (GPR)  6,16 bit Segment Registers  EFLAGS and EIP register  Control Registers (CR0-CR4) (16 bits)  Memory Management Registers Descriptor Table Registers (GDTR, IDTR, LDTR)  Debug Registers ( DR0-DR7)
  • 9.  Register ◦ Storage Locations. ◦ Much faster access compare to memory locations.  EAX: Accumulator , mostly stores return values from functions (APIs)  EBX: Base index (for use with arrays)  ECX: Counter  EDX: Data/general  ESI: Source index for string operations.
  • 10.  EDI: Destination index for string operations.  ESP: Stack pointer for top address of the stack.  EBP: Stack base pointer for holding the address of the current stack frame.  EIP: Instruction pointer. Holds the program counter, the next instruction address.  Segment registers: ◦ Used to address particular segments of memory ( code, data, stack ) !) CS: Code !!) SS: Stack !!!) ES: Extra !V) DS: Data V) FS, GS
  • 11.
  • 12.  Bit field of states  Status Flags ◦ Carrry (CF) : set when an arithmetic carry/borrow has been generated out of the MSB. ◦ Zero (ZF) : set when an arithmetic operation result is zero and reset otherwise. ◦ Sign (SF) : set when an arithmetic operation set the MSB i.e. the result value was negative. ◦ Trap (TF ) : when set permits operation of processor in single-step. Mostly used by debuggers. ◦ Interrupt (IF) : determines whether the CPU should handle maskable hardware interrupts. ◦ Direction (DF) : determines the direction (left-to-right or right-to-left) of string processing. ◦ Overflow (OF) : indicates arithmetic overflow.
  • 13.  Low level programming language  Symbolic representation of machine codes, constants.  Assembly language program consist of sequence of process instructions and meta statements  Assembler translates them to executable instructions that are loaded into memory and executed.  Basic Structure [label] : opcode operand1, operand2 opcode – mnemonic that symbolize instructions  Example. ◦ MOV AL, 61h => 10110000 01100001
  • 14. ADD dst, src - Adds the values of src and dst and stores the result into dst. - For example ADD EAX, 1 SUB dst, src - Subtracts src value from dst and stores the result in dst. - For example SUB EAX, 1 CMP dst, src - Subtracts src value from dst but does store the result in dst - Mostly used to set/reset decision making bits in EFLAGS register such as ZF - For example CMP EAX, EBX
  • 15. MOV dst, src - Moves data from src (left operand) to destination (right operand) - For example mov EDI, ESI Note : - Both operands cannot be memory locations. - Both the operands must be of the same size LEA dst, src - Stands for Load Effective Address. - Computes the effective address of src operand and stores it in dst operand. - For example LEA ECX,[EBX + 5] Note: - Generally brackets denote value at memory locations. - In case of LEA it does simple arithmetic and stores it in dst
  • 16. XOR dst, src - Performs a bitwise exclusive OR operation on the dst and src and stores the result in dst. - Each bit of the result is 1 if the corresponding bits of the operands are different, 0 if the corresponding bit are same Note : - When used with same register clears the contents of the register - Optimized way to clear the register. Better than MOV EAX, 0
  • 17. REP - Used with string operations - Repeats a string instruction until ECX (counter register) value is equal to zero. - For example REP MOVS byte ptr DS:[EDI], DS:[ESI] LOOP - Similar to loops in high level languages - Used to execute sequence of instructions multiple times. - For example MOV ECX, 10 Test : INC EBX INC EAX LOOP Test
  • 18. TEST dst, src - Performs bitwise logical and between dst and src - Updates the Zero flag bit of the EFLAGS register - Mostly used to check if the return value of the function is not zero - For example TEST EAX, EAX INT 3h - Breakpoint instruction - Used by debuggers to stop execution of the program at particular instruction
  • 19. CALL address - Performs two functions - Push address of the next instruction on stack (return address) - Jump to the address specified by the instruction - For example CALL dword ptr [EAX+4] RET - Transfers the control to the address previously pushed on the stack by CALL instruction - Mostly denotes the end of the function
  • 20. Jump instructions - Categorized as conditional and unconditional - Unconditional jump instructions - JMP (Far Jump) – E9 – (Cross segments) - JMP ( Short Jump ) – EB – (-127 to 128 bytes) - JMP ( Near Jump ) – E9 – (in a segment) - For example JMP EAX - Conditional jump instructions - Jumps according to bit flags set in the EFLAGS register - JC, JNC, JZ, JNZ, JS, JNS, JO, JNO - Unsigned comparisons JA, JAE, JB, JBE - Signed comparisons JG, JGE, JL, JLE - Usually followed by CMP instruction
  • 21. PUSH operand - Pushes operand on the stack - Decrements the stack pointer register by operand size - For example PUSH EAX POP operand - Stores the value pointed by the stack pointer in operand - Increments the stack pointer register by operand size - For example POP EAX Note: POP/PUSH EIP is an invalid instruction PUSHF, POPF
  • 22.  Describes how the arguments are passed and values returned by functions.  Steps performed when a function is called ◦ Arguments are passed to the called function ◦ Program execution is transferred to the address of the called function ◦ Called function starts with lines of code that prepare stack and registers for use within the function. Also known as function prologue.  For e.g. push ebp mov ebp, esp or with enter instruction ◦ Called function ends with lines of code that restore stack and registers set initially. Also known as function epilogue.  For e.g. mov esp, ebp pop ebp ret or with leave instruction ◦ Passed arguments are removed from the stack, known as stack cleanup. Can be performed by both calling function or called function depending on the calling convention used.
  • 23.  __cdecl (C calling convention) ◦ Arguments are passed from right to left and placed on the stack ◦ Stack cleanup is performed by the caller ◦ Return values are stored in EAX register ◦ Standard calling convention used by C compilers  __stdcall (Standard calling convention) ◦ Arguments are passed from right to left and placed on the stack ◦ Stack cleanup is performed by the called function ◦ Return values are stored in EAX register ◦ Standard calling convention for Microsoft Win32 API  __fastcall (Fast calling convention) ◦ Arguments passed are stored in registers for faster access  Thiscall ◦ Arguments are passed from right to left and placed on the stack. this pointer placed in ECX - Standard calling convention for calling member functions of C++ classes
  • 24.  Stack is a LIFO (Last In First Out) type data structure  Stacks grows downward in memory, from higher memory address to lower memory address  PUSH decrement the stack pointer i.e ESP  POP Increment the stack pointer i.e ESP  Each function has its own stack frame  Function prologue setup the stack frame for each function  Local variable of a function are stored into its stack frame
  • 25.
  • 26.
  • 27.  Each function creates its own stack.  Caller function stack: known as parent stack.  Called function stack: known as child stack. For e.g. main(){ ASM Pseudo: sum(); _main: } 123: push ebp 124: mov ebp,esp 125: sub esp,val 126: call _sum 127: mov esp,ebp 128: pop ebp 129: ret
  • 28.
  • 29.
  • 30.
  • 31.  #include <stdio.h>  /*  Author: Amit Malik  http://www.securityxploded.com - Compile in Dev C++  */  int mysum(int,int);  int main()  {  int a,b,s;  a = 5;  b = 6;  s = mysum(a,b); // call mysum function  printf("sum is: %d",s);  getchar();  }  int mysum(int l, int m) // mysum function  {  int c;  c = l + m;  return c;  }
  • 32.
  • 33.  64 bit instruction set architectures based on Intel 8086 CPU  Address a linear address space up to 16TB  16, 64 bit General Purpose Registers (GPR)  6, 16 bit Segment Registers  RFLAGS and RIP register  Control Registers (CR0-CR4) and CR8 (16 bits)  Memory Management Registers Descriptor Table Registers (GDTR, IDTR, LDTR) size expanded to 10 bytes  Debug Registers ( DR0-DR7)

Notes de l'éditeur

  1. The first three instructions (123,124,125) are known as prologue. And last three instructions(127,128,129) are know as epilogue. When main call the the sum it push the address of next instruction on stack..means 127 on stack and then create its stack. See next slides.
  2. Here main is preparing its stack. EBP (base pointer) register is used to track the variables. So we need to push parent function ebp on the stack so that when function return to parent function it can start normally.
  3. The instruction mov ebp,esp setting the stack for main(or setting the ebp for main to track variables). And sub esp, val is creating the space for local variables of main function. Although in e.g. we have no local variable but this is for illustrative purpose. NOTE: As we can see in the above pic that stack grows downward (from higher memory address to lower memory address) means something [ebp+val] point to parameters for function (can be pass by value or pass by reference) and everything [ebp-val] point to the local variable for that function. *val- can be any value in hex..like 3,4,a,b etc. etc. Note: ret (startup) address is the address of next instruction in startup function. Explanation of startup function is beyond the scope of this presentation. But main function return 0 or 1 to startup function. Means process successfully completed or error.
  4. Now main is calling sum. The first task is to push the address of next instruction means address 127 on stack. So that when function sum return it returns to 127 so that program execution continue in a normal way. Please note that no (another) instruction is required to push ret(127) on stack because call sum will do it for us.. Similar to like main, sum will creates its stack with similar instructions and also destroy its stack with similar instructions (127,128,129). Note: The instructions to create stack and destroy stack.. may vary with compiler to complier and are the issues of compiler optimization..for eg. Some compilers user push reg. instead of sub esp,val for integers.