예제 #1
0
 /**
  * Get a client saved in the database.
  *
  * @param integer $idClient
  * @return Client
  */
 public function getClient($idClient)
 {
     $mcrypt = new MCrypt();
     $sql = "SELECT * FROM client WHERE id_client = '" . $idClient . "'";
     $res = DB::query($sql);
     $row = mysqli_fetch_assoc($res);
     $client = new Client($row['id_client'], $row["client_name"], $row['agent'], $row['address'], $row["phone"], $row['email'], $row['website'], $row['user'], $mcrypt->decrypt($row['password']));
     DB::free($res);
     return $client;
 }
예제 #2
0
 function read($sessionId)
 {
     $data = (string) @file_get_contents("{$this->savePath}/sess_{$sessionId}");
     $key = $this->getkey($sessionId);
     //        $this->err($key);
     // TODO::sudo php5enmod mcrypt
     //        $crypt = new Crypt ();
     //        $crypt->setComplexTypes(TRUE);
     //        $crypt->setKey($key);
     //        $crypt->setData($data);
     //        $decrypt = $crypt->decrypt();
     //        $crypt = new \Crypt\AES ();
     //        $decrypt = $crypt->decrypt($data, $this->key, $this->iv);
     //        $security = new Security();
     //        $decrypt = $security->decrypt($data, $key);
     $crypt = new MCrypt($key);
     $decrypt = $crypt->decrypt($data);
     //        $this->err($data);
     //        $this->err($decrypt);
     return $decrypt;
 }
예제 #3
0
     $sql = "SELECT jar FROM app WHERE app_id2='" . $_SESSION['app_id2'] . "';";
 } else {
     $sql = "SELECT " . "jar" . $jarFlag . " FROM app WHERE app_id2='" . $_SESSION['app_id2'] . "';";
 }
 $result = mysql_query($sql) or die(mysql_error());
 $row3 = mysql_fetch_array($result);
 $jar_contents = file_get_contents("../download/" . $row3[0]);
 // echo $jar_contents;
 // file_put_contents('new_encrypted.jar', $jar_contents);
 // cbs
 // $cipher_block = $mcrypt->encrypt($xor_key,$jar_contents);
 $cipher_block = $mcrypt->encrypt($xor_key, $jar_contents, true);
 file_put_contents('../download/encrypted/' . $jarname, $cipher_block);
 $d_jar_contents = file_get_contents('../download/encrypted/' . $jarname);
 // $d_cipher_block = $mcrypt->decrypt($xor_key,$d_jar_contents);
 $d_cipher_block = $mcrypt->decrypt($xor_key, $d_jar_contents, true);
 file_put_contents('../download/encrypted/' . 'aaa.jar', $d_cipher_block);
 // $logo_jar_contents=file_get_contents('../download/'.'logo.png');
 // // $logo_cipher_block = $mcrypt->encrypt($xor_key,$logo_jar_contents);
 // $logo_cipher_block = $mcrypt->encrypt($xor_key,$logo_jar_contents,true);
 // $logo_jarname='enc_logo.png';
 // file_put_contents('../download/encrypted/'.$logo_jarname, $logo_cipher_block);
 // $d_logo_jar_contents=file_get_contents('../download/encrypted/'.$logo_jarname);
 // // $d_logo_cipher_block = $mcrypt->decrypt($xor_key,$d_logo_jar_contents);
 // $d_logo_cipher_block = $mcrypt->decrypt($xor_key,$d_logo_jar_contents,true);
 // file_put_contents('../download/encrypted/'.'dec_logo.png', $d_logo_cipher_block);
 $test_jar_contents = file_get_contents('../download/' . 'output123.jar');
 $test_cipher_block = $mcrypt->encrypt($xor_key, $test_jar_contents, true);
 $test_jarname = 'test_enc123.jar';
 file_put_contents('../download/encrypted/' . $test_jarname, $test_cipher_block);
 $test_d_jar_contents = file_get_contents('../download/encrypted/' . $test_jarname);
