forked from syphon1c/dracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.php
executable file
·147 lines (132 loc) · 5.06 KB
/
images.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* Description of images.php
* version: 1.0
* package: Dracker - Track and Trace
* copyright: Copyright (C) 2013 Gareth Phillips. All rights reserved.
* license: GNU/GPL, see license.htm.
*
* This file is part of the Dracker project.
*
* Dracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, under version 3 of the License.
*
* Dracker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dracker. If not, see <http://www.gnu.org/licenses/>.
*
* @author GPhillips
**/
function cleanInput($input) {
$search_input = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
$output = preg_replace($search_input, '', $input);
return $output;
}
function sanitize($input) {
if (is_array($input)) {
foreach($input as $var=>$val) {
$output[$var] = sanitize($val);
}
}
else {
if (get_magic_quotes_gpc()) {
$input = stripslashes($input);
}
$input = cleanInput($input);
$connection = new DatabaseConnection();
$output = mysql_real_escape_string($input);
}
return $output;
}
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
function ip_details($ip_lookup) {
$json = file_get_contents("http://ipinfo.io/{$ip_lookup}");
$details_lookup = json_decode($json);
return $details_lookup;
}
header('Content-Type: image/gif');
header("Content-Length: " . filesize("image.gif"));
$f = fopen('image.gif', 'rb');
fpassthru($f);
fclose($f);
include_once 'configs/DatabaseConnection.php';
include_once 'configs/EncryptionKey.php';
include_once 'inc/swiftmailer/lib/swift_required.php';
include_once 'SMTP.php';
if(isset($_GET['imageid'])) {
$refid=$_GET['imageid'];
$refid=sanitize($refid);
}
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$ip2 = "";
$host_name = gethostbyaddr($ip) ;
if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip2 = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$ip = sanitize($ip);
$browser = sanitize($browser);
$ip2 = sanitize($ip2);
$host_name = sanitize($host_name);
$time=date("y-m-d h:i:s");
$details_lookup = ip_details($ip);
$connection = new DatabaseConnection();
$queryDocumentDracks = $connection->executeQuery("INSERT INTO call_home VALUES (NULL, '$ip', '$host_name', '$ip2', '$browser', '', '$refid', '$time', '$details_lookup->org', '$details_lookup->city', '$details_lookup->country', '$details_lookup->region')");
$queryDocumentDracksOpened = $connection->executeQuery("UPDATE dracker_file SET Status= 'Opened' WHERE RefID= '$refid' AND Status='Waiting'");
$DrackerEmailAlert = "SELECT * FROM dracker_file WHERE RefID= '$refid'";
$smtpArray = $connection->executeQuery($DrackerEmailAlert);
while($smtpItems = mysql_fetch_array($smtpArray) ){
$send_to = $smtpItems['Email'];
$dracker_name = $smtpItems['FileName'];
}
$connection = new DatabaseConnection();
$querySMTPdefault = "SELECT * FROM settings_smtp WHERE sys_default= 1";
$smtpArray = $connection->executeQuery($querySMTPdefault);
while($smtpItems = mysql_fetch_array($smtpArray) ){
$sid = $smtpItems['id'];
$default = $smtpItems['sys_default'];
}
if($default ==1){
$current_url = curPageURL();
$login_url = str_replace("images.php?imageid=$refid",'login.php', $current_url);
//SMTP Create mail alert and send
$mailer = Swift_Mailer::newInstance ( $transport );
$logger = new Swift_Plugins_Loggers_ArrayLogger();
$mailer -> registerPlugin ( new Swift_Plugins_LoggerPlugin ( $logger ) );
$subject = "Dracker Alert - $dracker_name";
$sender_email = $smtp_senderemail;
$sender_friendly = $smtp_sendername;
$reply_to = $smtp_senderemail;
$message = "Hello,<br> <br>You have a hit!<br><br>Name: <b>$dracker_name</b><br>Source IP: <b>$ip</b><br>Agent: <b>$browser</b><br><br>more details on the Dracker portal. <br><br> $login_url";
//Create a message
$message = Swift_Message::newInstance ( $subject )
-> setSubject ( $subject )
-> setFrom ( array ( $sender_email => $sender_friendly ) )
-> setReplyTo ( $reply_to )
-> setTo ( $send_to )
-> setBody ( $message, 'text/html' )
;
//Send the message
$test = $mailer -> send ( $message, $failures );
}
?>