
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ[AVEXP.ASM]ÄÄÄ
   P386
   model flat
   jumps

   callx macro x
   extrn x:proc
   call x
   endm

WIN32_FIND_DATA STRUCT
  dwFileAttributes      DWORD      ?
  ftCreationTime        DWORD      ?,?
  ftLastAccessTime      DWORD      ?,?
  ftLastWriteTime       DWORD      ?,?
  nFileSizeHigh         DWORD      ?
  nFileSizeLow          DWORD      ?
  dwReserved0           DWORD      ?
  dwReserved1           DWORD      ?
  cFileName             BYTE 260 dup(?)
  cAlternate            BYTE 14 dup(?)
WIN32_FIND_DATA ENDS

   .data
   @cpright       db 13,10,'AvExp - AntiViral Exploiter'
                  db 13,10,'Type /? for help'
                  db 13,10,'NBK [MATRiX]',13,10,0
   fnameindex     dd 0,0,0
   nnnnn          db 11 dup(0)

   .data?
   @esp           dd ?
   screenhandle   dd ?
   cmdline        dd ?
   cmdlinelen     dd ?
   infectedfile   dd ?
   @finddata      WIN32_FIND_DATA<?>
   fnamehandle    dd ?
   filehandle     dd ?
   ofstable       db 600 dup(?)

   .code
   ;hiper virus test
   ;generates a lot of filez patched, to see where anti-virus
   ;got the "mark"

start:
   mov   @esp, esp
   push  -11                                 ;  STD_OUTPUT_HANDLE
   callx GetStdHandle
   mov   screenhandle, eax
   callx GetCommandLineA
   mov   cmdline, eax
   push  cmdline
   callx lstrlenA
   mov   cmdlinelen, eax

   call  random_ini                          ;  init random routine
   call  preprocess                          ;  check errors, parse cmd line
   call  make100copies                       ;  let's generate 100 copies of it
   call  openrandomize

   jmp   .fuimsg5

preprocess:
   pushad
   cmp   screenhandle, 0
   je    .fui
   push  260
   push  cmdline
   callx IsBadReadPtr
   dec   eax
   jz    .fuimsg1
   mov   al, '?'
   call  .parse
   dec   edi
   cmp   [edi], al
   je    .fuimsg4
   mov   al, ' '
   call  .parse
   test  ecx, ecx
   jz    .fuimsg1
   mov   infectedfile, edi
   push  offset @finddata
   push  infectedfile
   callx FindFirstFileA
   push  eax
   callx FindClose
   cmp   @finddata.nFileSizeLow, 1024
   jbe   .fuimsg1
   popad
   ret

.parse:
   mov   edi, cmdline
   mov   ecx, cmdlinelen
   repne scasb
   ret

.fuimsg5:
   call  .ftext5
   db 'OK',13,10,0

.ftext5:
   call  .wrt
   jmp   .saida

.fuimsg4:
   call  .ftext1
   db 13,10,'Usage: AvExp infected.exe'
   db 13,10,'Generate new files, random patched with 10 null bytes, to detect where'
   db 13,10,'AV got the mark from'
   db 13,10,"You've to scan the generated filez with your AV and get the 'clean' ones"
   db 13,10,'Then compare it with original (hex editor), locating the offset',13,10
   db 13,10,'NBK [MATRiX] | 2001 | www.nbk.hpg.com.br | nbk_vx@starmail.com',13,10,0

.fuimsg3:
   call  .ftext1
   db    13,10,'I/O Error',13,10,0

.fuimsg2:
   call  .ftext1
   db    13,10,'Out of memory',13,10,0

.fuimsg1:                                    ;  sair c/ mensagem de erro
   call  .ftext1
   db    13,10,'Bad Command Line',13,10,0

.ftext1:
   call  .wrt
   jmp   .fui

.fui:
   push  offset @cpright
   call  .wrt

.saida:
   mov   esp, @esp
   push  3*1000
   callx Sleep
   push  0ffffffffh
   callx ExitProcess

