Skip to content

Instantly share code, notes, and snippets.

View b2ag's full-sized avatar
🙃

Thomas b2ag

🙃
View GitHub Profile
@b2ag
b2ag / gist:058aee336bec57e06cb849528f4a3355
Last active February 21, 2018 23:11
Calculates CRC32C checksum to repair a borked checksum in a except from that unimpaired Btrfs superblock
i=32; sudo dd if=/dev/sdb1 of=/dev/stdout bs=1 skip=$(expr 65536 + $i ) count=$(expr 4096 - $i)|python -c "import crcmod; import sys; import struct; crc32c = crcmod.predefined.Crc('crc-32c'); crc32c.update(sys.stdin.buffer.read()); final_value=struct.unpack('<I', struct.pack('>I', crc32c.crcValue))[0]; print('0x{:08x}'.format(final_value));"
@b2ag
b2ag / gist:1eb9cafb0e269165191339fc9395b5e0
Last active April 28, 2023 22:47
Ghidra import_memory_map_from_other_program (assumes tool as program loaded and another program named 'FragmentBundle_F.prx' exists)
def import_memory_map_from_other_program( program2_name ):
program2_file = state.getProject().getProjectData().getRootFolder().getFile(program2_name)
program2 = program2_file.getImmutableDomainObject(currentProgram,ghidra.framework.model.DomainFile.DEFAULT_VERSION,monitor)
try:
# process each memory block from program2
for memblock in program2.getMemory().getBlocks():
#memblock = program2.getMemory().getBlocks()[0]
if memblock.isOverlay() or not memblock.isInitialized():
print('Memblock "{}" of "{}" is overlay or not initialized. Skipping.'.format(memblock.getName(),program2_name))
continue