Issues (39)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Engines/Google.php (6 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
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']) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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') {
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as and instead of && is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
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);
0 ignored issues
show
It seems like $arrLinks can also be of type object<Symfony\Component\DomCrawler\Crawler>; however, Aszone\SearchHacking\Utils::sanitazeLinks() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
69
70 View Code Duplication
            if (((count($results) == 0 && $body != 'repeat') && !$this->checkCaptcha($body))
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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;
0 ignored issues
show
$valid is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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