I wrote the target for this so anybody can repeat it. It is a small Windows console app, the kind of licence gate that ships in thousands of paid desktop tools: the user types a key, the program checks it locally, and a boolean decides which message gets printed.
0x2A5E1. Fail any of those and the program prints
Invalid licence key and exits 1.
route put it on pe_native in one call: PE32+, no packer, no .NET,
51 imports, seven sections, nothing suspicious. plan then returned three branch
candidates with the string that sits beside each one. The top entry:
{
"index": 0,
"kind": "FAIL",
"jump": "je",
"bytes": "7422",
"jcc_off": "0xc91",
"ref_off": "0xc3f",
"string": "Invalid licence key",
"verified": true
}
That entry is wrong, and the disassembler was right to call it verified anyway. File offset
0xc91 lands in __do_global_dtors, a runtime teardown loop that has
nothing to do with licences. It scored high because a string reference is nearby, which is
exactly the sort of thing a proximity heuristic gets wrong on a compiler that packs static
strings into one region.
Ten seconds with objdump settles it. The comparison and the branch that decides
which way the program goes:
1400015d6: call 140007cd8 <strlen> 1400015db: cmp $0x13,%rax ; length must be 19 1400015df: jne 140001659 ; -> error path 1400015e1: cmpb $0x2d,0x24(%rsp) ; dash at 4 1400015e6: jne 140001659 1400015e8: cmpb $0x2d,0x29(%rsp) ; dash at 9 1400015ed: jne 140001659 1400015ef: cmpb $0x2d,0x2e(%rsp) ; dash at 14 1400015f4: jne 140001659 140001603: movzbl (%rax,%r8,1),%ecx ; checksum loop 140001608: add %ecx,%edx 14000160a: add $0x1,%rax 14000160e: cmp $0x13,%rax 140001612: jne 140001603 140001614: cmp $0x943608bb,%edx ; the multiplied sum 14000161a: jne 140001659 ; <- this one decides it 14000161c: lea ...%rcx ; "Licence accepted" 140001623: call 140001530 <printf>
The branch at 14000161a is 75 3d: jne, jump forward
into the error path when the checksum does not match. Everything above it is key format
checking. Change that one byte to 74 and the conditional inverts, so the wrong
key falls through into the paid path instead of jumping away from it.
$ ree_ai.py patch '{"path":"invoicepro.exe","out":"invoicepro_patched.exe",
"patches":[{"offset":"0xc1a","mode":"flip"}]}'
{"dst": "invoicepro_patched.exe",
"results": [{"offset": "0xc1a", "mode": "flip",
"before": "753d", "after": "743d", "status": "applied"}]}
$ ree_ai.py verify '{"orig":"invoicepro.exe","new":"invoicepro_patched.exe"}'
{"same_size": true, "regions_changed": 1,
"diffs": [{"range": "0xc1a-0xc1a", "orig": "75", "new": "74"}]}
One byte, file length unchanged, nothing else touched. I could not run the PE here, there is
no Windows host on this machine, so I rebuilt the same source as a Linux binary and repeated
the exercise. Offset 0x1209, 75 36 to 74 36,
same verify result, one region changed. Then I ran both:
$ ./invoicepro_linux <<< "AAAA-BBBB-CCCC-DDDD" InvoicePro 3.2 Enter licence key: Invalid licence key (exit 1) $ ./invoicepro_linux_patched <<< "AAAA-BBBB-CCCC-DDDD" InvoicePro 3.2 Enter licence key: Licence accepted. Pro features unlocked. Batch export is available. (exit 0) $ ./invoicepro_linux_patched <<< "" InvoicePro 3.2 Enter licence key: Invalid licence key (exit 1)
Note the third run. The empty key is still rejected, because the length check upstream is untouched. That is what a one byte patch looks like from the outside: the program still validates shape, it just no longer cares whether the numbers add up.
Total cost to defeat this licence model: one byte, and about ten minutes if you know where to look. No packer, no obfuscator and no anti-debug change that number by much, they only change the ten minutes. The fix is not a better local check, it is not having the decision live on the customer's machine at all. Ask the server, per request, and hand back only what was paid for.
The source is 45 lines of C and both binaries are built from it: mingw for the PE, gcc for the ELF. Hashes below are the exact files used here, so you can confirm you are looking at the same thing.
invoicepro.exe 8dbd1b21c20e14899ea5e98052cee3ea8a54a43c889d1c79c5402e845935d26e invoicepro_patched one byte: 0xc1a 75 -> 74 (same size: true)