INNER CODE UNIT · JavaScript
phentsize
hackcatml/frida-flutterproxy · script.js:450
var phentsize = is32bit ? base.add(off_of_Elf32_Ehdr_phentsize).readU16() : base.add(off_of_Elf64_Ehdr_phentsize).readU16(); // Size of entries in the program header table
if (is32bit && phentsize != 32) { // 0x20
console.log("[!] Wrong e_phentsize. Should be 32. Let's assume it's 32");
phentsize = 32;
} else if (!is32bit && phentsize != 56) {
console.log("[!] Wrong e_phentsize. Should be 56. Let's assume it's 56");
phentsize = 56;
}
var phnum = is32bit ? base.add(off_of_Elf32_Ehdr_phnum).readU16() : base.add(off_of_Elf64_Ehdr_phnum).readU16(); // Number of entries in program header table
// If phnum is 0, try to get it from the file
if (phnum == 0) {
if (fd != null && fd !== -1){
console.log("[!] phnum is 0. Try to get it from the file")
ehdrs_from_file = Memory.alloc(64);
lseek(fd, 0, SEEK_SET);
read(fd, ehdrs_from_file, 64);
phnum = is32bit ? ehdrs_from_file.add(off_of_Elf32_Ehdr_phnum).readU16() : ehdrs_from_file.add(off_of_Elf64_Ehdr_phnum).readU16();
if (phnum == 0) {