simpleelf
v1.0.0
ไฟล์ ELF ไม่เพียง แต่เป็นวิธีการที่สามารถเรียกใช้งานได้ แต่เป็นวิธีที่สะดวกมากในการอธิบายเค้าโครงของโปรแกรมในหน่วยความจำ ความตั้งใจดั้งเดิมของโครงการนี้คือการอนุญาตให้บุคคลสร้างไฟล์ ELF ซึ่งอธิบายการแมปหน่วยความจำที่ใช้สำหรับโปรแกรมฝังตัว มีประโยชน์อย่างยิ่งสำหรับการใช้ร่วมกับเครื่องมือวิเคราะห์อื่น ๆ เช่น: IDA/GHIDRA/ฯลฯ ... พวกเขาสามารถมีข้อมูลที่ต้องการทั้งหมดโดยไม่จำเป็นต้องเปิดไฟล์ .bin ธรรมดาและใช้สคริปต์ Idapython หลายรายการ (ฉันป่วยจาก Load additional binary file... ตัวเลือก)
การร้องขอแบบดึงเป็นมากกว่ายินดีต้อนรับ?
ใช้ pip :
python3 -m pip install simpleelfหรือโคลนตัวเองและสร้าง:
git clone [email protected]:doronz88/simpleelf.git
cd simpleelf
python -m pip install -e . -Uตอนนี้คุณสามารถนำเข้า Simpleelf และเริ่มเล่นกับมันได้
การแยกวิเคราะห์เป็นเรื่องง่ายโดยใช้ ElfStruct ลองดู:
from simpleelf . elf_structs import ElfStructs
ElfStructs ( '<' ). Elf32 . parse ( elf32_buffer ) # outputs a constucts' container
ElfStructs ( '<' ). Elf64 . parse ( elf64_buffer ) # outputs a constucts' container การสร้างเป็นเรื่องง่ายโดยใช้ ElfBuilder ลองดู:
from simpleelf . elf_builder import ElfBuilder
from simpleelf import elf_consts
# can also be used with ELFCLASS64 to create 64bit layouts
e = ElfBuilder ( elf_consts . ELFCLASS32 )
e . set_endianity ( '<' )
e . set_machine ( elf_consts . EM_ARM )
code = b'CODECODE'
# add a segment
text_address = 0x1234
text_buffer = b'cybercyberbitimbitim' + code
e . add_segment ( text_address , text_buffer ,
elf_consts . PF_R | elf_consts . PF_W | elf_consts . PF_X )
# add a second segment
e . add_segment ( 0x88771122 , b'data in 0x88771122' ,
elf_consts . PF_R | elf_consts . PF_W | elf_consts . PF_X )
# add a code section inside the first segment
code_address = text_address + text_buffer . find ( code ) # point at CODECODE
code_size = len ( code )
e . add_code_section ( code_address , code_size , name = '.text' )
# set entry point
e . set_entry ( code_address )
# add .bss section. not requiring a loaded segment from
# file
bss_address = 0x5678
bss_size = 0x200
e . add_empty_data_section ( bss_address , bss_size , name = '.bss' )
# get raw elf
e . build ()