Universal Import Fixer (UIF) v1.2 (FINAL) 有个小BUG,修复IAT时经常出现内存访问异常而无法工作,不知其他兄弟有没有碰到。
最近跟踪了一下UIF,找到问题所在:
0045C47B . 8B06 MOV EAX,DWORD PTR DS:[ESI]
0045C47D . 2B07 SUB EAX,DWORD PTR DS:[EDI]
0045C47F . 8B15 481C4600 MOV EDX,DWORD PTR DS:[0x461C48]
0045C485 . 807C02 FF 90 CMP BYTE PTR DS:[EDX+EAX-0x1],0x90 //这里就是出现异常的地方
0045C48A . 74 20 JE SHORT 0045C4AC //因为指针前移一个字节后的地址可能会出现在未知空间或禁止访问的空间
0045C48C . 8B06 MOV EAX,DWORD PTR DS:[ESI]
0045C48E . 2B07 SUB EAX,DWORD PTR DS:[EDI]
0045C490 . 8B15 481C4600 MOV EDX,DWORD PTR DS:[0x461C48]
0045C496 . 807C02 05 90 CMP BYTE PTR DS:[EDX+EAX+0x5],0x90
0045C49B . 75 0F JNZ SHORT 0045C4AC ; 0045C4AC
0045C49D . 8B06 MOV EAX,DWORD PTR DS:[ESI]
0045C49F . 2B07 SUB EAX,DWORD PTR DS:[EDI]
0045C4A1 . 8B15 481C4600 MOV EDX,DWORD PTR DS:[0x461C48]
0045C4A7 . C64402 05 00 MOV BYTE PTR DS:[EDX+EAX+0x5],0x0
0045C4AC > 8B06 MOV EAX,DWORD PTR DS:[ESI]
0045C4AE . 2B07 SUB EAX,DWORD PTR DS:[EDI]
0045C4B0 . 8B15 481C4600 MOV EDX,DWORD PTR DS:[0x461C48]
0045C4B6 . 807C02 FF 90 CMP BYTE PTR DS:[EDX+EAX-0x1],0x90 //还有这里
0045C4BB . 75 0A JNZ SHORT 0045C4C7 ; 0045C4C7
0045B75B > \6A 40 PUSH 0x40 ; /Protect = PAGE_EXECUTE_READWRITE
0045B75D . 68 00100000 PUSH 0x1000 ; |AllocationType = MEM_COMMIT
0045B762 . A1 681C4600 MOV EAX,DWORD PTR DS:[0x461C68] ; | //这里改成add eax,0x2000
0045B767 . 05 00100000 ADD EAX,0x1000 ; | //也就是多申请0x1000
0045B76C . 50 PUSH EAX ; |Size //用于后面将内存指针往前移0x1000
0045B76D . 6A 00 PUSH 0x0 ; |Address = NULL
0045B76F . E8 B4ABFAFF CALL 00406328 ; \VirtualAlloc //申请内存
0045B774 . E9 2C300000 JMP 0045E7A5 ; 跳到补丁处
0045B779 > 833D 481C4600>CMP DWORD PTR DS:[0x461C48],0x0
0045B780 . 75 14 JNZ SHORT 0045B796 ; 0045B796
0045B782 . B8 F8D74500 MOV EAX,0x45D7F8 ; ASCII "Error! Virtual Memory is Low or Invalid 'Code Start','Code End'."
补丁代码:
0045E7A5 > \83F8 00 CMP EAX,0x0
0045E7A8 . 74 09 JE SHORT 0045E7B3 ; 0045E7B3
0045E7AA . 90 NOP
0045E7AB . 90 NOP
0045E7AC . 90 NOP
0045E7AD . 90 NOP
0045E7AE . 05 00100000 ADD EAX,0x1000 //内存指针前移0x1000以避免地址减1时出现内存不能读的异常问题
0045E7B3 > A3 481C4600 MOV DWORD PTR DS:[0x461C48],EAX
0045E7B8 .^ E9 BCCFFFFF JMP 0045B779 ; 0045B779
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课