Malware Analysis

Μάθετε το χάκινγκ στο AWS από το μηδέν μέχρι τον ήρωα με το htARTE (HackTricks AWS Red Team Expert)!

Άλλοι τρόποι για να υποστηρίξετε το HackTricks:

Φύλλα απατηλής ανάλυσης

https://www.jaiminton.com/cheatsheet/DFIR/#

Υπηρεσίες σε απευθείας σύνδεση

Εργαλεία ανίχνευσης και αντιιού

Yara

Εγκατάσταση

sudo apt-get install -y yara

Προετοιμασία κανόνων

Χρησιμοποιήστε αυτό το σενάριο για να κατεβάσετε και να συγχωνεύσετε όλους τους κανόνες yara για κακόβουλο λογισμικό από το github: https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9 Δημιουργήστε τον φάκελο rules και εκτελέστε το. Αυτό θα δημιουργήσει ένα αρχείο με το όνομα malware_rules.yar που περιέχει όλους τους κανόνες yara για κακόβουλο λογισμικό.

wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py
mkdir rules
python malware_yara_rules.py

Σάρωση

To begin the malware analysis process, it is important to perform a thorough scan of the infected system. This scan will help identify any malicious files or processes that may be present. There are several tools and techniques that can be used for this purpose.

Antivirus Scans

Running an antivirus scan is one of the simplest and most effective ways to detect malware on a system. Antivirus software is designed to identify and remove known malware signatures. It is important to keep the antivirus software up to date to ensure it can detect the latest threats.

File Analysis

Performing a detailed analysis of suspicious files can provide valuable insights into the nature of the malware. This can be done using tools such as file analyzers, hex editors, and disassemblers. By examining the file's structure and contents, it is possible to identify any malicious code or behavior.

Process Analysis

Analyzing the running processes on the system can help identify any malicious activity. Tools such as process monitors and system analyzers can be used to monitor the behavior of processes and identify any suspicious or unauthorized activity.

Network Analysis

Analyzing network traffic can provide information about the communication channels used by the malware. Tools such as packet sniffers and network analyzers can be used to capture and analyze network traffic. This can help identify any connections to malicious servers or unusual network behavior.

Memory Analysis

Analyzing the system's memory can reveal valuable information about the malware's behavior and capabilities. Tools such as memory dumpers and memory analyzers can be used to extract and analyze the contents of the system's memory. This can help identify any malicious processes or code that may be running in memory.

Registry Analysis

Analyzing the system's registry can provide insights into the malware's persistence mechanisms and configuration settings. Tools such as registry editors and registry analyzers can be used to examine the registry and identify any suspicious or malicious entries.

Log Analysis

Analyzing system logs can help identify any unusual or suspicious activity. Logs such as event logs, application logs, and security logs can provide valuable information about the malware's actions and impact on the system. Tools such as log analyzers can be used to parse and analyze log files.

By performing a comprehensive scan of the infected system using these techniques, it is possible to gather valuable information about the malware and its impact on the system. This information can then be used to further analyze and mitigate the threat.

yara -w malware_rules.yar image  #Scan 1 file
yara -w malware_rules.yar folder #Scan the whole folder

YaraGen: Έλεγχος για κακόβουλο λογισμικό και δημιουργία κανόνων

Μπορείτε να χρησιμοποιήσετε το εργαλείο YaraGen για να δημιουργήσετε κανόνες yara από ένα δυαδικό αρχείο. Ρίξτε μια ματιά σε αυτά τα εκπαιδευτικά: Μέρος 1, Μέρος 2, Μέρος 3

python3 yarGen.py --update
python3.exe yarGen.py --excludegood -m  ../../mals/

ClamAV

Εγκατάσταση

Για να εγκαταστήσετε το ClamAV, ακολουθήστε τα παρακάτω βήματα:

  1. Ανοίξτε ένα τερματικό.

  2. Εκτελέστε την εντολή sudo apt-get update για να ενημερώσετε τη λίστα των διαθέσιμων πακέτων.

  3. Εκτελέστε την εντολή sudo apt-get install clamav για να εγκαταστήσετε το ClamAV.

  4. Αναμένετε να ολοκληρωθεί η εγκατάσταση.

Μετά την εγκατάσταση, το ClamAV θα είναι έτοιμο να χρησιμοποιηθεί.

sudo apt-get install -y clamav

Σάρωση

To begin the malware analysis process, it is important to perform a thorough scan of the infected system. This scan will help identify any malicious files or processes that may be present. There are several tools and techniques that can be used for this purpose.

