SlideShare une entreprise Scribd logo
1  sur  21
www.SecurityXploded.com
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 SecurityXploded is
responsible for any damage or loss caused due to use or misuse of the
information presented here.




                              www.SecurityXploded.com
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.




For complete details of this course, visit our Security Training page.


                              www.SecurityXploded.com
harsimranwalia.info
   b44nz0r
   Research Scientist @ McAfee Labs
   Mechanical Engineer @IIT Delhi
   Independent Security Researcher
   RE, Exploit Analysis/Development, Malware Analysis


Twitter : b44nz0r
Email : walia.harsimran@gmail.com
Outline
 Break Point
 Debug Registers
 Flags
 API Help
Types of Breakpoints
 Software
 Hardware
 Memory
Breakpoint
   Software breakpoints are set by replacing the instruction
    at the target address with 0xCC (INT3/ Breakpoint
    interrupt)
   Hardware breakpoints are set via debug registers. Only 4
    hardware breakpoints can be set
   Debug registers:
     8 debug registers present
     DR0 – DR3 : Address of breakpoint
     DR6 : Debug Status – To determine which breakpoint is active
     DR7 : Debug Control – Flags to control the breakpoints such as
      break on read or on-write
   Debug registers are not accessible in Ring 3
Hardware Breakpoints
Memory
   To access memory, need of permissions
   Lots of permissions
       PAGE_GUARD
       PAGE_READWRITE
       PAGE_EXECUTE
       PAGE_EXECUTE_READ
   To set memory breakpoint,
     the permissions of that memory region is set to
      PAGE_GUARD
     whenever an access is made to that memory
      STATUS_GUARD_PAGE_VIOLATION exception is raised
     On getting the exception the debugger changes the
      permission back to the original
     Notifies the user of the breakpoint
Breakpoints
Flags (Eflags Register)
 1 register – 32 bits
 Each bit signifies a flag
 Few important ones are:

              Bit #        Abbreviation         Description

         0            CF                  Carry flag

         2            PF                  Parity flag

         4            AF                  Adjust flag

         6            ZF                  Zero flag

         7            SF                  Sign flag


         8            TF                  Trap flag (single step)



         9            IF                  Interrupt enable flag


         11           OF                  Overflow flag
Flags Demystified
   Carry flag is used to indicate when an arithmetic carry or borrow has
    been generated out of the most significant ALU bit position
   Parity flag indicates if the number of set bits is odd or even in the
    binary representation of the result of the last operation
   Adjust flag is used to indicate when an arithmetic carry or borrow has
    been generated out of the 4 least significant bits
   Zero Flag is used to check the result of an arithmetic operation,
    including bitwise logical instructions. It is set if an arithmetic result is
    zero, and reset otherwise
   Sign flag is used to indicate whether the result of last mathematic
    operation resulted in a value whose most significant bit was set
   A trap flag permits operation of a processor in single-step mode
   Overflow flag is used to indicate when an arithmetic overflow has
    occurred in an operation, indicating that the signed two's-
    complement result would not fit in the number of bits used for the
    operation
Basic Reversing Techniques
 Check for readable strings
 Import table (IAT) for imported Windows
  API
 Setting breakpoint on interesting API
 Single stepping
Variables
   Found under Names tab
     ○ L - library function
     ○ F - regular function
     ○ C - instruction
     ○ A - ascii string
     ○ D - data
     ○ I - imported name




                          www.SecurityXploded.com
Contd..



   Global variables are generally dword_<address>
     dword_402000 – as shown in image


   Local variables are of the form var_<offset>
     var_6C – as shown in image




                            www.SecurityXploded.com
Loop in IDA
   Red Line
     If condition is false
     (zero flag = 0)
   Green Line
     If condition is true
     (zero flag = 1)




                          www.SecurityXploded.com
Reversing a Simple Crackme
#include <stdio.h>
               #include <string.h>
               #include <stdlib.h>

               int main()
               {
                 char a[10],b[10],c[10],d[10];
                 int i,j,k,l,r,s;
                 printf("#Crackmenn");
                 printf("enter username: ");
                 scanf("%s",a);
                 printf("enter password: ");
                 scanf("%s",b);
                 k = strlen(a);


Crackme Code     l = strlen(b);
                 if (k <5 || k >=10){
                     printf("nInvalid! Username Lengthn");
                     printf("nHit Enter to Exitn");
                     getchar();
                 } else {
                 if (l != k){
                     printf("nInvalid! Password Lengthn");
                     printf("nHit Enter to Exitn");
                    getchar();
                 } else {
                    i = k-1;
                    j = 0;
                    while (i >= 0){
                        c[j] = a[i]+i;
                        i--;
                        j++;
                    }
                    c[j] = 0;
                    r = strlen(c);
                    if (r == l){
                        i = strcmp(c,b);
                        if (i == 0){
                          printf("nCongratulations! You did it..n");
                          printf("nHit Enter to Exitn");
                        } else {
                          printf("nAccess Denied! Wrong Passwordn");
References
   Complete Reference Guide for Reversing &
    Malware Analysis Training
Thank You !



www.SecurityXploded.com

Contenu connexe

Tendances

Tendances (20)

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]
 
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysis
Advanced Malware Analysis Training Session 6  - Malware Sandbox AnalysisAdvanced Malware Analysis Training Session 6  - Malware Sandbox Analysis
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysis
 
Advanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
Advanced Malware Analysis Training Session 4 - Anti-Analysis TechniquesAdvanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
Advanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
 
Advanced Malware Analysis Training Session 3 - Botnet Analysis Part 2
Advanced Malware Analysis Training Session 3 - Botnet Analysis Part 2Advanced Malware Analysis Training Session 3 - Botnet Analysis Part 2
Advanced Malware Analysis Training Session 3 - Botnet Analysis Part 2
 
Dynamic Binary Instrumentation
Dynamic Binary Instrumentation	Dynamic Binary Instrumentation
Dynamic Binary Instrumentation
 
Ida python intro
Ida python introIda python intro
Ida python intro
 
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automationAdvanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automation
 
Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1
 
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
 
Primer on password security
Primer on password securityPrimer on password security
Primer on password security
 
Reversing malware analysis training part6 practical reversing
Reversing malware analysis training part6 practical reversingReversing malware analysis training part6 practical reversing
Reversing malware analysis training part6 practical reversing
 
Reversing malware analysis training part3 windows pefile formatbasics
Reversing malware analysis training part3 windows pefile formatbasicsReversing malware analysis training part3 windows pefile formatbasics
Reversing malware analysis training part3 windows pefile formatbasics
 
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
 
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
Reversing & Malware Analysis Training Part 9 -  Advanced Malware AnalysisReversing & Malware Analysis Training Part 9 -  Advanced Malware Analysis
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
 
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit MitigationsCaptain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
 
Advanced Malware Analysis Training Session 1 - Detection and Removal of Malwares
Advanced Malware Analysis Training Session 1 - Detection and Removal of MalwaresAdvanced Malware Analysis Training Session 1 - Detection and Removal of Malwares
Advanced Malware Analysis Training Session 1 - Detection and Removal of Malwares
 
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...
 
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
 
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
 
Indicators of compromise: From malware analysis to eradication
Indicators of compromise: From malware analysis to eradicationIndicators of compromise: From malware analysis to eradication
Indicators of compromise: From malware analysis to eradication
 

Similaire à Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)

Reversing & malware analysis training part 6 practical reversing (i)
Reversing & malware analysis training part 6   practical reversing (i)Reversing & malware analysis training part 6   practical reversing (i)
Reversing & malware analysis training part 6 practical reversing (i)
Abdulrahman Bassam
 
C ISRO Debugging
C ISRO DebuggingC ISRO Debugging
C ISRO Debugging
splix757
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP
 

Similaire à Reversing & Malware Analysis Training Part 6 - Practical Reversing (I) (20)

Reversing & malware analysis training part 6 practical reversing (i)
Reversing & malware analysis training part 6   practical reversing (i)Reversing & malware analysis training part 6   practical reversing (i)
Reversing & malware analysis training part 6 practical reversing (i)
 
C tutorial
C tutorialC tutorial
C tutorial
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
C ISRO Debugging
C ISRO DebuggingC ISRO Debugging
C ISRO Debugging
 
C C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.inC C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.in
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 
C tutorial
C tutorialC tutorial
C tutorial
 
Secure Programming
Secure ProgrammingSecure Programming
Secure Programming
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
lec7-program-verification.pdf
lec7-program-verification.pdflec7-program-verification.pdf
lec7-program-verification.pdf
 
C Basics
C BasicsC Basics
C Basics
 
Exploiting buffer overflows
Exploiting buffer overflowsExploiting buffer overflows
Exploiting buffer overflows
 
Presentation1
Presentation1Presentation1
Presentation1
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
Fundamental of programming - مقدمات برنامه نویسی
Fundamental of programming - مقدمات برنامه نویسیFundamental of programming - مقدمات برنامه نویسی
Fundamental of programming - مقدمات برنامه نویسی
 

Plus de securityxploded

Plus de securityxploded (20)

Fingerprinting healthcare institutions
Fingerprinting healthcare institutionsFingerprinting healthcare institutions
Fingerprinting healthcare institutions
 
Hollow Process Injection - Reversing and Investigating Malware Evasive Tactics
Hollow Process Injection - Reversing and Investigating Malware Evasive TacticsHollow Process Injection - Reversing and Investigating Malware Evasive Tactics
Hollow Process Injection - Reversing and Investigating Malware Evasive Tactics
 
Buffer Overflow Attacks
Buffer Overflow AttacksBuffer Overflow Attacks
Buffer Overflow Attacks
 
Malicious Client Detection Using Machine Learning
Malicious Client Detection Using Machine LearningMalicious Client Detection Using Machine Learning
Malicious Client Detection Using Machine Learning
 
Understanding CryptoLocker (Ransomware) with a Case Study
Understanding CryptoLocker (Ransomware) with a Case StudyUnderstanding CryptoLocker (Ransomware) with a Case Study
Understanding CryptoLocker (Ransomware) with a Case Study
 
Linux Malware Analysis using Limon Sandbox
Linux Malware Analysis using Limon SandboxLinux Malware Analysis using Limon Sandbox
Linux Malware Analysis using Limon Sandbox
 
Introduction to SMPC
Introduction to SMPCIntroduction to SMPC
Introduction to SMPC
 
Breaking into hospitals
Breaking into hospitalsBreaking into hospitals
Breaking into hospitals
 
Bluetooth [in]security
Bluetooth [in]securityBluetooth [in]security
Bluetooth [in]security
 
Basic malware analysis
Basic malware analysisBasic malware analysis
Basic malware analysis
 
Automating Malware Analysis
Automating Malware AnalysisAutomating Malware Analysis
Automating Malware Analysis
 
Reverse Engineering Malware
Reverse Engineering MalwareReverse Engineering Malware
Reverse Engineering Malware
 
DLL Preloading Attack
DLL Preloading AttackDLL Preloading Attack
DLL Preloading Attack
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryption
 
Hunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of MemoryHunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of Memory
 
Return Address – The Silver Bullet
Return Address – The Silver BulletReturn Address – The Silver Bullet
Return Address – The Silver Bullet
 
Defeating public exploit protections (EMET v5.2 and more)
Defeating public exploit protections (EMET v5.2 and more)Defeating public exploit protections (EMET v5.2 and more)
Defeating public exploit protections (EMET v5.2 and more)
 
Hunting Ghost RAT Using Memory Forensics
Hunting Ghost RAT Using Memory ForensicsHunting Ghost RAT Using Memory Forensics
Hunting Ghost RAT Using Memory Forensics
 
Malicious Url Detection Using Machine Learning
Malicious Url Detection Using Machine LearningMalicious Url Detection Using Machine Learning
Malicious Url Detection Using Machine Learning
 
Anatomy of Exploit Kits
Anatomy of Exploit KitsAnatomy of Exploit Kits
Anatomy of Exploit Kits
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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...
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)

  • 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 SecurityXploded is responsible for any damage or loss caused due to use or misuse of the information presented here. www.SecurityXploded.com
  • 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. For complete details of this course, visit our Security Training page. www.SecurityXploded.com
  • 5. harsimranwalia.info  b44nz0r  Research Scientist @ McAfee Labs  Mechanical Engineer @IIT Delhi  Independent Security Researcher  RE, Exploit Analysis/Development, Malware Analysis Twitter : b44nz0r Email : walia.harsimran@gmail.com
  • 6. Outline  Break Point  Debug Registers  Flags  API Help
  • 7. Types of Breakpoints  Software  Hardware  Memory
  • 8. Breakpoint  Software breakpoints are set by replacing the instruction at the target address with 0xCC (INT3/ Breakpoint interrupt)  Hardware breakpoints are set via debug registers. Only 4 hardware breakpoints can be set  Debug registers:  8 debug registers present  DR0 – DR3 : Address of breakpoint  DR6 : Debug Status – To determine which breakpoint is active  DR7 : Debug Control – Flags to control the breakpoints such as break on read or on-write  Debug registers are not accessible in Ring 3
  • 10. Memory  To access memory, need of permissions  Lots of permissions  PAGE_GUARD  PAGE_READWRITE  PAGE_EXECUTE  PAGE_EXECUTE_READ  To set memory breakpoint,  the permissions of that memory region is set to PAGE_GUARD  whenever an access is made to that memory STATUS_GUARD_PAGE_VIOLATION exception is raised  On getting the exception the debugger changes the permission back to the original  Notifies the user of the breakpoint
  • 12. Flags (Eflags Register)  1 register – 32 bits  Each bit signifies a flag  Few important ones are: Bit # Abbreviation Description 0 CF Carry flag 2 PF Parity flag 4 AF Adjust flag 6 ZF Zero flag 7 SF Sign flag 8 TF Trap flag (single step) 9 IF Interrupt enable flag 11 OF Overflow flag
  • 13. Flags Demystified  Carry flag is used to indicate when an arithmetic carry or borrow has been generated out of the most significant ALU bit position  Parity flag indicates if the number of set bits is odd or even in the binary representation of the result of the last operation  Adjust flag is used to indicate when an arithmetic carry or borrow has been generated out of the 4 least significant bits  Zero Flag is used to check the result of an arithmetic operation, including bitwise logical instructions. It is set if an arithmetic result is zero, and reset otherwise  Sign flag is used to indicate whether the result of last mathematic operation resulted in a value whose most significant bit was set  A trap flag permits operation of a processor in single-step mode  Overflow flag is used to indicate when an arithmetic overflow has occurred in an operation, indicating that the signed two's- complement result would not fit in the number of bits used for the operation
  • 14. Basic Reversing Techniques  Check for readable strings  Import table (IAT) for imported Windows API  Setting breakpoint on interesting API  Single stepping
  • 15. Variables  Found under Names tab ○ L - library function ○ F - regular function ○ C - instruction ○ A - ascii string ○ D - data ○ I - imported name www.SecurityXploded.com
  • 16. Contd..  Global variables are generally dword_<address>  dword_402000 – as shown in image  Local variables are of the form var_<offset>  var_6C – as shown in image www.SecurityXploded.com
  • 17. Loop in IDA  Red Line  If condition is false  (zero flag = 0)  Green Line  If condition is true  (zero flag = 1) www.SecurityXploded.com
  • 19. #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char a[10],b[10],c[10],d[10]; int i,j,k,l,r,s; printf("#Crackmenn"); printf("enter username: "); scanf("%s",a); printf("enter password: "); scanf("%s",b); k = strlen(a); Crackme Code l = strlen(b); if (k <5 || k >=10){ printf("nInvalid! Username Lengthn"); printf("nHit Enter to Exitn"); getchar(); } else { if (l != k){ printf("nInvalid! Password Lengthn"); printf("nHit Enter to Exitn"); getchar(); } else { i = k-1; j = 0; while (i >= 0){ c[j] = a[i]+i; i--; j++; } c[j] = 0; r = strlen(c); if (r == l){ i = strcmp(c,b); if (i == 0){ printf("nCongratulations! You did it..n"); printf("nHit Enter to Exitn"); } else { printf("nAccess Denied! Wrong Passwordn");
  • 20. References  Complete Reference Guide for Reversing & Malware Analysis Training

Notes de l'éditeur

  1. #include &lt;stdio.h&gt;#include &lt;string.h&gt;#include &lt;stdlib.h&gt;int main(){ char a[10],b[10],c[10],d[10];inti,j,k,l,r,s;printf(&quot;#Crackme\\n\\n&quot;);printf(&quot;enter username: &quot;);scanf(&quot;%s&quot;,a);printf(&quot;enter password: &quot;);scanf(&quot;%s&quot;,b); k = strlen(a); l = strlen(b); if (k &lt;5 || k &gt;=10){printf(&quot;\\nInvalid! Username Length\\n&quot;);printf(&quot;\\nHit Enter to Exit\\n&quot;);getchar(); } else { if (l != k){printf(&quot;\\nInvalid! Password Length\\n&quot;);printf(&quot;\\nHit Enter to Exit\\n&quot;);getchar(); } else { i = k-1; j = 0; while (i &gt;= 0){ c[j] = a[i]+i; i--; j++; } c[j] = 0; r = strlen(c); if (r == l){ i = strcmp(c,b); if (i == 0){printf(&quot;\\nCongratulations! You did it..\\n&quot;);printf(&quot;\\nHit Enter to Exit\\n&quot;); } else {printf(&quot;\\nAccess Denied! Wrong Password\\n&quot;);printf(&quot;\\nHit Enter to Exit\\n&quot;); }getchar(); } } }getchar();}