{"id":13755592,"url":"https://github.com/snare/ida-efiutils","last_synced_at":"2025-04-08T04:18:13.874Z","repository":{"id":4593084,"uuid":"5735505","full_name":"snare/ida-efiutils","owner":"snare","description":"Some scripts for IDA Pro to assist with reverse engineering EFI binaries","archived":false,"fork":false,"pushed_at":"2019-05-23T18:47:30.000Z","size":492,"stargazers_count":277,"open_issues_count":4,"forks_count":69,"subscribers_count":40,"default_branch":"master","last_synced_at":"2024-02-12T16:11:26.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-09T06:30:54.000Z","updated_at":"2024-01-17T15:57:41.000Z","dependencies_parsed_at":"2022-09-13T19:14:27.356Z","dependency_job_id":null,"html_url":"https://github.com/snare/ida-efiutils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snare%2Fida-efiutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snare%2Fida-efiutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snare%2Fida-efiutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snare%2Fida-efiutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snare","download_url":"https://codeload.github.com/snare/ida-efiutils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773721,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T10:00:57.508Z","updated_at":"2025-04-08T04:18:13.853Z","avatar_url":"https://github.com/snare.png","language":"C","funding_links":[],"categories":["\u003ca id=\"e5e403123c70ddae7bd904d3a3005dbb\"\u003e\u003c/a\u003eELF","Reverse Engine"],"sub_categories":["\u003ca id=\"1c698e298f6112a86c12881fbd8173c7\"\u003e\u003c/a\u003eSwift"],"readme":"# EFI scripts for IDA Pro\n\nSome IDA scripts to assist with reverse engineering EFI executables.\n\nThis package contains the following files:\n\n1. `efiutils.py` - IDAPython module with some helper functions\n\n2. `efiguids.py` - A collection of known GUIDs for EFI protocols\n\n3. `efiguids_ami.py` - A collection of known GUIDs for protocols used in the AMI BIOS\n\n4. `behemoth.h` - A giant header containing a collection of type and structure definitions for EFI\n\n5. `structs.idc` - An IDC script containing some struct definitions (superseded by `behemoth.h`)\n\n6. `te_image.bt` - An 010 Editor template for TE binary images\n\n7. `te_loader.py` - An IDA Pro loader script for TE binary images\n\nThis is my first attempt at IDA scripting, so please forgive me and let me know if I've reinvented wheels/done anything silly.\n\n## Functions\n\nThe main useful functions are described below. See code and docstrings for more information on other functions.\n\n### `rename_tables()`\n\nFinds the first entry point for the binary, tries to track the parameters that were passed to the entry point function and rename global variables in which the key EFI tables are stored. The following renaming operations are performed:\n\n1. Global where `ImageHandle` ends up is renamed to `gImageHandle`.\n\n2. Global where `SystemTable` ends up is renamed to `gSystemTable`.\n\n3. Global where `SystemTable-\u003eBootServices` ends up is renamed to `gBootServices`.\n\n4. Global where `SystemTable-\u003eRuntimeServices` ends up is renamed to `gRuntimeServices`.\n\nCall instructions will only be followed one level deep, as most executables copy the table references in the entry point or a function called from the entry point. Change `MAX_STACK_DEPTH` if necessary.\n\n### `update_structs()`\n\nFinds cross-references to tables renamed above, and updates their names to be struct offsets from the appropriate structs. If `rename_tables()` failed you'll need to rename things manually as above for this to work properly.\n\n\nFor example:\n\n\t    mov     rax, cs:qword_whatever\n\t    call    qword ptr [rax+150h]\n\nBecomes:\n\n\t    mov     rax, cs:gBootServices\n\t    call    [rax+EFI_BOOT_SERVICES.UninstallMultipleProtocolInterfaces]\n\n### `rename_guids()`\n\nFinds GUIDs in data segments and renames them. 470 protocol GUIDs were pulled out of the TianoCore source, and proprietary Apple (and other vendor) GUIDs will be added as they are encountered.\n\n### `go()`\n\nConvenience method that does all of the above. \n\n## Usage\n\n1. Load up your EFI binary in IDA Pro\n\n2. Import `behemoth.h` to define the necessary data structures\n\n3. Add the structures from local types to your IDB\n\n4. Run `efiutils.py` to add it to python's path (or do this by some other method)\n\n5. Have a look at the code/docstrings, but probably:\n\n\t\timport efiutils; efiutils.go()\n\nTo use the `te_loader.py` TE image loader, install it as you would any other loader. On OS X this is done by copying or symlinking it inside the loaders folder at `idaq.app/Contents/MacOS/loaders/`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnare%2Fida-efiutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnare%2Fida-efiutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnare%2Fida-efiutils/lists"}