С TASM в FASM

Тема в разделе "WASM.BEGINNERS", создана пользователем r2max, 11 апр 2011.

  1. r2max

    r2max Женя

    Публикаций:
    0
    Регистрация:
    30 мар 2011
    Сообщения:
    40
    Адрес:
    Киев
    Очень прошу, переведите пожалуйста с TASM в FASM
    Заранее спасибо!
    Код (Text):
    1. .686p
    2. .model flat
    3.  
    4. include c:\tasm32\include\APImacro.inc
    5.  
    6. extrn   __imp__connect:dword
    7.  
    8. DATASEG
    9.  
    10. LineageII   db  "LineageII.dll",0       ;LineageII.dll is L2Walker (IG), the .exe is nothing but a simple loader.
    11.  
    12. CODESEG
    13.  
    14. public C DllEntryPoint
    15. DllEntryPoint   proc
    16.  
    17.     push ebp
    18.     mov ebp, esp
    19.     push ecx
    20.    
    21.     call remove_hooks
    22.     call kill_l2walker
    23.    
    24.     mov eax, 1
    25.     mov esp, ebp
    26.     pop ebp
    27.    
    28.     ret
    29.  
    30. DllEntryPoint   endp
    31.  
    32. remove_hooks    proc
    33.  
    34.     push ebp
    35.     mov ebp, esp
    36.     push ecx
    37.    
    38.     mov ebx, __imp__connect         ;move the address of ws2_32.connect into ebx
    39.    
    40.     lea edx, dword ptr ss:[ebp-4]       ;make it so we can write to this address + some odd bytes
    41.     push edx
    42.     push 40h
    43.     push 12h
    44.     push ebx
    45.     iWin32 VirtualProtect
    46.    
    47.     mov byte ptr [ebx], 08Bh            ;this is the start of ws2_32.connect, its the same in every version of Windows
    48.     mov byte ptr [ebx+1], 0FFh      ;hlaphex/l2phx hook the start of this function, so let's just overwrite their hook
    49.     mov byte ptr [ebx+2], 055h      ;with the original function.
    50.     mov byte ptr [ebx+3], 08Bh
    51.     mov byte ptr [ebx+4], 0ECh      ;until either bots hook the iat, this works beautifully, breaking both l2phx/hlaphex
    52.                                 ;with one little sub-routine   
    53.     mov esp, ebp
    54.     pop ebp
    55.     ret
    56.    
    57. remove_hooks    endp
    58.  
    59. kill_l2walker   proc
    60.  
    61.     push ebp
    62.     mov ebp, esp
    63.     push ecx
    64.    
    65.     push offset LineageII           ;because walker's lineageii.dll is packed with asprotect
    66.     iWin32 GetModuleHandleA         ;renaming it isn't an option =)
    67.     cmp eax, 0                  ;do we return an address?
    68.     je @@2                      ;if no, continue along.
    69.    
    70.     push 0                      ;exit code
    71.     push 0ffffffffh             ;-1 is pseudo handle for our process (l2.exe)
    72.     iWin32 NtTerminateProcess       ;l2.exe process silently exits
    73.    
    74. @@2:    mov esp, ebp                    ;continuing along..
    75.     pop ebp
    76.     ret
    77.  
    78. kill_l2walker   endp   
    79.  
    80. db 6 dup (0)
    81.  
    82. db "Fyyre",0
    83.  
    84. end DllEntryPoint
     
  2. r2max

    r2max Женя

    Публикаций:
    0
    Регистрация:
    30 мар 2011
    Сообщения:
    40
    Адрес:
    Киев
    ап...
     
  3. SadKo

    SadKo Владимир Садовников

    Публикаций:
    8
    Регистрация:
    4 июн 2007
    Сообщения:
    1.610
    Адрес:
    г. Санкт-Петербург
    Эммм, а самому чуть-чуть покурить мануалы?
     
  4. r2max

    r2max Женя

    Публикаций:
    0
    Регистрация:
    30 мар 2011
    Сообщения:
    40
    Адрес:
    Киев
    Ммм
    Объясните тогда просто что такое
    extrn __imp__connect:dword
    Єто тоже самое что и импорт
    ws2_32.connect
    ???
    И
    iWin32 этот тот же CALL?
     
  5. r2max

    r2max Женя

    Публикаций:
    0
    Регистрация:
    30 мар 2011
    Сообщения:
    40
    Адрес:
    Киев
    Перепроверьте на всяк случай как я переделал.
    А то откомпилировал и результата не добился....
    Заранее спасибо
    Код (Text):
    1. format PE GUI 4.0 DLL
    2. entry DllEntry
    3.  
    4. include 'INCLUDE\win32a.inc'
    5. section '.data' data readable writeable
    6. LineageII   db  "LineageII.dll",0       ;LineageII.dll is L2Walker (IG), the .exe is nothing but a simple loader.
    7. section '.text' code readable executable
    8.  
    9. DllEntry:
    10.     push    ebp
    11.     mov ebp, esp
    12.     cmp dword [ebp+0Ch], 1
    13.     jne @F
    14.     call remove_hooks
    15.     call kill_l2walker
    16. @@:
    17.     mov eax, 1
    18.     mov esp, ebp
    19.     pop ebp
    20.     ret
    21.    
    22. proc remove_hooks  
    23.  
    24.     push ebp
    25.     mov ebp, esp
    26.     push ecx
    27.    
    28.     mov ebx, [connect]      ;move the address of ws2_32.connect into ebx
    29.    
    30.     lea edx, dword [ebp-4]      ;make it so we can write to this address + some odd bytes
    31.     push edx
    32.     push 40h
    33.     push 12h
    34.     push ebx
    35.     call [VirtualProtect]
    36.    
    37.     mov byte [ebx], 08Bh            ;this is the start of ws2_32.connect, its the same in every version of Windows
    38.     mov byte [ebx+1], 0FFh      ;hlaphex/l2phx hook the start of this function, so let's just overwrite their hook
    39.     mov byte [ebx+2], 055h      ;with the original function.
    40.     mov byte [ebx+3], 08Bh
    41.     mov byte [ebx+4], 0ECh      ;until either bots hook the iat, this works beautifully, breaking both l2phx/hlaphex
    42.                                 ;with one little sub-routine    
    43.     mov esp, ebp
    44.     pop ebp
    45.     ret
    46.    
    47. endp   
    48.  
    49. proc kill_l2walker 
    50.  
    51.     push ebp
    52.     mov ebp, esp
    53.     push ecx
    54.    
    55.     push LineageII          ;because walker's lineageii.dll is packed with asprotect
    56.     call [ExitProcess]          ;renaming it isn't an option =)
    57.     cmp eax, 0                  ;do we return an address?
    58.     je @@2                      ;if no, continue along.
    59.    
    60.     push 0                      ;exit code
    61.     push 0ffffffffh             ;-1 is pseudo handle for our process (l2.exe)
    62.     call [ExitProcess]  ;l2.exe process silently exits
    63.    
    64. @@2:    mov esp, ebp                    ;continuing along..
    65.     pop ebp
    66.     ret
    67.  
    68. endp   
    69.    
    70. ;=================================================================================
    71. proc DllBind
    72.     xor eax, eax
    73.     inc eax
    74.     ret
    75. endp
    76. ;=================================================================================
    77. section '.idata' import data readable writeable
    78.     library     kernel32, 'kernel32.dll'
    79.     library     ws2_32, 'ws2_32.dll'
    80.    
    81.     import  kernel32,\
    82.             VirtualProtect, 'VirtualProtect',\
    83.             GetModuleHandleA, 'GetModuleHandleA',\
    84.             ExitProcess, 'ExitProcess'
    85.     import ws2_32,\
    86.             connect,'connect'
    87. section '.reloc' fixups data discardable
    88.  
    89. section '.edata' export data readable writeable
    90.     export  'nophx.dll',\
    91.             DllBind, 'DllBind'