在crackmes.de上找了几个简单的VB的crackme练习一下,有点收获终于搞懂了一点vb。小结一下备忘。
有错误或好建议,请大家指点。
一、第一个crackme分析。
这似乎是个有bug的crackme.这个crackme运行时,共分3步,第一步需要使用命令行参数来进行解码。要求参数为6个字节。如果参数为空或错误,就会导致解码错误。第二步点击unlock按钮,执行解码后的代码。第三步为check,如解码后的代码正确执行,并且文本框输入的密码为"just some password",则提示成功,否则失败。似乎这个程序的第一步有问题。作者误用了__imp_rtcVarBstrFromAnsi函数,最终导致第一步所需要的密码为不可显示字符,无法通过命令行传递给crackme,只能patch。具体分析如下:
1.静态分析-寻找控件结构以定位控件事件函数
在import中寻找EVENT_SINK_Release(或EVENT_SINK_QueryInterface或EVENT_SINK_AddRef)
.idata:00401058 extrn __imp_EVENT_SINK_AddRef
.text:0040126E EVENT_SINK_QueryInterface proc near ; DATA XREF: .text:004018E0o
.text:0040126E ; .text:00401974o ...
.text:0040126E FF 25 74 10 40 00 jmp ds:__imp_EVENT_SINK_QueryInterface
.text:0040126E EVENT_SINK_QueryInterface endp
.text:0040126E
.text:00401274
.text:00401274 ; =============== S U B R O U T I N E =======================================
.text:00401274
.text:00401274 ; Attributes: thunk
.text:00401274
.text:00401274 EVENT_SINK_AddRef proc near ; DATA XREF: .text:off_4018E4o
.text:00401274 ; .text:00401978o ...
.text:00401274 FF 25 58 10 40 00 jmp ds:__imp_EVENT_SINK_AddRef
.text:00401274 EVENT_SINK_AddRef endp
.text:00401274
.text:0040127A
.text:0040127A ; =============== S U B R O U T I N E =======================================
.text:0040127A
.text:0040127A ; Attributes: thunk
.text:0040127A
.text:0040127A EVENT_SINK_Release proc near ; DATA XREF: .text:004018E8o
.text:0040127A ; .text:0040197Co ...
.text:0040127A FF 25 6C 10 40 00 jmp ds:__imp_EVENT_SINK_Release
.text:0040127A EVENT_SINK_Release endp
.text:004018D4 dword_4018D4 dd 0 ; DATA XREF: .text:00401818o
.text:004018D8 dd offset dword_401800
.text:004018DC dd offset dword_401770
.text:004018E0 dd offset EVENT_SINK_QueryInterface
.text:004018E4 dd offset EVENT_SINK_AddRef
.text:004018E8 dd offset EVENT_SINK_Release
.text:004018EC dd 0Ah dup(0)
.text:00401914 dd offset sub_401B12
.text:00401918 dd 14h dup(0)
.text:00401968 dword_401968 dd 0 ; DATA XREF: .text:00401840o
.text:0040196C dd offset dword_401828
.text:00401970 dd offset dword_401770
.text:00401974 dd offset EVENT_SINK_QueryInterface
.text:00401978 dd offset EVENT_SINK_AddRef
.text:0040197C dd offset EVENT_SINK_Release
.text:00401980 dd offset sub_401AF8
.text:00401984 dd 10h dup(0)
.text:004019C4 dword_4019C4 dd 0 ; DATA XREF: .text:00401868o
.text:004019C8 dd offset dword_401850
.text:004019CC dd offset dword_401770
.text:004019D0 dd offset EVENT_SINK_QueryInterface
.text:004019D4 dd offset EVENT_SINK_AddRef
.text:004019D8 dd offset EVENT_SINK_Release
.text:004019DC dd 18h dup(0)
.text:00401A3C dword_401A3C dd 0 ; DATA XREF: .text:00401890o
.text:00401A40 dd offset dword_401878
.text:00401A44 dd offset dword_401770
.text:00401A48 dd offset EVENT_SINK_QueryInterface
.text:00401A4C dd offset EVENT_SINK_AddRef
.text:00401A50 dd offset EVENT_SINK_Release
.text:00401A54 dd offset sub_401B05
.text:00401A58 dd 10h dup(0)
.text:00401A98 dword_401A98 dd 0 ; DATA XREF: .text:004018B8o
.text:00401A9C dd offset dword_4018A0
.text:00401AA0 dd offset dword_401770
.text:00401AA4 dd offset EVENT_SINK_QueryInterface
.text:00401AA8 dd offset EVENT_SINK_AddRef
.text:00401AAC dd offset EVENT_SINK_Release
.text:00401AB0 dd 12h dup(0)
.text:00401800 From_struc dd 1F0040h ; DATA XREF: .text:004018D8o
.text:00401804 dd 38h
.text:00401808 dd offset unk_401C18
.text:0040180C dd 0FFFFFFFFh
.text:00401810 dd 0
.text:00401814 dd 0
.text:00401818 dd offset Frm_funclist ;控件对应的函数列表。
.text:0040181C dd 1B29B0h
.text:00401820 dd offset aForm ; "Form"
.text:00401824 dd 0FFFFFFFFh
.text:00401800 From_struc dd 1F0040h ; DATA XREF: .text:004018D8o
.text:00401804 dd 38h
.text:00401808 dd offset unk_401C18
.text:0040180C dd 0FFFFFFFFh
.text:00401810 dd 0
.text:00401814 dd 0
.text:00401818 dd offset Frm_funclist
.text:0040181C dd 1B29B0h
.text:00401820 dd offset aForm ; "Form"
.text:00401824 dd 0FFFFFFFFh
.text:00401828 Chkbtn_struc dd 110040h ; DATA XREF: .text:0040196Co
.text:0040182C dd 3Ch
.text:00401830 dd offset dword_401C84
.text:00401834 dd 30001h
.text:00401838 dd 0
.text:0040183C dd 0
.text:00401840 dd offset Chkbtn_funclist
.text:00401844 dd 1B29C0h
.text:00401848 dd offset aCmdcheck ; "cmdCheck"
.text:0040184C dd 30001h
.text:00401850 Txtserial_struc dd 180040h ; DATA XREF: .text:004019C8o
.text:00401854 dd 40h
.text:00401858 dd offset dword_401CA0
.text:0040185C dd 30002h
.text:00401860 dd 0
.text:00401864 dd 0
.text:00401868 dd offset Txtserial_funclist
.text:0040186C dd 1B29D0h
.text:00401870 dd offset aTxtserial ; "txtSerial"
.text:00401874 dd 30002h
.text:00401878 Unlockbtn_struc dd 110040h ; DATA XREF: .text:00401A40o
.text:0040187C dd 44h
.text:00401880 dd offset dword_401C84
.text:00401884 dd 30003h
.text:00401888 dd 0
.text:0040188C dd 0
.text:00401890 dd offset Unlockbtn_funclist
.text:00401894 dd 1B29C0h
.text:00401898 dd offset aCmdtest ; "cmdTest"
.text:0040189C dd 30003h
.text:004018A0 LblSerial_struc dd 120040h ; DATA XREF: .text:00401A9Co
.text:004018A4 dd 48h
.text:004018A8 dd offset dword_401CC4
.text:004018AC dd 30004h
.text:004018B0 dd 0
.text:004018B4 dd 0
.text:004018B8 dd offset LblSerial_funclist
.text:004018BC dd 1B29E0h
.text:004018C0 dd offset aLblserial ; "lblSerial"
.text:004018C4 dd 30004h
.text:004018C8 dd offset loc_401B00
.text:004018CC dd offset loc_401B0D
.text:004018D0 dd offset loc_401B1A
.text:004018D4 Frm_funclist dd 0 ; DATA XREF: .text:00401818o
.text:004018D8 dd offset From_struc
.text:004018DC dd offset dword_401770
.text:004018E0 dd offset EVENT_SINK_QueryInterface
.text:004018E4 dd offset EVENT_SINK_AddRef
.text:004018E8 dd offset EVENT_SINK_Release
.text:004018EC dd 0Ah dup(0)
.text:00401914 dd offset Form_Init
.text:00401918 dd 14h dup(0)
.text:00401968 Chkbtn_funclist dd 0 ; DATA XREF: .text:00401840o
.text:0040196C dd offset Chkbtn_struc
.text:00401970 dd offset dword_401770
.text:00401974 dd offset EVENT_SINK_QueryInterface
.text:00401978 dd offset EVENT_SINK_AddRef
.text:0040197C dd offset EVENT_SINK_Release
.text:00401980 dd offset Chkbtn_click
.text:00401984 dd 10h dup(0)
.text:004019C4 Txtserial_funclist dd 0 ; DATA XREF: .text:00401868o
.text:004019C8 dd offset Txtserial_struc
.text:004019CC dd offset dword_401770
.text:004019D0 dd offset EVENT_SINK_QueryInterface
.text:004019D4 dd offset EVENT_SINK_AddRef
.text:004019D8 dd offset EVENT_SINK_Release
.text:004019DC dd 18h dup(0)
.text:00401A3C Unlockbtn_funclist dd 0 ; DATA XREF: .text:00401890o
.text:00401A40 dd offset Unlockbtn_struc
.text:00401A44 dd offset dword_401770
.text:00401A48 dd offset EVENT_SINK_QueryInterface
.text:00401A4C dd offset EVENT_SINK_AddRef
.text:00401A50 dd offset EVENT_SINK_Release
.text:00401A54 dd offset Unlockbtn_click
.text:00401A58 dd 10h dup(0)
.text:00401A98 LblSerial_funclist dd 0 ; DATA XREF: .text:004018B8o
.text:00401A9C dd offset LblSerial_struc
.text:00401AA0 dd offset dword_401770
.text:00401AA4 dd offset EVENT_SINK_QueryInterface
.text:00401AA8 dd offset EVENT_SINK_AddRef
.text:00401AAC dd offset EVENT_SINK_Release
.text:00401AB0 dd 12h dup(0)
...
text:004025DD push 36h
...
.text:00402631 call esi ; __imp_rtcVarBstrFromAnsi
.text:00402633 lea ecx, [ebp-5Ch]
.text:00402636 push 0AFh
.text:0040263B push ecx
.text:0040263C call esi ; __imp_rtcVarBstrFromAnsi
.text:0040263E lea edx, [ebp-7Ch]
.text:00402641 push 27h
.text:00402643 push edx
.text:00402644 call esi ; __imp_rtcVarBstrFromAnsi
.text:00402646 lea eax, [ebp-9Ch]
.text:0040264C push 47h
.text:0040264E push eax
.text:0040264F call esi ; __imp_rtcVarBstrFromAnsi
.text:00402651 lea ecx, [ebp-0BCh]
.text:00402657 push 9Ah
.text:0040265C push ecx
.text:0040265D call esi ; __imp_rtcVarBstrFromAnsi
.text:0040265F lea edx, [ebp-0DCh]
.text:00402665 push 0CEh
.text:0040266A push edx
.text:0040266B call esi ; __imp_rtcVarBstrFromAnsi
.text:0040266D mov esi, ds:__imp___vbaVarCat
...
text:00402722 call ds:__imp_rtcCommandBstr
...
text:004027F6 call ds:__imp_rtcMidCharVar
...
text:00402840 xor eax, edx
.text:004028B1 call getcurrentprocid
...
.text:004028C7 call openprocess
...
.text:004028EE mov eax, offset loc_40246F
.text:004028F3 push eax
.text:004028F4 push edi
.text:004028F5 call writeprocmem
.text:0040246F mov word ptr [esi+34h], 0FFFFh
.text:00402255 cmp word ptr [esi+34h], 0FFFFh
...
.text:004022B4 push offset aJustSomePasswo ; "just some password"
.text:004022B9 call ds:__imp___vbaStrCmp
.text:004016A4 Form_struc dd 1F0040h ; DATA XREF: .text:00401728o
.text:004016A8 dd 34h
.text:004016AC dd offset dword_401988
.text:004016B0 dd 0FFFFFFFFh
.text:004016B4 dd 0
.text:004016B8 dd 0
.text:004016BC dd offset Form_funclist
.text:004016C0 dd 1E9A28h
.text:004016C4 dd offset aForm ; "Form"
.text:004016C8 dd 0FFFFFFFFh
.text:004016CC Text2_struc dd 110040h ; DATA XREF: .text:004017BCo
.text:004016D0 dd 38h
.text:004016D4 dd offset dword_401A14
.text:004016D8 dd 30002h
.text:004016DC dd 0
.text:004016E0 dd 0
.text:004016E4 dd offset Text2_funclist
.text:004016E8 dd 1E9A38h
.text:004016EC dd offset aText2 ; "Text2"
.text:004016F0 dd 30002h
.text:004016F4 Text1_struc dd 180040h ; DATA XREF: .text:00401818o
.text:004016F8 dd 3Ch
.text:004016FC dd offset dword_401A2C
.text:00401700 dd 30001h
.text:00401704 dd 0
.text:00401708 dd 0
.text:0040170C dd offset Text1_funclist
.text:00401710 dd 1E9A48h
.text:00401714 dd offset aText1 ; "Text1"
.text:00401718 dd 30001h
.text:0040171C dd offset loc_401894
.text:00401720 dd offset loc_4018A1
.text:00401724 Form_funclist dd 0 ; DATA XREF: .text:004016BCo
.text:00401728 dd offset Form_struc
.text:0040172C dd offset dword_401624
.text:00401730 dd offset EVENT_SINK_QueryInterface
.text:00401734 dd offset EVENT_SINK_AddRef
.text:00401738 dd offset EVENT_SINK_Release
.text:0040173C dd 6 dup(0)
.text:00401754 dd offset Form_init
.text:00401758 dd 18h dup(0)
.text:004017B8 Text2_funclist dd 0 ; DATA XREF: .text:004016E4o
.text:004017BC dd offset Text2_struc
.text:004017C0 dd offset dword_401624
.text:004017C4 dd offset EVENT_SINK_QueryInterface
.text:004017C8 dd offset EVENT_SINK_AddRef
.text:004017CC dd offset EVENT_SINK_Release
.text:004017D0 dd offset Text2_event
.text:004017D4 dd 10h dup(0)
.text:00401814 Text1_funclist dd 0 ; DATA XREF: .text:0040170Co
.text:00401818 dd offset Text1_struc
.text:0040181C dd offset dword_401624
.text:00401820 dd offset EVENT_SINK_QueryInterface
.text:00401824 dd offset EVENT_SINK_AddRef
.text:00401828 dd offset EVENT_SINK_Release
.text:0040182C dd 18h dup(0)
.text:0040188C
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
上传的附件: