PluginProbe ʕ •ᴥ•ʔ
Wordfence Security – Firewall, Malware Scan, and Login Security / 2.0.5
Wordfence Security – Firewall, Malware Scan, and Login Security v2.0.5
8.2.2 8.2.1 8.2.0 3.7.1 3.7.2 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.9.1 4.0.1 4.0.2 4.0.3 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.1 5.1.2 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.1 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.1 5.3.10 5.3.11 5.3.12 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.3.8 5.3.9 6.0.1 6.0.10 6.0.11 6.0.12 6.0.14 6.0.15 6.0.16 6.0.17 6.0.18 6.0.19 6.0.2 6.0.20 6.0.21 6.0.22 6.0.23 6.0.24 6.0.25 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.1 6.1.10 6.1.11 6.1.12 6.1.14 6.1.15 6.1.16 6.1.17 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 6.1.9 6.2.0 6.2.1 6.2.10 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.2.8 6.2.9 6.3.0 6.3.1 6.3.10 6.3.11 6.3.12 6.3.14 6.3.15 6.3.16 6.3.17 6.3.18 6.3.19 6.3.2 6.3.20 6.3.21 6.3.22 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.1 7.1.10 7.1.11 7.1.12 7.1.14 7.1.15 7.1.16 7.1.17 7.1.18 7.1.19 7.1.2 7.1.20 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.10.0 7.10.1 7.10.2 7.10.3 7.10.4 7.10.5 7.10.6 7.10.7 7.11.0 7.11.1 7.11.2 7.11.3 7.11.4 7.11.5 7.11.6 7.11.7 7.2.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.4.0 7.4.1 7.4.10 7.4.11 7.4.12 7.4.14 7.4.2 7.4.3 trunk 7.4.4 1.1 7.4.5 1.2 7.4.6 1.3 7.4.7 1.3.1 7.4.8 1.3.2 7.4.9 1.3.3 7.5.0 1.4.2 7.5.1 1.4.3 7.5.10 1.4.4 7.5.11 1.4.5 7.5.2 1.4.6 7.5.3 1.4.7 7.5.4 1.4.8 7.5.5 1.5.1 7.5.6 1.5.2 7.5.7 1.5.3 7.5.8 1.5.4 7.5.9 1.5.5 7.6.0 1.5.6 7.6.1 2.0.1 7.6.2 2.0.2 7.7.0 2.0.3 7.7.1 2.0.5 7.8.0 2.0.6 7.8.1 2.0.7 7.8.2 2.1.0 7.9.0 2.1.1 7.9.1 2.1.2 7.9.2 2.1.3 7.9.3 2.1.4 8.0.0 2.1.5 8.0.1 3.0.2 8.0.2 3.0.3 8.0.3 3.0.4 8.0.4 3.0.5 8.0.5 3.0.6 8.1.0 3.0.7 8.1.1 3.0.8 8.1.2 3.0.9 8.1.3 3.1.0 8.1.4 3.1.1 v1.4.1 3.1.2 3.1.4 3.1.6 3.2.1 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.1 3.4.4 3.4.5 3.5.1 3.5.2 3.6.1 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
wordfence / lib / wordfenceHash.php
wordfence / lib Last commit date
Diff 14 years ago .htaccess 14 years ago Diff.php 14 years ago IPTraf.php 14 years ago diffResult.php 14 years ago dropAll.php 14 years ago email_genericAlert.php 14 years ago email_newIssues.php 14 years ago email_unlockRequest.php 14 years ago menu_activity.php 14 years ago menu_blockedIPs.php 14 years ago menu_config.php 14 years ago menu_options.php 14 years ago menu_scan.php 14 years ago sysinfo.php 14 years ago viewFullActivityLog.php 14 years ago wf503.php 14 years ago wfAPI.php 14 years ago wfAction.php 14 years ago wfBrowscap.php 14 years ago wfBrowscapCache.php 14 years ago wfConfig.php 14 years ago wfCrawl.php 14 years ago wfDB.php 14 years ago wfDict.php 14 years ago wfIssues.php 14 years ago wfLockedOut.php 14 years ago wfLog.php 14 years ago wfModTracker.php 14 years ago wfRate.php 14 years ago wfScanEngine.php 14 years ago wfSchema.php 14 years ago wfUnlockMsg.php 14 years ago wfUtils.php 14 years ago wfViewResult.php 14 years ago wordfenceClass.php 14 years ago wordfenceConstants.php 14 years ago wordfenceHash.php 14 years ago wordfenceScanner.php 14 years ago wordfenceURLHoover.php 14 years ago
wordfenceHash.php
124 lines
1 <?php
2 require_once('wordfenceClass.php');
3 class wordfenceHash {
4 private $whitespace = array("\n","\r","\t"," ");
5 public $totalData = 0; //To do a sanity check, don't use 'du' because it gets sparse files wrong and reports blocks used on disk. Use : find . -type f -ls | awk '{total += $7} END {print total}'
6 public $totalFiles = 0;
7 public $totalDirs = 0;
8 public $linesOfPHP = 0;
9 public $linesOfJCH = 0; //lines of HTML, CSS and javascript
10 public $striplen = 0;
11 private $hashes = array();
12 public function __construct($striplen){
13 $this->striplen = $striplen;
14 }
15 public function hashPaths($path, $only = array()){ //base path and 'only' is a list of files and dirs in the bast that are the only ones that should be processed. Everything else in base is ignored. If only is empty then everything is processed.
16 if($path[strlen($path) - 1] != '/'){
17 $path .= '/';
18 }
19 if(! is_readable($path)){
20 wordfence::status(1, 'error', "Could not read directory $path to do sacn.");
21 exit();
22 }
23 $files = scandir($path);
24 foreach($files as $file){
25 if(sizeof($only) > 0 && (! in_array($file, $only))){
26 continue;
27 }
28 $file = $path . $file;
29 wordfence::status(2, 'info', "Hashing item in base dir: $file");
30 $this->_dirHash($file);
31 }
32 return $this->hashes;
33 }
34 private function _dirHash($path){
35 if(substr($path, -3, 3) == '/..' || substr($path, -2, 2) == '/.'){
36 return;
37 }
38 if(! is_readable($path)){ return; } //Applies to files and dirs
39 if(is_dir($path)){
40 $this->totalDirs++;
41 if($path[strlen($path) - 1] != '/'){
42 $path .= '/';
43 }
44 $cont = scandir($path);
45 for($i = 0; $i < sizeof($cont); $i++){
46 if($cont[$i] == '.' || $cont[$i] == '..'){ continue; }
47 $file = $path . $cont[$i];
48 if(is_file($file)){
49 $this->processFile($file);
50 } else if(is_dir($file)) {
51 $this->_dirHash($file);
52 }
53 }
54 } else {
55 if(is_file($path)){
56 $this->processFile($path);
57 }
58 }
59 }
60 private function processFile($file){
61 if(@filesize($file) > WORDFENCE_MAX_FILE_SIZE_TO_PROCESS){
62 wordfence::status(2, 'info', "Skipping file larger than 50 megs: $file");
63 return;
64 }
65 if(function_exists('memory_get_usage')){
66 wordfence::status(2, 'info', "Scanning: $file (Mem:" . sprintf('%.1f', memory_get_usage(true) / (1024 * 1024)) . "M)");
67 } else {
68 wordfence::status(2, 'info', "Scanning: $file");
69 }
70 $wfHash = $this->wfHash($file, true);
71 if($wfHash){
72 $this->hashes[substr($file, $this->striplen)] = $wfHash;
73 //Now that we know we can open the file, lets update stats
74 if(preg_match('/\.(?:js|html|htm|css)$/i', $file)){
75 $this->linesOfJCH += sizeof(file($file));
76 } else if(preg_match('/\.php$/i', $file)){
77 $this->linesOfPHP += sizeof(file($file));
78 }
79 $this->totalFiles++;
80 $this->totalData += filesize($file);
81 } else {
82 wordfence::status(2, 'error', "Could not gen hash for file: $file");
83 }
84 }
85 public function wfHash($file, $binary = true){
86 $md5 = @md5_file($file, $binary);
87 if(! $md5){ return false; }
88 //$sha = @hash_file('sha256', $file, $binary);
89 //if(! $sha){ return false; }
90 $fp = @fopen($file, "rb");
91 if(! $fp){
92 return false;
93 }
94 $ctx = hash_init('sha256');
95 while (!feof($fp)) {
96 hash_update($ctx, str_replace($this->whitespace,"",fread($fp, 65536)));
97 }
98 $shac = hash_final($ctx, $binary);
99 //Taking out $sha for now because we don't use it on the scanning server side
100 return array($md5, '', $shac, filesize($file) );
101 }
102 public static function bin2hex($hashes){
103 function wf_func1($elem){
104 return array(
105 bin2hex($elem[0]),
106 bin2hex($elem[1]),
107 bin2hex($elem[2])
108 );
109 }
110 return array_map('wf_func1', $hashes);
111 }
112 public static function hex2bin($hashes){
113 function wf_func2($elem){
114 return array(
115 pack('H*', $elem[0]),
116 pack('H*', $elem[1]),
117 pack('H*', $elem[2])
118 );
119 }
120 return array_map('wf_func2', $hashes);
121 }
122 }
123 ?>
124