background image

102

Chapter 7

Encoding with MSFencode

One of the best ways to avoid being stopped by antivirus software is to encode 
our payload with 

msfencode

Msfencode

 is a useful tool that alters the code in an 

executable so that it looks different to antivirus software but will still run the 
same way. Much as the binary attachment in email is encoded in Base64, 

msfencode

 encodes the original executable in a new binary. Then, when the 

executable is run, 

msfencode

 decodes the original code into memory and exe-

cutes it.

You can use 

msfencode -h

 to see a list of 

msfencode

 usage options. Of the 

msfencode

 options, the encoder formats are among the most important. For a 

list of encoder formats, we use 

msfencode -l

, as shown next. Notice that differ-

ent encoders are used for different platforms, because, for example, a Power 
PC (PPC) encoder will not operate correctly on an x86 platform because of 
differences in the two architectures.

root@bt:/opt/framework3/msf3# 

msfencode -l

Framework Encoders
==================

    Name                    Rank       Description
    ----                    ----       -----------
    cmd/generic_sh          good       Generic Shell Variable Substitution Command Encoder
    cmd/ifs                 low        Generic ${IFS} Substitution Command Encoder
    generic/none            normal     The "none" Encoder
    mipsbe/longxor          normal     XOR Encoder
    mipsle/longxor          normal     XOR Encoder
    php/base64              normal     PHP Base64 encoder
    ppc/longxor             normal     PPC LongXOR Encoder
    ppc/longxor_tag         normal     PPC LongXOR Encoder
    sparc/longxor_tag       normal     SPARC DWORD XOR Encoder
    x64/xor                 normal     XOR Encoder
    x86/alpha_mixed         low        Alpha2 Alphanumeric Mixedcase Encoder
    x86/alpha_upper         low        Alpha2 Alphanumeric Uppercase Encoder
    x86/avoid_utf8_tolower  manual     Avoid UTF8/tolower
    x86/call4_dword_xor     normal     Call+4 Dword XOR Encoder
    x86/countdown           normal     Single-byte XOR Countdown Encoder
    x86/fnstenv_mov         normal     Variable-length Fnstenv/mov Dword XOR Encoder
    x86/jmp_call_additive   normal     Jump/Call XOR Additive Feedback Encoder
    x86/nonalpha            low        Non-Alpha Encoder
    x86/nonupper            low        Non-Upper Encoder
    

x86/shikata_ga_nai      excellent  Polymorphic XOR Additive Feedback Encoder

    x86/single_static_bit   manual     Single Static Bit
    x86/unicode_mixed       manual     Alpha2 Alphanumeric Unicode Mixedcase Encoder
    x86/unicode_upper       manual     Alpha2 Alphanumeric Unicode Uppercase Encoder