#!/usr/bin/perl use strict; use FileHandle; my $fn = 'td.exe'; my $fh = FileHandle->new($fn, '+< :raw') or die "$fn: $!"; $fh->binmode(':raw'); my $buf = "\x90\x90\xEB"; my $inb; $fh->seek(0x13B0BAF, 0); $fh->read($inb, 3); if ($inb eq "\x7f\x13\x75") { print("Chunk#1: patched\n"); $fh->seek(0x13B0BAF, 0); $fh->write($buf, 3); } elsif ($inb eq $buf) { print("Chunk#1: already patched\n"); } else { printf("Chunk#1: unknown sequence: %02x.%02x.%02x\n", unpack("C3", $inb)); } $fh->seek(0x13B0BBA, 0); $fh->read($inb, 3); if ($inb eq "\x7f\x08\x75") { print("Chunk#2: patched\n"); $fh->seek(0x13B0BBA, 0); $fh->write($buf, 3); } elsif ($inb eq $buf) { print("Chunk#2: already patched\n"); } else { printf("Chunk#2: unknown sequence: %02x.%02x.%02x\n", unpack("C3", $inb)); } $fh->close(); __END__ .text:0000000141450147 jg short l_14145015B_lic_expired .text:0000000141450149 jnz short l_141450183_lic_success .text:000000014145014B mov eax, [rcx+10h] .text:000000014145014E inc eax .text:0000000141450150 cmp eax, ebx .text:0000000141450152 jg short l_14145015B_lic_expired .text:0000000141450154 jnz short l_141450183_lic_success .text:0000000141450156 cmp [rcx+0Ch], esi .text:0000000141450159 jle short l_141450183_lic_success .text:000000014145015B