Hi.
You need infect kern.bin file (parse opcodes and find empty or modifiable blocks and point to jump your code etc...). If you like build new rom you need code for compile this. I don't remember well but if you firmware use hash for detect changes in kernel.
The Moon is a malware with infection firmwares purposes.
Regards.