Skip to content

Instantly share code, notes, and snippets.

@oopsmishap
Created January 31, 2023 21:33
Show Gist options
  • Save oopsmishap/023498905bd1eb7cc00709f22af2a490 to your computer and use it in GitHub Desktop.
Save oopsmishap/023498905bd1eb7cc00709f22af2a490 to your computer and use it in GitHub Desktop.
Astaroth hide timewaster function calls
import idautils
import idaapi
import ida_bytes
import ida_search
import ida_segment
import ida_nalt
def find_function(pattern):
text = ida_segment.get_segm_by_name('.text')
return ida_search.find_binary(text.start_ea, text.end_ea, pattern, 16, ida_search.SEARCH_DOWN)
TIMEWASTE_FUNC_PATTERN = "55 8B EC 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 6A 00 53 89 4D F4 89 55 F8"
timewaste_func = find_function(TIMEWASTE_FUNC_PATTERN)
for ref in idautils.XrefsTo(timewaste_func, idaapi.XREF_ALL):
start = ref.frm - 35 # 5 bytes per instruction
end = ref.frm + 5
ida_bytes.patch_bytes(start, b'\x90'*40)
for x in range(start, end):
ida_nalt.hide_item(x)
print(f'Patched callee 0x{ref.frm:x} with nops')
@oopsmishap
Copy link
Author

Before:
image

After:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment