Guest User

trilogin.php

a guest
Feb 12th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <?php
  2.    
  3.     // Three menggunakan enkripsi tripledes - ECB
  4.     // Fungsi cryptECB diambil dari sini http://www.isapp.it/en/menu-en/31-tips-a-tricks/php/118-php-how-to-encrypt-text-in-triple-des-ecb.html
  5.     function cryptECB($crypt, $key) {
  6.          $iv_size = mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_ECB);
  7.          $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
  8.         // crypting  
  9.         $cryptText = mcrypt_encrypt(MCRYPT_3DES, $key, $crypt, MCRYPT_MODE_ECB, $iv);
  10.          
  11.         return $cryptText;
  12.     }
  13.    
  14.     // inisialisasi data
  15.     $key = "c5ec069257f724be";
  16.     $msisdn = "";
  17.     $password = "";
  18.  
  19.     if (empty($msisdn) && empty($password)) {
  20.       echo 'MSISDN dan PASSWORD harus diisi!';
  21.       exit(0);
  22.     }
  23.  
  24.     // ada string replacement juga pada saat enkripsi data
  25.     $search_replace = array(
  26.                         '+' => '-',
  27.                         '/' => '_',
  28.                       );
  29.  
  30.     // replace msisdn dan password yang sudah dienkripsi lalu hasilnya diencode juga ke base 64
  31.     $crypt_msisdn = str_replace(
  32.                       array_keys($search_replace),
  33.                       array_values($search_replace),
  34.                       base64_encode(cryptECB($msisdn, $key))
  35.                     );
  36.  
  37.     $crypt_password = str_replace(
  38.                       array_keys($search_replace),
  39.                       array_values($search_replace),
  40.                       base64_encode(cryptECB($password, $key))
  41.                     );
  42.  
  43.     // url sign in
  44.     $url = 'http://180.214.232.99/pro/sso/signin';
  45.  
  46.     // json data untuk dipost
  47.     $build_post = array(
  48.       'model' => 'sdk',
  49.       't_width' => '220',
  50.       't_height' => '220',
  51.       'msisdn' => $crypt_msisdn,
  52.       'user_agent' => 'Mozilla',
  53.       'brand' => 'generic',
  54.       'secret_key' => '52fb2db0ea6625ff',
  55.       'password' => $crypt_password,
  56.       'version' => '1.6.0'
  57.     );
  58.     $json_data = json_encode($build_post);
  59.     $fields = array(
  60.         'jsondata' => urlencode($json_data),
  61.       );
  62.  
  63.     $fields_string = '';
  64.     foreach($fields as $key=>$value) {
  65.         $fields_string .= $key.'='.$value.'&';
  66.     }
  67.     rtrim($fields_string, '&');
  68.  
  69.     // buka koneksi
  70.     $ch = curl_init();
  71.  
  72.     curl_setopt($ch,CURLOPT_URL, $url);
  73.     curl_setopt($ch,CURLOPT_POST, count($fields));
  74.     curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
  75.  
  76.     $result = curl_exec($ch);
  77.  
  78.     curl_close($ch);
  79. ?>
Add Comment
Please, Sign In to add comment