UNIX viruses - Silvio Cesare
CONTENTS
-------- improving THIS MANUAL UNIX-VIRUS mailing THE LIST INTRODUCTION THE NON ELF Infector FILE VIRUS (FILE INFECTION) MEMORY LAYOUT OF AN ELF executable ELF INFECTION VIRUS THE TEXT SEGMENT padding (padding INFECTION) infections infecting THE DATA. SEGMENT VIRUS (DATA INFECTION) VIRUS DETECTION THE TEXT SEGMENT VIRUS (TEXT INFECTION) INFECTION USING OBJECT CODE Parasites OBJECT CODE Linking THE implemented Infector NON (NOT AS) TRIVIAL Parasite CODE BEYOND ELF Parasites AND ENTER VIRUS IN UNIX THE LINUX Parasite VIRUS DEVELOPMENT OF THE. LINUX VIRUS improving LINUX VIRUS THE VIRUS DETECTION evading VIRUS INFECTION DETECTION IN ELF conclusion SOURCE (UUENCODED) improving THIS MANUAL For any comments or suggestions (even just to Say Hi) please Contact the author Silvio Cesare,.
. This has already Paper Future plans to
include more and Techniques Shared Object parasite infection. More to Come. THE VIRUS UNIX-mailing LIST This is the Charter for the Unix-Virus mailing list. Unix-Virus was Created to Discuss viruses in the Unix Environment from the Point of View of the Virus Creator, and the Anti-Virus Security Software Developer Writing. Anything related to viruses in the Unix Environment is open for discussion. Low level programming is commonly seen on the list, including Source code. The emphasis is on expanding the Knowledge of Virus Technology and not on the Distribution of viruses, so Binaries are discouraged but not totally excluded. The list is archived at Http://virus.beergrave.net and it is Recommended that the New Subscriber read the Material existing before Posting. To Subscribe to the list Send a message to Majordomo@virus.beergrave.net with 'UNIX-Subscribe. Virus' in the Body of the message. INTRODUCTION This Paper documents the algorithms and implementation of UNIX parasite and Virus code using ELF Objects. Introductions brief on UNIX Virus detection and evading detection are Given such. An implementation of parasite Various ELF infectors is provided for UNIX, and Linux on x86 Architecture for an ELF Virus is also supplied. Elementary programming and UNIX Knowledge is assumed, and an understanding of Linux x86 Architecture is assumed for the Linux implementation. ELF understanding is not required but Will Help. This Paper does not Document any significant programming Virus Techniques except those that are only applicable to the UNIX Environment. Nor does it TRY to replicate the ELF Specifications. The interested Reader is advised to read the ELF Documentation if this Paper is unclear in ELF specifics. THE NON ELF Infector FILE VIRUS (FILE INFECTION) An Interesting, yet Simple Idea for a Virus Takes note, that when You append one executable to another,. Original executes the executable, but the latter is still intact and retrievable and executable executable even if copied to a New file and executed. # CAT Host >> parasite parasite MV Host # # ./host Parasite Executed Now .. if the parasite keeps Track. Length of its own, it Can Copy the Original Host to a New file, then Execute it like Normal, working Making a parasite and Virus. The algorithm is as follows: * Execute parasite Work code * lseek to the End of the parasite * read the remaining portion of the file * write to a New file * Execute the New file The downfall with this approach is that the remaining executable no Longer. remains strip safe. Will this be expLAineD further on when a Greater understanding of the ELF Format is obtained, but to summarize, the ELF Headers no Longer Hold Into Account every portion of the file, and strip removes Unaccounted Portions. This is the premise of Virus detection with this Type of Virus. This method Same Can be used to infect LKM's following similar procedures. MEMORY LAYOUT OF AN ELF executable A Process Image consists of a 'text segment' and a 'Data segment'. The text segment is Given the memory RX Protection (Obvious from this that its self modifying code Can not be used in the text segment). Data is the segment Given the Protection Rw-. The segment as seen from the Process Image is typically not all in use as memory used by the Border Process rarely Lies on a page (or we Can Say, not congruent modulo the page to Size). . Padding completes the segment, and in Practice looks like this. Key: [...] A Complete page M Memory used in this segment P Padding Page Nr # 1 [PPPPMMMMMMMMMMMM] # 2 [mmmmmmmmmmmmmmmm] | - A segment # 3 [. MMMMMMMMMMMMPPPP] / Segments are not bound to use multiple pages, so a single page segment is quite possible. Page Nr # 1 [PPPPMMMMMMMMPPPP] <- A segment Typically, the Data segment directly proceeds the text segment which always starts on a page, but. the data segment may not. The memory layout for a Process Image is thus. Key: [...] A Complete page T Text D Data P Padding Page Nr # 1 [TTTTTTTTTTTTTTTT] <- Part of the text segment # 2 [TTTTTTTTTTTTTTTT] <- Part of the. text segment # 3 [TTTTTTTTTTTTPPPP] <- Part of the text segment # 4 [PPPPDDDDDDDDDDDD] <- Part of the Data segment # 5 [DDDDDDDDDDDDDDDD] <- Part of the Data segment # 6 [DDDDDDDDDDDDPPPP] <- Part of the Data segment. pages 1, 2, 3 constitute the text segment pages 4, 5, 6 constitute the segment Data From here on, the segment diagrams May use single pages for simplicity. eg Page Nr # 1 [TTTTTTTTTTTTPPPP] <- The text segment # 2 [PPPPDDDDDDDDPPPP] <- The Data segment For completeness, on x86, the stack segment is located after the Data segment Data segment giving the Enough Room for growth. Thus the stack is located at the top of memory (Remembering that it grows down). In an ELF file, loadable segments are physically present in the file, which completely describe the text and Process Image Data segments for loading. A simplified ELF Format for an executable Object relevant in this instance is. ELF Header . . Segment 1 <- Text Segment 2 <- Data . . Each segment has a Virtual address associated with its Starting Location. Absolute code that references Within each segment is. permissible and very probable. ELF INFECTION To INSERT parasite code means that the Process Image Load it must so that the Original Data and code is still intact. This means, that inserting a parasite requires the memory used in the segments to be Increased. The text segment compromises not only code, but also including the ELF Headers Things such as Dynamic Linking information. It May be possible to Keep the text segment as is, and create another segment consisting of the parasite code, however introducing an extra segment is certainly questionable and Easy to detect. Page padding at segment Borders however provides a practical Location for parasite code Given that. its size is able. Will not this Space Interferes with the Original segments, requiring no Relocation. Following the Guideline just Given of Preferencing the text segment, we Can See that the padding at the End of the text segment is a viable Solution. Extending the text segment backwards is a viable Solution and is documented and implemented further in this Article. Extending the. Forward text segment or the Data segment extending backward Will probably Overlap the segments. Relocating a segment in memory Will Cause Problems with absolutely any code that references memory. It is possible to Extend the Data segment, however this is not Preferred, as its not that UNIX Portable memory properly IMPLEMENT Execute Protection. An ELF however parasite is implemented. using this Technique and is expLAineD later in this Article. THE executable AND LINKAGE FORMAT A more Complete ELF executable layout is (ignoring section content - See Below). ELF Header Program Header Table Segment 1 Segment 2 Section Header Table optional In Practice, this is. what is normally seen. ELF Header Program Header Table 1 Segment 2 Segment Table Header Section Section 1 . . Section n Typically, the extra Sections (those not associated with a segment) are such Things as debugging information, etc. Symbol tables From the ELF. Specifications: "An ELF Header resides at the Beginning and holds a` `Road Map '' describing the file's Organization. Sections Hold the Bulk of Object file information for the Linking View: instructions, Data, Symbol Table, Relocation information, and so on. . ... ... A Program Table Header, if present, tells the System How to create a Process Image. Files used to Build a Process Image (Execute a Program) must have a Program Header Table; relocatable files do not need one. A section Header Table contains information describing the file's Sections. Every section has an Entry in the Table; each Entry section gives information such as the name, the section Size, etc. Files used during Linking must have a section Header Table; Other Object Files May or May not have one. ... ... Executable and Shared Object Files statically represent programs. Execute to such programs, the System uses the Dynamic Program Files to create representations, images or Process. A Process Image has segments that Hold its text, Data, stack, and so on. The Major Sections in this Part Discuss the following. Program Header. This section complements Part 1, describing file Object Structures that Relate directly to Program Execution. The primary Data structure, a Program Header Table, locates segment images Within the file and contains Other information necessary to create the memory Image for the Program. " An ELF Object May also Specify an Entry Point of the Program, that is, the Virtual memory. Location that Assumes Control of the Program. Thus to activate parasite code, the Program flow must include the New parasite. This Can be done by patching the Entry Point in the ELF Object to Point (Jump) directly to the parasite. It is then the. parasite's Responsibility that the code be executed Host - typically, by transferring the Host Control Back to the once.
การแปล กรุณารอสักครู่..
