Перехват в Chrome

Дата публикации 24 фев 2018 | Редактировалось 24 фев 2018
Что тут говорить, чисто для пруфа будущим хакерам :)
Код (Text):
  1. ; Searches for SSL class method table for Chrome
  2. ; ©2015 Sysenter    [sysenter@jabber.no]
  3. ; Private®
  4. ; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  5.     .686p
  6.     .model flat, stdcall  ; 32 bit memory model
  7.     option casemap :none  ; case sensitive
  8.  
  9.     ; *************
  10.     ; include files
  11.     ; *************
  12.  
  13.     include E:\masm32\include\windows.inc
  14.   include E:\masm32\include\kernel32.inc
  15.   include E:\masm32\include\user32.inc
  16.     include E:\masm32\include\msvcrt.inc
  17.     include E:\masm32\include\ntdll.inc
  18.   include E:\masm32\macros\macros.asm
  19.   include StrIPos.inc                                                ;поиск подстроки в строке
  20.   include Catchy32.inc                                            ;дизассемблер длин инструкций    
  21.   include HookAPI.inc                                             ;хук апи с дизассемблером длин инструкций
  22.    
  23.     ; *********
  24.     ; libraries
  25.     ; *********
  26.     includelib E:\masm32\lib\gdi32.lib
  27.     includelib E:\masm32\lib\user32.lib
  28.     includelib E:\masm32\lib\kernel32.lib
  29.     includelib E:\masm32\lib\Comctl32.lib
  30.     includelib E:\masm32\lib\comdlg32.lib
  31.     includelib E:\masm32\lib\shell32.lib
  32.     includelib E:\masm32\lib\msvcrt.lib
  33.  
  34.  
  35. .data
  36.     PR_Write DWORD ?
  37.     sign db 83h, 0C4h, 14h, 83h, 0C8h, 0FFh, 5Dh, 0C3h, 0F6h, 41h, 34h, 01,0
  38.     ;sign db 83h, 0C4h, 14h, 83h, 0C8h,0
  39.     base    DWORD ?
  40.     cnt    DWORD ?
  41.     stCS RTL_CRITICAL_SECTION <>
  42.  
  43. .code
  44.  
  45. ;Обработчик перехваченной функции
  46. newPR_Write proc near p1, p2, p3 : dword
  47.     pushad
  48.     invoke OutputDebugStringA,chr$(">")
  49.     ;invoke MyDebugPrint,chr$("PR_Write: Len"),p3
  50.     invoke OutputDebugStringA,p2
  51.     popad
  52.     ;GetBaseDelta eax
  53.     push p3
  54.     push p2
  55.     push p1
  56.     call PR_Write
  57.     pushad
  58.     invoke OutputDebugStringA,chr$("<")
  59.     popad
  60.     add  esp, 12
  61.  
  62.     leave
  63.     retn
  64.  
  65. newPR_Write endp
  66.  
  67. ; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  68. ;Вычисляет длину массива с Marker в конце
  69. array_Len proc InpStr: dword, Marker : byte
  70.     xor ecx,ecx
  71.     mov edx, InpStr
  72. _L_lenght:
  73.       mov al, [ecx+edx]                                        ;Считываем очередной символ массива
  74.       inc ecx
  75.       cmp al, Marker                                           ;Сравниваем прочитанный символ с Marker
  76.       jne _L_lenght
  77.       dec ecx
  78.     return ecx
  79. array_Len endp
  80.  
  81. ; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  82. thread proc param:PVOID
  83.     LOCAL mbi:MEMORY_BASIC_INFORMATION
  84.     LOCAL Address:DWORD
  85.     LOCAL MemSize:DWORD
  86.     LOCAL SignLen:DWORD
  87.     xor eax,eax
  88.     mov cnt,eax
  89. _L_Find_Module:
  90.     ;invoke crt__sleep, 3000
  91.     invoke Sleep, 3000
  92.     invoke  GetModuleHandleA, chr$("chrome.dll")
  93.     test eax, eax
  94.     jz _L_module_not_found
  95.     mov base,eax
  96.     invoke MyDebugPrint,chr$("DLL_PROCESS_ATTACH. Start in base:"),base
  97.         invoke array_Len, addr sign, 0h
  98.         mov SignLen, eax
  99.         invoke MyDebugPrint,chr$("Signature lenght:"),SignLen
  100.         mov eax,base
  101.         mov Address,eax
  102.         xor eax,eax
  103.         mov MemSize,eax
  104.         mov mbi.RegionSize,eax
  105.         .repeat
  106.             mov eax,mbi.RegionSize
  107.             add Address,eax
  108.             invoke VirtualQuery, Address, addr mbi, sizeof MEMORY_BASIC_INFORMATION ;Получаем размер виртуальной памяти
  109.             PUSH eax
  110.             invoke MyDebugPrint,chr$("Region Size:"),mbi.RegionSize
  111.             invoke MyDebugPrint,chr$("BaseAddress:"),mbi.BaseAddress
  112.             invoke MyDebugPrint,chr$("AllocationBase:"),mbi.AllocationBase
  113.             .if mbi.AllocationBase==0 || mbi.RegionSize==0
  114.                 jmp L_sign_not_found
  115.             .endif
  116.             invoke SetLastError,0
  117.          
  118.             invoke  StrIPos, mbi.BaseAddress, mbi.RegionSize,addr sign,SignLen
  119.             test eax,eax
  120.             jnz L_found
  121.             POP eax
  122.         .until eax == 0 || mbi.RegionSize==0 || mbi.AllocationBase==0
  123.         jmp L_sign_not_found
  124. L_found:
  125.         PUSH eax
  126.         invoke MyDebugPrint,chr$("!!!!!!!!!!Signature found in address:"),eax
  127.         POP eax
  128.         sub eax,27h ;39
  129.         mov  PR_Write, eax
  130.         push eax
  131.         invoke EnterCriticalSection, addr stCS
  132.         invoke SetLastError,0
  133.         pop eax
  134.          invoke  HookAPI,addr newPR_Write,addr PR_Write
  135.         push eax
  136.         invoke LeaveCriticalSection,addr stCS
  137.         pop eax
  138.         test eax,eax
  139.         jz _L_Error_Hook
  140.         return 1
  141. L_sign_not_found:
  142.         invoke GetLastError
  143.         invoke MyDebugPrint,chr$("Signature not found"),eax
  144.         return 1
  145. _L_module_not_found:
  146.         invoke GetLastError
  147.         invoke MyDebugPrint,chr$("Module not found#"),cnt
  148.         inc cnt
  149.         test cnt,2
  150.         jne _L_Find_Module
  151.         return 1
  152. _L_Error_Hook:
  153.         invoke GetLastError
  154.         invoke MyDebugPrint,chr$("Error Hook"),eax
  155.         return 1
  156.     invoke ExitThread,0
  157. thread endp
  158.  
  159.  
  160. ; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««    
  161. start:
  162. LibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD
  163.     LOCAL hThread:DWORD
  164.     LOCAL dwTID:DWORD
  165.  
  166.     .if reason == DLL_PROCESS_ATTACH
  167.         invoke InitializeCriticalSection, addr stCS
  168.         invoke CreateThread,0,0,addr thread,0,0,ADDR dwTID
  169.     .elseif reason == DLL_PROCESS_DETACH
  170.         invoke DeleteCriticalSection,addr stCS
  171.         invoke MyDebugPrint,chr$("DLL_PROCESS_DETACH."),0
  172.     .endif
  173.     return 1
  174. LibMain Endp
  175.  
  176. ; ##########################################################################
  177. end start
