-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
74 lines (57 loc) · 2.13 KB
/
index.php
File metadata and controls
74 lines (57 loc) · 2.13 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
<?php
session_start();
include "functions.php";
if(empty($_SERVER['HTTPS'])) {
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Origin: *");
header("Strict-Transport-Security: max-age=31536000; includeSubDomains");
$ip = $_SERVER['REMOTE_ADDR'];
$input = $_GET['input'];
$ipinfo_token = ""; // Your ipinfo.io API token
$abuseipdb_token = ""; // Your abuseipdb.com token
$threatfox_token = ""; // Your threatfox.abuse.ch token
$ipdata_token = ""; // Your ipdata.co token
$allowed_ip = in_array($_SERVER['REMOTE_ADDR'], ['0.0.0.0']); // Whitelisted IP's for the IP API calls
// ip return
if (!isset($input) || $input == "index.php") {
header('Content-Type: text/plain;');
echo $ip;
}
else {
// /host
if($input == "host") {
header('Content-Type: text/plain;');
echo $ip . ' | ' . gethostbyaddr($ip);
}
// /json
else if($input == "json") {
header('Content-Type: application/json; charset=utf-8');
$ip_array = Array (
"ip" => $ip,
"hostname" => gethostbyaddr($ip)
);
echo json_encode($ip_array, JSON_PRETTY_PRINT);
}
// /x.x.x.x
else if($allowed_ip && filter_var($input, FILTER_VALIDATE_IP,FILTER_FLAG_IPV4) || filter_var($input, FILTER_VALIDATE_IP,FILTER_FLAG_IPV6)) {
header('Content-Type: application/json; charset=utf-8');
echo json_encode(
getIpInfo($input, $ipinfo_token, $abuseipdb_token, $ipdata_token),
JSON_PRETTY_PRINT
);
}
// /domain.com
else if($allowed_ip && validateDomainName($input)) {
header('Content-Type: application/json; charset=utf-8');
echo json_encode(
getDomainInfo($input, $threatfox_token),
JSON_PRETTY_PRINT
);
}
else {
header('Location: /');
}
}
?>