Gitem

token2cookie2

Jul 31st, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //get
  2. <?php
  3. require 'UA.php';
  4. $UA  =  UAgent::generate( 'chrome', 'mac', array( 'en-US' ) );
  5. function get($url, $session = 0 ,$ref=0) {
  6.     global $UA;
  7.     $headers = Array(
  8.     'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg',
  9.     'Connection: Keep-Alive',
  10.     'Content-type: application/x-www-form-urlencoded;charset=UTF-8'
  11.     );
  12.     $process = curl_init($url);
  13.     curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
  14.     curl_setopt($process, CURLOPT_HEADER, 0);
  15.     if($ref)
  16.     {
  17.         curl_setopt($process, CURLOPT_REFERER, $ref);
  18.     }
  19.     curl_setopt($process, CURLOPT_USERAGENT, $UA);
  20.     curl_setopt( $process, CURLOPT_COOKIESESSION, true );
  21.     if($session){
  22.        
  23.         curl_setopt($process, CURLOPT_COOKIE, $session);
  24.     }
  25.     curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
  26.  
  27.     curl_setopt($process, CURLOPT_COOKIEFILE, realpath('cookie.txt'));
  28.     curl_setopt($process, CURLOPT_COOKIEJAR, realpath('cookie.txt'));
  29.     curl_setopt($process,CURLOPT_ENCODING , 'gzip');
  30.     curl_setopt($process, CURLOPT_TIMEOUT, 30);
  31.     curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
  32.     curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
  33.     $return = curl_exec($process);
  34.     // echo curl_getinfo($process)['url']; echo'|';
  35.     // echo curl_getinfo($process)['http_code'];
  36.     // echo '<br />';
  37.     curl_close($process);
  38.     return $return;
  39. }
  40. function explode_by($begin,$end,$data) {
  41.     $data = explode($begin,$data);
  42.     $data = explode($end,$data[1]);
  43.     return $data[0];
  44. }
  45. function convert_cookie($token){
  46.     $app = json_decode(file_get_contents('https://graph.facebook.com/app?access_token='.$token))->id;
  47.     $cookie = json_decode(file_get_contents('https://b-api.facebook.com/method/auth.getSessionForApp?format=json&access_token='.$token.'&new_app_id='.$app.'&generate_session_cookies=1'), true);
  48.     if (isset($cookie->error_code) )
  49.     {
  50.         $return['error'] = '2';
  51.         echo json_encode($return);
  52.         exit();
  53.     }
  54.     $c_user1 = $cookie['session_cookies']['0']['name'];$c_user2 = $cookie['session_cookies']['0']['value'];$xs1 = $cookie['session_cookies']['1']['name'];$xs2 = $cookie['session_cookies']['1']['value'];
  55.     return  ''.$c_user1.'='.$c_user2.'; '.$xs1.'='.$xs2.';';
  56. }
  57. function facebook_direct($url,$cookie) {
  58.     $html = get($url,$cookie);
  59.     $sd = explode_by('sd_src_no_ratelimit:"','"',$html);
  60.     $hd = explode_by('hd_src_no_ratelimit:"','"',$html);
  61.     $i=0;
  62.     if($sd) {
  63.         $jw[$i]["file"] = $sd;
  64.         $jw[$i]["label"] = "SD";
  65.         $jw[$i]["type"] = "video/mp4";
  66.         $i++;
  67.     }
  68.     if($hd) {
  69.         $jw[$i]["file"] = $hd;
  70.         $jw[$i]["label"] = "HD";
  71.         $jw[$i]["type"] = "video/mp4";
  72.     }
  73.     $html = json_encode($jw);
  74.     return $html;
  75. }
  76. $url = $_GET["url"];
  77. $login = $_GET["login"];
  78. if(preg_match("/EAA/", $login)) {
  79.     $cookie = convert_cookie($login);
  80.     echo facebook_direct($url,$cookie);
  81. } else {
  82.     echo facebook_direct($url,$login);
  83. }
  84. ?>
  85. //UA.php
  86. <?php
  87. /**
  88.  * User Agent Generator
  89.  * @version 1.0
  90.  * @link https://github.com/Dreyer/random-uagent
  91.  * @author Dreyer
  92.  */
  93.  
  94. class UAgent
  95. {
  96.     // General token that says the browser is Mozilla compatible,
  97.     // and is common to almost every browser today.
  98.     const MOZILLA = 'Mozilla/5.0 ';
  99.  
  100.     /**
  101.      * Processors by Arch.
  102.      */
  103.     public static $processors = array(
  104.         'lin' => array( 'i686', 'x86_64' ),
  105.         'mac' => array( 'Intel', 'PPC', 'U; Intel', 'U; PPC' ),
  106.         'win' => array( 'foo' )
  107.     );
  108.  
  109.     /**
  110.      * Browsers
  111.      *
  112.      * Weighting is based on market share to determine frequency.
  113.      */
  114.     public static $browsers = array(
  115.         34 => array(
  116.             89 => array( 'chrome', 'win' ),
  117.             9  => array( 'chrome', 'mac' ),
  118.             2  => array( 'chrome', 'lin' )
  119.         ),
  120.         32 => array(
  121.             100 => array( 'iexplorer', 'win' )
  122.         ),
  123.         25 => array(
  124.             83 => array( 'firefox', 'win' ),
  125.             16 => array( 'firefox', 'mac' ),
  126.             1  => array( 'firefox', 'lin' )
  127.         ),
  128.         7 => array(
  129.             95 => array( 'safari', 'mac' ),
  130.             4  => array( 'safari', 'win' ),
  131.             1  => array( 'safari', 'lin' )
  132.         ),
  133.         2 => array(
  134.             91 => array( 'opera', 'win' ),
  135.             6  => array( 'opera', 'lin' ),
  136.             3  => array( 'opera', 'mac' )
  137.         )
  138.     );
  139.  
  140.     /**
  141.      * List of Lanuge Culture Codes (ISO 639-1)
  142.      *
  143.      * @see: http://msdn.microsoft.com/en-gb/library/ee825488(v=cs.20).aspx
  144.      */
  145.     public static $languages = array(
  146.         'af-ZA', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB',
  147.         'ar-LY', 'ar-MA', 'ar-OM', 'ar-QA', 'ar-SA', 'ar-SY', 'ar-TN', 'ar-YE', 'be-BY',
  148.         'bg-BG', 'ca-ES', 'cs-CZ', 'Cy-az-AZ', 'Cy-sr-SP', 'Cy-uz-UZ', 'da-DK', 'de-AT',
  149.         'de-CH', 'de-DE', 'de-LI', 'de-LU', 'div-MV', 'el-GR', 'en-AU', 'en-BZ', 'en-CA',
  150.         'en-CB', 'en-GB', 'en-IE', 'en-JM', 'en-NZ', 'en-PH', 'en-TT', 'en-US', 'en-ZA',
  151.         'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO',  'es-CR', 'es-DO', 'es-EC', 'es-ES',
  152.         'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PR', 'es-PY', 'es-SV',
  153.         'es-UY', 'es-VE', 'et-EE', 'eu-ES', 'fa-IR', 'fi-FI', 'fo-FO', 'fr-BE', 'fr-CA',
  154.         'fr-CH', 'fr-FR', 'fr-LU', 'fr-MC', 'gl-ES', 'gu-IN', 'he-IL', 'hi-IN', 'hr-HR',
  155.         'hu-HU', 'hy-AM', 'id-ID', 'is-IS', 'it-CH', 'it-IT', 'ja-JP', 'ka-GE', 'kk-KZ',
  156.         'kn-IN', 'kok-IN', 'ko-KR', 'ky-KZ', 'Lt-az-AZ', 'lt-LT', 'Lt-sr-SP', 'Lt-uz-UZ',
  157.         'lv-LV', 'mk-MK', 'mn-MN', 'mr-IN', 'ms-BN', 'ms-MY', 'nb-NO', 'nl-BE', 'nl-NL',
  158.         'nn-NO', 'pa-IN', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sa-IN', 'sk-SK',
  159.         'sl-SI', 'sq-AL', 'sv-FI', 'sv-SE', 'sw-KE', 'syr-SY', 'ta-IN', 'te-IN', 'th-TH',
  160.         'tr-TR', 'tt-RU', 'uk-UA', 'ur-PK', 'vi-VN', 'zh-CHS', 'zh-CHT', 'zh-CN', 'zh-HK',
  161.         'zh-MO', 'zh-SG', 'zh-TW',  
  162.     );    
  163.  
  164.     /**
  165.      * Generate Device Platform
  166.      *
  167.      * Uses a random result with a weighting related to frequencies.
  168.      */
  169.     public static function generate_platform()
  170.     {
  171.         $rand = mt_rand( 1, 100 );
  172.         $sum = 0;
  173.  
  174.         foreach ( self::$browsers as $share => $freq_os )
  175.         {
  176.             $sum += $share;
  177.  
  178.             if ( $rand <= $sum )
  179.             {
  180.                 $rand = mt_rand( 1, 100 );
  181.                 $sum = 0;
  182.  
  183.                 foreach ( $freq_os as $share => $choice )
  184.                 {
  185.                     $sum += $share;
  186.  
  187.                     if ( $rand <= $sum )
  188.                     {
  189.                         return $choice;
  190.                     }
  191.                 }
  192.             }
  193.         }
  194.  
  195.         throw new Exception( 'Sum of $browsers frequency is not 100.' );
  196.     }
  197.  
  198.     private static function array_random( $array )
  199.     {
  200.         $i = array_rand( $array, 1 );
  201.  
  202.         return $array[$i];
  203.     }
  204.  
  205.     private static function get_language( $lang = array() )
  206.     {
  207.         return self::array_random( empty( $lang ) ? self::$languages : $lang );
  208.     }
  209.  
  210.     private static function get_processor( $os )
  211.     {
  212.         return self::array_random( self::$processors[$os] );
  213.     }
  214.  
  215.     private static function get_version_nt()
  216.     {  
  217.         // Win2k (5.0) to Win 7 (6.1).
  218.         return mt_rand( 5, 6 ) . '.' . mt_rand( 0, 1 );
  219.     }
  220.  
  221.     private static function get_version_osx()
  222.     {
  223.         return '10_' . mt_rand( 5, 7 ) . '_' . mt_rand( 0, 9 );
  224.     }
  225.  
  226.     private static function get_version_webkit()
  227.     {
  228.         return mt_rand( 531, 536 ) . mt_rand( 0, 2 );
  229.     }
  230.  
  231.     private static function get_verison_chrome()
  232.     {
  233.         return mt_rand( 13, 15 ) . '.0.' . mt_rand( 800, 899 ) . '.0';
  234.     }
  235.  
  236.     private static function get_version_gecko()
  237.     {
  238.         return mt_rand( 17, 31 ) . '.0';
  239.     }
  240.  
  241.     private static function get_version_ie()
  242.     {
  243.         return mt_rand( 7, 9 ) . '.0';
  244.     }
  245.  
  246.     private static function get_version_trident()
  247.     {
  248.         // IE8 (4.0) to IE11 (7.0).
  249.         return mt_rand( 4, 7 ) . '.0';
  250.     }
  251.  
  252.     private static function get_version_net()
  253.     {
  254.         // generic .NET Framework common language run time (CLR) version numbers.
  255.         $frameworks = array(
  256.             '2.0.50727',
  257.             '3.0.4506',
  258.             '3.5.30729',
  259.         );
  260.  
  261.         $rev = '.' . mt_rand( 26, 648 );
  262.  
  263.         return self::array_random( $frameworks ) . $rev;
  264.     }
  265.  
  266.     private static function get_version_safari()
  267.     {
  268.         if ( mt_rand( 0, 1 ) == 0 )
  269.         {
  270.             $ver = mt_rand( 4, 5 ) . '.' . mt_rand( 0, 1 );
  271.         }
  272.         else
  273.         {
  274.             $ver = mt_rand( 4, 5 ) . '.0.' . mt_rand( 1, 5 );
  275.         }
  276.  
  277.         return $ver;
  278.     }
  279.  
  280.     private static function get_version_opera()
  281.     {
  282.         return mt_rand( 15, 19 ) . '.0.' . mt_rand( 1147, 1284 ) . mt_rand( 49, 100 );
  283.     }
  284.  
  285.     /**
  286.      * Opera
  287.      *
  288.      * @see: http://dev.opera.com/blog/opera-user-agent-strings-opera-15-and-beyond/
  289.      */
  290.     public static function opera( $arch )
  291.     {
  292.         $opera = ' OPR/' . self::get_version_opera();
  293.  
  294.         // WebKit Rendering Engine (WebKit = Backend, Safari = Frontend).
  295.         $engine = self::get_version_webkit();
  296.         $webkit = ' AppleWebKit/' . $engine . ' (KHTML, like Gecko)';
  297.         $chrome = ' Chrome/' . self::get_verison_chrome();
  298.         $safari = ' Safari/' . $engine;
  299.  
  300.         switch ( $arch )
  301.         {
  302.             case 'lin':
  303.                 return '(X11; Linux {proc}) ' . $webkit . $chrome . $safari . $opera;
  304.             case 'mac':
  305.                 $osx = self::get_version_osx();
  306.                 return '(Macintosh; U; {proc} Mac OS X ' . $osx . ')' . $webkit . $chrome . $safari . $opera;
  307.             case 'win':
  308.                 // fall through.
  309.             default:
  310.                 $nt = self::get_version_nt();
  311.                 return '(Windows NT ' . $nt . '; WOW64) ' . $webkit . $chrome . $safari . $opera;
  312.         }
  313.     }    
  314.  
  315.     /**
  316.      * Safari
  317.      *
  318.      */
  319.     public static function safari( $arch )
  320.     {
  321.         $version = ' Version/' . self::get_version_safari();
  322.  
  323.         // WebKit Rendering Engine (WebKit = Backend, Safari = Frontend).
  324.         $engine = self::get_version_webkit();
  325.         $webkit = ' AppleWebKit/' . $engine . ' (KHTML, like Gecko)';
  326.         $safari = ' Safari/' . $engine;
  327.  
  328.         switch ( $arch )
  329.         {
  330.             case 'mac':
  331.                 $osx = self::get_version_osx();
  332.                 return '(Macintosh; U; {proc} Mac OS X ' . $osx . '; {lang})' . $webkit . $version . $safari;
  333.             case 'win':
  334.                 // fall through.
  335.             default:
  336.                 $nt = self::get_version_nt();
  337.                 return '(Windows; U; Windows NT ' . $nt . ')' . $webkit . $version . $safari;
  338.         }
  339.  
  340.     }
  341.  
  342.     /**
  343.      * Internet Explorer
  344.      *
  345.      * @see: http://msdn.microsoft.com/en-gb/library/ms537503(v=vs.85).aspx
  346.      */
  347.     public static function iexplorer( $arch )
  348.     {
  349.         $nt = self::get_version_nt();
  350.         $ie = self::get_version_ie();
  351.         $trident = self::get_version_trident();
  352.         $net = self::get_version_net();
  353.  
  354.         return '(compatible'
  355.             . '; MSIE ' . $ie
  356.             . '; Windows NT ' . $nt
  357.             . '; WOW64' // A 32-bit version of Internet Explorer is running on a 64-bit processor.
  358.             . '; Trident/' . $trident
  359.             . '; .NET CLR ' . $net
  360.             . ')';
  361.     }
  362.  
  363.     /**
  364.      * Firefox User-Agent
  365.      *
  366.      * @see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
  367.      */
  368.     public static function firefox( $arch )
  369.     {
  370.         // The release version of Gecko.
  371.         $gecko = self::get_version_gecko();
  372.  
  373.         // On desktop, the gecko trail is fixed.
  374.         $trail = '20100101';
  375.  
  376.         $release = 'rv:' . $gecko;
  377.         $version = 'Gecko/' . $trail . ' Firefox/' . $gecko;
  378.  
  379.         switch ( $arch )
  380.         {
  381.             case 'lin':
  382.                 return '(X11; Linux {proc}; ' . $release . ') ' . $version;
  383.             case 'mac':
  384.                 $osx = self::get_version_osx();
  385.                 return '(Macintosh; {proc} Mac OS X ' . $osx . '; ' . $release . ') ' . $version;
  386.             case 'win':
  387.                 // fall through.
  388.             default:
  389.                 $nt = self::get_version_nt();
  390.                 return '(Windows NT ' . $nt . '; {lang}; ' . $release . ') ' . $version;
  391.         }
  392.     }
  393.  
  394.     public static function chrome( $arch )
  395.     {
  396.         $chrome = ' Chrome/' . self::get_verison_chrome();
  397.  
  398.         // WebKit Rendering Engine (WebKit = Backend, Safari = Frontend).
  399.         $engine = self::get_version_webkit();
  400.         $webkit = ' AppleWebKit/' . $engine . ' (KHTML, like Gecko)';
  401.         $safari = ' Safari/' . $engine;
  402.  
  403.         switch ( $arch )
  404.         {
  405.             case 'lin':
  406.                 return '(X11; Linux {proc}) ' . $webkit . $chrome . $safari;
  407.             case 'mac':
  408.                 $osx = self::get_version_osx();
  409.                 return '(Macintosh; U; {proc} Mac OS X ' . $osx . ')' . $webkit . $chrome . $safari;
  410.             case 'win':
  411.                 // fall through.
  412.             default:
  413.                 $nt = self::get_version_nt();
  414.                 return '(Windows NT ' . $nt . ') ' . $webkit . $chrome . $safari;
  415.         }
  416.     }
  417.  
  418.     public static function random( $lang = array( 'en-US' ) )
  419.     {
  420.         list( $browser, $os ) = self::generate_platform();
  421.  
  422.         return self::generate( $browser, $os, $lang );
  423.     }
  424.  
  425.     public static function generate( $browser = 'chrome', $os = 'win', $lang = array( 'en-US' ) )
  426.     {
  427.         $ua = self::MOZILLA . call_user_func( 'UAgent::' . $browser, $os );
  428.  
  429.         $tags = array(
  430.             '{proc}' => self::get_processor( $os ),
  431.             '{lang}' => self::get_language( $lang ),
  432.         );
  433.  
  434.         $ua = str_replace( array_keys( $tags ), array_values( $tags ), $ua );
  435.  
  436.         return $ua;
  437.     }
  438. }
  439. ?>
Add Comment
Please, Sign In to add comment