|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: lenon |
|
5
|
|
|
* Date: 23/04/16 |
|
6
|
|
|
* Time: 01:43. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Aszone\SearchHacking\Engines; |
|
10
|
|
|
|
|
11
|
|
|
use Aszone\SearchHacking\Utils; |
|
12
|
|
|
|
|
13
|
|
|
class Yandex extends Engine |
|
14
|
|
|
{ |
|
15
|
|
|
public function run() |
|
16
|
|
|
{ |
|
17
|
|
|
$exit = false; |
|
18
|
|
|
$count = 0; |
|
19
|
|
|
$numPaginator = 0; |
|
20
|
|
|
$countProxyVirgin = rand(0, count($this->listOfVirginProxies) - 1); |
|
21
|
|
|
$resultFinal = array(); |
|
22
|
|
|
|
|
23
|
|
|
$countProxyFail = array(); |
|
24
|
|
|
|
|
25
|
|
|
while ($exit == false) { |
|
|
|
|
|
|
26
|
|
|
if ($count != 0) { |
|
27
|
|
|
$numPaginator = $count; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
$urlOfSearch = 'https://yandex.ru/search/?text='.urlencode($this->commandData['dork']).'&p='.$numPaginator.'&lr=10136'; |
|
31
|
|
|
|
|
32
|
|
|
$this->output('Page '.$count."\n"); |
|
33
|
|
|
|
|
34
|
|
View Code Duplication |
if ($this->commandData['virginProxies']) { |
|
|
|
|
|
|
35
|
|
|
$body = Utils::getBodyByVirginProxies($urlOfSearch, $this->listOfVirginProxies[$countProxyVirgin], $this->proxy); |
|
36
|
|
|
|
|
37
|
|
|
//Check if next group of return data or not |
|
38
|
|
|
$arrLinks = array(); |
|
39
|
|
|
if (!$this->checkCaptcha($body) and $body != 'repeat') { |
|
|
|
|
|
|
40
|
|
|
$arrLinks = Utils::getLinks($body); |
|
41
|
|
|
} else { |
|
42
|
|
|
--$count; |
|
43
|
|
|
//Count the proxys with fail and all fail proxys, finish action |
|
44
|
|
|
$countProxyFail[$countProxyVirgin] = $this->listOfVirginProxies[$countProxyVirgin]; |
|
45
|
|
|
$this->output("You has a problem with proxy, probaly you estress the engenier ...\n"); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
//Check if next virgin proxy or repeat of 0 |
|
49
|
|
|
if ($countProxyVirgin == count($this->listOfVirginProxies) - 1) { |
|
50
|
|
|
$countProxyVirgin = 0; |
|
51
|
|
|
} else { |
|
52
|
|
|
++$countProxyVirgin; |
|
53
|
|
|
} |
|
54
|
|
|
} else { |
|
55
|
|
|
$body = Utils::getBody($urlOfSearch, $this->proxy); |
|
56
|
|
|
|
|
57
|
|
|
$arrLinks = Utils::getLinks($body); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$this->output("\n".$urlOfSearch."\n"); |
|
61
|
|
|
|
|
62
|
|
|
$results = Utils::sanitazeLinks($arrLinks); |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
View Code Duplication |
if (((count($results) == 0 && $body != 'repeat') && !$this->checkCaptcha($body)) |
|
|
|
|
|
|
65
|
|
|
|| (count($countProxyFail) == count($this->listOfVirginProxies))) { |
|
66
|
|
|
$exit = true; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$resultFinal = array_merge($resultFinal, $results); |
|
70
|
|
|
|
|
71
|
|
|
++$count; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
return $resultFinal; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
private function checkCaptcha($body) |
|
78
|
|
|
{ |
|
79
|
|
|
return preg_match("/https:\/\/yandex.ru\/showcaptcha\?/", $body, $matches, PREG_OFFSET_CAPTURE); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
When comparing two booleans, it is generally considered safer to use the strict comparison operator.