Antivirus Scans

Running an antivirus scan is one of the most common and effective ways to detect malware on a system. Antivirus software is designed to identify and remove malicious files, and it can be used to scan both individual files and the entire system. It is recommended to use a reputable antivirus program and keep it updated to ensure the best possible protection.

Online Scanners

In addition to traditional antivirus software, there are also online scanners available that can be used to scan a system for malware. These scanners typically use cloud-based technology to analyze files and detect any malicious activity. Some popular online scanners include VirusTotal and Hybrid Analysis.

File Analysis

Another important aspect of the scan is file analysis. This involves examining individual files to determine if they are malicious or suspicious. There are various tools and techniques that can be used for file analysis, including static analysis and dynamic analysis. Static analysis involves examining the file's code and structure, while dynamic analysis involves running the file in a controlled environment to observe its behavior.

Process Analysis

In addition to file analysis, it is also important to analyze running processes on the system. This can help identify any malicious processes that may be running in the background. Tools such as Process Explorer can be used to view and analyze running processes, including their associated files and network connections.

Network Analysis

Lastly, conducting a network analysis can provide valuable insights into the malware's behavior and communication. This involves monitoring network traffic and analyzing any suspicious connections or activities. Tools such as Wireshark can be used to capture and analyze network packets, allowing for a deeper understanding of the malware's network activity.

By performing a thorough scan using a combination of these techniques, it is possible to identify and analyze malware on a system. This is an important first step in the malware analysis process and can provide valuable information for further investigation and mitigation.

sudo freshclam      #Update rules
clamscan filepath   #Scan 1 file
clamscan folderpath #Scan the whole folder

Capa ανιχνεύει δυνητικά κακόβουλες ικανότητες σε εκτελέσιμα αρχεία: PE, ELF, .NET. Έτσι, θα βρει πράγματα όπως τακτικές Att&ck ή ύποπτες ικανότητες όπως:

  • έλεγχος για σφάλμα OutputDebugString

  • εκτέλεση ως υπηρεσία

  • δημιουργία διεργασίας

Βρείτε το στο αποθετήριο Github.

IOCs

IOC σημαίνει Indicator Of Compromise. Ένα IOC είναι ένα σύνολο συνθηκών που αναγνωρίζουν ορισμένο ανεπιθύμητο λογισμικό ή επιβεβαιωμένο κακόβουλο λογισμικό. Οι Ομάδες Μπλε χρησιμοποιούν αυτού του είδους τον ορισμό για να αναζητήσουν αυτού του είδους τα κακόβουλα αρχεία στα συστήματά τους και τις δικτυακές τους υποδομές. Η κοινή χρήση αυτών των ορισμών είναι πολύ χρήσιμη, καθώς όταν το κακόβουλο λογισμικό αναγνωρίζεται σε έναν υπολογιστή και δημιουργείται ένα IOC για αυτό, άλλες Ομάδες Μπλε μπορούν να το χρησιμοποιήσουν για να αναγνωρίσουν το κακόβουλο λογισμικό πιο γρήγορα.

Ένα εργαλείο για τη δημιουργία ή τροποποίηση των IOC είναι το IOC Editor. Μπορείτε να χρησιμοποιήσετε εργαλεία όπως το Redline για να αναζητήσετε καθορισμένα IOC σε μια συσκευή.

Loki

Το Loki είναι ένα εργαλείο σάρωσης για απλούς δείκτες συμπεριφοράς. Η ανίχνευση βασίζεται σε τέσσερις μεθόδους ανίχνευσης:

1. File Name IOC
Regex match on full file path/name

2. Yara Rule Check
Yara signature matches on file data and process memory

3. Hash Check
Compares known malicious hashes (MD5, SHA1, SHA256) with scanned files

4. C2 Back Connect Check
Compares process connection endpoints with C2 IOCs (new since version v.10)

Linux Malware Detect

Linux Malware Detect (LMD) είναι ένα πρόγραμμα σάρωσης για κακόβουλο λογισμικό σε Linux που έχει κυκλοφορήσει υπό την άδεια GNU GPLv2 και έχει σχεδιαστεί γύρω από τις απειλές που αντιμετωπίζονται σε κοινόχρηστα περιβάλλοντα φιλοξενίας. Χρησιμοποιεί δεδομένα απειλών από συστήματα ανίχνευσης παραβίασης στο δίκτυο για να εξάγει κακόβουλο λογισμικό που χρησιμοποιείται ενεργά σε επιθέσεις και δημιουργεί υπογραφές για ανίχνευση. Επιπλέον, τα δεδομένα απειλών προέρχονται επίσης από τις υποβολές των χρηστών με το χαρακτηριστικό ελέγχου του LMD και από πόρους της κοινότητας κακόβουλου λογισμικού.

