示例#1
0
 public static function hook(GWF_User $user, GWF_Download $dl)
 {
     $dlid = $dl->getID();
     if ($dlid > 2) {
         return true;
     }
     $demo = $dlid == 2;
     if (false === ($row = BAIM_MC::generate($user, $demo))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $mime = $dl->getVar('dl_mime');
     $path = $dl->getDownloadPath();
     $temp_path = GWF_PATH . 'extra/temp/baim/' . $user->getVar('user_id') . '_' . $row->getToken();
     if (!Common::isFile($path)) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', htmlspecialchars($path));
     }
     if (Common::isFile($temp_path)) {
         if (false === unlink($temp_path)) {
             return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
         }
     }
     if ($mime === 'application/zip') {
         if (false === copy($path, $temp_path)) {
             return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
         }
         $have_zip = true;
     } else {
         $have_zip = false;
     }
     $zip = new GWF_ZipArchive();
     if (false === $zip->open($temp_path, GWF_ZipArchive::CREATE)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
     }
     if ($have_zip === false) {
         $filename = $dl->getVar('dl_filename');
         $zip->addFile($path, $filename);
         $dl->setCustomDownloadName($filename . '.zip');
     }
     if (false === $zip->addFromString('B.AiM/key.dat', self::getIniContent($row))) {
         return GWF_HTML::error('BAIM', 'The download slot is not a zip archive!');
     }
     $zip->addFromString('B.AiM/readme.txt', self::getReadmeContent($row));
     $zip->addFromString('B.AiM/release_notes.txt', self::getReleaseNotes($row));
     $zip->close();
     $dl->setCustomDownloadPath($temp_path);
     return '';
 }
示例#2
0
<?php

chdir('../../../../');
require_once 'protected/config.php';
require_once '../gwf3.class.php';
$gwf = new GWF3(getcwd(), array('website_init' => true, 'autoload_modules' => true, 'load_module' => false, 'get_user' => true, 'do_logging' => true, 'blocking' => true, 'no_session' => false, 'store_last_url' => true, 'ignore_user_abort' => true));
//GWF_Session::start();
//GWF_Language::init();
//GWF_HTML::init();
$wechall = GWF_Module::loadModuleDB('WeChall');
require_once GWF_CORE_PATH . 'module/WeChall/WC_CryptoChall.php';
$jpg_path = 'challenge/training/stegano/attachment/the.jpg';
$jpg_file = file_get_contents($jpg_path);
$solution = WC_CryptoChall::generateSolution('YouLikeAttachmentEh', true, false);
$zip_path = GWF_PATH . 'extra/temp/steganoattach/' . GWF_Session::getSessID() . '.zip';
$zip = new GWF_ZipArchive();
if (false === $zip->open($zip_path, GWF_ZipArchive::CREATE)) {
    die('zip error 1');
}
if (false === $zip->addFromString('solution.txt', $solution)) {
    die('zip error 2');
}
if (false === $zip->close()) {
    die('zip error 3');
}
$jpg_file .= file_get_contents($zip_path);
unlink($zip_path);
header('Content-Type: image/jpeg');
echo $jpg_file;
die;
示例#3
0
文件: Bundle.php 项目: sinfocol/gwf3
 private function exportMissingBits(GWF_ZipArchive $archive, $target)
 {
     $contents = '';
     $filename = 'missing_bits_' . $target . '.php';
     foreach ($this->missing_bits as $filename2 => $data) {
         $contents .= $this->exportMissingBitsB($filename2, $data);
     }
     $archive->addFromString($filename, $contents);
     //		file_put_contents('/tmp/'.$filename, $contents);
     //		$archive->addFile('/tmp/'.$filename, $filename);
     //		unlink('/tmp/'.$filename);
 }