Malware Analysis
Malware Analysis
Types OF MALIARE
1. Backdoor
   .
   2           Botnet
                 * provides
                                      attacker          access
                 *
                     all   infected machines                     receive           commands               from   a    central          command-and-control             Server
   .
   3           Downloader
                 *
                      downloads                   and         installs            malware            onto        victim's             device
   .
   4
           Information-stealing                                Malware
                     examples               Sniffers
                                                              Keyloggers
                                       :
                 *
                                                          ,
                 *
                      used       to        capture            online
                                                                         banking             or   emails
    .
    5           Launcher
   6       .
               Rootkit
                 often paired
                 *                            with      backdoors             :   to    provide          attacker          with       remote        access   .
                 *
                     difficult for           victim      to     detect
   .
   7           Scareware
s .
Spam-spending Malware
                 *
                      infects         machine           and uses                  it    to        send    spam        emails      .
a .
Worm or Virus
         ·
              used to detect                           malicious       activity                  or           malware            on   a   specific     host
NETWORK-BASED SIGNATURES
          -
              prioritize                incidents
         -
              reveal hidden Indicators
                                                                  xmore          in           depth
              Static                                                                                                                         Basic                                                               Advanced                Static
Basic
                                 Analysis                          Advanced                     Static             Analysis                                Dynamic Analysis                                                                          Analysis
*
    inspecting         executable file without                     *   reverse    engineering                    the Malware                 *
                                                                                                                                                 running       the malware                 to   observe uses                 debugger                to
                                                                                                                                                                                                                                                           investigate
    executing         it
                      .
    purpose confirms if file                   malicious               and                           code instructions. - purpose helps remove infections ,                                                      malware executable .
                                          is
                                                                             examining
                                                                                                                                                           :
              :
*
                                                                                                                            of
                  functionality                                                                understanding                                                   Or both                                                             about the malware's
limitations                     not    detect                                                  What the malware                                  requirements                safe execution environment                            Operation that               is difficult
                      may
                  :
                                                                                                                                                                       :
                                                                                                                                             *
sophisticated malware does by analysing to prevent system/network to obtain through other methods
                                                                   *
                                                                       challenges requires specialized
                                                                                          :
                                                                                              Knowledge           in disass-                                       -
                                                                                                                                                                       not        effective     against                                 analysis    of suspected
                                                                                              and    of concepts        .
REVERSE ENGINEERING
        dismantling        an
                                object        to   understand           it's    design        and     functionality
    .
        malware
                     understanding
                           detailed                 of    malware to        understand        it's   Denaviour       how it   spreads       impact on   system.
           *   enables                 analysis                                                                  ,                      ,
        vulnerability discovery
           *   helps      uncover     vulnerabilities         that   can be     exploited      ,
                                                                                                   allowing developers         to   patch      weaknesses   .
* ,
    .
        learning          and    skill    development
internals .
    .
        malware           analysis
    ·
        threat
                     intelligence
           *   provides     valuable      into      emerging          threats     ,
    ·
        incident response
    ·
        forensic          investigation
           *   to        conduct      in-depth           forensic      investigation
ETHICAL           AND LEGAL           CONSIDERATIONS
        .
            ethical       implications          of    reverse            engineering
responsible use
                                                                                                                                  to exploit                               harmful
                          -
                  xproffessional            responsibility
                          -malware        analysts          have         a
                                                                              duty        to     protect       sensitive info
        ·
                legal     consideration
                   x   intellectual          property
                          -reverse
                                            engineering may                        trespass      on    intelectual               property rights
x compliance
    1       .
                Disassembler
                  x
                       finding   vulnerabilities
    .
    2
                Debuggers
                  ↓    tool    that allows           you    to     execute                a    malware          step             by Step       ,   and monitors it's behaviours .
                why       use         a
                                           debugger
                  x
                       dynamic analysis
                  x
                       identify            malicious             functions
        .
        3        Hex Editors
                   x   tools     used      to
                                                 inspect/modify                           raw
                                                                                                  binary data                      of files
             safety
                          :
         *
                                      malware       on        virtual machine     or   sandbox   ensures        that      it   can't    effect the   host or network
               -running           a                       a
         behaviour               monitoring
               *   allows you         to   safely        observe       malware    interactions   ,   with   files   ,   networks       and OS
Common environments :
   ·
       Sandbox
   ·
       Virtual machine
CHAPTER            I
STATIC ANALYSIS
     ·
         inspecting                malware                            without                    execution.
     ·
         used       to           gather          info                about structure content and behaviour .   ,
     ·
         tools      help          uncover         :
