-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
69 lines (61 loc) · 1.46 KB
/
Copy pathindex.php
File metadata and controls
69 lines (61 loc) · 1.46 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
<?php
/**
*
* This is a php-ssl scanning agent API
*
* It takes json input, scans for :
* - hostname : ip or hostname
* - ports : ports to scan in order
*
*
* Response will be standard http codes:
*
* - 200 OK : Certificate fetched ok
*
* For 200 it will contain also data json field:
* - data:
* - hostname:
* - cert
*/
// api
try {
# functions and classes loader
require(dirname(__FILE__).'/functions/autoload.php');
# version
require(dirname(__FILE__).'/version.php');
# allowed hosts
require(dirname(__FILE__).'/config.php');
# register permitted hosts
$API->register_hosts ($permitted_direct_hosts);
$API->register_hosts_proxied ($permitted_proxied_hosts);
$API->register_trusted_proxies ($permitted_trusted_proxies);
$API->allow_private_ips (@$scan_private_ips);
# validate requesting host
$API->validate_requesting_host ();
# execute
$API->scan ();
# print
$API_result->set_success (true);
# version
$API_result->add_version ($version);
# print result
print $API_result->show ($API->get_result());
} catch (Exception $e) {
// set code
if ($API_result->get_code()===200) {
$API_result->set_code (500);
}
// set result
$err_result = [
"success" => false,
"code" => $API_result->get_code (),
"error" => $e->getMessage ()
];
// add ip if API class is correctly loaded
if (isset($API)) {
$err_result['ip'] = $API->resolve_ip ($API->hostname);
}
// output result
echo $API_result->show ($err_result);
}
exit();