DROPPING & COMPANIONING over ZIP archives
From the Archives infector series
by UnknowN MnemoniK/ikx


Intro

Zip are the most complex archive file to infect , obviously also the most used , a lot of programs use them , create them , modify them , make some phucked tricks on them , those programs are almost writted in C by bad coders using library, object and code and don't care about the structure. I have found only one prog that use a little assembler , but like all asm code writted by a c programmer , the code is unreadable , really , I have spend three hours about shitty things,the code might to be something coded by Jacky Qwerty , unreadable , uncomprehensible and without any sense but it works . Infect a zip is an art because a lot of platforms support them and specially BBS that convert ALL files they receive into zip files (with any kinda archiver) , zip are also really common on ftp but also on cdrom , waraz games , etc etc etc....

The zip file format

Zip doesn't use the same scheme of packet like another archive, it uses a <<locked>> and a little messy structure , for this reason there are a lot of infection ways ( Gewd for vx ), in fact, you have three types of areas of packets , the local files , the central directory and the end of central directory, the first contain a certain header plus the compressed file , the second contains severals informations ( and usefull for us ) and of course have his header , the third and the last one contains general informations about the file , here's the scheme

It's important to see how it works for any manipulation

Headers structure

I need to send a big thanks to Griyo and superx who sent me those informations that helped me a lot for the zip infection! I found this really easy to understand , I had tried to do the same things for the arj and rar

Note that ZIPECOM will be displayed at screen !

those datas becomes from a document writted by Raymond Clay , read it many times , when you have already well understand it , we can pass on the infection process

Infection

Of course ,for any infection , you must fix host os and compression to No compression , when done then we can continue infection

Okay , if you want infect any zip file , you will have 3 tricks to do , first drop the local header and the virus , second drop the central directory about the virus go to the end and modify the end of central dir structure and close the file

In fact , the situation is not too simple, there are many problems, first you must drop the virus as the last packet in the local file packets area Why not set it as the first packet ? because the zipofst of other packet will not correspond with the reality, after that you need also to put the central directory packet at the end of the file, and you must also modify the end of central directory packet.Okay but anyway if you write the last local , you overwrite the central, so you must save the central directory area, if you overwrite the central directory you will overwrite also the end of central header ,so you must save it also

The second big problem is to find the end of the local packets area ,good news, this is also the begin of central directory area,I know two methods to find the start of central directory

I have choosed the first solution I found the second one require too many disk acesses and it will raise user's suspects ,with the first solution , I can't read any byte I want from the end of the file,so I have choose to read only 5000 bytes from the end ( think that 80x25 = 2000 ), I haven't encountered zips that have an end of central bigger than 5000, it's okay and it's works right!

When I have located the offset of the local header ,I read it and put it into a buffer , after that , I get the offset of the start of the central directory , I save the central directory area plus the location , I write the virus and a new header , I write all the central directory , the new central directory and the modified end of central directory

Companing ? Yeah, this is possible because we can found the original name in the central directory , when an EXE file is found , then we copy the name into a buffer and write it into the central directory and the local header. For that operation you need to scan each header , if no exe found you can also drop a file into the zip but this is more dangerous

We can build the zip infection algorithm , it's mine , there's a lot of other , that can be quite good

Zip open ways to a lot of infection types , sure, you'll surprised in the next issue of Xine to see how zip can be used by VX to do something you would never imagine

Anyway , I invite you to see the code below , compile this code with TASM & TLINK and test it with a TEST.ZIP file in the directory , test with and without an executable in the file

Improvent ? Build a vxd and correct some mistake is cool , like usual , a 32 bits asm crc is cool too , anyway , some surprise'll come Les petits d‚linquants (C) Unkm98!