Back to index

php5  5.3.10
Public Member Functions | Public Attributes | Private Member Functions
corrupt_zipmaker Class Reference

ZIP archive writer. More...

List of all members.

Public Member Functions

 setComment ($comment)
 Set a comment on the ZIP file.
 getMTime ($time)
 addFile ($filename, $mtime, $data, $comment=null, $compress=null, $filecorrupt=null, $centralcorrupt=null, $fakecomp=1)
 writeZip ($zipfile, $corrupt=null)

Public Attributes

 $offset = 0
 $comment = ""
 $central = ""
 $start = ""

Private Member Functions

 getFileEntry ($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $corrupt, $fakecomp)
 getCentralEntry ($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $corrupt, &$offset, $fakecomp)

Detailed Description

ZIP archive writer.

Definition at line 36 of file corrupt_zipmaker.php.inc.


Member Function Documentation

corrupt_zipmaker::addFile ( filename,
mtime,
data,
comment = null,
compress = null,
filecorrupt = null,
centralcorrupt = null,
fakecomp = 1 
)

Definition at line 253 of file corrupt_zipmaker.php.inc.

       {
              $mtime = $this->getMTime($mtime ? $mtime : null);

              $uncomplength = strlen($data);
              $crc32 = crc32($data) & 0xFFFFFFFF;
              $compmethod = 0;
              switch ($compress) {
                     case 'gz' :
                            $data = gzcompress($data);
                            $compmethod = 8;
                            break;
                     case 'bz2' :
                            $data = bzcompress($data);
                            $compmethod = 12;
                            break;
              }
              $complength = strlen($data);

              $this->start .= ($file = $this->getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $filecorrupt, $fakecomp));

              $offset = 0;
              $this->central .= $this->getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $centralcorrupt, $offset, $fakecomp);

              $this->offset += $offset;
              $this->count++;
       }

Here is the call graph for this function:

corrupt_zipmaker::getCentralEntry ( compmethod,
mtime,
crc32,
complength,
uncomplength,
filename,
comment,
corrupt,
&$  offset,
fakecomp 
) [private]

Definition at line 164 of file corrupt_zipmaker.php.inc.

       {
              settype($comment, 'string');
              switch ($corrupt) {
                     case null :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'encrypt' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x01\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'compress' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $fakecomp) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'crc32' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'complength' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength - 1, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'uncomplength' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'filename_len' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'offset' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset - 1).
                                          $filename . $comment;
                            $offset = strlen($central) - 1;
                            break;
                     case 'comment' :
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment) + 1,0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $comment;
                            $offset = strlen($central);
                            break;
                     case 'extralen1' :
                            $extra = 'nu' . 0xffff; // way huge size
                            $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), strlen($extra),strlen($comment),0x00,0x00,
                                                 0x0000, $this->offset).
                                          $filename . $extra . $comment;
                            $offset = strlen($central);
                            break;
              }
              return $central;
       }

Here is the caller graph for this function:

corrupt_zipmaker::getFileEntry ( compmethod,
mtime,
crc32,
complength,
uncomplength,
filename,
data,
corrupt,
fakecomp 
) [private]

Definition at line 87 of file corrupt_zipmaker.php.inc.

       {
              switch ($corrupt) {
                     case null :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
                                          $filename .
                                          $data;
                            break;
                     case 'compress' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $fakecomp) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
                                          $filename .
                                          $data;
                            break;
                     case 'encrypt' :
                            $file = "PK\x03\x04\x14\x00\x01\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
                                          $filename .
                                          $data;
                            break;
                     case 'crc32' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00) .
                                          $filename .
                                          $data;
                            break;
                     case 'complength' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength + 1, $uncomplength, strlen($filename), 0x00) .
                                          $filename .
                                          $data;
                            break;
                     case 'uncomplength' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00) .
                                          $filename .
                                          $data;
                            break;
                     case 'filename_len' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00) .
                                          $filename .
                                          $data;
                            break;
                     case 'extra_len' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 1) .
                                          $filename .
                                          $data;
                            break;
                     case 'filename' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
                                          substr($filename, 1) .
                                          $data;
                            break;
                     case 'data' :
                            $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) .
                                          $mtime .
                                          pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) .
                                          $filename .
                                          substr($data, 1);
                            break;
              }
              return $file;
       }

