generated from clearbluejar/ghidra-python-vscode-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
733c045
commit 89780e2
Showing
3 changed files
with
142 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import pyhidra | ||
|
||
#### Section to make autocomplete work | ||
try: | ||
import ghidra | ||
from ghidra_builtins import * | ||
except: | ||
pass | ||
#### | ||
|
||
PROJECT_NAME = os.getenv('PROJECT_NAME') | ||
PROJECT_LOCATION = os.path.join(os.getenv('GHIDRA_PROJECTS_PATH'),PROJECT_NAME) | ||
|
||
pyhidra.start(True) # setting Verbose output | ||
|
||
with pyhidra.open_program("/bin/ls", project_name=PROJECT_NAME, project_location=PROJECT_LOCATION) as flat_api: | ||
|
||
prog = flat_api.getCurrentProgram() | ||
|
||
print("Program Info:") | ||
program_name = prog.getName() | ||
creation_date = prog.getCreationDate() | ||
language_id = prog.getLanguageID() | ||
compiler_spec_id = prog.getCompilerSpec().getCompilerSpecID() | ||
print("Program: {}: {}_{} ({})\n".format(program_name, language_id, compiler_spec_id, creation_date)) | ||
|
||
# Get info about the current program's memory layout | ||
print("Memory layout:") | ||
print("Imagebase: " + hex(prog.getImageBase().getOffset())) | ||
for block in prog.getMemory().getBlocks(): | ||
start = block.getStart().getOffset() | ||
end = block.getEnd().getOffset() | ||
print("{} [start: 0x{}, end: 0x{}]".format(block.getName(), start, end)) |