Инклуды:
HookAPI.inc
Код (Text):
  1. .code
  2.  
  3. ;; ==================================================================================================== ;;
  4. ;; HookAPI - procedure sets hook on given API address                                                   ;;
  5. ;;           replace original API start to push addr and retn to handler procedure                      ;;
  6. ;;           creates trampoline contained replaced code of original API and return to code after it     ;;
  7. ;;           changes given API pointer to address of trampoline (real API code start)                   ;;
  8. ;; __in    lpHandlerProc - pointer to handler procedure                                                 ;;
  9. ;; __inout plpAPI        - pointer to API pointer                                                       ;;
  10. ;; ==================================================================================================== ;;
  11. HookAPI proc lpHandlerProc, plpAPI : dword
  12.     local  lpAPI : dword
  13.     local  flOldProtect : dword
  14.     local  tramp : dword
  15.    
  16.     mov  eax, plpAPI
  17.     mov  eax, [eax]
  18.     mov  lpAPI, eax
  19.  
  20.  
  21.     ;; Change API memory protection
  22.     invoke VirtualProtect, lpAPI,32,PAGE_EXECUTE_READWRITE,addr flOldProtect
  23.     test eax, eax
  24.     jz   @ret
  25.     invoke MyDebugPrint,chr$("Hook: Memory protected"),lpAPI  
  26.  
  27.  
  28.     ;; Allocate memory for trampoline
  29.     invoke  VirtualAlloc, 0, 32, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE
  30.     test eax, eax
  31.     jz   @alloc_err
  32.     mov tramp,eax
  33.  
  34.     invoke MyDebugPrint,chr$("Hook: Memory allocated"),tramp
  35.     mov  edi, tramp
  36.  
  37.  
  38.     ;; Get size of code to copy
  39.     xor  ecx, ecx
  40.     mov  esi, lpAPI
  41.  
  42. @@:    mov  eax, ebx
  43.     add  eax, c_Catchy
  44.     call eax
  45.     cmp  eax, -1
  46.  
  47.     je   @error_c_Catchy
  48.  
  49.     add  esi, eax        ;; esi = current code instruction
  50.     add  ecx, eax        ;; eax = current instructions len
  51.     cmp  ecx, 5
  52.     jb   @B
  53.     pushad
  54.     invoke MyDebugPrint,chr$("Hook: Code lenght"),ecx
  55.     popad
  56.     ;; Copy original api code to new place
  57.     mov  eax, edi    ;; save
  58.     sub  esi, ecx    ;; pointer to current API start
  59.     rep  movsb
  60.  
  61.  
  62.  
  63.  
  64.     ;; Write return to original API code + len of copied code
  65.     mov  byte ptr [edi], 68h        ;; PUSH offset original API + offsed of copied code
  66.     mov  dword ptr [edi+1], esi        ;; addr
  67.     mov  byte ptr [edi+5], 0C3h        ;; RETN
  68.  
  69.    
  70.  
  71.     ;; New real API address
  72.     mov  edi, plpAPI
  73.     mov  [edi], eax
  74.  
  75.  
  76.     ;; Edit original API code start
  77.     mov  edi, lpAPI
  78.     mov  eax, lpHandlerProc
  79.     mov  byte ptr [edi], 0E9h        ;; JMP FAR
  80.  
  81.     sub  eax, edi
  82.     sub  eax, 5
  83.  
  84.  
  85.     mov  dword ptr [edi+1], eax        ;; addr
  86.  
  87.     jmp  @oldprotect
  88.  
  89. @error_c_Catchy:
  90.     invoke GetLastError
  91.     invoke MyDebugPrint,chr$("Hook: error_c_Catchy"),eax
  92.     invoke  VirtualFree, edi, 0, MEM_RELEASE
  93.     invoke  VirtualProtect, lpAPI, 32, flOldProtect, addr flOldProtect
  94.     mov eax,0
  95.     ret
  96.    
  97. @oldprotect:
  98.     invoke GetLastError
  99.     ;; Restore old API memory protection
  100.     invoke  VirtualProtect, lpAPI, 32, flOldProtect, addr flOldProtect
  101.     invoke MyDebugPrint,chr$("Hook: done. no error"),eax
  102.     mov eax,1
  103.     ret
  104.  
  105. @alloc_err:
  106.     invoke GetLastError
  107.     invoke MyDebugPrint,chr$("Hook: error memory allocation"),eax
  108.     ;; Restore old API memory protection
  109.     invoke  VirtualProtect, lpAPI, 32, flOldProtect, addr flOldProtect
  110.     mov eax,0
  111.     ret
  112.  
  113. @ret:
  114.     invoke GetLastError
  115.     invoke MyDebugPrint,chr$("Hook: error memory protection"),eax
  116.     mov eax,0
  117.     ret
  118. HookAPI endp
  119.  
  120.  
