-
Notifications
You must be signed in to change notification settings - Fork 1
/
idaSSLdump.py
55 lines (46 loc) · 1.58 KB
/
idaSSLdump.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import time
from idc import *
from idaapi import *
from idautils import *
class DbgHook(DBG_Hooks):
def __init__(self):
DBG_Hooks.__init__(self)
def __logToFile__(self, action, text):
f = open('ssllog.txt', 'a')
f.write('\n[%s] %s => %s\n' % (time.ctime(), action, text))
f.close()
def __hooker__(self, ea):
stack = cpu.Ebp if cpu.Ebp < cpu.Esp else cpu.Esp
Message("Stack %0.8X\n" % stack)
funcName = GetDisasm(ea)
if 'SSL_write' in funcName:
text = GetManyBytes(cpu.Ebx, cpu.Eax, True)
self.__logToFile__('Write', text)
else:
# msg = GetManyBytes(stack + 4, 4)
# Message("Stack+4 " + str(msg) + "\n")
# if msg:
# msg = msg[::-1].encode('hex')
# StepOver()
# text = GetString(int(msg, 16))
text = GetManyBytes(cpu.Ebx, cpu.Eax, True)
self.__logToFile__('Read', text)
continue_process()
def dbg_bpt(self, tid, ea):
self.__hooker__(ea)
return 0
debugger = DbgHook()
debugger.hook()
ssl_func = ['SSL_write', 'SSL_read']
current_addr = ScreenEA()
# Find all ssl function and set breakpoint
for function in Functions(SegStart(current_addr), SegEnd(current_addr)):
funcName = GetFunctionName(function)
if funcName in ssl_func:
for xref in CodeRefsTo(function, 0):
if funcName == 'SSL_write':
AddBpt(xref)
else:
xref += 5
AddBpt(xref)
# SetBptAttr(xref, BPTATTR_FLAGS, 0x0)