Tuesday, February 10, 2015

Bash completions for msfvenom!

outdated post...

As you know, commands msfpayload and msfencode will be deleted from popular framework Metasploit.
We will use msfvenom instead.

Bash completions for msfvenom:
root@kaka:~# msfvenom -e <TAB><TAB>
cmd/echo                      x86/alpha_upper
cmd/generic_sh                x86/avoid_underscore_tolower
cmd/ifs                       x86/avoid_utf8_tolower
cmd/perl                      x86/bloxor
cmd/powershell_base64         x86/call4_dword_xor
cmd/printf_php_mq             x86/context_cpuid
generic/eicar                 x86/context_stat
generic/none                  x86/context_time
mipsbe/byte_xori              x86/countdown
mipsbe/longxor                x86/fnstenv_mov
mipsle/byte_xori              x86/jmp_call_additive
mipsle/longxor                x86/nonalpha
php/base64                    x86/nonupper
ppc/longxor                   x86/opt_sub
ppc/longxor_tag               x86/shikata_ga_nai
sparc/longxor_tag             x86/single_static_bit
x64/xor                       x86/unicode_mixed
x86/add_sub                   x86/unicode_upper
x86/alpha_mixed               
root@kaka:~# msfvenom -e 
This will make your life easier :)

Checked in Ubuntu 12/14. For those who don't know how to apply this:

Copy this code into '/etc/bash_completion.d/msfvenom', open new console and woohoo!
 # bash completion for msfvenom by Korznikov Alexander

_msfvenom()
{
    local cur prev

    COMPREPLY=()
    cur=`_get_cword`
    prev=`_get_pword`

    case $prev in
    
         -f|--format)
            COMPREPLY=( $( compgen -W ' asp aspx aspx-exe dll elf elf-so exe exe-only exe-service exe-small loop-vbs macho msi msi-nouac osx-app psh psh-net \
            psh-reflection vba vba-exe vbs war bash c csharp dw dword java js_be js_le num perl pl powershell ps1 py python \
            raw rb ruby sh vbapplication vbscript ' -- "$cur" ) )
            return 0
            ;;
         -e|--encoder)
            COMPREPLY=( $( compgen -W ' cmd/echo cmd/generic_sh cmd/ifs cmd/perl cmd/powershell_base64 cmd/printf_php_mq generic/eicar \
            generic/none mipsbe/byte_xori mipsbe/longxor mipsle/byte_xori mipsle/longxor php/base64 ppc/longxor \
            ppc/longxor_tag sparc/longxor_tag x64/xor x86/add_sub x86/alpha_mixed x86/alpha_upper \
            x86/avoid_underscore_tolower x86/avoid_utf8_tolower x86/bloxor x86/call4_dword_xor \
            x86/context_cpuid x86/context_stat x86/context_time x86/countdown x86/fnstenv_mov \
            x86/jmp_call_additive x86/nonalpha x86/nonupper x86/opt_sub x86/shikata_ga_nai \
            x86/single_static_bit x86/unicode_mixed x86/unicode_upper ' -- "$cur" ) )
            return 0
            ;;
         -p|--payload)
            COMPREPLY=( $( compgen -W ' aix/ppc/shell_bind_tcp aix/ppc/shell_find_port aix/ppc/shell_interact aix/ppc/shell_reverse_tcp android/meterpreter/reverse_http \
            android/meterpreter/reverse_https android/meterpreter/reverse_tcp android/shell/reverse_http android/shell/reverse_https android/shell/reverse_tcp \
            bsd/sparc/shell_bind_tcp bsd/sparc/shell_reverse_tcp bsd/x86/exec bsd/x86/metsvc_bind_tcp bsd/x86/metsvc_reverse_tcp bsd/x86/shell/bind_ipv6_tcp \
            bsd/x86/shell/bind_tcp bsd/x86/shell/find_tag bsd/x86/shell/reverse_ipv6_tcp bsd/x86/shell/reverse_tcp bsd/x86/shell_bind_tcp \
            bsd/x86/shell_bind_tcp_ipv6 bsd/x86/shell_find_port bsd/x86/shell_find_tag bsd/x86/shell_reverse_tcp bsd/x86/shell_reverse_tcp_ipv6 \
            bsdi/x86/shell/bind_tcp bsdi/x86/shell/reverse_tcp bsdi/x86/shell_bind_tcp bsdi/x86/shell_find_port bsdi/x86/shell_reverse_tcp \
            cmd/unix/bind_awk cmd/unix/bind_inetd cmd/unix/bind_lua cmd/unix/bind_netcat cmd/unix/bind_netcat_gaping cmd/unix/bind_netcat_gaping_ipv6 \
            cmd/unix/bind_nodejs cmd/unix/bind_perl cmd/unix/bind_perl_ipv6 cmd/unix/bind_ruby cmd/unix/bind_ruby_ipv6 cmd/unix/bind_zsh \
            cmd/unix/generic cmd/unix/interact cmd/unix/reverse cmd/unix/reverse_awk cmd/unix/reverse_bash cmd/unix/reverse_bash_telnet_ssl \
            cmd/unix/reverse_lua cmd/unix/reverse_netcat cmd/unix/reverse_netcat_gaping cmd/unix/reverse_nodejs cmd/unix/reverse_openssl \
            cmd/unix/reverse_perl cmd/unix/reverse_perl_ssl cmd/unix/reverse_php_ssl cmd/unix/reverse_python cmd/unix/reverse_python_ssl \
            cmd/unix/reverse_ruby cmd/unix/reverse_ruby_ssl cmd/unix/reverse_ssl_double_telnet cmd/unix/reverse_zsh  cmd/windows/adduser \
            cmd/windows/bind_lua cmd/windows/bind_perl cmd/windows/bind_perl_ipv6 cmd/windows/bind_ruby cmd/windows/download_eval_vbs \
            cmd/windows/download_exec_vbs cmd/windows/generic cmd/windows/reverse_lua cmd/windows/reverse_perl cmd/windows/reverse_powershell \
            cmd/windows/reverse_ruby firefox/exec firefox/shell_bind_tcp firefox/shell_reverse_tcp generic/custom generic/debug_trap \
            generic/shell_bind_tcp generic/shell_reverse_tcp generic/tight_loop java/jsp_shell_bind_tcp java/jsp_shell_reverse_tcp \
            java/meterpreter/bind_tcp java/meterpreter/reverse_http java/meterpreter/reverse_https java/meterpreter/reverse_tcp \
            java/shell/bind_tcp java/shell/reverse_tcp java/shell_reverse_tcp linux/armle/adduser linux/armle/exec linux/armle/shell/bind_tcp \
            linux/armle/shell/reverse_tcp linux/armle/shell_bind_tcp linux/armle/shell_reverse_tcp linux/mipsbe/exec linux/mipsbe/reboot \
            linux/mipsbe/shell/reverse_tcp linux/mipsbe/shell_bind_tcp linux/mipsbe/shell_reverse_tcp linux/mipsle/exec linux/mipsle/reboot \
            linux/mipsle/shell/reverse_tcp linux/mipsle/shell_bind_tcp linux/mipsle/shell_reverse_tcp linux/ppc/shell_bind_tcp linux/ppc/shell_find_port \
            linux/ppc/shell_reverse_tcp linux/ppc64/shell_bind_tcp linux/ppc64/shell_find_port linux/ppc64/shell_reverse_tcp linux/x64/exec \
            linux/x64/shell/bind_tcp linux/x64/shell/reverse_tcp linux/x64/shell_bind_tcp linux/x64/shell_bind_tcp_random_port linux/x64/shell_find_port \
            linux/x64/shell_reverse_tcp linux/x86/adduser linux/x86/chmod linux/x86/exec linux/x86/meterpreter/bind_ipv6_tcp linux/x86/meterpreter/bind_nonx_tcp \
            linux/x86/meterpreter/bind_tcp linux/x86/meterpreter/find_tag linux/x86/meterpreter/reverse_ipv6_tcp linux/x86/meterpreter/reverse_nonx_tcp \
            linux/x86/meterpreter/reverse_tcp linux/x86/metsvc_bind_tcp linux/x86/metsvc_reverse_tcp linux/x86/read_file linux/x86/shell/bind_ipv6_tcp \
            linux/x86/shell/bind_nonx_tcp linux/x86/shell/bind_tcp linux/x86/shell/find_tag linux/x86/shell/reverse_ipv6_tcp linux/x86/shell/reverse_nonx_tcp \
            linux/x86/shell/reverse_tcp linux/x86/shell_bind_ipv6_tcp linux/x86/shell_bind_tcp linux/x86/shell_bind_tcp_random_port linux/x86/shell_find_port \
            linux/x86/shell_find_tag linux/x86/shell_reverse_tcp linux/x86/shell_reverse_tcp2 netware/shell/reverse_tcp nodejs/shell_bind_tcp \
            nodejs/shell_reverse_tcp nodejs/shell_reverse_tcp_ssl osx/armle/execute/bind_tcp osx/armle/execute/reverse_tcp osx/armle/shell/bind_tcp \
            osx/armle/shell/reverse_tcp osx/armle/shell_bind_tcp osx/armle/shell_reverse_tcp osx/armle/vibrate osx/ppc/shell/bind_tcp \
            osx/ppc/shell/find_tag osx/ppc/shell/reverse_tcp osx/ppc/shell_bind_tcp osx/ppc/shell_reverse_tcp osx/x64/dupandexecve/bind_tcp \
            osx/x64/dupandexecve/reverse_tcp osx/x64/exec osx/x64/say osx/x64/shell_bind_tcp osx/x64/shell_find_tag \
            osx/x64/shell_reverse_tcp osx/x86/bundleinject/bind_tcp osx/x86/bundleinject/reverse_tcp osx/x86/exec osx/x86/isight/bind_tcp \
            osx/x86/isight/reverse_tcp osx/x86/shell_bind_tcp osx/x86/shell_find_port osx/x86/shell_reverse_tcp osx/x86/vforkshell/bind_tcp \
            osx/x86/vforkshell/reverse_tcp osx/x86/vforkshell_bind_tcp osx/x86/vforkshell_reverse_tcp php/bind_perl php/bind_perl_ipv6 \
            php/bind_php php/bind_php_ipv6 php/download_exec php/exec php/meterpreter/bind_tcp php/meterpreter/bind_tcp_ipv6 \
            php/meterpreter/reverse_tcp php/meterpreter_reverse_tcp php/reverse_perl php/reverse_php php/shell_findsock \
            python/meterpreter/bind_tcp python/meterpreter/reverse_http python/meterpreter/reverse_tcp python/shell_reverse_tcp python/shell_reverse_tcp_ssl \
            ruby/shell_bind_tcp ruby/shell_bind_tcp_ipv6 ruby/shell_reverse_tcp ruby/shell_reverse_tcp_ssl solaris/sparc/shell_bind_tcp \
            solaris/sparc/shell_find_port solaris/sparc/shell_reverse_tcp solaris/x86/shell_bind_tcp solaris/x86/shell_find_port solaris/x86/shell_reverse_tcp \
            tty/unix/interact windows/adduser windows/dllinject/bind_hidden_ipknock_tcp windows/dllinject/bind_hidden_tcp windows/dllinject/bind_ipv6_tcp \
            windows/dllinject/bind_nonx_tcp windows/dllinject/bind_tcp windows/dllinject/bind_tcp_rc4 windows/dllinject/find_tag windows/dllinject/reverse_hop_http \
            windows/dllinject/reverse_http windows/dllinject/reverse_ipv6_tcp windows/dllinject/reverse_nonx_tcp windows/dllinject/reverse_ord_tcp windows/dllinject/reverse_tcp \
            windows/dllinject/reverse_tcp_allports windows/dllinject/reverse_tcp_dns windows/dllinject/reverse_tcp_rc4 windows/dllinject/reverse_tcp_rc4_dns  \
            windows/dns_txt_query_exec windows/download_exec windows/exec windows/format_all_drives windows/loadlibrary windows/messagebox \
            windows/meterpreter/bind_hidden_ipknock_tcp windows/meterpreter/bind_hidden_tcp windows/meterpreter/bind_ipv6_tcp windows/meterpreter/bind_nonx_tcp \
            windows/meterpreter/bind_tcp windows/meterpreter/bind_tcp_rc4 windows/meterpreter/find_tag windows/meterpreter/reverse_hop_http \
            windows/meterpreter/reverse_http windows/meterpreter/reverse_https windows/meterpreter/reverse_https_proxy windows/meterpreter/reverse_ipv6_tcp \
            windows/meterpreter/reverse_nonx_tcp windows/meterpreter/reverse_ord_tcp windows/meterpreter/reverse_tcp windows/meterpreter/reverse_tcp_allports \
            windows/meterpreter/reverse_tcp_dns windows/meterpreter/reverse_tcp_rc4 windows/meterpreter/reverse_tcp_rc4_dns windows/metsvc_bind_tcp \
            windows/metsvc_reverse_tcp windows/patchupdllinject/bind_hidden_ipknock_tcp windows/patchupdllinject/bind_hidden_tcp windows/patchupdllinject/bind_ipv6_tcp \
            windows/patchupdllinject/bind_nonx_tcp windows/patchupdllinject/bind_tcp windows/patchupdllinject/bind_tcp_rc4 windows/patchupdllinject/find_tag \
            windows/patchupdllinject/reverse_ipv6_tcp windows/patchupdllinject/reverse_nonx_tcp windows/patchupdllinject/reverse_ord_tcp windows/patchupdllinject/reverse_tcp \
            windows/patchupdllinject/reverse_tcp_allports windows/patchupdllinject/reverse_tcp_dns windows/patchupdllinject/reverse_tcp_rc4 windows/patchupdllinject/reverse_tcp_rc4_dns \
            windows/patchupmeterpreter/bind_hidden_ipknock_tcp windows/patchupmeterpreter/bind_hidden_tcp windows/patchupmeterpreter/bind_ipv6_tcp \
            windows/patchupmeterpreter/bind_nonx_tcp windows/patchupmeterpreter/bind_tcp windows/patchupmeterpreter/bind_tcp_rc4 windows/patchupmeterpreter/find_tag \
            windows/patchupmeterpreter/reverse_ipv6_tcp windows/patchupmeterpreter/reverse_nonx_tcp windows/patchupmeterpreter/reverse_ord_tcp windows/patchupmeterpreter/reverse_tcp \
            windows/patchupmeterpreter/reverse_tcp_allports windows/patchupmeterpreter/reverse_tcp_dns windows/patchupmeterpreter/reverse_tcp_rc4 \
            windows/patchupmeterpreter/reverse_tcp_rc4_dns windows/shell/bind_hidden_ipknock_tcp windows/shell/bind_hidden_tcp windows/shell/bind_ipv6_tcp \
            windows/shell/bind_nonx_tcp windows/shell/bind_tcp windows/shell/bind_tcp_rc4 windows/shell/find_tag windows/shell/reverse_hop_http \
            windows/shell/reverse_http windows/shell/reverse_ipv6_tcp windows/shell/reverse_nonx_tcp windows/shell/reverse_ord_tcp \
            windows/shell/reverse_tcp windows/shell/reverse_tcp_allports windows/shell/reverse_tcp_dns windows/shell/reverse_tcp_rc4 windows/shell/reverse_tcp_rc4_dns \
            windows/shell_bind_tcp windows/shell_bind_tcp_xpfw windows/shell_hidden_bind_tcp windows/shell_reverse_tcp windows/speak_pwned \
            windows/upexec/bind_hidden_ipknock_tcp windows/upexec/bind_hidden_tcp windows/upexec/bind_ipv6_tcp windows/upexec/bind_nonx_tcp windows/upexec/bind_tcp \
            windows/upexec/bind_tcp_rc4 windows/upexec/find_tag windows/upexec/reverse_hop_http windows/upexec/reverse_http windows/upexec/reverse_ipv6_tcp \
            windows/upexec/reverse_nonx_tcp windows/upexec/reverse_ord_tcp windows/upexec/reverse_tcp windows/upexec/reverse_tcp_allports windows/upexec/reverse_tcp_dns \
            windows/upexec/reverse_tcp_rc4 windows/upexec/reverse_tcp_rc4_dns windows/vncinject/bind_hidden_ipknock_tcp windows/vncinject/bind_hidden_tcp \
            windows/vncinject/bind_ipv6_tcp windows/vncinject/bind_nonx_tcp windows/vncinject/bind_tcp windows/vncinject/bind_tcp_rc4 \
            windows/vncinject/find_tag windows/vncinject/reverse_hop_http windows/vncinject/reverse_http windows/vncinject/reverse_ipv6_tcp windows/vncinject/reverse_nonx_tcp \
            windows/vncinject/reverse_ord_tcp windows/vncinject/reverse_tcp windows/vncinject/reverse_tcp_allports windows/vncinject/reverse_tcp_dns \
            windows/vncinject/reverse_tcp_rc4 windows/vncinject/reverse_tcp_rc4_dns windows/x64/exec windows/x64/loadlibrary windows/x64/meterpreter/bind_tcp \
            windows/x64/meterpreter/reverse_https windows/x64/meterpreter/reverse_tcp windows/x64/shell/bind_tcp windows/x64/shell/reverse_https \
            windows/x64/shell/reverse_tcp windows/x64/shell_bind_tcp windows/x64/shell_reverse_tcp windows/x64/vncinject/bind_tcp \
            windows/x64/vncinject/reverse_https windows/x64/vncinject/reverse_tcp ' -- "$cur" ) )
            return 0
            ;;
    esac

    if [[ "$cur" == * ]]; then
    COMPREPLY=( $( compgen -W ' -p --payload -l --list -n --nopsled -f --format -e --encoder \
            -a --arch --platform -s --space -b --bad-chars -i --iterations \
            -c --add-code -x --template -k --keep --payload-options -o \
            --out -v --var-name -h --help --help-formats ' -- "$cur" ) ) 
            
            
    # this removes any options from the list of completions that have
    # already been specified somewhere on the command line, as long as
    # these options can only be used once (in a word, "options", in
    # opposition to "tests" and "actions", as in the find(1) manpage).
    onlyonce=' -p --payload -l --list -n --nopsled -f --format -e --encoder \
     -a --arch --platform -s --space -b --bad-chars -i --iterations \
     -c --add-code -x --template -k --keep --payload-options -o \
     --out -v --var-name -h --help --help-formats '
    COMPREPLY=( $( \
           (while read -d ' ' i; do
            [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
            continue
            # flatten array with spaces on either side,
            # otherwise we cannot grep on word boundaries of
            # first and last word
            COMPREPLY=" ${COMPREPLY[@]} "
            # remove word from list of completions
            COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
            done
            printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
          ) )
     
#    else
#        _filedir 
    fi
} &&
complete -F _msfvenom msfvenom


gl!

No comments:

Post a Comment