Дизасм длинн инструкций: Catchy32.inc
Код (Text):
  1. ;==================================================================================================================================================
  2. ;                 ********         ***        ***********     *********     ***     ***    ***     ***                *******        *******      
  3. ;              ***********     **** ****     ***********    ***********    ***     ***    ***     ***              ***** *****    ***** *****    
  4. ;             ***     ***    ***     ***        ***        ***     ***    ***     ***     ***   ***               **      ***    **     ****      
  5. ;            ***            ***********        ***        ***            ***********       ** **                        ****         ****        
  6. ;           ***     ***    ***********        ***        ***     ***    ***********        ***                  **      ***     ****              
  7. ;          ***********    ***     ***        ***        ***********    ***     ***        ***                  ***** *****    ***********        
  8. ;          *********     ***     ***        ***         *********     ***     ***        ***                    *******      ***********          
  9. ;==================================================Catchy32 v1.6 - Length Disassembler Engine 32bit================================================
  10. ;SIZE=580 bytes
  11. ;Version:
  12. ;1.0-test version
  13. ;1.1-added: support prefix
  14. ;1.2-added: TableEXT
  15. ;1.3-added: support for 0F6h and 0F7h groups
  16. ;1.4-tables fixed
  17. ;   -SIB byte handling fixed
  18. ;1.5-code fixed&optimized
  19. ;   -processing 0F6h and 0F7h groups is corrected
  20. ;   -processing 0A0h-0A3h groups is corrected
  21. ;1.6-code fixed
  22. ;   -added: max lenght=15 bytes
  23. ;==================================================================================================================================================
  24. ;in:   esi - pointer to opcode
  25. ;out:  eax - opcode length or 0ffffffffh if error
  26. ;(c) sars [HI-TECH] 2003
  27. ;sars@ukrtop.com
  28. ;==================================================================================================================================================
  29. pref66h equ 1
  30. pref67h equ 2
  31.  
  32. .code
  33.  
  34. ;---------------Initial adjustment----------------
  35. c_Catchy:
  36.     pushad
  37.     call    c_Delta
  38.  
  39. ;------------Delta-offset calculation-------------
  40. c_Delta:
  41.     pop    ebp
  42.     sub    ebp, offset c_Delta
  43.     xor    ecx, ecx
  44.  
  45. ;----Flags extraction, checks for some opcodes----
  46. c_ExtFlags:
  47.     xor    eax, eax
  48.     xor    ebx, ebx
  49.     cdq
  50.     lodsb                ;al <- opcode
  51.     mov     cl, al            ;cl <- opcode
  52.     cmp    al, 0fh            ;Test on prefix 0Fh
  53.     je     c_ExtdTable      
  54.     cmp     word ptr [esi-1], 20CDh    ;Test on VXD call
  55.     jne     c_NormTable
  56.     inc    esi            ;If VXD call (int 20h), then command length is 6 bytes
  57.     lodsd
  58.     jmp     c_CalcLen
  59.  
  60. c_ExtdTable:                ;Load flags from extended table
  61.     lodsb
  62.     inc     ah            ;EAX=al+100h (100h/2 - lenght first table)
  63.  
  64. c_NormTable:                ;Load flags from normal table
  65.     shr     eax, 1            ;Elements tables on 4 bits
  66.     mov     al, byte ptr [ebp+c_Table+eax]
  67.  
  68. c_CheckC1:  
  69.     jc     c_IFC1
  70.     shr    eax, 4            ;Get high 4-bits block if offset is odd, otherwise...
  71.  
  72. c_IFC1:
  73.     and      eax, 0Fh            ;...low
  74.     xchg     eax, ebx            ;EAX will be needed for other purposes
  75.  
  76. ;--------------Opcode type checking---------------
  77. c_CheckFlags:
  78.     cmp     bl, 0Eh            ;Test on ErrorFlag
  79.     je     c_Error
  80.     cmp     bl, 0Fh            ;Test on PrefixFlag
  81.     je     c_Prefix
  82.     or     ebx, ebx            ;One byte command  
  83.     jz     c_CalcLen                  
  84.     btr    ebx, 0            ;Command with ModRM byte
  85.     jc     c_ModRM
  86.     btr     ebx, 1            ;Test on imm8,rel8 etc flag
  87.     jc     c_incr1
  88.     btr    ebx, 2            ;Test on ptr16 etc flag
  89.     jc     c_incr2
  90.  
  91. ;-----imm16/32,rel16/32, etc types processing-----
  92. c_16_32:
  93.     and     bl, 11110111b            ;Reset 16/32 sign
  94.  
  95.     cmp     cl, 0A0h            ;Processing group 0A0h-0A3h
  96.     jb    c_Check66h
  97.     cmp    cl, 0A3h
  98.     ja    c_Check66h
  99.     test    ch, pref67h
  100.     jnz    c_incr2
  101.     jmp    c_incr4
  102.        
  103. c_Check66h:                ;Processing other groups
  104.     test     ch, pref66h                  
  105.     jz     c_incr4                          
  106.     jmp     c_incr2                          
  107.  
  108. ;---------------Prefixes processing---------------
  109. c_Prefix:
  110.     cmp     cl, 66h
  111.     je     c_SetFlag66h
  112.     cmp     cl, 67h
  113.     jne     c_ExtFlags
  114.  
  115. c_SetFlag67h:
  116.     or    ch, pref67h
  117.     jmp     c_ExtFlags
  118.  
  119. c_SetFlag66h:
  120.     or     ch, pref66h
  121.     jmp     c_ExtFlags
  122.  
  123. ;--------------ModR/M byte processing-------------
  124. c_ModRM:
  125.     lodsb
  126.  
  127. c_Check_0F6h_0F7h:                ;Check on 0F6h and 0F7h groups
  128.     cmp     cl, 0F7h
  129.     je     c_GroupF6F7
  130.     cmp     cl, 0F6h
  131.     jne     c_ModXX          
  132.    
  133. c_GroupF6F7:                ;Processing groups 0F6h and 0F7h
  134.     test     al, 00111000b  
  135.     jnz     c_ModXX
  136.     test     cl, 00000001b
  137.     jz    c_incbt1          
  138.     test    ch, 1
  139.     jnz    c_incbt2  
  140.     inc     esi
  141.     inc     esi
  142. c_incbt2:    inc     esi
  143. c_incbt1:    inc     esi
  144.  
  145. c_ModXX:                    ;Processing MOD bits
  146.     mov     edx, eax
  147.     and     al, 00000111b        ;al <- only R/M bits
  148.     test    dl, 11000000b        ;Check MOD bits
  149.     jz      c_Mod00
  150.     jp      c_CheckFlags        ;Or c_Mod11
  151.     js      c_Mod10
  152.    
  153. c_Mod01:
  154.     test     ch, pref67h
  155.     jnz     c_incr1             ;16-bit addressing
  156.     cmp     al, 4            ;Check SIB
  157.     je     c_incr2
  158.     jmp     c_incr1
  159.  
  160. c_Mod00:
  161.     test     ch, pref67h
  162.     jz     c_Mod00_32        ;32-bit addressing
  163.     cmp     al, 6
  164.     je     c_incr2
  165.     jmp     c_CheckFlags  
  166. c_Mod00_32:
  167.     cmp     al, 4            ;Check SIB
  168.     jne     c_disp32
  169.  
  170. c_SIB:                    ;Processing SIB byte
  171.     lodsb
  172.     and     al, 00000111b
  173.     cmp     al, 5
  174.     je     c_incr4
  175.     jmp     c_CheckFlags  
  176.  
  177. c_disp32:  
  178.     cmp     al, 5
  179.     je     c_incr4
  180.     jmp     c_CheckFlags
  181.  
  182. c_Mod10:
  183.     test     ch, pref67h
  184.     jnz     c_incr2            ;16-bit addressing
  185.     cmp     al, 4            ;Check SIB
  186.     je     c_incr5
  187.     jmp     c_incr4
  188.  
  189. c_incr5:    inc     esi
  190. c_incr4:    inc     esi
  191.     inc     esi
  192. c_incr2:    inc     esi
  193. c_incr1:    inc     esi
  194.     jmp     c_CheckFlags  
  195.  
  196. ;-----------Command length calculation------------
  197. c_CalcLen:
  198.     sub     esi, [esp+4*1]
  199.     cmp    esi, 15
  200.     ja     c_Error
  201.     mov     [esp+4*7], esi
  202.     jmp     c_Exit
  203.  
  204. ;----------------Setting the error----------------
  205. c_Error:
  206.     xor     eax, eax
  207.     dec     eax
  208.     mov     [esp+4*7], eax  
  209.  
  210. ;---------Restore the registers and exit----------
  211. c_Exit:
  212.     popad
  213.     ret
  214. ;-------------------------------------------------
  215.  
  216. ;==================================================================================================================================================
  217.  
  218. ;Flag tables for normal and extended Intel opcodes
  219. ;(c) sars [HI-TECH] 2003
  220. ;sars@ukrtop.com
  221. ;
  222. ;Version:
  223. ;01-test version
  224. ;02-added: TableEXT
  225. ;03-added: new flags
  226. ;04-added: support for MMX, SSE, SSE2, 3DNOW
  227. ;
  228. ;Description:
  229. ;Size of table element is 4 bits.
  230. ;0h-one byte instruction
  231. ;1h-ModRM byte
  232. ;2h-imm8,rel8 etc
  233. ;4h-ptr16 etc
  234. ;8h-imm16/32,rel16/32 etc
  235. ;0Fh-prefix
  236. ;0Eh-unsupported opcodes
  237.  
  238. ;3DNOW-Supported
  239. ;SSE-Supported
  240. ;SSE2-Supported
  241. ;MMX-Supported
  242.  
  243. ;================NORMAL OPCODES================
  244. c_Table:
  245. ;    01  23    45   67   89   AB   CD   EF
  246. db 011h,011h,028h,000h,011h,011h,028h,000h;0Fh
  247. db 011h,011h,028h,000h,011h,011h,028h,000h;1Fh
  248. db 011h,011h,028h,0F0h,011h,011h,028h,0F0h;2Fh
  249. db 011h,011h,028h,0F0h,011h,011h,028h,0F0h;3Fh
  250. db 000h,000h,000h,000h,000h,000h,000h,000h;4Fh
  251. db 000h,000h,000h,000h,000h,000h,000h,000h;5Fh
  252. db 000h,011h,0FFh,0FFh,089h,023h,000h,000h;6Fh
  253. db 022h,022h,022h,022h,022h,022h,022h,022h;7Fh
  254. db 039h,033h,011h,011h,011h,011h,011h,011h;8Fh
  255. db 000h,000h,000h,000h,000h,0C0h,000h,000h;9Fh
  256. db 088h,088h,000h,000h,028h,000h,000h,000h;AFh
  257. db 022h,022h,022h,022h,088h,088h,088h,088h;BFh
  258. db 033h,040h,011h,039h,060h,040h,002h,000h;CFh
  259. db 011h,011h,022h,000h,011h,011h,011h,011h;DFh
  260. db 022h,022h,022h,022h,088h,0C2h,000h,000h;EFh
  261. db 0F0h,0FFh,000h,011h,000h,000h,000h,011h;FFh
  262. ;==============================================
  263. Lentable equ $-c_Table
  264. comment !
  265. ;===============EXTENDED OPCODES===============
  266. c_TableEXT:
  267. ;    01  23    45   67   89   AB   CD   EF
  268. db 011h,011h,0E0h,000h,000h,0EEh,0E1h,003h;0Fh
  269. db 011h,011h,011h,011h,01Eh,0EEh,0EEh,0EEh;1Fh
  270. db 011h,011h,01Eh,01Eh,011h,011h,011h,011h;2Fh
  271. db 000h,000h,000h,0EEh,0EEh,0EEh,0EEh,0EEh;3Fh
  272. db 011h,011h,011h,011h,011h,011h,011h,011h;4Fh
  273. db 011h,011h,011h,011h,011h,011h,011h,011h;5Fh
  274. db 011h,011h,011h,011h,011h,011h,011h,011h;6Fh
  275. db 033h,033h,011h,010h,011h,011h,011h,011h;7Fh
  276. db 088h,088h,088h,088h,088h,088h,088h,088h;8Fh
  277. db 011h,011h,011h,011h,011h,011h,011h,011h;9Fh
  278. db 000h,001h,031h,011h,000h,001h,031h,011h;AFh
  279. db 011h,011h,011h,011h,0EEh,031h,011h,011h;BFh
  280. db 011h,031h,033h,031h,000h,000h,000h,000h;CFh
  281. db 0E1h,011h,011h,011h,011h,011h,011h,011h;DFh
  282. db 011h,011h,011h,011h,011h,011h,011h,011h;EFh
  283. db 0E1h,011h,011h,011h,011h,011h,011h,01Eh;FFh
  284. ;==============================================
  285. !
  286. ;==================================================================================================================================================
поиск подстроки в строке: StrIPos.inc
Код (Text):
  1. ; DEBUG MODE ----------------------------------
  2. ENABLE_DEBUG_MODE                equ     TRUE
  3.  
  4. .code
  5. ; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  6. MyDebugPrint proc msg:dword,param:dword
  7.     IFDEF ENABLE_DEBUG_MODE
  8.         local bufferx[1024]:byte
  9.         pushad
  10.         invoke wsprintf, addr bufferx, chr$("%s [%08X]"), msg, param ;crt_
  11.         invoke OutputDebugStringA, addr bufferx
  12.         popad
  13.     ELSE
  14.         nop
  15.     ENDIF
  16.     ret
  17. MyDebugPrint    ENDP
  18. ; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  19.  
  20. ;; ==================================================================================================== ;;
  21. ;; StrIPos - case insensitive search first entry of char in string                                      ;;
  22. ;; __in lpString    - pointer to string                                                                 ;;
  23. ;; __in nStringLen  - len of string                                                                     ;;
  24. ;; __in lpSubString - pointer to substring                                                              ;;
  25. ;; __in nSubStrLen  - len of substring                                                                  ;;
  26. ;; Return:  0 - failed                                                                                  ;;
  27. ;;         !0 - success, pointer to start of founded substring                                          ;;
  28. ;; ==================================================================================================== ;;
  29. StrIPos proc uses ebx ecx edx edi esi lpString, nStringLen, lpSubString, nSubStrLen : dword
  30.  
  31.     ;; Check strings len
  32.     xor  eax, eax
  33.     cmp  nStringLen, eax
  34.     jle  @ret
  35.     cmp  nSubStrLen, eax
  36.     jle  @ret
  37.    
  38.     ;invoke MyDebugPrint,chr$("StrIPos step: "),1
  39.  
  40.     ;; Init string vars
  41.     mov  esi, lpString        ;; esi = first symbol pointer
  42.     dec  esi
  43.     mov  ebx, nStringLen
  44.     add  ebx, esi            ;; ebx = last symbol pointer
  45.    
  46.     ;invoke MyDebugPrint,chr$("StrIPos step: "),2
  47.  
  48. @nextcycle:
  49.     xor  eax, eax
  50.     cmp  esi, ebx            ;; check if last symbol in string
  51.     je   @ret
  52.  
  53.     inc  esi                ;; next symbol ptr search from
  54.     mov  ecx, esi            ;; copy symbol ptr search from, for use in compare
  55.  
  56.     mov  edi, lpSubString    ;; init substring var
  57.     mov  edx, nSubStrLen    ;; init substring var
  58.  
  59.     ;invoke MyDebugPrint,chr$("StrIPos step: "),3
  60.  
  61.  
  62.     ;; Case insensitive symbol compare
  63. @nextchar:
  64.     mov  al, [ecx]
  65.     cmp  al, [edi]
  66.     je   @charmatch
  67.    
  68.     ;invoke MyDebugPrint,chr$("StrIPos step: "),4
  69.  
  70.     cmp  al, "z"
  71.     ja   @nextcycle
  72.     cmp  al, "a"
  73.     jb   @cmpupper
  74.  
  75.     ;invoke MyDebugPrint,chr$("StrIPos step: "),5
  76.  
  77.     sub  al, 32
  78.     cmp  al, [edi]
  79.     je   @charmatch
  80.     jmp  @nextcycle
  81.  
  82. @cmpupper:
  83.     cmp  al, "Z"
  84.     ja   @nextcycle
  85.     cmp  al, "A"
  86.     jb   @nextcycle
  87.  
  88.     add  al, 32
  89.     cmp  al, [edi]
  90.     jne  @nextcycle
  91.  
  92.  
  93. @charmatch:
  94.    
  95.     ;invoke MyDebugPrint,chr$("StrIPos step: "),6
  96.  
  97.     inc  ecx                ;; next symbol in string
  98.     inc  edi                ;; next symbol in substring
  99.     dec  edx                ;; substring len
  100.     jnz  @nextchar
  101.  
  102.    
  103.     ;; Substring found
  104.     mov  eax, esi
  105.    
  106.     ;invoke MyDebugPrint,chr$("StrIPos step: "),7
  107.  
  108. @ret:
  109.     ret
  110. StrIPos endp
  111.  
  112.  
