-
Notifications
You must be signed in to change notification settings - Fork 5
/
idapythonrc.py
32 lines (26 loc) · 951 Bytes
/
idapythonrc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import binascii
import sys
from hexdump import hexdump as _hexdump
# https://github.com/nlitsme/idascripts/raw/master/enumerators.py
from enumerators import Texts, Code, NonFuncs, Undefs, ArrayItems, Addrs, NotTails, BytesThat, Heads, Funcs, FChunks, Names
if sys.version_info.major < 3:
bytes = str
def hexdump(data, *args, **kwargs):
if isinstance(data, bytearray): # hexdump do not accept bytearray
data = bytes(data)
return _hexdump(data, *args, **kwargs)
hd = hexdump
def xorb(data, b):
return bytearray(i ^ b for i in bytearray(data))
def xor(a, b):
if not a or not b:
return bytearray(b'')
if len(a) < len(b):
a, b = b, a
a = bytearray(a)
b = bytearray(b) * (len(a) // len(b) + 1)
return bytearray(i ^ j for i, j in zip(a, b))
# for ironstrings and shellcode
def set_vivsect_arch(arch='i386'):
import vivisect
vivisect.defconfig['viv']['parsers']['blob']['arch'] = arch