Skip to content

Instantly share code, notes, and snippets.

@stvemillertime
stvemillertime / 100DaysOfYARA.yar
Created January 3, 2022 22:16 — forked from Droogy/100DaysOfYARA.yar
100 Days of YARA
import "pe"
import "hash"
import "math"
rule packedTextSection {
meta:
description = " Look for high-entropy .text sections within PE files "
author = "Droogy"
DaysOfYARA = "3/100"
@stvemillertime
stvemillertime / go_tmilk.py
Created October 21, 2021 16:04 — forked from JusticeRage/go_tmilk.py
Go Type Milking - IDA script to extract type information from Go binaries
"""
got_tmilk.py - Go Type Milking
Written by Ivan Kwiatkowski @ Kaspersky GReAT
Shared under the terms of the GPLv3 license
"""
C_HEADER = """
enum golang_kind : __int8
{
INVALID = 0x0,
meta:
id: beaconconfig
title: Cobalt Strike Beacon Config
endian: be
doc: |
Cobalt Strike Beacon is a popular offensive security tool. Beacon itself
is a DLL that gets injected into memory and can be staged from C2 servers.
The Beacon DLL (in unencoded form) contains a configuration section that gets
patched by the C2 server. This section is a fixed predictable structure
#!/usr/bin/env python3
'''
A simplified FLOSS implementation that only supports stackstrings.
requirements:
- yara-python
- unicorn
author: Willi Ballenthin
email: william.ballenthin@fireeye.com
rule get_eip
{
meta:
author = "William Ballenthin"
email = "william.ballenthin@fireeye.com"
license = "Apache 2.0"
copyright = "FireEye, Inc"
description = "Match x86 that appears to fetch $PC."
strings:
@stvemillertime
stvemillertime / ida_match_yara.py
Created August 16, 2021 13:36 — forked from williballenthin/ida_match_yara.py
search for YARA matches in each function within IDA Pro.
#!/usr/bin/env python2
'''
search for YARA matches in each function within IDA Pro.
upon execution, prompts the user to provide the YARA rules file.
requirements:
- hexdump
- yara-python
author: Willi Ballenthin
@stvemillertime
stvemillertime / stackstrings.yara
Last active August 16, 2021 13:35 — forked from williballenthin/stackstrings.yara
match x86 that appears to be stack string creation
rule stack_strings
{
meta:
author = "William Ballenthin"
email = "william.ballenthin@fireeye.com"
license = "Apache 2.0"
copyright = "FireEye, Inc"
description = "Match x86 that appears to be stack string creation."
strings:

manual import resolution

example from 0f5d5d07c6533bc6d991836ce79daaa1:

_0:00F20012 33 D2                   xor     edx, edx
_0:00F20014 64 8B 52 30             mov     edx, fs:[edx+30h] // TEB->PEB
_0:00F20018 8B 52 0C                mov     edx, [edx+0Ch]    // PEB->LDR_DATA
_0:00F2001B 8B 52 14                mov     edx, [edx+14h]    // LDR_DATA->InMemoryOrderLinks (_LDR_DATA_TABLE_ENTRY)
                                                              // alt: 0xC: InLoadOrderLinks
 // alt: 0x1C: InInitializationOrderLinks
We can't make this file beautiful and searchable because it's too large.
.dll names start with #,Hash,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
API Name ,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8 ,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,
#advapi32.dll,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
A_SHAFinal, 0x00000366, 0xcd8000cd, 0x207b408d, 0x1176ff9a, 0x94da5e05, 0xe55e8219, 0x201a8b76, 0xf5e52c56, 0xe3b6bd11, 0xf1c52e36, 0xaab636d1, 0xb31a99ba, 0xe26ba2e1, 0xb52e8e6d, 0xe027ce65, 0xb7aa7784, 0x019f01c7, 0x5f406f0d, 0x6af8f60f, 0x5c9eb472, 0x83806f5f, 0x9b11cc66, 0xcc44df4b, 0xdc4345f8, 0xbcb6e411, 0x4ce2d319, 0x984b493c, 0x869ec636, 0x7c5d08f0, 0x72a5d0f6, 0x017dad10,
A_SHAInit, 0x00000310, 0xbb0000d5, 0x9ded0096, 0x0137f983, 0x02d5d9ac, 0x851635cf, 0xf2f3829a, 0xe8aa0d8d, 0xb1c1a8f6, 0x87dcd656, 0xd799e6c9, 0x542a89ad, 0xe9d76339, 0xd79837f8, 0xf42a786c, 0x3b9a5bfc, 0x015901b7, 0x1d409e95, 0x268c77f7, 0xb4324688, 0xf437e849, 0x80933a52, 0x7842fd4b, 0xde8217b5, 0xa8c1b1f6, 0x5afb0338, 0x426d7bf6, 0x543689a1, 0x47c6054b, 0x4e54c13c, 0x005f6c38,
/*
I've only tested about half of these, so use with care. Some of them are too common for any practical use.
You gotta find which ones are within your prevalence comfort zone. For me <10-20K is pretty decent. For you that might not work.
This list of CLSIDs ripped raw from https://github.com/decalage2/oletools/blob/master/oletools/common/clsid.py
I took those and then stole a script from github to convert the CLSIDs from string GUID form to hex GUID form, then I mass created the rules.