一個Linux病毒的原型分析(轉)

ba發表於2007-08-15
一個Linux病毒的原型分析(轉)[@more@]  本文僅做參考學習

  技術天地: 這篇文章的目的主要是對最近寫的一個Linux病毒原型程式碼做一個總結, 同時向對這方面有興趣的朋友做一個簡單的介紹。 閱讀這篇文章你需要一些知識,要對ELF有所瞭解、能夠閱讀一些嵌入了彙編的C程式碼、瞭解病毒的基本工作原理。

  作者既不是一個virus coder,也不是anti-viruscoder,這篇文章旨透過對一個Linux的病毒原型的工作原理和關鍵環節的分析和介紹來讓揭開病毒的神秘面紗,使您瞭解病毒的工作機理,也同時對理解Linux的系統程式設計有所幫助。

  一、 介紹

  寫這篇文章的目的主要是對最近寫的一個Linux病毒原型程式碼做一個總結,同時向對這方面有興趣的朋友做一個簡單的介紹。閱讀這篇文章你需要一些知識,要對ELF有所瞭解、能夠閱讀一些嵌入了彙編的C程式碼、瞭解病毒的基本工作原理。

  二、 ELF Infector (ELF檔案感染器)

  為了製作病毒檔案,我們需要一個ELF檔案感染器,用於製造第一個帶毒檔案。對於ELF檔案感染技術,在Silvio Cesare的《UNIX ELF PARASITES AND VIRUS》一文中已經有了一個非常好的分析、描述,在這方面我還沒有發現可以對其進行補充的地方,因此在這裡我把Silvio Cesare對ELF Infection過程的總結貼出來,以供參考:
CODE:
The final algorithm is using this information is.
* Increase p_shoff by PAGE_SIZE in the ELF header
* Patch the insertion code (parasite) to jump to the entry point
(original)
* Locate the text segment program header
* Modify the entry point of the ELF header to point to the new
code (p_vaddr + p_filesz)
* Increase p_filesz by account for the new code (parasite)
* Increase p_memsz to account for the new code (parasite)
* For each phdr who's segment is after the insertion (text segment)
* increase p_offset by PAGE_SIZE
* For the last shdr in the text segment
* increase sh_len by the parasite length
* For each shdr who's section resides after the insertion
* Increase sh_offset by PAGE_SIZE
* Physically insert the new code (parasite) and pad to PAGE_SIZE, into
the file - text segment p_offset + p_filesz (original)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617731/viewspace-959652/,如需轉載,請註明出處,否則將追究法律責任。

一個Linux病毒的原型分析(轉)
請登入後發表評論 登入
全部評論

相關文章