Кому надо - сигнатуры отищет в новых версиях ;)

12 3.454
RET

RET
Well-Known Member

Регистрация:
5 янв 2008
Публикаций:
17

Комментарии


      1. RET 27 мар 2018
        Я в шапке не написал, что это PoC?
        "Что тут говорить, чисто для пруфа будущим хакерам :)"
        Щас это не актуально. Но в качестве развития пойдет.
        >Интереснее это работа с кипэлайв в хроме при инжекте, но это никто не выкладывает.
        - естественно - поддержка порядка 6k$/мес с учетами крипта и обходов, какой идиот выложит полный пруф?
      2. TermoSINteZ 9 мар 2018
        @unс1e
        это раздел статей. Вам это о чем-нибудь говорит?
      3. unc1e 9 мар 2018
        TermoSINteZ, сорсы сплайса на ассемблере, чем вам не угодило то?
      4. RET 3 мар 2018
        >В армию после шк забирают?
        Я свое еще в 98 - 2002 отслужил.
        О качестве сорцев - они не на паблик писались а чисто для профита.
      5. zerodawn 2 мар 2018
        Все это есть в сорцах ISFB, но в гораздо более качественном исполнении.

        > прощаюсь на 1 год и 3 месяца
        В армию после шк забирают?
      6. TermoSINteZ 1 мар 2018
        > прощаюсь на 1 год и 3 месяца
        Ну вообще прям гора с плеч.

        А по факту - ребят отпишитесь тут хоть кто-то кому "это" нужно и пригодилось ))))
      7. RET 1 мар 2018
        Я и не претендую, тут у кого хоть мозг есть - сам догонит, за УГ - ты сам школоло, можешь забанить - поверь пох.... уже, прощаюсь на 1 год и 3 месяца, читайте нах...
      8. TermoSINteZ 28 фев 2018
        вы же понимаете, что пока не оформите в виде полноценной статьи - из песочницы "это уг" никуда не уйдет.
      9. RET 24 фев 2018
        Тут чисто пруф, ребята, так что АВ - ваша забота
        PR_Write - ищите в гугле, функа была с сорцами.
      10. LastNoob 24 фев 2018
        Что говорит антивирусник?
      11. unc1e 24 фев 2018
        А что принимает newPR_Write вторым аргументом (p2)? Какую функу по сигнатуре ищете?
        // с браузерами не работал, только с играми