rkhunter

Εργαλεία όπως το rkhunter μπορούν να χρησιμοποιηθούν για να ελέγξουν το σύστημα αρχείων για πιθανά rootkits και κακόβουλο λογισμικό.

sudo ./rkhunter --check -r / -l /tmp/rkhunter.log [--report-warnings-only] [--skip-keypress]

FLOSS

FLOSS είναι ένα εργαλείο που θα προσπαθήσει να βρει κρυπτογραφημένες συμβολοσειρές μέσα σε εκτελέσιμα χρησιμοποιώντας διάφορες τεχνικές.

PEpper

Το PEpper ελέγχει μερικά βασικά πράγματα μέσα στο εκτελέσιμο (δυαδικά δεδομένα, εντροπία, URLs και IPs, μερικούς κανόνες yara).

PEstudio

Το PEstudio είναι ένα εργαλείο που επιτρέπει να λάβετε πληροφορίες για τα εκτελέσιμα των Windows, όπως εισαγωγές, εξαγωγές, κεφαλίδες, αλλά επίσης θα ελέγξει τον ιότοπο και θα βρει δυνητικές τεχνικές Att&ck.

Detect It Easy(DiE)

Το DiE είναι ένα εργαλείο για να ανιχνεύσετε αν ένα αρχείο είναι κρυπτογραφημένο και επίσης να βρείτε packers.

NeoPI

Το NeoPI είναι ένα σενάριο Python που χρησιμοποιεί διάφορες στατιστικές μεθόδους για να ανιχνεύσει κρυπτογραφημένο και κρυφό περιεχόμενο μέσα σε αρχεία κειμένου/σεναρίου. Ο σκοπός του NeoPI είναι να βοηθήσει στην ανίχνευση κρυμμένου κώδικα web shell.

php-malware-finder

Το php-malware-finder κάνει το καλύτερο δυνατό για να ανιχνεύσει κρυπτογραφημένο/αμφίβολο κώδικα καθώς και αρχεία που χρησιμοποιούν συχνά PHP λειτουργίες που χρησιμοποιούνται σε κακόβουλο λογισμικό/webshells.

Apple Binary Signatures

Όταν ελέγχετε ένα δείγμα κακόβουλου λογισμικού, πρέπει πάντα να ελέγχετε την υπογραφή του δυαδικού καθώς ο προγραμματιστής που το υπέγραψε μπορεί να έχει ήδη συνδεθεί με κακόβουλο λογισμικό.

#Get signer
codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier"

#Check if the app’s contents have been modified
codesign --verify --verbose /Applications/Safari.app

#Check if the signature is valid
spctl --assess --verbose /Applications/Safari.app

Τεχνικές Ανίχνευσης

Στοίβα Αρχείων

Εάν γνωρίζετε ότι ένας φάκελος που περιέχει τα αρχεία ενός διακομιστή ιστού ενημερώθηκε τελευταία φορά σε μια συγκεκριμένη ημερομηνία. Ελέγξτε την ημερομηνία δημιουργίας και τροποποίησης όλων των αρχείων στον διακομιστή ιστού και εάν υπάρχει κάποια ύποπτη ημερομηνία, ελέγξτε αυτό το αρχείο.

Βάσεις

Εάν τα αρχεία ενός φακέλου δεν έπρεπε να έχουν τροποποιηθεί, μπορείτε να υπολογίσετε το hash των αρχικών αρχείων του φακέλου και να τα συγκρίνετε με τα τρέχοντα. Οτιδήποτε έχει τροποποιηθεί θα είναι ύποπτο.

Στατιστική Ανάλυση

Όταν οι πληροφορίες αποθηκεύονται σε αρχεία καταγραφής, μπορείτε να ελέγξετε στατιστικά στοιχεία όπως πόσες φορές έχει προσπελαστεί κάθε αρχείο ενός διακομιστή ιστού, καθώς ένα web shell μπορεί να είναι ένα από τα πιο.

Μάθετε το hacking στο AWS από το μηδέν μέχρι τον ήρωα με το htARTE (HackTricks AWS Red Team Expert)!

Άλλοι τρόποι για να υποστηρίξετε το HackTricks:

Last updated