Skip to content

Instantly share code, notes, and snippets.

View alexander-hanel's full-sized avatar
😶

Alexander Hanel alexander-hanel

😶
View GitHub Profile
@alexander-hanel
alexander-hanel / readme.md
Last active August 9, 2022 19:00
Golang SSA Generation on Windows
@alexander-hanel
alexander-hanel / pe_ham_brute.py
Created November 10, 2020 17:24
Brute force XOR encrypted executables using hamming distance
"""
Author:
Alexander Hanel
Name:
pe_ham_brute.py
Purpose:
- POC that searches for n-grams and uses them as the XOR key.
- Also uses hamming distance to guess key size. Check out cryptopals Challenge 6
for more details https://cryptopals.com/sets/1/challenges/6
Example:
# pip3 install pygore
# modified version of code from https://go-re.tk/pygore/
import glob
import pygore
from hashlib import md5
def go_hash(data):
return md5(b','.join(data)).hexdigest()
for _file in glob.glob("*"):
if _file.endswith(".py") or _file.endswith(".txt"):
continue
@alexander-hanel
alexander-hanel / nopme.py
Last active January 16, 2024 08:02
IDAPYTHON script for patching bytes that match a regex pattern with NOPs.
import idautils
import re
import struct
"""
Example 1
.text:3500108D 60 pusha
.text:3500108E 66 B8 65 4B mov ax, 4B65h
.text:35001092
@alexander-hanel
alexander-hanel / example.py
Created September 3, 2020 17:21
get offset from hexrays output
ea = idaapi.get_screen_ea()
cfunc = idaapi.decompile(ea)
for cc, item in enumerate(cfunc.treeitems):
if item.ea != BADADDR:
if cfunc.treeitems.at(cc).ea == here():
print(cc)
@alexander-hanel
alexander-hanel / ida_regex.py
Created July 28, 2020 17:16
IDAPython Regex Example
import idautils
import re
import struct
"""
String Storage
Example 1
.text:004344F5 8D 05 47 3E 50 00 lea eax, stru_503E47
@alexander-hanel
alexander-hanel / gui.py
Created April 16, 2020 21:27
IDAPython PYQT Example
from idaapi import PluginForm
from PyQt5 import QtCore, QtGui, QtWidgets
import sip
class MyPluginFormClass(PluginForm):
def OnCreate(self, form):
"""
Called when the widget is created
"""
@alexander-hanel
alexander-hanel / enum_me.py
Last active August 12, 2024 15:15
IDAPython PROCESSINFOCLASS & THREADINFOCLASS Enum Values for ZwQueryInformationProcess & ZwQueryInformationThread
# IDAPYTHON 7.4
id = idc.add_enum(-1, "PROCESSINFOCLASS", idaapi.hex_flag())
# 0x0 ProcessBasicInformation, // 0, q: PROCESS_BASIC_INFORMATION, PROCESS_EXTENDED_BASIC_INFORMATION
idc.add_enum_member(id, "ProcessBasicInformation", 0, -1)
# 0x1 ProcessQuotaLimits, // 1, qs: QUOTA_LIMITS, QUOTA_LIMITS_EX
idc.add_enum_member(id, "ProcessQuotaLimits", 1, -1)
# 0x2 ProcessIoCounters, // 2, q: IO_COUNTERS
idc.add_enum_member(id, "ProcessIoCounters", 2, -1)
# 0x3 ProcessVmCounters, //3, q: VM_COUNTERS, VM_COUNTERS_EX, VM_COUNTERS_EX2
idc.add_enum_member(id, "ProcessVmCounters", 3, -1)