├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── composer.json ├── phpunit.xml.dist ├── resources ├── AllGoogleSites.ini ├── Blacklist.ini ├── Errors.ini ├── SitesProxysFree.ini └── shells.ini ├── src ├── Engines │ ├── Bing.php │ ├── DuckDuckGo.php │ ├── Engine.php │ ├── EngineInterface.php │ ├── Google.php │ ├── Yahoo.php │ └── Yandex.php ├── SearchHacking.php └── Utils.php └── tests ├── Engines ├── BingTest.php ├── DuckDuckGoTest.php ├── GoogleTest.php ├── YahooTest.php └── YandexTest.php └── SearchHackingTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | vendor/ 3 | 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | sudo: false 4 | 5 | php: 6 | - 5.6 7 | - 7 8 | - hhvm 9 | 10 | matrix: 11 | allow_failures: 12 | - php: hhvm 13 | 14 | before_script: 15 | - composer self-update 16 | - composer install --prefer-source 17 | 18 | notifications: 19 | email: false 20 | 21 | script: 22 | - ./vendor/bin/phpunit 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 ASZone 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/aszone/search-hacking.svg?branch=master)](https://travis-ci.org/aszone/search-hacking) 2 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/aszone/search-hacking/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/aszone/search-hacking/?branch=master) 3 | 4 | # Search Hacking 5 | 6 | > Search Hacking is a collection of libraries for search results based in dork 7 | 8 | ## Instalation 9 | 10 | The recommended way to install PHP Avenger is through 11 | [Composer](http://getcomposer.org). 12 | 13 | ```bash 14 | # Install Composer 15 | curl -sS https://getcomposer.org/installer | php 16 | ``` 17 | 18 | Next, run the Composer command to install the latest beta version of Search Hacking: 19 | 20 | ```bash 21 | php composer.phar require aszone/search-hacking 22 | ``` 23 | ## Basic Usage 24 | 25 | > Use command for init process, result will print in monitor and save in txt on folder results. 26 | 27 | ```bash 28 | 29 | 30 | ``` 31 | 32 | ## Help and docs 33 | * [Documentation](http://phpavenger.aszone.com.br). 34 | * [Examples](http://phpavenger.aszone.com.br/examples). 35 | * [Videos](http://youtube.com/aszone). 36 | * [Steakoverflow](http://phpavenger.aszone.com.br). 37 | 38 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aszone/search-hacking", 3 | "type": "library", 4 | "description": "AsZone Component - Search Hacking", 5 | "keywords": ["search","dork","search hacking","hacker","php","hacking","google hacking","ghdb","bing","yandex","yahoo","dukedukego"], 6 | "homepage": "http://www.lenonleite.com.br", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Lenon Leite", 11 | "email": "lenonleite@gmail.com.br", 12 | "homepage": "http://www.lenonleite.com.br" 13 | }, 14 | { 15 | "name": "ASZone", 16 | "homepage": "https://www.aszone.com.br" 17 | } 18 | 19 | ], 20 | "require": { 21 | "php": ">=5.6", 22 | "guzzlehttp/guzzle":"~5.3", 23 | "symfony/dom-crawler":"~2.8", 24 | "symfony/css-selector":"2.8", 25 | "aszone/fakeheaders": "~0.1", 26 | "aszone/proxyavenger": "~0.1" 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "Aszone\\SearchHacking\\": "src/", 31 | "Aszone\\SearchHacking\\Test\\": "tests/" 32 | } 33 | }, 34 | "require-dev": { 35 | "phpunit/phpunit": "^5.6" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | tests/ 17 | 18 | 19 | 20 | 21 | 22 | src/ 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /resources/AllGoogleSites.ini: -------------------------------------------------------------------------------- 1 | [google] 2 | 1=www.google.com 3 | 2=www.google.ac 4 | 3=www.google.com.om 5 | 4=www.google.ad 6 | 5=www.google.ae 7 | 6=www.google.com.af 8 | 7=www.google.com.ag 9 | 8=www.google.com.ai 10 | 9=www.google.am 11 | 10=www.google.it.ao 12 | 11=www.google.com.ar 13 | 12=www.google.cat 14 | 13=www.google.as 15 | 14=www.google.at 16 | 15=www.google.com.au 17 | 16=www.google.az 18 | 17=www.google.ba 19 | 18=www.google.com.bd 20 | 19=www.google.be 21 | 20=www.google.bf 22 | 21=www.google.bg 23 | 22=www.google.com.bh 24 | 23=www.google.bi 25 | 24=www.google.bj 26 | 25=www.google.com.bn 27 | 26=www.google.com.bo 28 | 27=www.google.com.br 29 | 28=www.google.bs 30 | 29=www.google.co.bw 31 | 30=www.google.com.by 32 | 31=www.google.com.bz 33 | 32=www.google.ca 34 | 33=www.google.com.kh 35 | 34=www.google.cc 36 | 35=www.google.cd 37 | 36=www.google.cf 38 | 37=www.google.cn 39 | 38=www.google.com.co 40 | 39=www.google.co.nz 41 | 40=www.google.cg 42 | 41=www.google.ch 43 | 42=www.google.ci 44 | 43=www.google.co.ck 45 | 44=www.google.cl 46 | 45=www.google.cm 47 | 46=www.google.co.cr 48 | 47=www.google.com.cu 49 | 48=www.google.cv 50 | 49=www.google.cz 51 | 50=www.google.de 52 | 51=www.google.nu 53 | 52=www.google.dj 54 | 53=www.google.dk 55 | 54=www.google.dm 56 | 55=www.google.com.do 57 | 56=www.google.dz 58 | 57=www.google.no 59 | 58=www.google.com.ec 60 | 59=www.google.ee 61 | 60=www.google.com.eg 62 | 61=www.google.es 63 | 62=www.google.com.et 64 | 63=www.google.com.np 65 | 64=www.google.fi 66 | 65=www.google.com.fj 67 | 66=www.google.fm 68 | 67=www.google.fr 69 | 68=www.google.ga 70 | 69=www.google.nl 71 | 70=www.google.ge 72 | 71=www.google.gf 73 | 72=www.google.gg 74 | 73=www.google.com.gh 75 | 74=www.google.com.gi 76 | 75=www.google.nr 77 | 76=www.google.gl 78 | 77=www.google.gm 79 | 78=www.google.gp 80 | 79=www.google.gr 81 | 80=www.google.com.gt 82 | 81=www.google.com.ni 83 | 82=www.google.gy 84 | 83=www.google.com.hk 85 | 84=www.google.hn 86 | 85=www.google.hr 87 | 86=www.google.ht 88 | 87=www.google.com.ng 89 | 88=www.google.hu 90 | 89=www.google.co.id 91 | 90=www.google.iq 92 | 91=www.google.ie 93 | 92=www.google.co.il 94 | 92=www.google.com.nf 95 | 93=www.google.im 96 | 94=www.google.co.in 97 | 95=www.google.io 98 | 96=www.google.is 99 | 97=www.google.it 100 | 98=www.google.ne 101 | 99=www.google.je 102 | 100=www.google.com.jm 103 | 101=www.google.jo 104 | 102=www.google.co.jp 105 | 103=www.google.co.ke 106 | 104=www.google.com.na 107 | 105=www.google.ki 108 | 106=www.google.kg 109 | 107=www.google.co.kr 110 | 108=www.google.com.kw 111 | 109=www.google.kz 112 | 110=www.google.co.mz 113 | 111=www.google.la 114 | 112=www.google.com.lb 115 | 113=www.google.com.lc 116 | 114=www.google.li 117 | 115=www.google.lk 118 | 116=www.google.com.my 119 | 117=www.google.co.ls 120 | 118=www.google.lt 121 | 119=www.google.lu 122 | 120=www.google.lv 123 | 121=www.google.com.ly 124 | 122=www.google.com.mx 125 | 123=www.google.co.ma 126 | 124=www.google.md 127 | 125=www.google.me 128 | 126=www.google.mg 129 | 127=www.google.mk 130 | 128=www.google.mw 131 | 129=www.google.ml 132 | 130=www.google.mn 133 | 131=www.google.ms 134 | 132=www.google.com.mt 135 | 133=www.google.mu 136 | 134=www.google.mv 137 | 135=www.google.com.pa 138 | 136=www.google.com.pe 139 | 137=www.google.com.ph 140 | 138=www.google.com.pk 141 | 139=www.google.pn 142 | 140=www.google.com.pr 143 | 141=www.google.ps 144 | 142=www.google.pt 145 | 143=www.google.com.py 146 | 144=www.google.com.qa 147 | 145=www.google.ro 148 | 146=www.google.rs 149 | 147=www.google.ru 150 | 148=www.google.rw 151 | 149=www.google.com.sa 152 | 150=www.google.com.sb 153 | 151=www.google.sc 154 | 152=www.google.se 155 | 153=www.google.com.sg 156 | 154=www.google.sh 157 | 155=www.google.si 158 | 156=www.google.sk 159 | 157=www.google.com.sl 160 | 158=www.google.sn 161 | 159=www.google.sm 162 | 160=www.google.so 163 | 161=www.google.st 164 | 162=www.google.com.sv 165 | 163=www.google.td 166 | 164=www.google.tg 167 | 165=www.google.co.th 168 | 166=www.google.tk 169 | 167=www.google.tl 170 | 168=www.google.tm 171 | 169=www.google.to 172 | 170=www.google.com.tn 173 | 171=www.google.com.tr 174 | 172=www.google.tt 175 | 173=www.google.com.tw 176 | 174=www.google.co.tz 177 | 175=www.google.com.ua 178 | 176=www.google.co.ug 179 | 177=www.google.co.uk 180 | 178=www.google.us 181 | 179=www.google.com.uy 182 | 180=www.google.co.uz 183 | 181=www.google.com.vc 184 | 182=www.google.co.ve 185 | 183=www.google.vg 186 | 184=www.google.co.vi 187 | 185=www.google.com.vn 188 | 186=www.google.vu 189 | 187=www.google.ws 190 | 188=www.google.co.za 191 | 189=www.google.co.zm 192 | 190=www.google.co.zw -------------------------------------------------------------------------------- /resources/Blacklist.ini: -------------------------------------------------------------------------------- 1 | [blacklisst] 2 | 153=softwarepublico.gov.br 3 | 154=svn.softwarepublico.gov.br 4 | 155=dev.softwarepublico.gov.br 5 | 156=repositorio.interlegis.gov.br 6 | 157=ftp.bahiatursa.ba.gov.br 7 | 158=versionamento.gov.br 8 | 169=softwarepublico.gov.br 9 | -------------------------------------------------------------------------------- /resources/Errors.ini: -------------------------------------------------------------------------------- 1 | [mysql] 2 | 1=mysql_ 3 | 2=You have an error in your SQL syntax 4 | 3=Warning: mysql_ 5 | 4=function.mysql 6 | 5=MySQL result index 7 | 6=syntax 8 | 7=MySQL 9 | 8=mysqli.query 10 | 9=num_rows 11 | 10=mysql error: 12 | 11=Error Executing Database Query 13 | 12=SQL 14 | 13=Fatal error 15 | 14=Warning 16 | 15=Invalid Querystring 17 | 16=Input string was not in a correct format 18 | 17=GetArray() 19 | 18=FetchRow() 20 | 19=MySQL Error 21 | 20=MySQL ODBC 22 | 21=MySQL Driver 23 | 22=supplied argument is not a valid MySQL result resource 24 | 23=on MySQL result index 25 | 26 | [mariadb] 27 | 1=MariaDB server version for the right syntax 28 | 2=You have an error in your SQL syntax 29 | 3=SQL 30 | 4=Fatal error 31 | 5=Warning 32 | 6=Invalid Querystring 33 | 7=Input string was not in a correct format 34 | 8=GetArray() 35 | 9=FetchRow() 36 | 37 | [sql-server] 38 | 1=Microsoft JET Database 39 | 2=ODBC Microsoft Access Driver 40 | 3=500 - Internal server error 41 | 4=Microsoft OLE DB Provider 42 | 5=Unclosed quotes 43 | 6=ADODB.Command 44 | 7=ADODB.Field error 45 | 8=Microsoft VBScript 46 | 9=Microsoft OLE DB Provider for SQL Server 47 | 10=Unclosed quotation mark 48 | 11=SQLServer JDBC Driver 49 | 12=Error Executing Database Query 50 | 13=SQL 51 | 14=Fatal error 52 | 15=Warning 53 | 16=Invalid Querystring 54 | 17=Input string was not in a correct format 55 | 18=GetArray() 56 | 19=FetchRow() 57 | 20=ADODB.Recordset 58 | 21=500 - Internal server error 59 | 22=Microsoft OLE DB Provider 60 | 23=Unclosed quotes 61 | 24=Active Server Pages error 62 | 25=OLE/DB provider returned message 63 | 26=OLE DB Provider for ODBC 64 | 27=error '800a0d5d 65 | 28=error '800a000d 66 | 29=Unclosed quotation mark after the character string 67 | 30=[Microsoft][SQL Server Native Client 11.0][SQL Server] 68 | 31=Warning: odbc_ 69 | 70 | [oracle] 71 | 1=Microsoft OLE DB Provider for Oracle 72 | 2=ORA-01756 73 | 3=ORA- 74 | 4=SQL 75 | 5=Fatal error 76 | 6=Warning 77 | 7=Invalid Querystring 78 | 8=Input string was not in a correct format 79 | 9=GetArray() 80 | 10=FetchRow() 81 | 11=Oracle ODBC 82 | 12=Oracle Error 83 | 13=Oracle Driver 84 | 14=Oracle DB2 85 | 15=error ORA- 86 | 16=SQL command not properly ende 87 | 88 | [postgresql] 89 | 1=pg_ 90 | 2=Warning: pg_ 91 | 3=PostgreSql Error: 92 | 4=function.pg 93 | 5=SQL 94 | 6=Fatal error 95 | 7=Warning 96 | 8=Invalid Querystring 97 | 9=Input string was not in a correct format 98 | 10=GetArray() 99 | 11=FetchRow() 100 | 101 | [php] 102 | 1=Warning: include 103 | 2=Fatal error: include 104 | 3=Warning: require 105 | 4=Fatal error: require 106 | 5=ADODB_Exception 107 | 108 | [asp] 109 | 1=Version Information: Microsoft .NET Framework 110 | 2=Server.Execute Error 111 | 112 | [zend-framework] 113 | 1=mail.transport.username 114 | 2=mail.transport.password 115 | 3=db.params.username 116 | 4=db.params.password 117 | 5=db.params.dbname' 118 | 119 | [wordpress] 120 | 1=define('DB_NAME' 121 | 2=define('DB_USER' 122 | 3=define('DB_PASSWORD' 123 | 4=define('DB_HOST' -------------------------------------------------------------------------------- /resources/SitesProxysFree.ini: -------------------------------------------------------------------------------- 1 | [proxys] 2 | 1=http://www.freeproxylists.net/ 3 | 2=http://www.google-proxy.net/ -------------------------------------------------------------------------------- /resources/shells.ini: -------------------------------------------------------------------------------- 1 | [shell] 2 | 1=c99shell 3 | 2=C99Shell v 4 | 3=
5 | 4=awen asp.net webshell 7 | 6="; 8 | 7=JSP Backdoor Reverse Shell 9 | 8=Simple CGI backdoor by DK 10 | 9=execute command: 11 | 10=Execute Shell Command 12 | 11=r57shell 13 | 12=r57Shell 14 | 13=heroes1412 15 | 14=MyShell 16 | 15=PHP Shell 17 | 16=PHPShell 18 | 17=REMVIEW TOOLS 19 | 18=<title>iTSecTeam 20 | 19=JSP Backdoor Reverse Shell 21 | 20=* ernealizm * 22 | 21=JSP Shell 23 | 22=KNULL Shell 24 | 23=.+- WSO.+ 25 | 24=SST Sheller ! 26 | 25=SyRiAn Sh3ll 27 | 26=<title>Mini Php Shell 28 | 27=<title>ASPX Shell 29 | 28=ZoRBaCK Connect 30 | 29=.+Ani-Shell.+ 31 | 30=Stored Procedure Execute 32 | 31=:: www.h4ckcity.org :: Coded By 2MzRp & LocalMan :: 33 | 32=PhpShell 2.0 34 | 33=.+NTDaddy.+ 35 | 34=PHP-Terminal -------------------------------------------------------------------------------- /src/Engines/Bing.php: -------------------------------------------------------------------------------- 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 Bing 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 | $totalOutProxy = 5; 23 | $countOutProxy = 0; 24 | 25 | while ($exit == false) { 26 | if ($count != 0) { 27 | $numPaginator = 10 * $count; 28 | } 29 | 30 | $urlOfSearch = 'http://www.bing.com/search?q='.urlencode($this->commandData['dork']).'&filt=rf&first='.$numPaginator; 31 | 32 | $this->output('Page '.$count."\n"); 33 | 34 | if ($this->commandData['virginProxies']) { 35 | $this->output('*'.$countProxyVirgin.'*'); 36 | 37 | $this->output('&'.$this->listOfVirginProxies[$countProxyVirgin].'&'); 38 | 39 | $body = Utils::getBodyByVirginProxies($urlOfSearch, $this->listOfVirginProxies[$countProxyVirgin], $this->proxy); 40 | 41 | $arrLinks = Utils::getLinks($body); 42 | 43 | //Check if next virgin proxy or repeat of 0 44 | if ($countProxyVirgin == count($this->listOfVirginProxies) - 1) { 45 | $countProxyVirgin = 0; 46 | } else { 47 | ++$countProxyVirgin; 48 | } 49 | } else { 50 | $body = Utils::getBody($urlOfSearch, $this->proxy); 51 | 52 | $arrLinks = Utils::getLinks($body); 53 | 54 | ++$countOutProxy; 55 | } 56 | 57 | $this->output("\n".$urlOfSearch."\n"); 58 | 59 | $results = Utils::sanitazeLinks($arrLinks); 60 | 61 | if ((count($results) == 0 && $body != 'repeat') || ($countOutProxy == $totalOutProxy)) { 62 | $exit = true; 63 | } 64 | 65 | $resultFinal = array_merge($resultFinal, $results); 66 | ++$count; 67 | } 68 | 69 | return $resultFinal; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Engines/DuckDuckGo.php: -------------------------------------------------------------------------------- 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 DuckDuckGo 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 | $countError = 0; 23 | 24 | $numberForUrl = $this->getNumberForUrl(); 25 | 26 | while ($exit == false) { 27 | switch ($count) { 28 | case 0: 29 | $numPaginator = 0; 30 | break; 31 | case 1: 32 | $numPaginator = 30; 33 | break; 34 | case 2: 35 | $numPaginator = 80; 36 | break; 37 | case 3: 38 | $numPaginator = 130; 39 | break; 40 | case 4: 41 | $numPaginator = 180; 42 | break; 43 | default: 44 | $numPaginator = 230; 45 | break; 46 | 47 | } 48 | 49 | $urlOfSearch = 'https://duckduckgo.com/d.js?q='.urlencode($this->commandData['dork']).'&ct=BR&ss_mkt=us&sp=1&l=wt-wt&vqd='.$numberForUrl.'&p=1&s='.$numPaginator; 50 | 51 | $this->output('Page '.$count."\n"); 52 | 53 | if ($this->commandData['virginProxies']) { 54 | $body = Utils::getBodyByVirginProxies($urlOfSearch, $this->listOfVirginProxies[$countProxyVirgin], $this->proxy); 55 | 56 | $arrLinks = $this->getLinks($body); 57 | 58 | if ($this->checkReturnError($body)) { 59 | $this->output("You has a problem with proxy, probaly you stress the engenier ...\n"); 60 | --$count; 61 | ++$countError; 62 | if ($countError == 4) { 63 | $exit = true; 64 | } 65 | } else { 66 | $countError = 0; 67 | } 68 | 69 | //Check if next virgin proxy or repeat of 0 70 | if ($countProxyVirgin == count($this->listOfVirginProxies) - 1) { 71 | $countProxyVirgin = 0; 72 | } else { 73 | ++$countProxyVirgin; 74 | } 75 | } else { 76 | $body = Utils::getBody($urlOfSearch, $this->proxy); 77 | 78 | $arrLinks = $this->getLinks($body); 79 | } 80 | 81 | $this->output("\n".$urlOfSearch."\n"); 82 | 83 | $results = $this->sanitazeLinks($arrLinks); 84 | 85 | if ((count($results) == 0 and $body != 'repeat')) { 86 | $exit = true; 87 | } 88 | 89 | $resultFinal = array_merge($resultFinal, $results); 90 | 91 | ++$count; 92 | } 93 | 94 | return $resultFinal; 95 | } 96 | 97 | private function getNumberForUrl() 98 | { 99 | $firstUrlOfSearch = 'https://duckduckgo.com/?q='.urlencode($this->commandData['dork']).'&search_plus_one=form&ia=web'; 100 | $body = Utils::getBody($firstUrlOfSearch, $this->proxy); 101 | 102 | $validXmlrpc = preg_match("/','.*&vqd=(.*?)&/", $body, $matches, PREG_OFFSET_CAPTURE); 103 | 104 | if (isset($matches[1][0])) { 105 | return $matches[1][0]; 106 | } 107 | 108 | return false; 109 | } 110 | 111 | public function sanitazeLinks($links = array()) 112 | { 113 | $hrefs = array(); 114 | 115 | if (!empty($links)) { 116 | foreach ($links as $keyLink => $valueLink) { 117 | $validResultOfBlackList = Utils::checkBlacklist($valueLink); 118 | if (!$validResultOfBlackList and $valueLink) { 119 | $hrefs[] = $valueLink; 120 | } 121 | } 122 | 123 | $hrefs = array_unique($hrefs); 124 | } 125 | 126 | return $hrefs; 127 | } 128 | 129 | public function getLinks($body) 130 | { 131 | $result = []; 132 | $validXmlrpc = preg_match("/DDG\.Data\.languages\.resultLanguages', (.*?)\);if/", $body, $matches, PREG_OFFSET_CAPTURE); 133 | 134 | if (isset($matches[1][0])) { 135 | $resultJson = json_decode($matches[1][0]); 136 | foreach ($resultJson as $resultsByLanguage) { 137 | foreach ($resultsByLanguage as $resultByLanguage) { 138 | $result[] = $resultByLanguage; 139 | } 140 | } 141 | } 142 | 143 | return $result; 144 | } 145 | 146 | public function checkReturnError($body) 147 | { 148 | $valid = preg_match("/Dvar q=window\.location\.href\.indexOf/", $body, $matches, PREG_OFFSET_CAPTURE); 149 | 150 | if ($valid) { 151 | return true; 152 | } 153 | 154 | return false; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/Engines/Engine.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace Aszone\SearchHacking\Engines; 4 | 5 | abstract class Engine implements EngineInterface 6 | { 7 | protected $error; 8 | protected $listOfVirginProxies; 9 | protected $usingVirginProxies; 10 | protected $tor; 11 | protected $commandData; 12 | protected $proxies; 13 | protected $proxy; 14 | 15 | private $defaultCommandData = [ 16 | 'dork' => false, 17 | 'pl' => false, 18 | 'tor' => false, 19 | 'virginProxies' => false, 20 | 'proxyOfSites' => false, 21 | ]; 22 | 23 | public function __construct(array $data) 24 | { 25 | $this->commandData = array_merge($this->defaultCommandData, $data); 26 | 27 | if ($this->hasProxy()) { 28 | $this->proxies = new Proxies(); 29 | } 30 | 31 | if ($this->commandData['tor']) { 32 | $this->proxy = $this->proxies->getTor(); 33 | } 34 | 35 | if ($this->commandData['proxyOfSites']) { 36 | $this->proxy = $this->proxies->getProxyOfSites(); 37 | } 38 | 39 | if ($this->commandData['virginProxies']) { 40 | $this->listOfVirginProxies = $this->proxies->getVirginSiteProxies(); 41 | $this->usingVirginProxies = true; 42 | } 43 | } 44 | 45 | public function validate() 46 | { 47 | if ($this->commandData['virginProxies'] && !$this->proxies->checkVirginProxiesExist()) { 48 | $error['type'] = 'vp'; 49 | $error['result'] = 'There is no list of botnets Virgin Proxy'; 50 | 51 | $this->error = $error; 52 | 53 | return false; 54 | } 55 | 56 | return true; 57 | } 58 | 59 | public function hasProxy() 60 | { 61 | return $this->commandData['virginProxies'] 62 | || $this->commandData['proxyOfSites'] 63 | || $this->commandData['tor']; 64 | } 65 | 66 | public function getError() 67 | { 68 | return $this->error; 69 | } 70 | 71 | public function output($value) 72 | { 73 | echo $value; 74 | } 75 | 76 | public function run() 77 | { 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Engines/EngineInterface.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace Aszone\SearchHacking\Engines; 4 | 5 | interface EngineInterface 6 | { 7 | public function run(); 8 | 9 | public function getError(); 10 | 11 | public function validate(); 12 | 13 | public function output($value); 14 | } 15 | -------------------------------------------------------------------------------- /src/Engines/Google.php: -------------------------------------------------------------------------------- 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 | 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 | 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 | -------------------------------------------------------------------------------- /src/Engines/Yahoo.php: -------------------------------------------------------------------------------- 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 Yahoo 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 | while ($exit == false) { 24 | if ($count != 0) { 25 | $numPaginator = (100 * $count) + 1; 26 | } 27 | 28 | $urlOfSearch = 'https://search.yahoo.com/search?p='.urlencode($this->commandData['dork']).'&fr=yfp-t-707&pz=100&b='.$numPaginator; 29 | 30 | $this->output('Page '.$count."\n"); 31 | 32 | if ($this->commandData['virginProxies']) { 33 | $body = Utils::getBodyByVirginProxies($urlOfSearch, $this->listOfVirginProxies[$countProxyVirgin], $this->proxy); 34 | 35 | $arrLinks = Utils::getLinks($body); 36 | 37 | if ($countProxyVirgin == count($this->listOfVirginProxies) - 1) { 38 | $countProxyVirgin = 0; 39 | } else { 40 | ++$countProxyVirgin; 41 | } 42 | } else { 43 | $body = Utils::getBody($urlOfSearch, $this->proxy); 44 | 45 | $arrLinks = Utils::getLinks($body); 46 | } 47 | 48 | $this->output("\n".$urlOfSearch."\n"); 49 | 50 | $results = Utils::sanitazeLinks($arrLinks); 51 | 52 | if ((count($results) == 0 and $body != 'repeat')) { 53 | $exit = true; 54 | } 55 | 56 | $resultFinal = array_merge($resultFinal, $results); 57 | 58 | ++$count; 59 | } 60 | 61 | return $resultFinal; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Engines/Yandex.php: -------------------------------------------------------------------------------- 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 | 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 | 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 | -------------------------------------------------------------------------------- /src/SearchHacking.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace Aszone\SearchHacking; 4 | 5 | use Aszone\SearchHacking\Engines\EngineInterface; 6 | 7 | class SearchHacking 8 | { 9 | private $engine; 10 | 11 | public function __construct(EngineInterface $engine, $proxyPath = null) 12 | { 13 | $this->engine = $engine; 14 | 15 | if (file_exists($proxyPath)) { 16 | unlink($this->proxyPath); 17 | } 18 | } 19 | 20 | public function run() 21 | { 22 | if ($this->engine->getError()) { 23 | return $this->engine; 24 | } 25 | 26 | return $this->engine->run(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Utils.php: -------------------------------------------------------------------------------- 1 | <?php 2 | /** 3 | * Created by PhpStorm. 4 | * User: lenon 5 | * Date: 03/04/16 6 | * Time: 19:24. 7 | */ 8 | 9 | namespace Aszone\SearchHacking; 10 | 11 | use Symfony\Component\DomCrawler\Crawler; 12 | use Aszone\FakeHeaders\FakeHeaders; 13 | use GuzzleHttp\Client; 14 | 15 | class Utils 16 | { 17 | public static function sanitazeLinks($links = array()) 18 | { 19 | $hrefs = array(); 20 | 21 | if (!empty($links)) { 22 | foreach ($links as $keyLink => $valueLink) { 23 | $url = static::clearLink($valueLink->getAttribute('href')); 24 | $validResultOfBlackList = static::checkBlacklist($url); 25 | 26 | if (!$validResultOfBlackList and $url) { 27 | $hrefs[] = $url; 28 | } 29 | } 30 | 31 | $hrefs = array_unique($hrefs); 32 | } 33 | 34 | return $hrefs; 35 | } 36 | 37 | public static function checkBlacklist($url = '') 38 | { 39 | if (!empty($url)) { 40 | $validXmlrpc = preg_match("/(https?\:\/\/|^)(.+?)\//", $url, $matches, PREG_OFFSET_CAPTURE); 41 | $url = ''; 42 | 43 | if (isset($matches[2][0])) { 44 | $url = $matches[2][0]; 45 | } 46 | 47 | $ini_blakclist = parse_ini_file(__DIR__.'/../resources/Blacklist.ini'); 48 | 49 | $key = array_search($url, $ini_blakclist); 50 | 51 | if ($key != false) { 52 | return true; 53 | } 54 | } 55 | 56 | return false; 57 | } 58 | 59 | public static function clearLink($url = '') 60 | { 61 | if (!empty($url)) { 62 | $validXmlrpc = preg_match('/search%3Fq%3Dcache:.+?:(.+?)%252B/', $url, $matches, PREG_OFFSET_CAPTURE); 63 | 64 | if (isset($matches[1][0])) { 65 | return $matches[1][0]; 66 | } 67 | 68 | $validXmlrpc = preg_match("/search\?q=cache:.+?:(.+?)\+/", $url, $matches, PREG_OFFSET_CAPTURE); 69 | 70 | if (isset($matches[1][0])) { 71 | return $matches[1][0]; 72 | } 73 | 74 | $validXmlrpc = preg_match('/url=(.*?)&tld/', $url, $matches, PREG_OFFSET_CAPTURE); 75 | 76 | if (isset($matches[1][0])) { 77 | return urldecode($matches[1][0]); 78 | } 79 | 80 | //Msn Bing 81 | $validXmlrpc = preg_match("/^((http|https):\/\/|www).+?\/?ld=.+?\&u=(.+?)\n/", $url, $matches, PREG_OFFSET_CAPTURE); 82 | 83 | if (isset($matches[1][0])) { 84 | return urldecode($matches[1][0]); 85 | } 86 | 87 | $validXmlrpc = preg_match("/^((http|https):\/\/|www)(.+?)\//", $url, $matches, PREG_OFFSET_CAPTURE); 88 | 89 | if (isset($matches[0][0])) { 90 | $check[] = strpos($url, 'www.blogger.com'); 91 | $check[] = strpos($url, 'youtube.com'); 92 | $check[] = strpos($url, '.google.'); 93 | $check[] = strpos($url, 'yandex.ru'); 94 | $check[] = strpos($url, 'microsoft.com'); 95 | $check[] = strpos($url, 'microsofttranslator.com'); 96 | $check[] = strpos($url, '.yahoo.com'); 97 | $check[] = strpos($url, 'yahoo.uservoice.com'); 98 | $check[] = strpos($url, 'www.mozilla.org'); 99 | $check[] = strpos($url, 'www.facebook.com'); 100 | $check[] = strpos($url, 'go.mail.ru'); 101 | $check[] = strpos($url, '/search/srpcache?p='); 102 | $check[] = strpos($url, 'flickr.com'); 103 | 104 | $tmp = array_filter($check); 105 | 106 | if (empty($tmp)) { 107 | return trim($url); 108 | } 109 | } 110 | } 111 | 112 | return false; 113 | } 114 | 115 | public static function getLinks($body) 116 | { 117 | $crawler = new Crawler($body); 118 | 119 | return $crawler->filter('a'); 120 | } 121 | 122 | public static function getBody($urlOfSearch, $proxy) 123 | { 124 | $header = new FakeHeaders(); 125 | $valid = true; 126 | 127 | try { 128 | $client = new Client([ 129 | 'defaults' => [ 130 | 'headers' => ['User-Agent' => $header->getUserAgent()], 131 | 'proxy' => $proxy, 132 | 'timeout' => 60, 133 | ], 134 | ]); 135 | 136 | return $client->get($urlOfSearch)->getBody()->getContents(); 137 | } catch (\Exception $e) { 138 | $message = 'ERROR : '.$e->getMessage()."\n"; 139 | 140 | if ($proxy == false) { 141 | $message .= "Your ip is blocked, we are using proxy at now...\n"; 142 | } 143 | 144 | return $message; 145 | } 146 | 147 | return false; 148 | } 149 | 150 | public static function getBodyByVirginProxies($urlOfSearch, $urlProxie, $proxy) 151 | { 152 | $header = new FakeHeaders(); 153 | 154 | echo 'Proxy : '.$urlProxie."\n"; 155 | 156 | $dataToPost = ['body' => ['url' => $urlOfSearch]]; 157 | 158 | $valid = true; 159 | while ($valid == true) { 160 | try { 161 | $client = new Client([ 162 | 'defaults' => [ 163 | 'headers' => ['User-Agent' => $header->getUserAgent()], 164 | 'proxy' => $proxy, 165 | 'timeout' => 60, 166 | ], 167 | ]); 168 | 169 | $res = $client->post($urlProxie, $dataToPost); 170 | $body = $res->getBody()->getContents(); 171 | 172 | //check if change new tor ip 173 | $valid = false; 174 | } catch (\Exception $e) { 175 | echo 'ERROR : '.$e->getMessage()."\n"; 176 | if ($proxy == false) { 177 | echo "This ip of virgin proxy is blocked, we are using proxy at now...\n"; 178 | } 179 | 180 | return 'repeat'; 181 | } 182 | } 183 | 184 | return $body; 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /tests/Engines/BingTest.php: -------------------------------------------------------------------------------- 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\Test; 10 | 11 | use Aszone\SearchHacking\Engines\Bing; 12 | 13 | class BingTest extends \PHPUnit_Framework_TestCase 14 | { 15 | private $instance; 16 | 17 | public function setUp() 18 | { 19 | $this->instance = new Bing(['dork' => 'site:com.ar ext:sql password']); 20 | } 21 | 22 | public function testRun() 23 | { 24 | $links = $this->instance->run(); 25 | 26 | $this->assertTrue($this->hasArrayOfLinks($links)); 27 | } 28 | 29 | private function hasArrayOfLinks($links) 30 | { 31 | return (bool) array_filter($links, function ($link) { 32 | return strpos($link, 'http') === 0; 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/Engines/DuckDuckGoTest.php: -------------------------------------------------------------------------------- 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\Test; 10 | 11 | use Aszone\SearchHacking\Engines\DuckDuckGo; 12 | 13 | class DuckDuckGoTest extends \PHPUnit_Framework_TestCase 14 | { 15 | private $instance; 16 | 17 | public function setUp() 18 | { 19 | $this->instance = new DuckDuckGo(['dork' => 'site:com.ar ext:sql password']); 20 | } 21 | 22 | public function testRun() 23 | { 24 | $links = $this->instance->run(); 25 | 26 | $this->assertTrue($this->hasArrayOfLinks($links)); 27 | } 28 | 29 | private function hasArrayOfLinks($links) 30 | { 31 | return (bool) array_filter($links, function ($link) { 32 | return strpos($link, 'http') === 0; 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/Engines/GoogleTest.php: -------------------------------------------------------------------------------- 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\Test; 10 | 11 | use Aszone\SearchHacking\Engines\Google; 12 | 13 | class GoogleTest extends \PHPUnit_Framework_TestCase 14 | { 15 | private $instance; 16 | 17 | public function setUp() 18 | { 19 | $this->instance = new Google(['dork' => 'site:com.ar ext:sql password']); 20 | } 21 | 22 | public function testRun() 23 | { 24 | $links = $this->instance->run(); 25 | 26 | $this->assertTrue($this->hasArrayOfLinks($links)); 27 | } 28 | 29 | private function hasArrayOfLinks($links) 30 | { 31 | return (bool) array_filter($links, function ($link) { 32 | return strpos($link, 'http') === 0; 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/Engines/YahooTest.php: -------------------------------------------------------------------------------- 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\Test; 10 | 11 | use Aszone\SearchHacking\Engines\Yahoo; 12 | 13 | class YahooTest extends \PHPUnit_Framework_TestCase 14 | { 15 | private $instance; 16 | 17 | public function setUp() 18 | { 19 | $this->instance = new Yahoo(['dork' => 'site:com.ar ext:sql password']); 20 | } 21 | 22 | public function testRun() 23 | { 24 | $links = $this->instance->run(); 25 | 26 | $this->assertTrue($this->hasArrayOfLinks($links)); 27 | } 28 | 29 | private function hasArrayOfLinks($links) 30 | { 31 | return (bool) array_filter($links, function ($link) { 32 | return strpos($link, 'http') === 0; 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/Engines/YandexTest.php: -------------------------------------------------------------------------------- 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\Test; 10 | 11 | use Aszone\SearchHacking\Engines\Yandex; 12 | 13 | class YandexTest extends \PHPUnit_Framework_TestCase 14 | { 15 | private $instance; 16 | 17 | public function setUp() 18 | { 19 | $this->instance = new Yandex(['dork' => 'site:com.ar ext:sql password']); 20 | } 21 | 22 | public function testRun() 23 | { 24 | $links = $this->instance->run(); 25 | 26 | $this->assertTrue($this->hasArrayOfLinks($links)); 27 | } 28 | 29 | private function hasArrayOfLinks($links) 30 | { 31 | return (bool) array_filter($links, function ($link) { 32 | return strpos($link, 'http') === 0; 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/SearchHackingTest.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | namespace Aszone\SearchHacking\Test; 4 | 5 | use Aszone\SearchHacking\Engines\EngineInterface; 6 | use Aszone\SearchHacking\SearchHacking; 7 | 8 | class SearchHackingTest extends \PHPUnit_Framework_TestCase 9 | { 10 | private $instance; 11 | 12 | private $engine; 13 | 14 | public function setUp() 15 | { 16 | $this->engine = $this->createMock(EngineInterface::class); 17 | $this->instance = new SearchHacking($this->engine); 18 | } 19 | 20 | public function testRun() 21 | { 22 | $this->engine->method('run') 23 | ->willReturn(true); 24 | 25 | $result = $this->instance->run(); 26 | 27 | $this->assertTrue($result); 28 | } 29 | } 30 | --------------------------------------------------------------------------------