Hello Randori,
First of all thanks for you tool and work publishing your analysis about Fortigate firmware analysis.
I was trying to analyze latest FortiGate firmware 7.4.7 and I have encountered that the tool is not working and found the root cause. I would like to share it with you in order to detect why.
First of all, I downloaded the following FortigateVM image.

I then converted flatkc to ELF for analysis using vmlinux-to-elf. Apparently, the Kernel image has not been modified because it dates to January 20.
~/fgate/vmlinux-to-elf$ ./vmlinux-to-elf ../flatkc ../flatkc.elf
[+] Kernel successfully decompressed in-memory (the offsets that follow will be given relative to the decompressed binary)
[+] Version string: Linux version 4.19.13 (root@build) (gcc version 10.3.0 (GCC)) #1 SMP Mon Jan 20 18:15:22 America 2025
[+] Guessed architecture: x86_64 successfully in 2.36 seconds
[+] Found kallsyms_token_table at file offset 0x013d14b8
[+] Found kallsyms_token_index at file offset 0x013d17f8
[+] Found kallsyms_markers at file offset 0x013d0f50
[+] Found kallsyms_names at file offset 0x0134bf78
[+] Found kallsyms_num_syms at file offset 0x0134bf70
[i] Null addresses overall: 25.3565 %
[+] Found kallsyms_addresses at file offset 0x012f5ae0
[+] Successfully wrote the new ELF kernel to ../flatkc.elf
After that the tool is not working and I have found that the symbol rsa_parse_pub_key is not available.

Moreover, found that rsa_set_pub_key is not calling rsa_parse_pub_key . According to source code it should (https://github.com/torvalds/linux/blob/v4.19/crypto/rsa.c#L267) but that is not the case.
~/fgate$ objdump -M intel -d --disassemble=rsa_set_pub_key flatkc.elf
flatkc.elf: file format elf64-x86-64
Disassembly of section .text:
ffffffff80c02cd6 <rsa_set_pub_key>:
ffffffff80c02cd6: 55 push rbp
ffffffff80c02cd7: 48 89 e5 mov rbp,rsp
ffffffff80c02cda: 41 54 push r12
ffffffff80c02cdc: 53 push rbx
ffffffff80c02cdd: 48 83 ec 50 sub rsp,0x50
ffffffff80c02ce1: 4c 89 c3 mov rbx,r8
ffffffff80c02ce4: 65 48 8b 04 25 28 00 mov rax,QWORD PTR gs:0x28
ffffffff80c02ceb: 00 00
ffffffff80c02ced: 48 89 45 e8 mov QWORD PTR [rbp-0x18],rax
ffffffff80c02cf1: 48 8b 47 08 mov rax,QWORD PTR [rdi+0x8]
ffffffff80c02cf5: 8b 00 mov eax,DWORD PTR [rax]
ffffffff80c02cf7: 89 45 a4 mov DWORD PTR [rbp-0x5c],eax
ffffffff80c02cfa: 4d 8b 20 mov r12,QWORD PTR [r8]
ffffffff80c02cfd: 48 8b 07 mov rax,QWORD PTR [rdi]
ffffffff80c02d00: 48 89 45 a8 mov QWORD PTR [rbp-0x58],rax
ffffffff80c02d04: 48 8b 47 10 mov rax,QWORD PTR [rdi+0x10]
ffffffff80c02d08: 48 89 45 b8 mov QWORD PTR [rbp-0x48],rax
ffffffff80c02d0c: 48 8b 47 18 mov rax,QWORD PTR [rdi+0x18]
ffffffff80c02d10: 48 89 45 c0 mov QWORD PTR [rbp-0x40],rax
ffffffff80c02d14: 48 8b 47 20 mov rax,QWORD PTR [rdi+0x20]
ffffffff80c02d18: 48 89 45 c8 mov QWORD PTR [rbp-0x38],rax
ffffffff80c02d1c: 48 8b 47 28 mov rax,QWORD PTR [rdi+0x28]
ffffffff80c02d20: 48 89 45 d0 mov QWORD PTR [rbp-0x30],rax
ffffffff80c02d24: 48 8b 47 30 mov rax,QWORD PTR [rdi+0x30]
ffffffff80c02d28: 48 89 45 d8 mov QWORD PTR [rbp-0x28],rax
ffffffff80c02d2c: 48 8b 47 38 mov rax,QWORD PTR [rdi+0x38]
ffffffff80c02d30: 48 89 45 e0 mov QWORD PTR [rbp-0x20],rax
ffffffff80c02d34: 48 8d 45 a4 lea rax,[rbp-0x5c]
ffffffff80c02d38: 48 89 45 b0 mov QWORD PTR [rbp-0x50],rax
ffffffff80c02d3c: 48 8d 7d a8 lea rdi,[rbp-0x58]
ffffffff80c02d40: e8 4d 50 6f ff call ffffffff802f7d92 <crypto_register_acomps>
ffffffff80c02d45: 85 c0 test eax,eax
ffffffff80c02d47: 74 03 je ffffffff80c02d4c <rsa_set_pub_key+0x76>
ffffffff80c02d49: 4c 89 23 mov QWORD PTR [rbx],r12
ffffffff80c02d4c: 48 8b 5d e8 mov rbx,QWORD PTR [rbp-0x18]
ffffffff80c02d50: 65 48 2b 1c 25 28 00 sub rbx,QWORD PTR gs:0x28
ffffffff80c02d57: 00 00
ffffffff80c02d59: 75 09 jne ffffffff80c02d64 <rsa_set_pub_key+0x8e>
ffffffff80c02d5b: 48 83 c4 50 add rsp,0x50
ffffffff80c02d5f: 5b pop rbx
ffffffff80c02d60: 41 5c pop r12
ffffffff80c02d62: 5d pop rbp
ffffffff80c02d63: c3 ret
ffffffff80c02d64: e8 19 ce 6e ff call ffffffff802efb82 <_einittext+0x1efb82>
Disassembly of section .init.text:
Disassembly of section .altinstr_aux:
Disassembly of section .altinstr_replacement:
Disassembly of section .exit.text:
Reviewing your blog post you did find rsa_parse_pub_key symbol. I would appreciate so much if you can help me about understanding how that symbol is not found as I believe is the same Kernel that you used for your decryption research.
Thanks!
Hello Randori,
First of all thanks for you tool and work publishing your analysis about Fortigate firmware analysis.
I was trying to analyze latest FortiGate firmware 7.4.7 and I have encountered that the tool is not working and found the root cause. I would like to share it with you in order to detect why.
First of all, I downloaded the following FortigateVM image.
I then converted flatkc to ELF for analysis using vmlinux-to-elf. Apparently, the Kernel image has not been modified because it dates to January 20.
After that the tool is not working and I have found that the symbol rsa_parse_pub_key is not available.
Moreover, found that rsa_set_pub_key is not calling rsa_parse_pub_key . According to source code it should (https://github.com/torvalds/linux/blob/v4.19/crypto/rsa.c#L267) but that is not the case.
Reviewing your blog post you did find rsa_parse_pub_key symbol. I would appreciate so much if you can help me about understanding how that symbol is not found as I believe is the same Kernel that you used for your decryption research.
Thanks!