|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Aszone\SearchHacking\Engines; |
|
4
|
|
|
|
|
5
|
|
|
use Aszone\SearchHacking\Utils; |
|
6
|
|
|
use Aszone\FakeHeaders\FakeHeaders; |
|
7
|
|
|
use GuzzleHttp\Client; |
|
8
|
|
|
|
|
9
|
|
|
class Google extends Engine |
|
10
|
|
|
{ |
|
11
|
|
|
private $siteGoogle; |
|
12
|
|
|
|
|
13
|
|
|
private function loadGoogleSite() |
|
14
|
|
|
{ |
|
15
|
|
|
$ini_google_sites = parse_ini_file(__DIR__.'/../../resources/AllGoogleSites.ini'); |
|
16
|
|
|
$this->siteGoogle = $ini_google_sites[array_rand($ini_google_sites)]; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function run() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->loadGoogleSite(); |
|
22
|
|
|
|
|
23
|
|
|
$exit = false; |
|
24
|
|
|
$count = 0; |
|
25
|
|
|
$paginator = ''; |
|
26
|
|
|
$countProxyVirgin = rand(0, count($this->listOfVirginProxies) - 1); |
|
27
|
|
|
$resultFinal = array(); |
|
28
|
|
|
$countProxyFail = array(); |
|
29
|
|
|
|
|
30
|
|
|
while ($exit == false) { |
|
|
|
|
|
|
31
|
|
|
if ($count != 0) { |
|
32
|
|
|
$numPaginator = 100 * $count; |
|
33
|
|
|
$paginator = '&start='.$numPaginator; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
$urlOfSearch = 'https://'.$this->siteGoogle.'/search?q='.urlencode($this->commandData['dork']).'&num=100&btnG=Search&pws=1'.$paginator; |
|
37
|
|
|
|
|
38
|
|
|
$this->output('Page '.$count."\n"); |
|
39
|
|
|
|
|
40
|
|
View Code Duplication |
if ($this->commandData['virginProxies']) { |
|
|
|
|
|
|
41
|
|
|
$body = Utils::getBodyByVirginProxies($urlOfSearch, $this->listOfVirginProxies[$countProxyVirgin], $this->proxy); |
|
42
|
|
|
|
|
43
|
|
|
//Check if exist captcha |
|
44
|
|
|
//Check if next group of return data or not |
|
45
|
|
|
$arrLinks = array(); |
|
46
|
|
|
if (!$this->checkCaptcha($body) and $body != 'repeat') { |
|
|
|
|
|
|
47
|
|
|
$arrLinks = Utils::getLinks($body); |
|
48
|
|
|
} else { |
|
49
|
|
|
--$count; |
|
50
|
|
|
$countProxyFail[$countProxyVirgin] = $this->listOfVirginProxies[$countProxyVirgin]; |
|
51
|
|
|
|
|
52
|
|
|
$this->output("You has a problem with proxy, probaly you estress the engenier ...\n"); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
//Check if next virgin proxy or repeat of 0 |
|
56
|
|
|
if ($countProxyVirgin == count($this->listOfVirginProxies) - 1) { |
|
57
|
|
|
$countProxyVirgin = 0; |
|
58
|
|
|
} else { |
|
59
|
|
|
++$countProxyVirgin; |
|
60
|
|
|
} |
|
61
|
|
|
} else { |
|
62
|
|
|
$body = $this->getBody($urlOfSearch); |
|
63
|
|
|
$arrLinks = Utils::getLinks($body); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$this->output("\n".$urlOfSearch."\n"); |
|
67
|
|
|
|
|
68
|
|
|
$results = Utils::sanitazeLinks($arrLinks); |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
|
View Code Duplication |
if (((count($results) == 0 && $body != 'repeat') && !$this->checkCaptcha($body)) |
|
|
|
|
|
|
71
|
|
|
|| (count($countProxyFail) == count($this->listOfVirginProxies))) { |
|
72
|
|
|
$exit = true; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
$resultFinal = array_merge($resultFinal, $results); |
|
76
|
|
|
|
|
77
|
|
|
++$count; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $resultFinal; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
private function getBody($urlOfSearch) |
|
84
|
|
|
{ |
|
85
|
|
|
$header = new FakeHeaders(); |
|
86
|
|
|
$valid = true; |
|
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
try { |
|
89
|
|
|
$client = new Client([ |
|
90
|
|
|
'defaults' => [ |
|
91
|
|
|
'headers' => ['User-Agent' => $header->getUserAgent()], |
|
92
|
|
|
'proxy' => $this->proxy, |
|
93
|
|
|
'timeout' => 60, |
|
94
|
|
|
], |
|
95
|
|
|
]); |
|
96
|
|
|
|
|
97
|
|
|
return $client->get($urlOfSearch)->getBody()->getContents(); |
|
98
|
|
|
} catch (\Exception $e) { |
|
99
|
|
|
$this->output('ERROR : '.$e->getMessage()."\n"); |
|
100
|
|
|
|
|
101
|
|
|
if ($this->proxy == false) { |
|
102
|
|
|
$this->output("Your ip is blocked, we are using proxy at now...\n"); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
return false; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
private function checkCaptcha($body) |
|
110
|
|
|
{ |
|
111
|
|
|
return preg_match('/CaptchaRedirect/', $body, $matches, PREG_OFFSET_CAPTURE); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
When comparing two booleans, it is generally considered safer to use the strict comparison operator.