x file headers
x imported functions
Xembedded strings .
OBJECTIVE
         safely          extract            :
     ·
              ↓
                  recognizing key                     indicators                     (emedded             IP       address            ,
                                                                                                                                            C2       servers (
              x
                   gaining         insight        into
                                                                      functionality                    (use        of       certain libraries /API
TECHNIQUES
              -
                  identifies      type     and        structure              of file             from       "magic bytes"
                                                                                                               first few   bytes   of the   file
importance :
                                     obfuscation
                  detecting
                                                                 :
              -
                         ·
                             malware            authors               use        techniques               like
                                                                                                                    encrypting payload; making                                  it   harder   to
                                                                                                                                                                                                   analyze .
                                                if file
                         ·
                             Verifying                           is     misnamed                   ,
                                                                                                         such        a s exe                       named pdf
      -data                       found         in     the       Leader         of Pe           files                                                    DE    Files       Consits     of header   followed             several    sections
                 may         be
                                                                                                                                                                                                              by
                                                                                                                                                                       :
                                                                                                                                                     *
                                                                                                                                                                                                                                              .
- header is packed with info because it holds metadata about the file .
      -
          an
               analyst       uses     static         analysis        to   examine              files    for     patterns   ,
                                                                                                                               commands       and   functions              that   indicates   program's   behavior
      -
          if   exec     command            in        found   ,
                                                                     it
                                                                          suggests              that      the
                                                                                                                 program         can    launch/create           new         processes .
      -
          if   DDL      (dynamic      Link       Library)            is   found       ,   it    means         that     the       executable         may        connect            to   S e r ve r             DLL   :
                                                                                                                                                                                                                         file   that contains     code   to   perform   tasks   -
Disassembly
          -
               process              of
                                                 converting               machine         code                  of     executable          file    back         into       low-level       assembly language.
characteristics of disassembly :
1. Low-level code :
                     -
                         turns                   executable                file      to    code                      that
                                                                                                                             closely       resembles machine                        instructions    :   with      no
                                                                                                                                                                                                                        logical   expressions   shown    (loops/conditions)
         . processor-specific
         2                                                            :
         .
         3     Readable but                             hard to             understand                      :
· IDA Pro :
                     -
                         widely-used                              interactive              disassembler
          ·
               Ghidra      :
          .
               Radare 2             :
Disassembly example :
.
3   Decompilation                       :
-offers more detailed and readable form of original code-closer to source code written before compilation.
characteristics of decompilation :
          1.
               High-level                   code   :
         .
         2     Easier to           understand             :
                                                                                                                      not
                         easier to                 analyze However                   code
                                                                                                   might                     be   exact    as     source        code   -
         .
         3     Not    perfect                :
                                                                                                                    making resulting                                       or
tools        for               decompilation                      :
        ·
            Ghidra     :
                   -decompiles                   to
                                                      higher-level pseudocode
        .
            Hex-Rays                 Decompiler       (IDA    pro
                                                                         plugin)
                                                                                       C-like        pseudocode
                   -converts                   assembly           back        into
        .
            RetDec         :
- Open-source decompiler
decompilation example :
        -
            malware            is
                                     downloading payload                     from    malicious       domain
        >
        -
disassembly vs .
                                               decompilation
when    to      use        disassembly
   ·
       handle        obfuscated         or
                                             highly     optimized      binaries   where    decompilers might fail .
                                                                                          of malware's    function
   When
   -            you      want       a
                                         higher       level
                                                                   understanding
   -
       you're        analyzing      simple code              without   heavy obfuscation.
   -
       time     is    limited   ,
                                    quick      overview         is   needed ·
CHAPTER         3
DYNAMIC ANALYSIS
    ·
         executing program/malware                          sample            in   a            controlled environment to                          observe           and understand it's behavior
    .
         reveals runtime              characteristics                 ,
                                                                          including                process creation             ,     file       system manipulation                    ,   network    activity
TECHNIQUES
    1.
         Sandboxing
            -
                virtualized         environment            where           suspicous              are   executed     safely.
            -
                captures            changes         made         by   malware          ,
                                                                                               including   file modifications              ,   network       communications       ,   and    process   creation   .
                                           of
    key         components                           sandboxing
                                                                              :
* Virtualization :
            *
                    logging        mechanisms          :
                      -
                          tracks    and records            all    actions in           an         environment       (network                   connections      ,   actions   taken, errors      encountered
HOW        SANDBOX          WORKS                         :
9. File Submission :
-File Input :
-Unknown nature :
                     -
                         file       May               be        malware               or
                                                                                               goodware
-BE File :
       .
       2    Execution           in               aSandbox :
              -
                  Execution                  :
              -
                  Isolation              :
                     >
                     -
                         Sandbox ensures                                        all       malicious             behavior              doesn't effect real                    system
                  Monitoring
                                                  :
              -
* file modification
                                                      >
                                                      -       creating deleting
                                                                        ,                              ,
                                                                                                           modifying system                       files
* process creation :
                                                      -       launching          processes                  ,   or
                                                                                                                      injecting            code      into   existing          machines
                                             registry changes
                                                                                               :
                                *
                                        network
                                                                     activity
                                                                                           :
                                *
                                                      >
                                                      -
                                                              attemps            to        communicate                     with        external             server           or   command      and   control   servers   .
.
3
    Generating                   the report
Observed Dehaviors .
                metrics            in the
         key                                       report          :
     ~
                file
           *
                           system         changes
                                                           :
                                                    create/modify files
                           did malware                                               ?
                       -
* network communications :
                       -
                           did     attacker           communicate                 with   external    Ip   or       C2      Server   ?
            *
                registry           modification            :
                       -
                           were
                                         system            configurations            modified ?
* process injection :
                       -   were
                                         any        files              injected   with   malicious   code      ?
· malware identification :
           -
                 file        in     classified             an
                                                                       malware/goodware        based      on        it's      behavior   in    the   Jandbox
.
2
    Debugging
                                                                                                                             breakpoints                 and                        it's
     -
          analyzing            a
                                   program                  by        running       it       step         by setting                               ,
                                                                                                                                                                        examining           state.
     ·
         key       concepts                in
                                                  debugging
* breakpoints
               ·
                    Stepping
* code manipulation
1. Breakpoints :
1. software breakpoints
                           >
                           -   tools            that   allows              developers             to     pause     code     execution     at            a     specific point
9. instruction replacement :
2. resumption :
                           ~   When               to       use
                                                                 :
1 Suspicious functions :
                                                       When
                                                       -               you want              to        halt   at   a   critical    function            such    as        CreateProcess     or   WriteFile
2 system calls :
     *   halts     the
                             program            only       if       a       specified      condition a              true   when      the    breakpointa           reached
     ~
         How       conditional             breakpoints                  work    :
x Condition evaluation :
               x   flexible         monitoring
                                                       :
      When
      *            to   use    :
               x   Reguter          or    Variable
                                                       Changes
                                                                        :
                         -
                             only        when   reguter         contains            specific       value   ·
xComplex behavior :
      -monitors            specific                            address           or   variables         and    hoult      execution         when        data            read       Written execution
                                               memory                                                                                                               u          ,                 ,
      -
          How   data       breakpoints            work     :
                x
                    memory monitoring
xvariable tracking
                           Xtracks
                                               changes         to     variables        in       stack    ,   where   malware     manipulates              sensitive        data         :   like
                                                                                                                                                                                                      encryption keys
      >
      -   When      to     use   :
                               and
                xheap                          stack    monitoring
x data manipulation
4
.   Instruction breakpoints
      >
      -
          halts          execution               when          a      specific          instruction             is executed             :   Useful to              monitor          Malware behavior                  at     specific points   .
      -
          how instruction                      breakpoints           work    :
x instruction-level prection
                                                                       of how                                                                                                                                              functions .
                           X    allows
                                                 tracking                               malware                interacts        with             system            Apls    or        it's            own      custom
-when to use :
xAPI CallS :
                    System             call
                                                 monitoring
                                                                       :
                x
· Step-into :
.
3       Code        manipulation                    :
behavior .
                                           tools :
         ·
             debugging
                   Ollydbg
                                           :
               ·
                       X
                           32-bit
                                               debugger         that     allows    setting       breakpoints           ,
States
      ·
          examining               a
                                        system's            Ram        for evidence              of     malicious         activities
      ·
          used     to        uncover              evidence                     of malware       injection      ,   hidden process               ,
                                                                                                                                                    encrypted payloads.
      ·
          discovering                   code          injection            :
            -
                advanced malware                            may       create         hidden      processes          that       don't appear         in   standard   listing
      ·
          loaded modules                      :
                            for                                                                                    processes
            -   looks                  suspicious       DLLs          or
                                                                               injected       codes     into
          network connections
                                                        :
      ·
                                                                                                                                                                    .
      ·   handles            or        descriptors            :
            -
                used          to        track          file       and
                                                                               registry         access     from memory                 .
          Votality
                        :
      ·
  ·
      file   and      process         monitoring     :
                       file                                                     creations .
         Capture               system     changes          ,   new    process
                   traffic
      network
                                  analysis
                                               :
  ·
  ·
      API      Call    logging
         -to   detect         which    system      calls        the malware        relies   on.
DIC SLIDE 22