-
Notifications
You must be signed in to change notification settings - Fork 16
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
78449d6
commit b844590
Showing
1 changed file
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Iterate GUIDs and display one per line. | ||
|
||
import sys | ||
|
||
import dnfile | ||
|
||
|
||
def show_guids(fname): | ||
# parse .NET executable | ||
dn = dnfile.dnPE(fname, clr_lazy_load=True) | ||
# if no CLR data found, do nothing | ||
if not hasattr(dn, "net"): | ||
return | ||
|
||
# get the (first) GUID stream | ||
g: dnfile.stream.GuidHeap = dn.net.metadata.streams.get(b"#GUID", None) | ||
if g: | ||
# get size of the stream | ||
size = g.sizeof() // 16 | ||
print(f"INFO: size={size}") | ||
offset = 1 | ||
# while there is still data in the stream | ||
while offset <= size: | ||
# read the guid | ||
item = g.get(offset) | ||
if item is None: | ||
rva = g.rva + (offset * 16) | ||
print(f"Bad GUID: rva=0x{rva:08x}") | ||
break | ||
|
||
print(item) | ||
# continue to next entry | ||
offset += 1 | ||
|
||
|
||
# for each filepath provided on command-line | ||
for fname in sys.argv[1:]: | ||
show_guids(fname) |