POL1TC@L HOOK
  • Home
  • About
  • Cyber Security
  • Politics
  • Sports
  • Contact

wargames CTF - deus x64 one

2/10/2024

0 Comments

 
Reverse Engineering CTF. 

These are a series of challenges which need to be solved. We will be using Binary Ninja to reverse engineer the program. The program looks as follows with 3 different sections: 
Picture

1. x64_ASM

Lets begin with section 1) x64_ASM. After pressing 1, we are presented with the following screen which asks for 2 args: 
Picture
Lets begin reverse engineering. 
The source code shows this function which handles the logic. 
Picture
As we can see the instruction_test(arg1, arg2) function plays a crucial role. Lets take a look at its assembly 
Picture
Very simple. If the result of the function does not equal 0x7a69 (31337), evaluation failed. Going back to the assembly provided in the first screenshot, some quick maths gives us the answer 30569. Therefore arg1 = 0 and arg2 = 30569
Picture

2. serial

The second challenge asks for a serial.
Picture
Source code below:
Picture
As you can see, the check_serial(serial) function does the heavy lifting. Lets analyse its assembly.
Picture
The check_serial function looks to see if each value of arg1 is a particular number converting these hex to ascii gives us the following serial number: ​189715
Picture

3. encrypt

The third and final challenge asks for a password 
Picture
If you provide a password of the wrong length you receive this error:
Picture
Lets look at the code and begin reverse engineering. As we can see from the code below, the password needs to 14 characters long (0xe = 14).
Picture
Picture
Providing a password of length 14 gives us this screen.
Picture
It appears to check each character. Analysing the earlier source code and assembly shows the check is done under encryption_check(password). Lets disassemble this function. 
Picture
Following the logic of the disassembled function, we can see that it takes our arguments and encrypts them via XOR against 0x17. If the output does not equal gW""`xesHav{~s, then it goes to the invalid_encryped_char() function. 
Therefore gW""`xesHav{~s is our encrypted string and with this, we can write a very simple decryption routine to obtain the password.
Picture
Quick C++ program I wrote to decrypt and encrypt the strings for demo purposes. The decrypt function essentially reverses the XOR encryption routine. Encrypt function shows how the CTF challenge encrypts the password in the first place. Running the program outputs the following. 

1) The decrypted string = p@55w0rd_valid
2) The encrypted string = gW""`xesHav{~s
Picture
Entering the decrypted string into the CTF challenge shows us:
Picture
Finished. Hope you enjoyed it.
0 Comments

microcorruption: Level 3 -Hanoi

12/22/2022

0 Comments

 
​This level was also simple although a bit harder than the previous levels.
 
The main function is extremely short, passing off much of the work to the login function.
Here it prints out the a series of strings using a puts function. The most important string being:
 
“Remember: passwords are between 8 and 16 characters:”.
 
Due to this we can assume some kind of overflow is expected. Later on within the function it tries to compare hex value 0x11 with memory address &0x2410.
To do so, the final (17th) character would need to be a hex encoded character. This would be 11

Picture

Password: ​4141414141414141414141414141414211
0 Comments

Malware analysis - Analysing Kovter

12/9/2022

0 Comments

 
​Today we are going to talk about analysing the Kovter malware. For those unfamiliar with Kovter, it gained fame in 2015 for being one of the more prominent attacks which utilised living of the land attacks.  Before we begin, there are several concepts which must be explained

1) living off the land – Living off the land refers to using native or signed scripts/binaries to further an attackers goal 

2) Sysmon – Sysmon refers to a tool created by Microsoft which enhances Microsoft wineventlog by providing addition logging based on event codes. It also allows for the customisation as it can ingests a XML with custom command which can monitor select files/ports as shown below 
​
Picture
Lab Setup
​
Picture
  1. Splunk infrastructure
  • Universal Forwarder helps to forward logs to the indexer. It is then searched from the search head 
  1. Kovter Malware is run on Windows 10 virtual machine 
  2. Sysmon installed on Windows 10 VM
  3. Fakenet mimics the internet to prevent kovter from reaching command and control servers
  4. No AV. We need Kovter to run without being
  5. UAC disabled, need Kovter to run without being hindered​


​kovter overview

After sifting through the logs using splunk which were enhanced by SYSMON, I was able to come to the following conclusion. 

  1. Kovter uses WMIprives (PID 2692) to launch mshta( PID 7824), unsure of how this is done. Could be command line or perhaps using WMI script. 
  2. Powershell then downloads a script which runs in memory
  3. I believe the script the runs regsvr32 (PID4740) which completes many tasks

3.1) Sets the value under HKU\S-1-5-21-3652906336-4086003666-492231068-1000\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1809 to 0x00000003. This allows pop ups on internet explorer

3.2)  Sets the value under HKU\S-1-5-21-3652906336-4086003666-492231068-1000\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1206 to 0. This allows scripting of Internet explorers Web Browser security control

3.3) Places Malicious bat file in registry for persistence. This executes another mshta upon restart 

3.4 Write a separate registry entry which reads payload

Registry persistence and tricks

Kovter took advantage of Registry Jumping. File extension class .251b2fb data pointed to HKEY_USERS\S-1-5-21-3652906336-4086003666-492231068-1000_Classes\522960\shell\open\command which contained our malicious mshta command.

It also used extended characters to obstruct analysis
Picture
As you can see, the fields all appear to have data in the fields. However clicking on the value htavir (probably after hta virus, why though?) shows no data. In fact clicking and attempting to edit the box failed. After dumping the registry hive to disk and analysing, I believe the issue is this highlighted below:​
Picture
This extended character helps to stop analysts from  inputting any data and tampering with the payload 

Thanks for reading

0 Comments

microcorruption: level 2 - sydney

6/13/2019

 
​This the second level of Microcorruption. If you haven’t seen the first level, please go back.
Let’s Begin!
 
This level is slightly more difficult than the previous level, but again nothing strenuous. Scrolling through the disassembly we again see the check_password function. Quick analysis of it shows several compare functions (cmp). This shows us its comparing our input to a hard-coded password little by little.
​ 
Picture

​Converting these Hex values gives us the following password: Sl)pQ/*b
However, we must take into account the endianness of the system. Simply put, there are two ways to arrange data in memory, big endian and little endian.
In big-endian the most significant byte, the byte containing the most significant bit (the leftmost byte), is stored first, at the lowest address. The least significant byte, then, has the higher address.
In little-endian the least significant byte, (the rightmost byte) is stored first, at the lowest address. The most significant byte, then, has the higher address.
The diagram below explains how this works. 
​
Picture

​This essentially means we have to change the alphabetical order of our passwords around. E.g the first hex value may be “0x536c = Sl”, this in reality should be “lS”. The endianness switches the position of the letters around. Doing this for all hex values gives us the correct password: lSp)/Qb*

Microcorruption: Level 1 - new orleans

1/16/2019

 
Picture
So this is the beginning of the Microcorruption CTF. It’s a embedded reverse engineering minigame. Please complete the Tutorial if you haven’t already before reading this. I recommend you read the lock manual as well. This will give you a basic understanding of LockIT and MSP430 Assembly.

DISCLAIMER: I’m really not an expert at reverse engineering/ assembly. If you notice a error on my behalf please tell me.

Lets begin

This level is very easy and can be solved in two different ways.
 
1) Check_password Function
First method is by analysing the check password function. Here we can see the compare being used between register r13 (your input) and memory address 0x2400. Going to the memory address reveals the password.



























2) Create_Password Function
 
In the previous method the password was found in memory, this method shows us that the password was actually hard-coded into the assembly and written to memory address 0x2400. 


Picture
​
The first instruction of the function moves r15 to the memory address. The remaining functions write the hardcoded password in. If your new, the hardcoded password is written in hex and highlighted in the yellow box.
 
Password: [mHub71

    Archives

    February 2024
    January 2023
    December 2022
    March 2020
    June 2019
    January 2019

    Categories

    All
    Malware
    Privilege Escalation
    Python
    Reverse Engineering
    Splunk

Powered by Create your own unique website with customizable templates.
  • Home
  • About
  • Cyber Security
  • Politics
  • Sports
  • Contact