msm8916-mainline / qtestsign Goto Github PK
View Code? Open in Web Editor NEWSimple tool to "sign" ELF Qualcomm firmware images using dummy certificates ("test keys")
License: GNU General Public License v2.0
Simple tool to "sign" ELF Qualcomm firmware images using dummy certificates ("test keys")
License: GNU General Public License v2.0
Hi,
I know this qtestsign is not made for other/newer SOCs. I still wanna try this out with a minor branded sdm636 phone and found something strange. please take a look if you are willing to support other SOCs.
the weird happened in Program Headers, looks like the load address altered. and the supposed hash/cert section is absent/stripped in the output mbn file. the source mbn and the output mbn file is zipped.
~/source/qtestsign# readelf -a e3_hyp-test-signed.mbn
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: AArch64
Version: 0x1
Entry point address: 0x85810000
Start of program headers: 64 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 4
Size of section headers: 64 (bytes)
Number of section headers: 0
Section header string table index: 0
There are no sections in this file.
There are no sections to group in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
NULL 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000120 0x0000000000000000 0x0
NULL 0x0000000000001000 0x0000000085a18000 0x0000000085a18000
0x00000000000009a8 0x0000000000001000 0x1000
LOAD 0x0000000000002000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x1000
LOAD 0x0000000000002000 0x0000000085810000 0x0000000085810000
0x000000000003f000 0x0000000000208000 RWE 0x1000
There is no dynamic section in this file.
There are no relocations in this file.
The decoding of unwind sections for machine type AArch64 is not currently supported.
Dynamic symbol information is not available for displaying symbols.
No version information found in this file.
and the original:
~/source/qtestsign# readelf -a e3_hyp.mbn
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: AArch64
Version: 0x1
Entry point address: 0x85810000
Start of program headers: 64 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 4
Size of section headers: 64 (bytes)
Number of section headers: 0
Section header string table index: 0
There are no sections in this file.
There are no sections to group in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
NULL 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000120 0x0000000000000000 0x0
NULL 0x0000000000001000 0x0000000085a18000 0x0000000085a18000
0x00000000000019a8 0x0000000000002000 0x1000
LOAD 0x0000000000002000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x1000
LOAD 0x0000000000003000 0x0000000085810000 0x0000000085810000
0x000000000003f000 0x0000000000208000 RWE 0x1000
There is no dynamic section
./qtestsign.py hyp ../qhypstub.elf
Before: Elf(ehdr=Ehdr(ei_magic=b'\x7fELF', ei_class=2, ei_data=1, ei_version=1, ei_os_abi=0, ei_abi_version=0, e_type=2, e_machine=183, e_version=1, e_entry=2252341248, e_phoff=64, e_shoff=428688, e_flags=0, e_ehsize=64, e_phentsize=56, e_phnum=2, e_shentsize=64, e_shnum=9, e_shstrndx=8), phdrs=[Phdr(p_type=1, p_offset=65536, p_vaddr=2147483648, p_paddr=2147483648, p_filesz=355044, p_memsz=355044, p_flags=7, p_align=65536), Phdr(p_type=1, p_offset=421888, p_vaddr=2252341248, p_paddr=2252341248, p_filesz=4096, p_memsz=4096, p_flags=7, p_align=2048)])
Traceback (most recent call last):
File "./qtestsign.py", line 61, in
_sign_elf(elf_bytes, out, FW_SW_ID[args.type])
File "./qtestsign.py", line 35, in _sign_elf
hashseg.generate(elf, sw_id)
File "/home/boomhacker/qhypstub/qtestsign/hashseg.py", line 122, in generate
cert_chain = sign.generate_cert_chain(sw_id)
File "/home/boomhacker/qhypstub/qtestsign/sign.py", line 32, in generate_cert_chain
root_key, builder = _begin_cert()
File "/home/boomhacker/qhypstub/qtestsign/sign.py", line 18, in _begin_cert
key = rsa.generate_private_key(public_exponent=65537, key_size=KEY_BITS)
TypeError: generate_private_key() missing 1 required positional argument: 'backend'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.