-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsucuri.php
58 lines (48 loc) · 1.32 KB
/
sucuri.php
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
<?php
/* -----------------------------------
Script: Sucuri SiteCheck Scan
Author: Jeffry Ghazally
Usage: Sucuri <host>
Desc: Uses the website sitecheck.sucuri.net
to determine if a site is compromised or clean and returns a status
via Growl.
Updated: 14/6/12
----------------------------------- */
//Pull hostname off of the command line
$q=$argv[1];
//Retrieve status from isup.me
$url = "http://sitecheck.sucuri.net/scanner/?scan={$q}&serialized&alfred";
$timeout = 10;
//Request Curl
$crl = curl_init();
curl_setopt ($crl, CURLOPT_URL, $url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$def = curl_exec($crl);
curl_close ($crl);
$def = unserialize($def);
$output = "Site: {$q} \r\n";
$warnings = '';
$status = '';
if ( empty($def) ) {
echo "{$q } : Invalid web site provided.";
die;
}
// Loop through the array and find all warn
foreach ( (array)$def as $node ) {
if ( isset($node['WARN']) ) {
foreach ((array)$node['WARN'] as $warn) {
// loop through each warn array
foreach ((array)$warn as $w) {
$warnings[] = $w;
}
}
}
}
if ( !empty($warnings) ) {
$status = "Sucuri Found Errors : \r\n";
$warnings = implode(" \n\r ", $warnings);
} else {
$status = 'Your interwebs is secure';
}
echo $output . $status . $warnings;