//ini_set('display_errors', 'On');
//var_dump(function_exists('utf8_decode'));
/*
 * Following code will list the values from the query and encrypt
 * For the message the android application
 */
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
require_once __DIR__ . '/mcrypt.php';
$db = new DB_CONNECT();
$mcrypt = new MCrypt();
//get the encrypted query and use the mycrypt libary to unencrypt it
$encrypted_data = $_REQUEST["query"];
$query = $mcrypt->decrypt($encrypted_data);
//run the query
$result = mysql_query($query) or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
    /*
    	Take all the results and encrypt them and display them.
    */
    $response["responce"] = array();
    $product = array();
    $data = "";
    while ($row = mysql_fetch_array($result)) {
        for ($i = 0; $i < count($row) / 2; $i = $i + 1) {
            $data .= $row[$i];
            if ($i < count($row) / 2 - 1) {
                $data .= ",";
예제 #5
0
 // $jar_contents=file_get_contents($row3[0]);
 if ($jarFlag == "0") {
     $sql = "SELECT jar FROM app WHERE app_id2='" . $_SESSION['app_id2'] . "';";
 } else {
     $sql = "SELECT " . "jar" . $jarFlag . " FROM app WHERE app_id2='" . $_SESSION['app_id2'] . "';";
 }
 $result = mysql_query($sql) or die(mysql_error());
 $row3 = mysql_fetch_array($result);
 $jar_contents = file_get_contents("../download/" . $row3[0]);
 // echo $jar_contents;
 // file_put_contents('new_encrypted.jar', $jar_contents);
 // cbs
 $cipher_block = $mcrypt->encrypt($xor_key, $jar_contents);
 file_put_contents('../download/encrypted/' . $jarname, $cipher_block);
 $d_jar_contents = file_get_contents('../download/encrypted/' . $jarname);
 $d_cipher_block = $mcrypt->decrypt($xor_key, $d_jar_contents);
 $d_jarname = 'aaa.jar';
 file_put_contents('../download/encrypted/' . $d_jarname, $d_cipher_block);
 $logo_jar_contents = file_get_contents("../download/" . "logo.png");
 $logo_cipher_block = $mcrypt->encrypt($xor_key, $logo_jar_contents);
 $logo_jarname = 'enc_logo.png';
 file_put_contents('../download/encrypted/' . $logo_jarname, $logo_cipher_block);
 $d_logo_jar_contents = file_get_contents('../download/encrypted/' . $logo_jarname);
 $d_logo_cipher_block = $mcrypt->decrypt($xor_key, $d_logo_jar_contents);
 $d_logo_jarname = 'dec_logo.png';
 file_put_contents('../download/encrypted/' . $d_logo_jarname, $d_logo_cipher_block);
 // echo $cipher_block;
 $cipher_jar_uri = "http://140.118.109.165:8081/sub_project2/download/encrypted/" . $jarname;
 $arr = array('flag' => 'success', 'enable_block' => $enable_block1, 'enable_block2' => $enable_block2, 'enable_block3' => $enable_block3, 'cipher_jar_uri' => $cipher_jar_uri, 'hahaha' => $xor_key, 'sessionid' => $_SESSION['sessionid']);
 // 'app_id'=>$_SESSION['app_id'],
 echo json_encode($arr);
예제 #6
0
파일: des.php 프로젝트: xiangku7890/basic
        $len = strlen($string);
        $pad = $blocksize - $len % $blocksize;
        $string .= str_repeat(chr($pad), $pad);
        return $string;
    }
    private function strippadding($string)
    {
        $slast = ord(substr($string, -1));
        $slastc = chr($slast);
        $pcheck = substr($string, -$slast);
        if (preg_match("/{$slastc}{" . $slast . "}/", $string)) {
            $string = substr($string, 0, strlen($string) - $slast);
            return $string;
        } else {
            return false;
        }
    }
    function hexToStr($hex)
    {
        $string = '';
        for ($i = 0; $i < strlen($hex) - 1; $i += 2) {
            $string .= chr(hexdec($hex[$i] . $hex[$i + 1]));
        }
        return $string;
    }
}
$encryption = new MCrypt();
$str = '我是中国人大佛傲东方那份难';
echo $en = $encryption->encrypt($str) . PHP_EOL;
echo $de = $encryption->decrypt($en);
var_dump($de == $str);
예제 #7
0
 private static function check_auth()
 {
     if (!sizeof($_COOKIE) > 0) {
         return null;
     }
     if (!isset($_COOKIE['mpmi_r'])) {
         return null;
     }
     if (!isset($_COOKIE['mpmi_t'])) {
         return null;
     }
     if (!isset($_COOKIE['mpmi_b'])) {
         return null;
     }
     $cookie_of_rand = MCrypt::decrypt($_COOKIE['mpmi_r']);
     $cookie_of_time = MCrypt::decrypt($_COOKIE['mpmi_t']);
     $cookie_of_browser = MCrypt::decrypt($_COOKIE['mpmi_b']);
     $rand_array = explode(' ', $cookie_of_rand);
     $user = new M_User($rand_array[0], true);
     if ($user) {
         if ($user->compare_lastlogin($cookie_of_rand, $cookie_of_time, $cookie_of_browser)) {
             self::$auth = true;
             self::$user = $user->get_username();
             self::$user_id = $user->get_id();
             self::$group_id = $user->get_group_id();
         }
     }
 }
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        return utf8_encode(trim($decrypted));
    }
    protected function hex2bin($hexdata)
    {
        $bindata = '';
        for ($i = 0; $i < strlen($hexdata); $i += 2) {
            $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
        }
        return $bindata;
    }
}
$mcrypt = new MCrypt();
// Get the connexion parameter
$dbname = $mcrypt->decrypt($_REQUEST['dbname']);
$host = $mcrypt->decrypt($_REQUEST['host']);
$username = $mcrypt->decrypt($_REQUEST['username']);
$password = $mcrypt->decrypt($_REQUEST['password']);
//Open the connexion to the database
$connect = new PDO('mysql:host=' . $host . ';dbname=' . $dbname, $username, $password);
$connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$connect->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$connect->exec("SET CHARACTER SET utf8");
//Execute the request
$result = $connect->prepare(str_replace("\\'", "'", $_REQUEST['request']));
$result->execute();
//If we need to get de last insert id
if (isset($_REQUEST['isNeedToGetId'])) {
    echo $mcrypt->encrypt($connect->lastInsertId());
} else {
예제 #9
0
파일: index.php 프로젝트: basweerman/xi
$output = json_encode(array('error' => API_RESULT_NO_COMMAND));
if ($_GET['q']) {
    require_once '../globals.php';
    require_once 'ximcrypt.php';
    $hostname = 'localhost';
    $username = '******';
    $password = '******';
    $database = 'xi';
    $db = new mysqli($hostname, $username, $password);
    @mysqli_select_db($db, $database);
    //  echo $_GET['q'];
    //  echo '<hr>';
    //echo base64_decode($_GET['q']);
    //$q = json_decode(base64_decode($_GET['q']), true);
    $mcrypt = new MCrypt();
    $q = json_decode($mcrypt->decrypt($_GET['q']), true);
    //    print_r($q);
    //echo $q['api'];
    switch ($q['API']) {
        case 'xiIsRemoteServerUp':
            $output = isRemoteServerUp() ? json_encode(array('RESULT' => API_RESULT_REMOTE_SERVER_UP)) : json_encode(array('RESULT' => API_RESULT_REMOTE_SERVER_DOWN));
            break;
        case 'xiIsLocalServerUp':
            $output = isLocalServerUp() ? json_encode(array('RESULT' => API_RESULT_LOCAL_SERVER_UP)) : json_encode(array('RESULT' => API_RESULT_LOCAL_SERVER_DOWN));
            break;
        case 'xiRunLocalQuery':
            $output = runLocalQuery($q) ? json_encode(array('RESULT' => API_RESULT_LOCAL_QUERY_SUCCESS)) : json_encode(array('RESULT' => API_RESULT_LOCAL_QUERY_FAILED));
            break;
        case 'xiUploadToRemoteServer':
            echo uploadToRemoteServer($q);
            exit;