Day 8

Shellcodes of the world, unite!

Welcome to Day 8 of Advent of Cyber 2024!

Today, we dive into the fascinating realm of shellcode generation and execution. In this challenge, we’ll use msfvenom to craft a reverse shell payload and help Glitch regain access by troubleshooting and executing the shellcode.

  • Shellcode: A small, assembly-written piece of code used in exploits like buffer overflows to inject commands into vulnerable systems, often granting attackers control.

  • Reverse Shell: A connection initiated by the target system to the attacker, allowing remote command execution. In this task, your AttackBox will act as the listener.

Lets Begin:

Open the terminal on the AttackBox and execute the following command to generate the shellcode:

Replace ATTACKBOX_IP with your AttackBox's IP address.

Generating script

The output will include a hex-encoded byte array, starting with values like 0xfc, 0xe8, etc. These hexadecimal numbers represent the instructions to be executed on the target machine.

Now we will use PowerShell to call a few Windows APIs via C# code. Below is a simple PowerShell script that will execute our shellcode:

Replace SHELLCODE_PLACEHOLDER with your shellcode byte array

Replaced with actual shellcode

On the AttackBox, start a listener to get the reverse shell connection:

Now copy, paste the script to the powershell, executing it line by line as shown below:

Powershell

Once you execute the final line in the PowerShell terminal and press Enter, you will get a reverse shell in the AttackBox, giving you complete access to the computer even if the Windows Defender is enabled.

Now you the windows powershell is in your hand, you can execute any commands like dir,type etc...

RCE

After successfully executing the shellcode and establishing a reverse shell, navigate to the glitchs' Desktop to get the flag:

Flag

If you need to modify the shellcode to a new IP and port (e.g., ATTACKBOX_IP and port 4444):

  1. Re-run the msfvenom command with updated values:

  2. Replace the old shellcode in the PowerShell script with the updated shellcode.

Questions

1.What is the flag value once Glitch gets reverse shell on the digital vault using port 4444? Note: The flag may take around a minute to appear in the C:\Users\glitch\Desktop directory. You can view the content of the flag by using the command type C:\Users\glitch\Desktop\flag.txt

A: AOC{GOT _MY_ACCESS_B@CK007}

Stay tuned for Day 9, and happy hacking! 🎄

Thank you!

Last updated

Was this helpful?