.wrt:
   pushad
   lea   eax, [esp+(4*8)+(4*1)]
   push  dword ptr [eax]
   callx lstrlenA
   mov   ecx, eax
   push  0
   mov   eax, esp
   push  0
   push  eax
   push  ecx
   lea   eax, [esp+(4*8)+(4*4)+(4*1)]
   push  dword ptr [eax]                     ;  primeiro arg. = buffer
   push  screenhandle
   callx WriteFile
   pop   eax
   popad
   ret   (4*1)

make100copies:
   mov   fnameindex, '0000' xor ''
   mov   fnameindex+4, 'EXE.'
   mov   ecx, 10

.dec:
   call  .cpy
   inc   byte ptr fnameindex+2
   loop  .dec
   ret

.cpy:
   pushad
   mov   ecx, 10

.cp:
   push  ecx
   push  1
   push  offset fnameindex
   push  offset @finddata.cFileName
   callx CopyFileA
   test  eax, eax
   jz    .fuimsg3                            ;  I/O error
   inc   byte ptr fnameindex+3
   pop   ecx
   loop  .cp
   mov   byte ptr fnameindex+3, '0'
   popad
   ret

openrandomize:
call textpatch
   db 'Patching',0
textpatch:
   call  .wrt
   mov   eax, @finddata.nFileSizeLow
   sub   edx, edx
   mov   ecx, 1024
   div   ecx
   test  edx, edx
   jnz   .rndthem
   dec   @finddata.nFileSizeLow

.rndthem:
   mov   fnameindex, '0000'
   mov   fnameindex+4, 'EXE.'
   mov   ecx, 10

.decx:
   call  .cpyx
   inc   byte ptr fnameindex+2
   loop  .decx
   ret

.cpyx:
   pushad
   mov   ecx, 10

.cpx:
   push  ecx
   push  0
   push  0
   push  3                                   ;  OPEN_EXISTING
   push  0
   push  1                                   ;  FILE_SHARE_READ
   push  80000000h or 40000000h              ;  READ OR WRITE
   push  offset fnameindex
   callx CreateFileA
   mov   filehandle, eax
   dec   eax
   jz    .fuimsg3

recalc:
   call  getrandom
   and   eax, @finddata.nFileSizeLow
   cmp   eax, 248+5                    ; se for zero
   jbe   recalc
   mov   edi, offset ofstable
   sub   ecx, ecx

recmp:
   add   edi, 4
   cmp   [edi], eax                    ;  se ja foi usada
   je    recalc
   cmp   [edi], ecx                    ;  fim da table ?
   jne   recmp
   mov   [edi], eax
   sub   eax, 5
;EAX = new pointer
   push  0                                   ;  FILE_BEGIN
   push  0
   push  eax
   push  filehandle
   callx SetFilePointer
   inc   eax
   jz    .fuimsg3
   push  0
   mov   eax, esp
   push  0
   push  eax
   push  10
   push  offset nnnnn
   push  filehandle
   callx WriteFile
   pop   eax
   push  filehandle
   callx CloseHandle
call textpt
   db '.',0
textpt:
   call  .wrt
   mov   filehandle, 0
   inc   byte ptr fnameindex+3
   pop   ecx
   loop  .cpx
   mov   byte ptr fnameindex+3, '0'
   popad
   ret

random_ini:
   pushad
   callx GetTickCount
   mov   rnd_dword, eax
   call  getrandom
   and   eax, 255
   mov   ecx, eax

 @rand:
   call  getrandom
   loop  @rand
   popad
   ret

   ;rand dword

getrandom:
   push  ecx
   push  edx
   mov   eax, 12345678h
   rnd_dword equ dword ptr $-4
   mov   ecx,41C64E6Dh
   mul   ecx
   add   eax,00003039h
   and   eax,7FFFFFFFh
   mov   rnd_dword, eax
   pop   edx
   pop   ecx
   ret

   end start
   end
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ[AVEXP.ASM]ÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ[README.TXT]ÄÄÄ
AvExp
~~~~~

This simple tool only patches 10 null bytes, in random positions, all diferents,
trying to locate from where AV is scanning your virus. It creates/patches 100
files.
It helps me with invictus.dll

Coded in a bored day (monday) at work

NBK [MATRiX]
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ[README.TXT]ÄÄÄ
