Skip to content

Instantly share code, notes, and snippets.

@tansautn
Last active June 9, 2020 09:07
Show Gist options
  • Save tansautn/8ebbcae35944479b54e4d38bd55d21b3 to your computer and use it in GitHub Desktop.
Save tansautn/8ebbcae35944479b54e4d38bd55d21b3 to your computer and use it in GitHub Desktop.
SPYPRO Bot Fake Referer
{
"name": "zuko/fkr",
"type": "project",
"require": {
"symfony/panther": "^1.0@dev"
},
"authors": [
{
"name": "Zuko",
"email": "tansautn@gmail.com"
}
],
"minimum-stability": "dev"
}
<?php
/**
* --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- *
* @PROJECT : Magebay Spytool
* @AUTHOR : Zuko
* @COPYRIGHT : © 2019 Magebay - Magento Ext Provider
* @LINK : https://www.magebay.com/
* @FILE : fake-referer.php
* @CREATED : 17:03 , 11/May/2019
* --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- *
**/
use Symfony\Component\Panther\ProcessManager\ChromeManager;
include __DIR__.'/vendor/autoload.php';
//error_reporting( E_ERROR );
date_default_timezone_set('UTC');
/* Config */
$baseUrlApi = 'https://tools.spypro.io/api/';
$gateUrl = 'https://tools.spypro.io/gate?uri=';
//$baseUrlApi = 'https://zuko.pro/fapi/api/';
$pageNum = @$argv[1] ?: 1;
$day = @$argv[2] ?: 3;
if($pageNum === 'reset'){
$incrementValue = -1;
echo 'SET INCREMENT = ' . ($incrementValue + 1) . PHP_EOL;
file_put_contents('fake-referer-auto-increment.txt',$incrementValue + 1);
exit();
}
$limitnf = 100;
$twoDaysAgo = date('Y-m-d', strtotime('-' . $day . ' days'));
$incrementValue = file_get_contents('fake-referer-auto-increment.txt') === '' ? 1 : (int)file_get_contents('fake-referer-auto-increment.txt');
$pageNum += $incrementValue;
$url_pages = "{$baseUrlApi}posts?fbads=1&created_at=gt:{$twoDaysAgo}&limit={$limitnf}&page={$pageNum}";
//$url_pages = $baseUrlApi . 'posts?id=1870224';
echo $url_pages . PHP_EOL;
$postData = file_get_contents($url_pages);
$postData = json_decode($postData,true);
if(count($postData['data'])) {
$incrementValue = file_get_contents('fake-referer-auto-increment.txt') === '' ? 1 : (int)file_get_contents('fake-referer-auto-increment.txt');
echo 'SET INCREMENT = ' . ($incrementValue + 1) . PHP_EOL;
file_put_contents('fake-referer-auto-increment.txt',$incrementValue + 1);
$postData = $postData['data'];
$spentTime = microtime(true);
$iCount = 0;
$cOptions = [];
foreach ($postData as $item) {
if($item['status'] == 1 || $item['status'] == 2){
/* $url = $item['org_url_post'];
echo $url . PHP_EOL;*/
echo $item['post_website'] . PHP_EOL;
echo $item['org_url_post'] . PHP_EOL;
echo $item['id'] . PHP_EOL;
$url = $item['post_website'];
$isBitly = false;
if($url && $url !== '' && $url !== 'NoURL'){
try {
init:
echo 'Fake REFERER & Accessing : ' . $url . PHP_EOL;
$client = \Symfony\Component\Panther\Client::createChromeClient(null, null, $cOptions);
getData:
$beforeStart = microtime(true);
$execTime = null;
try{
$crawler = $client->request('GET', $gateUrl . urlencode($url));
$result = $client->getInternalResponse();
}catch (\Exception $e){
if($e instanceof \RuntimeException && strpos($e->getMessage(),'The port') !== false){
$port = str_between($e->getMessage(),'The port','is already in use');
++$port;
if($client instanceof ChromeManager){
$client->quit();
}
$cOptions = ['port' => $port];
$client = \Symfony\Component\Panther\Client::createChromeClient(null,null,$cOptions);
echo $e->getMessage().PHP_EOL;
goto getData;
}elseif(strpos($e->getMessage(),'Operation timed out after') !== false){
echo 'Timeout , continue next loop'. PHP_EOL;
}elseif(strpos($e->getMessage(),'session deleted') !== false){
echo 'session crash , continue next loop'. PHP_EOL;
}else{
echo get_class($e) . PHP_EOL;
}
if($client instanceof ChromeManager){
$client->quit();
}
continue;
}
$execTime = microtime(true) - $beforeStart;
if($result){
$iCount++;
echo sprintf('OK - HTTP CODE : %s - Content : %s%s', $result->getStatusCode(), $result->getHeader('content_type'), PHP_EOL);
echo sprintf('Total Time : %s%s%s', $execTime, PHP_EOL, PHP_EOL);
}
$client->quit();
if($isBitly){
continue;
}
}
catch (\Exception $e) {
continue;
}
}
if(strpos($item['org_url_post'],'bit.ly') !== false) {
$url = $item['org_url_post'];
$isBitly = true;
goto init;
}
}
}
$spentTime = microtime(true) - $spentTime;
echo PHP_EOL;
echo '------- REPORT -------' . PHP_EOL;
echo 'Accessed : ' . $iCount . ' urls' . PHP_EOL;
echo 'Spent : ' . $spentTime . ' secs' . PHP_EOL;
}
function str_between($haystack,$before,$after){
$str = explode($before,$haystack)[1];
$str = explode($after,$str)[0];
return trim($str);
}
function curlGetData($url,$returnInfo = false){
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_REFERER, 'https://tools.spypro.io');
curl_setopt($ch, CURLOPT_URL, $url);
$_body = curl_exec($ch);
$_info = curl_getinfo($ch);
/* if($_info['total_time'] < 1){
$fileName = preg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $url);
$fileName = preg_replace("([\.]{2,})", '', $fileName) . '.html';
file_put_contents('debug-logs/' . $fileName,$_body);
echo 'Debug html : https://zuko.pro/fapi/debug-logs/' . $fileName . PHP_EOL;
}*/
// $_error = curl_error($ch);
$lastUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$_info['EFFECTIVE_URL'] = $lastUrl;
curl_close($ch);
return $returnInfo ? $_info : $_body;
}
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2019-07-25T08:38:19.9686963</Date>
<Author>ZUKO-WORKPC\Zuko</Author>
<URI>\Zuko\php fake-referer</URI>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Repetition>
<Interval>PT15M</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
<Enabled>true</Enabled>
<Delay>PT10M</Delay>
</LogonTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-3742515154-3125140647-4188878469-1001</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>false</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>E:\Github\spytools\fkr\run.bat</Command>
<WorkingDirectory>E:\Github\spytools\fkr\</WorkingDirectory>
</Exec>
</Actions>
</Task>
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2019-07-29T13:43:50.546999</Date>
<Author>ZUKO-WORKPC\Zuko</Author>
<URI>\Zuko\reset increment</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2019-07-29T14:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-3742515154-3125140647-4188878469-1001</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>false</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>php</Command>
<Arguments>fake-referer.php reset</Arguments>
<WorkingDirectory>E:\Github\spytools\fkr</WorkingDirectory>
</Exec>
</Actions>
</Task>
@ECHO OFF
start /B php.exe fake-referer.php 1 5 >> logfile1.txt
start /B php.exe fake-referer.php 2 5 >> logfile2.txt
start /B php.exe fake-referer.php 3 5 >> logfile3.txt
start /B php.exe fake-referer.php 4 5 >> logfile4.txt
start /B php.exe fake-referer.php 5 5 >> logfile5.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment