Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2025, 04:57
wx69wx2023 wx69wx2023 is offline
Family
 
Join Date: Sep 2023
Posts: 316
Rept. Given: 48
Rept. Rcvd 59 Times in 34 Posts
Thanks Given: 586
Thanks Rcvd at 875 Times in 229 Posts
wx69wx2023 Reputation: 59
and it give the py,try it.

Here’s a Python script for IDA to help you locate the entry point in a dumped process manually loaded into IDA. The script will:

1. Scan memory for potential PE headers (MZ and PE signatures).


2. Locate the AddressOfEntryPoint in the PE header.


3. Calculate the real entry point by adding ImageBaseAddress + AddressOfEntryPoint.


4. Set an IDA function at the entry point for analysis.




---

IDA Python Script to Find Entry Point

from ida_bytes import get_dword, get_bytes
from ida_idaapi import BADADDR
from ida_funcs import add_func
from idaapi import set_name

def find_pe_headers():
"""Search for PE headers in memory regions."""
start_ea = idaapi.get_inf_structure().min_ea
end_ea = idaapi.get_inf_structure().max_ea
pe_headers = []

for ea in range(start_ea, end_ea, 0x1000): # Scan in 4KB steps
if get_bytes(ea, 2) == b"MZ": # Check for 'MZ' signature
pe_headers.append(ea)

return pe_headers

def get_entry_point(pe_base):
"""Extract the entry point from the PE header."""
e_lfanew = get_dword(pe_base + 0x3C) # Offset to PE header
pe_header = pe_base + e_lfanew

if get_bytes(pe_header, 2) != b"PE": # Check 'PE' signature
return None

optional_header = pe_header + 0x18
address_of_entry_point = get_dword(optional_header + 0x10) # Offset 0x10 in Optional Header

image_base = get_dword(optional_header + 0x1C) # ImageBase field
real_entry_point = image_base + address_of_entry_point

return real_entry_point

def main():
pe_headers = find_pe_headers()
if not pe_headers:
print("No PE headers found.")
return

for pe_base in pe_headers:
entry_point = get_entry_point(pe_base)
if entry_point and entry_point != BADADDR:
print(f"Possible Entry Point Found: 0x{entry_point:X}")
add_func(entry_point) # Create function in IDA
set_name(entry_point, "EntryPoint", idaapi.SN_NOWARN)
break # Stop after the first valid PE header

main()


---

How to Use This in IDA:

1. Load your process dump into IDA.


2. Open IDA’s Python console (Ctrl + Alt + P).


3. Copy-paste the script and run it.


4. If an entry point is found, IDA will highlight it and name it EntryPoint.




---

What This Script Does:

Searches memory for potential PE headers.

Reads AddressOfEntryPoint from the PE header.

Calculates the actual entry point.

Creates an IDA function at the detected entry point.


If the script fails to find the entry, let me know—I can refine it based on your dump’s structure.
Reply With Quote
The Following User Says Thank You to wx69wx2023 For This Useful Post:
rcer (03-04-2025)
  #2  
Old 03-04-2025, 21:59
rcer rcer is offline
Friend
 
Join Date: Dec 2008
Posts: 171
Rept. Given: 5
Rept. Rcvd 9 Times in 8 Posts
Thanks Given: 6
Thanks Rcvd at 30 Times in 22 Posts
rcer Reputation: 9
Thumbs up

Quote:
Originally Posted by wx69wx2023 View Post
and it give the py,try it.

Here’s a Python script for IDA to help you locate the entry point in a dumped process manually loaded into IDA. The script will:

1. Scan memory for potential PE headers (MZ and PE signatures).


2. Locate the AddressOfEntryPoint in the PE header.


3. Calculate the real entry point by adding ImageBaseAddress + AddressOfEntryPoint.


4. Set an IDA function at the entry point for analysis.




---

IDA Python Script to Find Entry Point

from ida_bytes import get_dword, get_bytes
from ida_idaapi import BADADDR
from ida_funcs import add_func
from idaapi import set_name

def find_pe_headers():
"""Search for PE headers in memory regions."""
start_ea = idaapi.get_inf_structure().min_ea
end_ea = idaapi.get_inf_structure().max_ea
pe_headers = []

for ea in range(start_ea, end_ea, 0x1000): # Scan in 4KB steps
if get_bytes(ea, 2) == b"MZ": # Check for 'MZ' signature
pe_headers.append(ea)

return pe_headers

def get_entry_point(pe_base):
"""Extract the entry point from the PE header."""
e_lfanew = get_dword(pe_base + 0x3C) # Offset to PE header
pe_header = pe_base + e_lfanew

if get_bytes(pe_header, 2) != b"PE": # Check 'PE' signature
return None

optional_header = pe_header + 0x18
address_of_entry_point = get_dword(optional_header + 0x10) # Offset 0x10 in Optional Header

image_base = get_dword(optional_header + 0x1C) # ImageBase field
real_entry_point = image_base + address_of_entry_point

return real_entry_point

def main():
pe_headers = find_pe_headers()
if not pe_headers:
print("No PE headers found.")
return

for pe_base in pe_headers:
entry_point = get_entry_point(pe_base)
if entry_point and entry_point != BADADDR:
print(f"Possible Entry Point Found: 0x{entry_point:X}")
add_func(entry_point) # Create function in IDA
set_name(entry_point, "EntryPoint", idaapi.SN_NOWARN)
break # Stop after the first valid PE header

main()


---

How to Use This in IDA:

1. Load your process dump into IDA.


2. Open IDA’s Python console (Ctrl + Alt + P).


3. Copy-paste the script and run it.


4. If an entry point is found, IDA will highlight it and name it EntryPoint.




---

What This Script Does:

Searches memory for potential PE headers.

Reads AddressOfEntryPoint from the PE header.

Calculates the actual entry point.

Creates an IDA function at the detected entry point.


If the script fails to find the entry, let me know—I can refine it based on your dump’s structure.
Nice py script, and I will give it a shot today
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Update Dump (WUA) [C++ source] HarrySpoofer Source Code 2 07-23-2022 23:14
How to find out what process issued a windows service start? DavidXanatos General Discussion 9 05-21-2020 18:46
Load and Execute unsigned code into kernel in Windows 10x64 TechLord General Discussion 1 03-12-2017 16:30


All times are GMT +8. The time now is 07:52.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )