rcemoss Posted May 9, 2008 Posted May 9, 2008 Got a window that has a field for a machine specific license and a field for a key that pops the getwindowtexta in the following code with every keystroke until the field is filled. TIA for any explanation of code..text:004F0FAD align 10h.text:004F0FB0 push 0FFFFFFFFh.text:004F0FB2 push offset loc_579A18.text:004F0FB7 mov eax, large fs:0.text:004F0FBD push eax.text:004F0FBE mov large fs:0, esp.text:004F0FC5 push ecx.text:004F0FC6 push esi.text:004F0FC7 mov esi, ecx.text:004F0FC9 lea ecx, [esp+4].text:004F0FCD call ??0CString@@QAE@XZ ; CString::CString(void).text:004F0FD2 lea eax, [esp+4].text:004F0FD6 mov ecx, esi.text:004F0FD8 push eax.text:004F0FD9 push 4D0h.text:004F0FDE mov dword ptr [esp+18h], 0.text:004F0FE6 call ?GetDlgItem@CWnd@@QBEPAV1@H@Z ; CWnd::GetDlgItem(int).text:004F0FEB mov ecx, eax.text:004F0FED call ?GetWindowTextA@CWnd@@QBEXAAVCString@@@Z ; CWnd::GetWindowTextA(CString &).text:004F0FF2 lea ecx, [esp+4].text:004F0FF6 call ?TrimLeft@CString@@QAEXXZ ; CString::TrimLeft(void).text:004F0FFB lea ecx, [esp+4].text:004F0FFF call ?TrimRight@CString@@QAEXXZ ; CString::TrimRight(void).text:004F1004 lea ecx, [esp+4].text:004F1008 call ?MakeUpper@CString@@QAEXXZ ; CString::MakeUpper(void).text:004F100D mov eax, [esp+4].text:004F1011 cmp dword ptr [eax-8], 14h.text:004F1015 jl short loc_4F103A.text:004F1017 push eax.text:004F1018 call sub_4EF910.text:004F101D add esp, 4.text:004F1020 test eax, eax.text:004F1022 jz short loc_4F103A.text:004F1024 push 1.text:004F1026 push 1.text:004F1028 mov ecx, esi.text:004F102A call ?GetDlgItem@CWnd@@QBEPAV1@H@Z ; CWnd::GetDlgItem(int).text:004F102F mov ecx, eax.text:004F1031 call ?EnableWindow@CWnd@@QAEHH@Z ; CWnd::EnableWindow(int).text:004F1036 push 0.text:004F1038 jmp short loc_4F104E
enhzflep Posted May 10, 2008 Posted May 10, 2008 (edited) Basically, from what I can tell - the code you've shown is doing the following: 4F0FCD: create new string variable (this is MS Visual C++ mfc code) 4F0FE6: get handle of dialog item (text input box), number 1232d (4D0h) 4F0FED: get text of window identified by above handle, and put it into our new string variable 4F0FF6: remove leading spaces from entered text " Hello World " ----> "Hello World " 4F0FFF: remove trailing spaces from text "Hello World " ---> "Hello World" 4F1008: convert to upper-case "Hello World" ---> "HELLO WORLD" 4F1011: check string length = 20 (14h) 4F1015: jump to buggerOff if length is less than 20 4F1018: ????????? 4F1020: check that eax contains something after function call 4F1022: jump to buggerOff if we get a 0 return value from above function 4F102A: get a window handle 4F1031: Enable/Disable the window (Enable, I think - does a button become usable at some point?) 4F1038: jmp to buggerOff2 buggerOff: (4F103A) ... ... ... ... ... buggerOff2: (4F104E) If you could get a graph-view of this code in IDA Pro you should be able to get a better idea of just what's happening. Just look for the longest/most complex path right near the serial number entry code. This is typically the successfull activation/registration path - the one with the most chances to be given a BadBoy message. Without knowing what comes after the code you posted, it's a little hard to tell, though I'd be surprised if the actuall checking of the ser-num didn't come somewhere not far below the bottom of this code-fragment. Hope that helps shed a little light on it. Edited May 10, 2008 by enhzflep
rcemoss Posted May 12, 2008 Author Posted May 12, 2008 (edited) Basically, from what I can tell - the code you've shown is doing the following:4F0FCD: create new string variable (this is MS Visual C++ mfc code)4F0FE6: get handle of dialog item (text input box), number 1232d (4D0h)4F0FED: get text of window identified by above handle, and put it into our new string variable4F0FF6: remove leading spaces from entered text " Hello World " ----> "Hello World "4F0FFF: remove trailing spaces from text "Hello World " ---> "Hello World"4F1008: convert to upper-case "Hello World" ---> "HELLO WORLD"4F1011: check string length = 20 (14h)4F1015: jump to buggerOff if length is less than 204F1018: ????????? 4F1020: check that eax contains something after function call4F1022: jump to buggerOff if we get a 0 return value from above function4F102A: get a window handle4F1031: Enable/Disable the window (Enable, I think - does a button become usable at some point?) 4F1038: jmp to buggerOff2buggerOff: (4F103A)...............buggerOff2: (4F104E)If you could get a graph-view of this code in IDA Pro you should be able to get a better idea of just what's happening. Just look for the longest/most complex path right near the serial number entry code. This is typically the successfull activation/registration path - the one with the most chances to be given a BadBoy message.Without knowing what comes after the code you posted, it's a little hard to tell, though I'd be surprised if the actuall checking of the ser-num didn't come somewhere not far below the bottom of this code-fragment.Hope that helps shed a little light on it.Great help, turns out that the 4F1031 turns on the "Unlock" button so the routine at 4F1018 appears to check the 20 character string gathered at 4F0FED. I've posted the code for 4F1018 along with attached flowchart for same if anyone has time to take a look. TIA.004EF910 sub_4EF910 proc near ; CODE XREF: sub_4EF520+61p004EF910 ; sub_4EF520+EFp ...004EF910004EF910 var_30 = dword ptr -30h004EF910 var_2C = dword ptr -2Ch004EF910 var_28 = dword ptr -28h004EF910 var_24 = byte ptr -24h004EF910 var_20 = byte ptr -20h004EF910 var_1C = byte ptr -1Ch004EF910 var_18 = byte ptr -18h004EF910 var_14 = byte ptr -14h004EF910 var_10 = byte ptr -10h004EF910 var_C = dword ptr -0Ch004EF910 var_4 = dword ptr -4004EF910 arg_0 = dword ptr 4004EF910004EF910 mov eax, large fs:0004EF916 push 0FFFFFFFFh004EF918 push offset SEH_4EF910004EF91D push eax004EF91E mov eax, [esp+0Ch+arg_0]004EF922 mov large fs:0, esp004EF929 sub esp, 24h004EF92C push ebx004EF92D push ebp004EF92E xor ebp, ebp004EF930 push esi004EF931 cmp eax, ebp004EF933 push edi004EF934 jnz short loc_4EF94B004EF936 pop edi004EF937 pop esi004EF938 pop ebp004EF939 xor eax, eax004EF93B pop ebx004EF93C mov ecx, [esp+30h+var_C]004EF940 mov large fs:0, ecx004EF947 add esp, 30h004EF94A retn004EF94B ; ---------------------------------------------------------------------------004EF94B004EF94B loc_4EF94B: ; CODE XREF: sub_4EF910+24j004EF94B push eax004EF94C lea ecx, [esp+44h+arg_0]004EF950 mov [esp+44h+var_2C], ebp004EF954 call ??0CString@@QAE@PBD@Z ; CString::CString(char const *)004EF959 mov eax, [esp+40h+arg_0]004EF95D mov [esp+40h+var_4], ebp004EF961 mov eax, [eax-8]004EF964 cmp eax, 14h004EF967 jge short loc_4EF98F004EF969 lea ecx, [esp+40h+arg_0]004EF96D mov [esp+40h+var_4], 0FFFFFFFFh004EF975 call ??1CString@@QAE@XZ ; CString::~CString(void)004EF97A pop edi004EF97B pop esi004EF97C pop ebp004EF97D xor eax, eax004EF97F pop ebx004EF980 mov ecx, [esp+30h+var_C]004EF984 mov large fs:0, ecx004EF98B add esp, 30h004EF98E retn004EF98F ; ---------------------------------------------------------------------------004EF98F004EF98F loc_4EF98F: ; CODE XREF: sub_4EF910+57j004EF98F cmp eax, 11h004EF992 jge short loc_4EF9BA004EF994 lea ecx, [esp+40h+arg_0]004EF998 mov [esp+40h+var_4], 0FFFFFFFFh004EF9A0 call ??1CString@@QAE@XZ ; CString::~CString(void)004EF9A5 pop edi004EF9A6 pop esi004EF9A7 pop ebp004EF9A8 xor eax, eax004EF9AA pop ebx004EF9AB mov ecx, [esp+30h+var_C]004EF9AF mov large fs:0, ecx004EF9B6 add esp, 30h004EF9B9 retn004EF9BA ; ---------------------------------------------------------------------------004EF9BA004EF9BA loc_4EF9BA: ; CODE XREF: sub_4EF910+82j004EF9BA lea ecx, [esp+40h+arg_0]004EF9BE call ?MakeUpper@CString@@QAEXXZ ; CString::MakeUpper(void)004EF9C3 push 43h004EF9C5 push ebp004EF9C6 lea ecx, [esp+48h+arg_0]004EF9CA call ?SetAt@CString@@QAEXHD@Z ; CString::SetAt(int,char)004EF9CF push 50h004EF9D1 push 1004EF9D3 lea ecx, [esp+48h+arg_0]004EF9D7 call ?SetAt@CString@@QAEXHD@Z ; CString::SetAt(int,char)004EF9DC mov ecx, [esp+40h+arg_0]004EF9E0 xor edi, edi004EF9E2 xor esi, esi004EF9E4 mov eax, [ecx-8]004EF9E7 add eax, 0FFFFFFFDh004EF9EA test eax, eax004EF9EC jle short loc_4EFA31004EF9EE004EF9EE loc_4EF9EE: ; CODE XREF: sub_4EF910+11Fj004EF9EE push 1004EF9F0 lea edx, [esp+44h+var_28]004EF9F4 push esi004EF9F5 push edx004EF9F6 lea ecx, [esp+4Ch+arg_0]004EF9FA call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EF9FF mov eax, [eax]004EFA01 push ebp004EFA02 push eax004EFA03 mov ecx, offset dword_5C6CB8004EFA08 mov byte ptr [esp+48h+var_4], 1004EFA0D call ?Find@CString@@QBEHPBDH@Z ; CString::Find(char const *,int)004EFA12 lea ecx, [esp+40h+var_28]004EFA16 add edi, eax004EFA18 mov byte ptr [esp+40h+var_4], 0004EFA1D call ??1CString@@QAE@XZ ; CString::~CString(void)004EFA22 mov eax, [esp+40h+arg_0]004EFA26 inc esi004EFA27 mov eax, [eax-8]004EFA2A add eax, 0FFFFFFFDh004EFA2D cmp esi, eax004EFA2F jl short loc_4EF9EE004EFA31004EFA31 loc_4EFA31: ; CODE XREF: sub_4EF910+DCj004EFA31 mov ecx, dword_5C6CB8004EFA37 mov eax, edi004EFA39 cdq004EFA3A mov ecx, [ecx-8]004EFA3D or edi, 0FFFFFFFFh004EFA40 idiv ecx004EFA42 cmp edx, 23h004EFA45 jl short loc_4EFA49004EFA47 mov edx, edi004EFA49004EFA49 loc_4EFA49: ; CODE XREF: sub_4EF910+135j004EFA49 inc edx004EFA4A push 1004EFA4C push edx004EFA4D lea edx, [esp+48h+var_28]004EFA51 push edx004EFA52 mov ecx, offset dword_5C6CB8004EFA57 call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFA5C mov eax, [eax]004EFA5E lea ecx, [esp+40h+var_28]004EFA62 mov bl, [eax]004EFA64 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFA69 push 1004EFA6B lea ecx, [esp+44h+var_28]004EFA6F push 11h004EFA71 push ecx004EFA72 lea ecx, [esp+4Ch+arg_0]004EFA76 call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFA7B mov edx, [eax]004EFA7D mov cl, [edx]004EFA7F cmp bl, cl004EFA81 lea ecx, [esp+40h+var_28]004EFA85 setnz bl004EFA88 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFA8D test bl, bl004EFA8F jz short loc_4EFAB3004EFA91 lea ecx, [esp+40h+arg_0]004EFA95 mov [esp+40h+var_4], edi004EFA99 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFA9E pop edi004EFA9F pop esi004EFAA0 pop ebp004EFAA1 xor eax, eax004EFAA3 pop ebx004EFAA4 mov ecx, [esp+30h+var_C]004EFAA8 mov large fs:0, ecx004EFAAF add esp, 30h004EFAB2 retn004EFAB3 ; ---------------------------------------------------------------------------004EFAB3004EFAB3 loc_4EFAB3: ; CODE XREF: sub_4EF910+17Fj004EFAB3 lea eax, [esp+40h+var_24]004EFAB7 push eax004EFAB8 call sub_4F0110004EFABD lea ecx, [esp+44h+var_28]004EFAC1 push eax004EFAC2 push ecx004EFAC3 mov byte ptr [esp+4Ch+var_4], 2004EFAC8 call sub_4F0480004EFACD add esp, 0Ch004EFAD0 lea ecx, [esp+40h+var_24]004EFAD4 mov byte ptr [esp+40h+var_4], 4004EFAD9 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFADE mov edx, [esp+40h+var_28]004EFAE2 mov eax, [edx-8]004EFAE5 cmp eax, 4004EFAE8 jl short loc_4EFB69004EFAEA lea eax, [esp+40h+var_1C]004EFAEE push 4004EFAF0 push eax004EFAF1 lea ecx, [esp+48h+var_28]004EFAF5 call ?Right@CString@@QBE?AV1@H@Z ; CString::Right(int)004EFAFA mov esi, [eax]004EFAFC push 4004EFAFE lea ecx, [esp+44h+var_20]004EFB02 push 0Ah004EFB04 push ecx004EFB05 lea ecx, [esp+4Ch+arg_0]004EFB09 mov byte ptr [esp+4Ch+var_4], 5004EFB0E call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFB13 mov eax, [eax]004EFB15004EFB15 loc_4EFB15: ; CODE XREF: sub_4EF910+227j004EFB15 mov dl, [eax]004EFB17 mov bl, [esi]004EFB19 mov cl, dl004EFB1B cmp dl, bl004EFB1D jnz short loc_4EFB3D004EFB1F test cl, cl004EFB21 jz short loc_4EFB39004EFB23 mov dl, [eax+1]004EFB26 mov bl, [esi+1]004EFB29 mov cl, dl004EFB2B cmp dl, bl004EFB2D jnz short loc_4EFB3D004EFB2F add eax, 2004EFB32 add esi, 2004EFB35 test cl, cl004EFB37 jnz short loc_4EFB15004EFB39004EFB39 loc_4EFB39: ; CODE XREF: sub_4EF910+211j004EFB39 xor eax, eax004EFB3B jmp short loc_4EFB41004EFB3D ; ---------------------------------------------------------------------------004EFB3D004EFB3D loc_4EFB3D: ; CODE XREF: sub_4EF910+20Dj004EFB3D ; sub_4EF910+21Dj004EFB3D sbb eax, eax004EFB3F sbb eax, edi004EFB41004EFB41 loc_4EFB41: ; CODE XREF: sub_4EF910+22Bj004EFB41 test eax, eax004EFB43 lea ecx, [esp+40h+var_20]004EFB47 setz bl004EFB4A call ??1CString@@QAE@XZ ; CString::~CString(void)004EFB4F lea ecx, [esp+40h+var_1C]004EFB53 mov byte ptr [esp+40h+var_4], 4004EFB58 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFB5D test bl, bl004EFB5F jz short loc_4EFB69004EFB61 mov [esp+40h+var_2C], 1004EFB69004EFB69 loc_4EFB69: ; CODE XREF: sub_4EF910+1D8j004EFB69 ; sub_4EF910+24Fj004EFB69 lea eax, [esp+40h+var_1C]004EFB6D push eax004EFB6E call sub_4EFF60004EFB73 lea ecx, [esp+44h+var_30]004EFB77 push eax004EFB78 push ecx004EFB79 mov byte ptr [esp+4Ch+var_4], 6004EFB7E call sub_4F0480004EFB83 add esp, 0Ch004EFB86 lea ecx, [esp+40h+var_1C]004EFB8A mov byte ptr [esp+40h+var_4], 8004EFB8F call ??1CString@@QAE@XZ ; CString::~CString(void)004EFB94 mov edx, [esp+40h+var_30]004EFB98 mov eax, [edx-8]004EFB9B cmp eax, 4004EFB9E jl loc_4EFCA8004EFBA4 lea eax, [esp+40h+var_10]004EFBA8 push 4004EFBAA push eax004EFBAB lea ecx, [esp+48h+var_30]004EFBAF call ?Left@CString@@QBE?AV1@H@Z ; CString::Left(int)004EFBB4 mov esi, [eax]004EFBB6 push 4004EFBB8 lea ecx, [esp+44h+var_14]004EFBBC push 2004EFBBE push ecx004EFBBF lea ecx, [esp+4Ch+arg_0]004EFBC3 mov byte ptr [esp+4Ch+var_4], 9004EFBC8 call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFBCD mov eax, [eax]004EFBCF mov byte ptr [esp+40h+var_4], 0Ah004EFBD4004EFBD4 loc_4EFBD4: ; CODE XREF: sub_4EF910+2E6j004EFBD4 mov dl, [eax]004EFBD6 mov bl, [esi]004EFBD8 mov cl, dl004EFBDA cmp dl, bl004EFBDC jnz short loc_4EFBFC004EFBDE test cl, cl004EFBE0 jz short loc_4EFBF8004EFBE2 mov dl, [eax+1]004EFBE5 mov bl, [esi+1]004EFBE8 mov cl, dl004EFBEA cmp dl, bl004EFBEC jnz short loc_4EFBFC004EFBEE add eax, 2004EFBF1 add esi, 2004EFBF4 test cl, cl004EFBF6 jnz short loc_4EFBD4004EFBF8004EFBF8 loc_4EFBF8: ; CODE XREF: sub_4EF910+2D0j004EFBF8 xor eax, eax004EFBFA jmp short loc_4EFC00004EFBFC ; ---------------------------------------------------------------------------004EFBFC004EFBFC loc_4EFBFC: ; CODE XREF: sub_4EF910+2CCj004EFBFC ; sub_4EF910+2DCj004EFBFC sbb eax, eax004EFBFE sbb eax, edi004EFC00004EFC00 loc_4EFC00: ; CODE XREF: sub_4EF910+2EAj004EFC00 test eax, eax004EFC02 jz short loc_4EFC7F004EFC04 lea eax, [esp+40h+var_18]004EFC08 push 4004EFC0A push eax004EFC0B lea ecx, [esp+48h+var_30]004EFC0F call ?Left@CString@@QBE?AV1@H@Z ; CString::Left(int)004EFC14 mov esi, [eax]004EFC16 push 4004EFC18 lea ecx, [esp+44h+var_20]004EFC1C push 6004EFC1E push ecx004EFC1F lea ecx, [esp+4Ch+arg_0]004EFC23 mov byte ptr [esp+4Ch+var_4], 0Bh004EFC28 call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFC2D mov eax, [eax]004EFC2F004EFC2F loc_4EFC2F: ; CODE XREF: sub_4EF910+341j004EFC2F mov dl, [eax]004EFC31 mov bl, [esi]004EFC33 mov cl, dl004EFC35 cmp dl, bl004EFC37 jnz short loc_4EFC57004EFC39 test cl, cl004EFC3B jz short loc_4EFC53004EFC3D mov dl, [eax+1]004EFC40 mov bl, [esi+1]004EFC43 mov cl, dl004EFC45 cmp dl, bl004EFC47 jnz short loc_4EFC57004EFC49 add eax, 2004EFC4C add esi, 2004EFC4F test cl, cl004EFC51 jnz short loc_4EFC2F004EFC53004EFC53 loc_4EFC53: ; CODE XREF: sub_4EF910+32Bj004EFC53 xor eax, eax004EFC55 jmp short loc_4EFC5B004EFC57 ; ---------------------------------------------------------------------------004EFC57004EFC57 loc_4EFC57: ; CODE XREF: sub_4EF910+327j004EFC57 ; sub_4EF910+337j004EFC57 sbb eax, eax004EFC59 sbb eax, edi004EFC5B004EFC5B loc_4EFC5B: ; CODE XREF: sub_4EF910+345j004EFC5B test eax, eax004EFC5D lea ecx, [esp+40h+var_20]004EFC61 setz bl004EFC64 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFC69 lea ecx, [esp+40h+var_18]004EFC6D mov byte ptr [esp+40h+var_4], 0Ah004EFC72 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFC77 test bl, bl004EFC79 jnz short loc_4EFC7F004EFC7B xor ebp, ebp004EFC7D jmp short loc_4EFC84004EFC7F ; ---------------------------------------------------------------------------004EFC7F004EFC7F loc_4EFC7F: ; CODE XREF: sub_4EF910+2F2j004EFC7F ; sub_4EF910+369j004EFC7F mov ebp, 1004EFC84004EFC84 loc_4EFC84: ; CODE XREF: sub_4EF910+36Dj004EFC84 lea ecx, [esp+40h+var_14]004EFC88 mov byte ptr [esp+40h+var_4], 9004EFC8D call ??1CString@@QAE@XZ ; CString::~CString(void)004EFC92 lea ecx, [esp+40h+var_10]004EFC96 mov byte ptr [esp+40h+var_4], 8004EFC9B call ??1CString@@QAE@XZ ; CString::~CString(void)004EFCA0 test ebp, ebp004EFCA2 jnz loc_4EFDB2004EFCA8004EFCA8 loc_4EFCA8: ; CODE XREF: sub_4EF910+28Ej004EFCA8 mov eax, [esp+40h+var_30]004EFCAC cmp dword ptr [eax-8], 8004EFCB0 jl loc_4EFDB2004EFCB6 lea ecx, [esp+40h+var_20]004EFCBA push 4004EFCBC push ecx004EFCBD lea ecx, [esp+48h+var_30]004EFCC1 call ?Right@CString@@QBE?AV1@H@Z ; CString::Right(int)004EFCC6 mov esi, [eax]004EFCC8 push 4004EFCCA lea edx, [esp+44h+var_18]004EFCCE push 2004EFCD0 push edx004EFCD1 lea ecx, [esp+4Ch+arg_0]004EFCD5 mov byte ptr [esp+4Ch+var_4], 0Ch004EFCDA call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFCDF mov eax, [eax]004EFCE1 mov byte ptr [esp+40h+var_4], 0Dh004EFCE6004EFCE6 loc_4EFCE6: ; CODE XREF: sub_4EF910+3F8j004EFCE6 mov dl, [eax]004EFCE8 mov bl, [esi]004EFCEA mov cl, dl004EFCEC cmp dl, bl004EFCEE jnz short loc_4EFD0E004EFCF0 test cl, cl004EFCF2 jz short loc_4EFD0A004EFCF4 mov dl, [eax+1]004EFCF7 mov bl, [esi+1]004EFCFA mov cl, dl004EFCFC cmp dl, bl004EFCFE jnz short loc_4EFD0E004EFD00 add eax, 2004EFD03 add esi, 2004EFD06 test cl, cl004EFD08 jnz short loc_4EFCE6004EFD0A004EFD0A loc_4EFD0A: ; CODE XREF: sub_4EF910+3E2j004EFD0A xor eax, eax004EFD0C jmp short loc_4EFD12004EFD0E ; ---------------------------------------------------------------------------004EFD0E004EFD0E loc_4EFD0E: ; CODE XREF: sub_4EF910+3DEj004EFD0E ; sub_4EF910+3EEj004EFD0E sbb eax, eax004EFD10 sbb eax, edi004EFD12004EFD12 loc_4EFD12: ; CODE XREF: sub_4EF910+3FCj004EFD12 test eax, eax004EFD14 jz short loc_4EFD91004EFD16 lea eax, [esp+40h+var_14]004EFD1A push 4004EFD1C push eax004EFD1D lea ecx, [esp+48h+var_30]004EFD21 call ?Right@CString@@QBE?AV1@H@Z ; CString::Right(int)004EFD26 mov esi, [eax]004EFD28 push 4004EFD2A lea ecx, [esp+44h+var_10]004EFD2E push 6004EFD30 push ecx004EFD31 lea ecx, [esp+4Ch+arg_0]004EFD35 mov byte ptr [esp+4Ch+var_4], 0Eh004EFD3A call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFD3F mov eax, [eax]004EFD41004EFD41 loc_4EFD41: ; CODE XREF: sub_4EF910+453j004EFD41 mov dl, [eax]004EFD43 mov bl, [esi]004EFD45 mov cl, dl004EFD47 cmp dl, bl004EFD49 jnz short loc_4EFD69004EFD4B test cl, cl004EFD4D jz short loc_4EFD65004EFD4F mov dl, [eax+1]004EFD52 mov bl, [esi+1]004EFD55 mov cl, dl004EFD57 cmp dl, bl004EFD59 jnz short loc_4EFD69004EFD5B add eax, 2004EFD5E add esi, 2004EFD61 test cl, cl004EFD63 jnz short loc_4EFD41004EFD65004EFD65 loc_4EFD65: ; CODE XREF: sub_4EF910+43Dj004EFD65 xor eax, eax004EFD67 jmp short loc_4EFD6D004EFD69 ; ---------------------------------------------------------------------------004EFD69004EFD69 loc_4EFD69: ; CODE XREF: sub_4EF910+439j004EFD69 ; sub_4EF910+449j004EFD69 sbb eax, eax004EFD6B sbb eax, edi004EFD6D004EFD6D loc_4EFD6D: ; CODE XREF: sub_4EF910+457j004EFD6D test eax, eax004EFD6F lea ecx, [esp+40h+var_10]004EFD73 setz bl004EFD76 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFD7B lea ecx, [esp+40h+var_14]004EFD7F mov byte ptr [esp+40h+var_4], 0Dh004EFD84 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFD89 test bl, bl004EFD8B jnz short loc_4EFD91004EFD8D xor ebp, ebp004EFD8F jmp short loc_4EFD96004EFD91 ; ---------------------------------------------------------------------------004EFD91004EFD91 loc_4EFD91: ; CODE XREF: sub_4EF910+404j004EFD91 ; sub_4EF910+47Bj004EFD91 mov ebp, 1004EFD96004EFD96 loc_4EFD96: ; CODE XREF: sub_4EF910+47Fj004EFD96 lea ecx, [esp+40h+var_18]004EFD9A mov byte ptr [esp+40h+var_4], 0Ch004EFD9F call ??1CString@@QAE@XZ ; CString::~CString(void)004EFDA4 lea ecx, [esp+40h+var_20]004EFDA8 mov byte ptr [esp+40h+var_4], 8004EFDAD call ??1CString@@QAE@XZ ; CString::~CString(void)004EFDB2004EFDB2 loc_4EFDB2: ; CODE XREF: sub_4EF910+392j004EFDB2 ; sub_4EF910+3A0j004EFDB2 mov eax, [esp+40h+var_2C]004EFDB6 test eax, eax004EFDB8 jnz short loc_4EFDC2004EFDBA test ebp, ebp004EFDBC jz loc_4EFE57004EFDC2004EFDC2 loc_4EFDC2: ; CODE XREF: sub_4EF910+4A8j004EFDC2 push 3004EFDC4 lea eax, [esp+44h+var_10]004EFDC8 push 0Eh004EFDCA push eax004EFDCB lea ecx, [esp+4Ch+arg_0]004EFDCF call ?Mid@CString@@QBE?AV1@HH@Z ; CString::Mid(int,int)004EFDD4 mov eax, [eax]004EFDD6 push eax ; Str004EFDD7 call ds:atoi004EFDDD add esp, 4004EFDE0 lea ecx, [esp+40h+var_10]004EFDE4 mov esi, eax004EFDE6 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFDEB cmp esi, 385h004EFDF1 jg short loc_4EFE13004EFDF3 jz short loc_4EFE25004EFDF5 cmp esi, 14Eh004EFDFB jz short loc_4EFE0C004EFDFD cmp esi, 1ECh004EFE03 jnz short loc_4EFE1B004EFE05 mov esi, 3004EFE0A jmp short loc_4EFE2A004EFE0C ; ---------------------------------------------------------------------------004EFE0C004EFE0C loc_4EFE0C: ; CODE XREF: sub_4EF910+4EBj004EFE0C mov esi, 2004EFE11 jmp short loc_4EFE2A004EFE13 ; ---------------------------------------------------------------------------004EFE13004EFE13 loc_4EFE13: ; CODE XREF: sub_4EF910+4E1j004EFE13 cmp esi, 3E6h004EFE19 jz short loc_4EFE25004EFE1B004EFE1B loc_4EFE1B: ; CODE XREF: sub_4EF910+4F3j004EFE1B xor esi, esi004EFE1D xor ebp, ebp004EFE1F mov [esp+40h+var_2C], esi004EFE23 jmp short loc_4EFE2A004EFE25 ; ---------------------------------------------------------------------------004EFE25004EFE25 loc_4EFE25: ; CODE XREF: sub_4EF910+4E3j004EFE25 ; sub_4EF910+509j004EFE25 mov esi, 1004EFE2A004EFE2A loc_4EFE2A: ; CODE XREF: sub_4EF910+4FAj004EFE2A ; sub_4EF910+501j ...004EFE2A call ?AfxGetModuleState@@YGPAVAFX_MODULE_STATE@@XZ ; AfxGetModuleState(void)004EFE2F mov eax, [eax+4]004EFE32 push 0004EFE34 push offset off_5BA6B8004EFE39 push offset off_5BA6A0004EFE3E push 0004EFE40 push eax004EFE41 call __RTDynamicCast004EFE46 mov eax, [eax+0D8h]004EFE4C add esp, 14h004EFE4F mov ecx, eax004EFE51 push esi004EFE52 call sub_403AB0004EFE57004EFE57 loc_4EFE57: ; CODE XREF: sub_4EF910+4ACj004EFE57 lea ecx, [esp+40h+var_30]004EFE5B mov byte ptr [esp+40h+var_4], 4004EFE60 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFE65 lea ecx, [esp+40h+var_28]004EFE69 mov byte ptr [esp+40h+var_4], 0004EFE6E call ??1CString@@QAE@XZ ; CString::~CString(void)004EFE73 test ebp, ebp004EFE75 jnz short loc_4EFE83004EFE77 mov eax, [esp+40h+var_2C]004EFE7B test eax, eax004EFE7D jnz short loc_4EFE83004EFE7F xor esi, esi004EFE81 jmp short loc_4EFE88004EFE83 ; ---------------------------------------------------------------------------004EFE83004EFE83 loc_4EFE83: ; CODE XREF: sub_4EF910+565j004EFE83 ; sub_4EF910+56Dj004EFE83 mov esi, 1004EFE88004EFE88 loc_4EFE88: ; CODE XREF: sub_4EF910+571j004EFE88 lea ecx, [esp+40h+arg_0]004EFE8C mov [esp+40h+var_4], edi004EFE90 call ??1CString@@QAE@XZ ; CString::~CString(void)004EFE95 mov ecx, [esp+40h+var_C]004EFE99 mov eax, esi004EFE9B pop edi004EFE9C pop esi004EFE9D pop ebp004EFE9E pop ebx004EFE9F mov large fs:0, ecx004EFEA6 add esp, 30h004EFEA9 retn004EFEA9 sub_4EF910 endpsub_4EF910_flowchart.rarsub_4EF910_C_Code.rar Edited May 12, 2008 by rcemoss
enhzflep Posted May 17, 2008 Posted May 17, 2008 Ouch, that looks like a bitch of a function when dead-listed!I've been looking over that code mate, and while I thought I had nutted it out, on closer inspection I'm wondering if it doesn't write to memory elsewhere in the program, thus voiding any efort to simply set eax + ecx and exit. Gotta say thanks mate, without seeing this code I'd probably still be without the HexRays decomp. How good is that thing?! Sure, ity doesn't always get it right, as we can see from it thinking that the input to this func is an int, but it's still well worth someone else's money. :whistling: Perhaps this code's operation would be clearer if seen live and running, though without that it seems as though the function return in the bottom left of the graph is the desired end-point of the function. Does it work ok if you manipulate the jumps so that the function exits with eax not = to 0? Or even, what happens if you simply set eax to 1 & avoid the call to this function alltogether, does it still fall over elsewhere? Is this function called only once near the start somewhere, or does it get a continual thrashing? Hmm, questions, questions.If you could mention the name of the target, I'd be more than a litttle interested in having a closer look (even if it was something as useless to me as a kid's educational prog) - you know? It's the locked door, not the contents that make this pursuit so engaging..Me puts on my Fravia hat & goes looking for a challenge....
enhzflep Posted May 23, 2008 Posted May 23, 2008 (edited) I've had a bit of a play with the target, and while I'm not much of a fisherman it does function okay. It seems that the registration scheme is in fact the big long function you posted. Notice that in all exits from the function except for one, that eax is xored with itself? If you get this function to return 1 in eax, the program is perfectly haapy, and tells you you've registered and removes the 14 day trial period message.All I did was put breakpoints on all the RETs for the function, then changed eax to 1 before allowing the function to exit. It seemed to function fine. I noticed that the same function is called from about 5 places in the program, so figured that it may be the real-deal, and not just some function to tell the program if it can enable the "Register" button or not. I see that the number I was trying at the time is the number displayed as my entered serial. I suppose 1 of those 5 checks would have been comparing the saved serial to see if it was valid. I can't be certain that this fix will work - you may just have to enter something as the serial number, so that the 20 chars or more condition is satisfied. I dunno, you'll have to have a play around with it.Anyway, it's just 3 instructions. If you goto RVA 004EF910, you'll be at the start of the start of the function called from 4F1018. This is the checkRegistration function.If you assemble in these 3 instructions, the checkRegistration function always returns 1. xor eax, eax inc eax retand you're done.EDIT: confimed. Install, patch, run. - You also have to disable the Registration option under the Help menu - it appears with the Close button disabled, and no way of exiting the dialog. Edited May 23, 2008 by enhzflep
rcemoss Posted June 4, 2008 Author Posted June 4, 2008 Works great, I had set breaks on all the returns but wasn't smart enough to put together setting the EAX, instead I was just trying to hit the proper return point. I greatly appreciate you taking a look. Sorry for the late reply was on holiday and spouse wouldn't let me open the laptop.
enhzflep Posted June 7, 2008 Posted June 7, 2008 (edited) Heh, heh. Nah, I was just too lazy to try to get to the correct return point, I tried it as a quick hack, and it worked. I just got lucky. No dramas about reply speed, - I'm happy to have learned during the course of the exercise. I mean, I wouldn't have hunted down the excellent decompiler plugin for IDA without your questions.Thank-youNow all I gotta do is cancel the damn emails that they keeps sending me about my schedule... Edited June 7, 2008 by enhzflep
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now