-
Notifications
You must be signed in to change notification settings - Fork 0
/
ida_s.py
51 lines (42 loc) · 1.11 KB
/
ida_s.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
from idautils import *
from idaapi import *
from idc import *
from ida_name import *
import os
import socket
# connect to the listener
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("Connecting to listener...")
s.connect(("localhost", 1338))
s.send("[+] Script started\n".encode())
auto_wait()
# rebase program to 0x0
offset = idaapi.get_imagebase()
idaapi.rebase_program(-offset, MSF_NOFIX)
def func_disasm(func):
disasm = ""
for line in FuncItems(func):
disasm += GetDisasm(line) + "\n"
return disasm
def check_syscall(func_disasm):
patterns = [
"int 2Eh",
"syscall"
]
for line in func_disasm.split("\n"):
for pattern in patterns:
if pattern in line:
return True
return False
try:
for func in Functions():
addr = get_func(func).start_ea
name = get_func_name(addr)
disasm = func_disasm(func)
# check is syscall
if check_syscall(disasm):
s.send(f"{name} {hex(addr)}\n".encode())
except Exception as e:
s.send(str(e).encode())
s.close()
exit()