Here is the caller graph for this function:

Parameters:
int$timeUnix timestamp of the date to convert
Returns:
the date formated as a ZIP date

Definition at line 71 of file corrupt_zipmaker.php.inc.

       {
              $mtime = ($time !== null ? getdate($time) : getdate());
              $mtime = preg_replace(
                            "/(..){1}(..){1}(..){1}(..){1}/",
                            "\\x\\4\\x\\3\\x\\2\\x\\1",
                            dechex(($mtime['year']-1980<<25)|
                                   ($mtime['mon'    ]<<21)|
                                   ($mtime['mday'   ]<<16)|
                                   ($mtime['hours'  ]<<11)|
                                   ($mtime['minutes']<<5)|
                                   ($mtime['seconds']>>1)));
              eval('$mtime = "'.$mtime.'";');
              return $mtime;
       }

Here is the caller graph for this function:

Set a comment on the ZIP file.

Definition at line 65 of file corrupt_zipmaker.php.inc.

{ $this->comment = $comment; }
corrupt_zipmaker::writeZip ( zipfile,
corrupt = null 
)

Definition at line 281 of file corrupt_zipmaker.php.inc.

       {
              $write = $this->start . $this->central;
              switch ($corrupt) {
                     case null :
                            $write .= "PK\x05\x06\x00\x00\x00\x00" .
                                   pack("vvVVv", $this->count, $this->count,
                                   $this->offset, strlen($this->start),
                                   strlen($this->comment)) . $this->comment;
                            break;
                     case 'disknumber' :
                            $write .= "PK\x05\x06\x01\x00\x01\x00" .
                                   pack("vvVVv", $this->count, $this->count,
                                   $this->offset, strlen($this->start),
                                   strlen($this->comment)) . $this->comment;
                            break;
                     case 'count1' :
                            $write .= "PK\x05\x06\x00\x00\x00\x00" .
                                   pack("vvVVv", $this->count + 1, $this->count,
                                   $this->offset, strlen($this->start),
                                   strlen($this->comment)) . $this->comment;
                            break;
                     case 'count2' :
                            $write .= "PK\x05\x06\x00\x00\x00\x00" .
                                   pack("vvVVv", $this->count, $this->count + 1,
                                   $this->offset, strlen($this->start),
                                   strlen($this->comment)) . $this->comment;
                            break;
                     case 'cdir_offset' :
                            $write .= "PK\x05\x06\x00\x00\x00\x00" .
                                   pack("vvVVv", $this->count, $this->count,
                                   $this->offset, strlen($this->start) - 3,
                                   strlen($this->comment)) . $this->comment;
                            break;
                     case 'cdir_len' :
                            $write .= "PK\x05\x06\x00\x00\x00\x00" .
                                   pack("vvVVv", $this->count, $this->count,
                                   $this->offset - 5, strlen($this->start),
                                   strlen($this->comment)) . $this->comment;
                            break;
                     case 'comment' :
                            $write .= "PK\x05\x06\x00\x00\x00\x00" .
                                   pack("vvVVv", $this->count, $this->count,
                                   strlen($this->start), $this->offset + 1,
                                   strlen($this->comment) + 1) . $this->comment;
                            break;
                     case 'none' :
              }
              file_put_contents($zipfile, $write);
       }

Member Data Documentation

Definition at line 54 of file corrupt_zipmaker.php.inc.

Definition at line 48 of file corrupt_zipmaker.php.inc.

Definition at line 42 of file corrupt_zipmaker.php.inc.

Definition at line 60 of file corrupt_zipmaker.php.inc.


The documentation for this class was generated from the following file: