
Estrattore di pattern per codice offuscato
Fnord è un estrattore di pattern per codice offuscato
Fnord ha due funzioni principali:
Fnord elabora il file con una finestra scorrevole di dimensione variabile per estrarre tutte le sequenze con una lunghezza minima -m X (predefinita: 4) fino a una lunghezza massima -x X (predefinita: 40). Per ogni lunghezza, Fnord presenterà le sequenze più frequenti -t X (predefinito: 3) in una tabella.
Ogni riga della tabella contiene:
Fnord genera anche una regola YARA sperimentale. Durante la creazione della regola YARA, calcola un punteggio basato sulla lunghezza della sequenza e sul numero di occorrenze (lunghezza * occorrenze). Quindi elabora ciascuna sequenza rimuovendo tutti i caratteri non alfabetici e confrontandole con un elenco di parole chiave (case-insensitive) per rilevare sequenze più interessanti di altre. Prima di scrivere ogni stringa nella regola, Fnord calcola una distanza di Levenshtein e salta le sequenze troppo simili a quelle già integrate nella regola.
[Sperimentale] Fnord è stato creato alcuni giorni fa e l'ho testato con una manciata di campioni. Immagino che nelle prossime settimane regolerò le impostazioni predefinite e aggiungerò altre parole chiave, filtri e opzioni di punteggio.
Se hai trovato codice offuscato in un campione, usa un editor esadecimale per estrarre la sezione offuscata del campione e salvala in un nuovo file. Usa quel nuovo file per l'analisi.
Gioca con i flag -s, -k, -r, --yara-strings, -m e -e.
Per favore, inviami campioni che producono regole YARA deboli che potrebbero essere migliorate.
____ __
/ __/__ ___ _______/ /
/ _// _ \/ _ \/ __/ _ /
/_/ /_//_/\___/_/ \_,_/ Pattern Extractor for Obfuscated Code
v0.7, Florian Roth
usage: fnord.py [-h] [-f file] [-m min] [-x max] [-t top] [-n min-occ]
[-e min-entropy] [--strings] [--include-padding] [--debug]
[--noyara] [-s similarity] [-k keywords-multiplier]
[-r structure-multiplier] [-c count-limiter] [--yara-exact]
[--yara-strings max] [--show-score] [--show-count]
[--author author]
Fnord - Pattern Extractor for Obfuscated Code
optional arguments:
-h, --help show this help message and exit
-f file File to process
-m min Minimum sequence length
-x max Maximum sequence length
-t top Number of items in the Top x list
-n min-occ Minimum number of occurrences to show
-e min-entropy Minimum entropy
--strings Show strings only
--include-padding Include 0x00 and 0x20 in the extracted strings
--debug Debug output
YARA Rule Creation:
--noyara Do not generate an experimental YARA rule
-s similarity Allowed similarity (use values between 0.1=low and
10=high, default=1.5)
-k keywords-multiplier
Keywords multiplier (multiplies score of sequences if
keyword is found) (best use values between 1 and 5,
default=2.0)
-r structure-multiplier
Structure multiplier (multiplies score of sequences if
it is identified as code structure and not payload)
(best use values between 1 and 5, default=2.0)
-c count-limiter Count limiter (limts the impact of the count by
capping it at a certain amount) (best use values
between 5 and 100, default=20)
--yara-exact Add magic header and magic footer limitations to the
rule
--yara-strings max Maximum sequence length
--show-score Show score in comments of YARA rules
--show-count Show count in sample in comments of YARA rules
--author author YARA rule author
git clone https://github.com/Neo23x0/Fnord.git e cd Fnordpip3 install -r ./requirements.txtpython3 ./fnord.py --helppython3 fnord.py -f ./test/wraeop.sct --yara-strings 10
python3 fnord.py -f ./test/vbs.txt --show-score --show-count -t 1 -x 20
python3 fnord.py -f ./test/inv-obf.txt --show-score --show-count -t 1 --yara-strings 4 --yara-exact



La cartella ./test contiene script dannosi che potrebbero essere rilevati dal tuo antivirus locale. Non danneggiano il tuo sistema finché non li esegui.
yarGen utilizza un approccio di whitelisting per filtrare le stringhe migliori per la creazione di una regola YARA. yarGen applica alcune espressioni regolari per regolare i punteggi delle stringhe prima di creare le regole YARA. Ma il suo approccio è molto diverso dal metodo utilizzato da Fnord, che calcola il punteggio delle sequenze di byte basandosi sulle statistiche.
Mentre yarGen è più adatto per codice non offuscato, Fnord è solo per codice offuscato e dovrebbe produrre risultati molto migliori di yarGen.
Seguimi su Twitter per aggiornamenti @cyb3rops