-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrap.class.php
More file actions
122 lines (108 loc) · 3.62 KB
/
Scrap.class.php
File metadata and controls
122 lines (108 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
class Scrap
{
public $emailsRecords;
public $urlRecords;
public $ajaxRecords;
public $imgsPhpRecords;
public $sqliRecords;
//busca imagenes cargadas con php
protected function parsearImgByPhp($source)
{
return strpos($source, ".php");
}
protected function parsearAjaxRequest($source)
{
return substr_count($source, "ajax");
}
protected function getEmails($source)
{
$regex = '/[a-z\d._%+-]+@[a-z\d.-]+\.[a-z]{2,4}\b/i';
preg_match_all($regex, $source, $emails);
return $emails;
}
public function getWebSource($url)
{
$source = @file_get_contents($url);
if (!empty($source)) {
$this->emailsRecords = $this->parsearEmail($source);
$this->urlRecords = $this->parsearUrls($source);
$this->ajaxRecords = $this->parsearAjaxRequest($source);
}
}
protected function getLinks($url)
{
$regex = '<a\s[^>*href=(\"??)()[^\" >]*?)\\1[^>]*>(.*)<\/a>';
preg_match_all("/$regex/siU", $content, $matches);
}
public function fuerzaBruta()
{
/*************************************/
$charSet = utf8_decode('abcdefghijklmnopqrstuvwxyz');
$maxLength = strlen($charSet);
$cantCaracteres = $size = strlen($charSet);
$base = array();
$counter = 0;
$baseSize = 1;
$libNum = 1;
$tr = true;
$combinations = 0;
for ($i = 1; $i <= $maxLength; $i++) {
$combinations += pow($size, $i);
}
flush();
while ($baseSize <= $maxLength && $tr) {
set_time_limit(0);
for ($i = 0; $i < $cantCaracteres && $tr; $i++) {
$base[0] = $i;
$cadena = '';
for ($j = $baseSize - 1; $j >= 0; $j--)
if (!empty($charSet[$base[$j]]))
$cadena .= $charSet[$base[$j]];
$archivo = 'diccionarios/lib' . $libNum . '.txt';
$file = fopen($archivo, 'a+');
fwrite($file, $cadena . "\n");
fclose($file);
if (strlen($cadena) == 10)
$tr = false;
# die("strlen de cadena es igual a 5");
echo $cadena . "<br/>";
#echo "tamaño: ".filesize($archivo)."<br/>";
clearstatcache();
if (file_exists($archivo) && filesize($archivo) > (1024 * 1024)) {
$libNum++;
}
//$destino = "http://www.".$cadena.".com.ar";
//$source = @file_get_contents($destino);
/*
if(!empty($source))
{
$this->emailsRecords = $this->parisearEmail($source);
$this->urlRecords = $this->parsearUrls($source);
$this->ajaxRecords = $this->parsearAjaxRequest($source);
}
*/
flush();
ob_flush();
}
for ($i = 0; $i < $baseSize; $i++) {
if ($base[$i] == $size - 1)
$counter++;
else
break;
}
if ($counter == $baseSize) {
for ($i = 0; $i <= $baseSize; $i++) {
$base[$i] = 0;
}
$baseSize = count($base);
} else {
$base[$counter]++;
for ($i = 0; $i < $counter; $i++) {
$base[$i] = 0;
}
}
$counter = 0;
}
}
}