-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathipb.php
1765 lines (1630 loc) · 88.9 KB
/
ipb.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
IP-Biter: The Hacker-friendly Tracking Framework
Copyright (C) 2017-2023 Damiano Falcioni ([email protected])
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/*START CONFIGURATION SECTION*/
$dashboardPage = 'dashboard';
$dashboardPageSecret = '';
$adminPage = 'admin';
$adminPageSecret = '';
$configFolder = 'configs';
$reportFolder = 'reports';
$errorLogFile = 'error.log';
$darkTheme = true;
$debugMode = false;
$anonymRedirectService = 'https://url.rw/?'; //Leave it empty in order to not use a referer protection service
/*END CONFIGURATION SECTION*/
/*
README.md
# IP-Biter - Framework
#### The Hacker-friendly Tracking Framework
IP-Biter is an open source, easy to deploy, tracking framework that generate high configurable and unique tracking images and links to embed in e-mails,
sites or chat systems and visualize, in a hacker-friendly dashboard, high detailed reports of the tracked users who visualize the image or open the links.
![](https://user-images.githubusercontent.com/8982949/33372623-f6abdc46-d4fe-11e7-921c-536300d02237.jpg)
## Features
- Very high configurable tracking image generation
- Tracking links generation
- Tracking hidden and not recognizable from the target point of view
- Integrated Dashboard
- Integrated Overview Dashboard (Admin only)
- Self-tracking prevention
- Possibility to stop and start the tracking at any time
- Possibility to hide the Dashboard and protect its access with a password
- Live tracking reports from the Dashboard
- Tracking reports live delivered to a configurable mail address and telegram chat
- Different IP analysis services
- User-Agent analysis service
- Integrate URL shortening service
- AllInOne PHP file
- No need for a Database
- Open Source
...and many many more!
Give it a try!
![](https://user-images.githubusercontent.com/8982949/33380631-09b9720e-d51c-11e7-9da1-b6886569e399.png)
## Getting Started
#### Deploy IP-Biter
0) Copy ipb.php in your PHP server and optionally create a .htaccess file as described in the next security notes.
- Some configurable parameters are available in the firsts uncommented PHP lines of the ipb.php file, identified by the comment "START CONFIGURATION SECTION".
#### Access the Dashboard
1) Access the dashboard through ipb.php?op=$dashboardPage (replacing $dashboardPage with its effective value).
- $dashboardPage is the PHP variable defined in the "START CONFIGURATION SECTION" of the ipb.php file. The default value is "dashboard" so the default URL is `ipb.php?op=dashboard`.
- If the PHP variable $dashboardPage is empty you can access the dashboard through the URL `ipb.php`.
- If the PHP variable $dashboardPageSecret is not empty then a login page will appear, asking for the $dashboardPageSecret value.
#### Create a new configuration
2) When the dashboard is opened without parameters, a new configuration is created.
- Another empty new configuration can be generate clicking the "New" button.
3) Optionally provide mails and Telegram Bot token and chat id where you want to be notified.
- Telegram Note: To obtain a token, create a Telegram Bot following the instructions under [https://core.telegram.org/bots/features#botfather](https://core.telegram.org/bots/features#botfather).
- Telegram Note: To obtain a chat id, start a new chat with your bot, then open `https://api.telegram.org/bot<token>/getUpdates` replacing `<token>` with your bot token. You will find your chat id under result/message/chat/id of the returned JSON. More instructions for groups or topics chat id can be found on [this Gist](https://gist.github.com/nafiesl/4ad622f344cd1dc3bb1ecbe468ff9f8a).
4) Configure the tracking image and the advanced setting if needed.
- It is possible to left the original image url empty. In this case an empty image will be used.
5) Add tracking links if needed.
- It is possible to left the original link empty. In this case the link will generate a 404 page.
6) **Save the configuration**
7) Distribute the generated image or the links to start the tracking.
- You can click the copy button and paste in a html rich email editor like gmail.
- NOTE: If you try to open the generated image or links but have in the same browser the dashboard page opened and loaded, your request will not be tracked (self-tracking prevention feature).
#### Load an existing configuration
8) When the dashboard is opened with the parameter "uuid", the associated configuration is loaded.
- Another configuration can be loaded pasting the "Track UUID" in the dashboard relative field and clicking the "Load" button,
9) The reports will be automatically visualized in the "Tracking Reports" section of the dashboard.
## Admin Overview Page
1) Access the Admin page through ipb.php?op=$adminPage (replacing $adminPage with its effective value).
- $adminPage is the PHP variable defined in the "START CONFIGURATION SECTION" of the ipb.php file. The default value is "admin" so the default URL is `ipb.php?op=admin`.
- If the PHP variable $adminPage is empty the admin page will be not available.
- If the PHP variable $adminPageSecret is not empty then a login page will appear, asking for the $adminPageSecret value.
2) All the defined configuration will be visualized in a table.
## Security Notes
- Change the folders name and the dashboard page in the configuration section in order to improve the security
- Add the following lines to the .htaccess file in order to deny the access to the "configs" and "reports" folders:
```
DirectoryIndex ipb.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(configs/|reports/|error.log) - [F]
</IfModule>
```
## Live DEMO
<!--
Hi and welcome to a tracking link live demonstration.
The one below is an autogenerated link that redirect to http://ipbiter.rf.gd/?op=dashboard (the demo page) and in the meanwhile, will track you :P
From this link you are not able to access the relative dashboard.
Did not trust me?
Try to hack it as a challenge and report me your success; you will be rewarded with a coffee <3
-->
Have a look at the [DEMO](https://damianofalcioni.alwaysdata.net/ipb.php?op=l&tid=4a33afe3-2a49-455f-b1a1-19e28aa12faf&lid=f2d41e3b-da57-4efb-8490-e0678d5090d2)
## Support Me <3
<!--
Hi and welcome again to a tracking image live demonstration.
The one below is an autogenerated link that show the image at https://user-images.githubusercontent.com/8982949/33011169-6da4af5e-cddd-11e7-94e5-a52d776b94ba.png.
The link will track you as soon as the image is loaded in the browser :)
From this link you are not able to access the relative dashboard.
Did not trust me?
Try to hack it as a challenge and report me your success; you will be rewarded with another coffee <3
-->
[![Buy me a coffee](https://damianofalcioni.alwaysdata.net/ipb.php?op=i&tid=4a33afe3-2a49-455f-b1a1-19e28aa12faf)](https://www.paypal.me/damianofalcioni/0.99)
*/
error_reporting($debugMode?-1:0);
if(function_exists('ini_set')) {
ini_set("display_errors", $debugMode?1:0);
}
function logError($message) {
global $errorLogFile;
file_put_contents(__DIR__.'/'.$errorLogFile, date('d/m/Y H:i:s', time()).' '.$_SERVER['REMOTE_ADDR'].' '.$message."\r\n", FILE_APPEND | LOCK_EX);
};
function shutdownHandler() {
$error = error_get_last();
if ($error!=null)
logError("ERROR on line ".$error['line'].": ".$error['message']);
}
register_shutdown_function('shutdownHandler');
if(!function_exists('getallheaders')){
function getallheaders() {
$retval = array();
foreach($_SERVER as $key => $val){
$keySplit = explode('_' , $key);
if(array_shift($keySplit) == 'HTTP'){
array_walk($keySplit, function(&$singleKey){
$singleKey = ucfirst(strtolower($singleKey));
});
$retval[join('-', $keySplit)] = $val;
}
}
return $retval;
}
}
function file_get_contents_url($url, $payload, $contentType) {
$protocol = strtolower(strtok($url, ':'));
if(($protocol == 'http' || $protocol == 'https') && !ini_get("allow_url_fopen"))
throw new Exception('Can not open urls with file_get_contents as allow_url_fopen is set to false.');
if(!in_array($protocol, stream_get_wrappers()))
throw new Exception('Can not open '.$protocol.' urls with file_get_contents as no wrapper available.'.($protocol == 'https' ? ' OPENSSL extension is '.(!extension_loaded('openssl')?'NOT ':'').'enabled' : ''));
$content = @file_get_contents($url, false, stream_context_create(array(
'http'=>array(
'method'=>$payload!=null ? 'POST' : 'GET',
'header'=>($contentType!=null ? 'Content-Type: '.$contentType.'\r\n' : '').($payload!=null ? 'Content-Length: '.strlen($payload).'\r\n' : ''),
'content'=>$payload!=null ? $payload : '',
'ignore_errors'=>true
),
'ssl'=>file_exists(dirname(__FILE__).'/cacert.pem')?array(
'cafile'=>dirname(__FILE__).'/cacert.pem' //downloaded from https://curl.se/ca/cacert.pem
):array()
)));
if ($content === false)
throw new Exception('Error calling '.$url.': '.(error_get_last()!=null?error_get_last()['message']:'No error reported'));
if($protocol == 'http' || $protocol == 'https') {
preg_match('{HTTP\/\S*\s(\d{3})}', $http_response_header[0], $match);
$httpReturnCode = intval($match[1]);
if ($httpReturnCode < 200 || $httpReturnCode > 299)
throw new Exception('URL returned http code '.$httpReturnCode.': '.$content);
}
return $content;
}
function curl($url, $payload, $contentType) {
try {
if(!function_exists('curl_init'))
throw new Exception('Function curl_init not found. PHP CURL extension is '.(!extension_loaded('curl')?'NOT ':'').'enabled');
$ch = curl_init();
if ($ch === false)
throw new Exception('PHP CURL: failed to initialize');
if (isset($payload)) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
}
if (isset($contentType))
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:'.$contentType));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
if (file_exists(dirname(__FILE__).'/cacert.pem'))
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/cacert.pem');
$content = curl_exec($ch);
if ($content === false)
throw new Exception(curl_error($ch), curl_errno($ch));
$httpReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpReturnCode < 200 || $httpReturnCode > 299)
throw new Exception('PHP CURL: URL call returned error code '.$httpReturnCode.': '.$content);
return $content;
} catch(Throwable $ex) {
throw $ex;
} finally {
if (is_resource($ch)) {
curl_close($ch);
}
}
}
function req($url, $payload, $contentType) {
$errorMsg = '';
try {
return file_get_contents_url($url, $payload, $contentType);
} catch(Throwable $ex) {
$errorMsg = 'file_get_contents_url: '.$ex->getMessage();
}
try {
return curl($url, $payload, $contentType);
} catch(Throwable $ex) {
$errorMsg = $errorMsg.'\ncurl: '.$ex->getMessage();
}
throw new Exception('Error contacting '.$url.': '.$errorMsg);
}
function sendNotifications($config, $track){
global $dashboardPage;
$notificationText = 'Your tracking image/link has been accessed right now by <b>'.$track['ip'].'</b>. Check all the details in the <a href="'.(isset($_SERVER['HTTPS'])?'https':'http').'://'.$_SERVER['HTTP_HOST'].strtok($_SERVER['REQUEST_URI'],'?').'?op='.$dashboardPage.'&uuid='.$config->uuid.'">DASHBOARD</a>';
try {
if(isset($config->notificationAddress) && $config->notificationAddress!=''){
if(!function_exists('mail'))
throw new Exception('PHP mail function not available');
$mailText = '<html><body><p>'.$notificationText.'</p></body></html>';
$mailSent = mail($config->notificationAddress, '[Tracking Live Report] '.$config->mailId, wordwrap($mailText, 70, "\r\n"), "MIME-Version: 1.0\r\nContent-type:text/html;charset=UTF-8\r\n");
if(!$mailSent)
throw new Exception('Mail not sent: '. error_get_last()!=null?error_get_last()['message']:'No PHP error detected');
}
} catch(Throwable $ex) {
logError('Failed to send notification for config UUID '.$config->uuid.' : '.$ex->getMessage());
}
try {
if(isset($config->telegramToken) && $config->telegramToken!='' && isset($config->telegramChatId) && $config->telegramChatId!=''){
$notificationText = str_replace('localhost', '127.0.0.1', $notificationText); //Telegram bug: localhost not parsed
$telegramSent = req('https://api.telegram.org/bot'.$config->telegramToken.'/sendMessage', json_encode(array('chat_id'=>$config->telegramChatId, 'parse_mode'=>'html', 'text'=>'[Tracking Live Report] '.$config->mailId."\n".$notificationText)), 'application/json');
if(json_decode($telegramSent)->ok === false)
throw new Exception('Failed to send telegram message to chat '.$config->telegramChatId.': '.$telegramSent);
}
} catch(Throwable $ex) {
logError('Failed to send notification for config UUID '.$config->uuid.' : '.$ex->getMessage());
}
}
function validateUUID($uuid) {
if (!is_string($uuid) || (preg_match('/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i', $uuid) !== 1))
throw new Exception('invalid uuid: '.$uuid);
}
if(
((!isset($_REQUEST['op']) && $dashboardPage == '') || (isset($_REQUEST['op']) && $_REQUEST['op'] == $dashboardPage)) &&
((!isset($_REQUEST['secret']) && $dashboardPageSecret == '') || (isset($_REQUEST['secret']) && $_REQUEST['secret'] == $dashboardPageSecret))
){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html class="no-js" lang="en">
<head>
<title>IP-Biter Dashboard</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAc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NYaBpwfpKBGqu0NFexxb3fb0B1W/jlo0nzY0d7+qECYVxMA9PyZ+XmrMyd34B/+MEzxs3rnkaXL5po8OHnzHQNWOUagLZtBEDHUlKjH8iJEEzXR3qFBVqW4juGEMNIYyUE8bumaXNsoDGbi1nokrSww4Z75wZGnS/H6onMj1tEgsWMXErQ0MPNw8CpVBDFTvZOLR99rqyVU0hKiE0XvISJtKaO0uFlXMosTauPstA9fXMHHe0+R8rtcfVP6mOLHIzuP8YgNe4WptlH5DE/oxUObPQHkAQ71EnG3axChw6HNFIBMVm2kM9ZeS6GvrRuGiF7vjx/m2azTT/bUoCZn+j+OfW64752lQmfclAwVrRqHYWxslX49Cie97GrRx3UcbBWvfw5Xl2ji7WK8pc55pQMxMl39ppvl7ItnDyTptnun6rIVGaTmeutfPLNIpy/XUK89dpHfz9ALDjFNzjbekeji7aIb/idDS+g+MrthkxIJ26gAAAABJRU5ErkJggg==">
<link rel="stylesheet" type="text/css" href="<?php echo $darkTheme==false?'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css':'https://bootswatch.com/3/slate/bootstrap.min.css';?>">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
var Dashboard = {
documentTitle : 'IP-Biter Dashboard',
_dashboardSecret : '<?php echo isset($_REQUEST['secret'])?$_REQUEST['secret']:'';?>',
_anonymRedirectService : '<?php echo $anonymRedirectService;?>',
_imageCustomHeaderIds : {},
_trackingLinksIds : {},
_trackTimestamp : 0,
_backgroudTrackListUpdateId : 0,
_backgroudTrackListUpdateIntervallInSeconds : 10,
_isFocused : true,
trackingUUID : '',
services : {
callUrlShortnerService : function(url, successCallback, failureCallback){
Utils.callService('shortening', 'url='+encodeURIComponent(url), null, function(data){
successCallback(data.shortenedUrl);
}, failureCallback);
},
callConfigSaverService : function(configJson, successCallback, failureCallback){
Utils.callService('save', null, configJson, successCallback, failureCallback);
},
callLoadConfigService : function(uuid, successCallback, failureCallback){
Utils.callService('loadConfig', 'id='+uuid, null, function(data){
successCallback(data.config);
}, failureCallback);
},
callLoadTrackingReportService : function(uuid, successCallback, failureCallback){
Utils.callService('loadTrack', 'id='+uuid, null, function(data){
successCallback(data.track);
}, failureCallback);
},
callConfigDeleteService : function(uuid, successCallback, failureCallback){
Utils.callService('deleteConfig', 'id='+uuid, null, successCallback, failureCallback);
},
callTrackDeleteService : function(uuid, successCallback, failureCallback){
Utils.callService('deleteTrack', 'id='+uuid, null, successCallback, failureCallback);
},
callPingTrackService : function(uuid, time, successCallback, failureCallback){
Utils.callService('ping', 'id='+uuid+'&time='+time+'&rnd='+Utils.generateUUID(), null, function(data){
successCallback(data.valid);
}, failureCallback);
},
callWhoisService : function(ip, successCallback, failureCallback){
Utils.callService('ipwhois', 'ip='+ip, null, function(data){
successCallback(data.whoisResults);
}, failureCallback);
}
},
loadUUID : function(){
var uuid = $('#trackUUIDTxt').val();
Dashboard.cleanAll();
$('#trackUUIDTxt').val(uuid);
$('#configurationDiv').collapse('hide');
$('#reportsDiv').collapse('show');
Dashboard.services.callLoadConfigService(uuid, function(configJson){
Dashboard.setCookie();
Dashboard.trackingUUID = configJson.trackUUID;
$('#trackingEnabledChk').prop('checked', configJson.trackingEnabled);
$('#mailIdTxt').val(configJson.mailId);
$('#notificationMailTxt').val(configJson.notificationAddress);
$('#notificationTelegramTokenTxt').val(configJson.telegramToken);
$('#notificationTelegramChatIdTxt').val(configJson.telegramChatId);
$('#trackingImageOriginalUrlTxt').val(configJson.trackingImage).trigger('change');
$('#trackingImageHTTPStatusTxt').val(configJson.trackingImageStatusCode);
configJson.trackingImageCustomHeaderList.forEach(function(item){
Dashboard.addCustomHTTPHeader(item);
});
$('#trackingImgUrlTxt').val(configJson.trackingImageGeneratedUrl);
$('#trackingImgShortUrlTxt').val(configJson.trackingImageShortUrl);
for(var linkId in configJson.trackingLinks)
Dashboard.addTrackingLink(linkId, configJson.trackingLinks[linkId].original, configJson.trackingLinks[linkId].generated, configJson.trackingLinks[linkId].shortened);
Dashboard.loadTrackingReports();
}, function(error){
Utils.showError(error, $('#trackUUIDMsgs'));
});
},
newUUID : function(){
Dashboard.cleanAll();
Dashboard.addDefaultHTTPHeader();
Dashboard.trackingUUID = Utils.generateUUID();
$('#trackUUIDTxt').val(Utils.generateUUID());
$('#configurationDiv').collapse('show');
$('#reportsDiv').collapse('hide');
var imageLink = Dashboard.generateTrackingImageUrl();
$('#trackingImgUrlTxt').val(imageLink);
Dashboard.services.callUrlShortnerService(imageLink, function(shortUrl){
$('#trackingImgShortUrlTxt').val(shortUrl);
}, function(error){
$('#trackingImgShortUrlTxt').val('');
Utils.showError(error, $('#trackingImageConfigDiv'));
});
},
saveConfiguration : function(){
var configJson = Dashboard.generateConfigJson();
Dashboard.services.callConfigSaverService(configJson, function(successData){
Dashboard.setCookie();
Utils.showSuccess('Configuration Saved', $('#saveConfigMsgs'));
Dashboard.loadTrackingReports();
if(Utils.getURLParameter('uuid') != configJson.uuid)
setTimeout(function(){
$('<form method="post" action="'+Utils.getCurrentPath()+'?uuid='+configJson.uuid+(Utils.getURLParameter('op')!=''?'&op='+Utils.getURLParameter('op'):'')+'"><input name="secret" type="hidden" value="'+Dashboard._dashboardSecret+'"></form>').appendTo($('body')).submit().remove();
}, 1000);
},function(error){
Utils.showError(error, $('#saveConfigMsgs'));
});
},
deleteConfiguration : function(){
var uuid = $('#trackUUIDTxt').val();
Dashboard.services.callConfigDeleteService(uuid, function(successData){
Utils.showSuccess('Configuration Deleted', $('#trackUUIDMsgs'));
Dashboard.newUUID();
},function(error){
Utils.showError(error, $('#trackUUIDMsgs'));
});
},
deleteTrackingReports : function(){
var uuid = $('#trackUUIDTxt').val();
Dashboard.services.callTrackDeleteService(uuid, function(successData){
Utils.showSuccess('Tracks Deleted', $('#trackReportMsgs'));
Dashboard.loadTrackingReports();
},function(error){
Utils.showError(error, $('#trackReportMsgs'));
});
},
loadTrackingReports : function(update){
Dashboard.services.callLoadTrackingReportService($('#trackUUIDTxt').val(), function(trackingReportJson){
Dashboard._trackTimestamp = trackingReportJson.time;
if(!update)
$('#reportsDiv').empty();
var _generateAnalyzeIPButtons = function(ip){
var ipAnalyzeServiceList = [{
name : 'shodan.io',
url : 'https://www.shodan.io/search?query='+ip
}, {
name : 'centralops.net',
url : 'https://centralops.net/co/DomainDossier.aspx?addr='+ip+'&dom_whois=true&dom_dns=true&traceroute=true&net_whois=true&svc_scan=true'
}, {
name : 'udger.com',
url : 'https://udger.com/resources/online-parser?action=analyze&Fip='+ip
}, {
name : 'ip-tracker.org',
url : 'http://www.ip-tracker.org/locator/ip-lookup.php?ip='+ip
}, {
name : 'infobyip.com',
url : 'https://www.infobyip.com/ip-'+ip+'.html'
}, {
name : 'infobyip.com whois',
url : 'https://www.infobyip.com/ipwhois-'+ip+'.html'
}, {
name : 'ipinfo.io', //json https://ipinfo.io/8.8.8.8/json
url : 'https://ipinfo.io/'+ip
}, {
name : 'ipapi.co', //json https://ipapi.co/8.8.8.8/json/
url : 'https://ipapi.co/'+ip
}, {
name : 'whois.com',
url : 'https://www.whois.com/whois/'+ip
}, {
name : 'ripe.net statistics',
url : 'https://stat.ripe.net/'+ip
}];
//http://freegeoip.net/json/83.65.190.82
//https://stackoverflow.com/questions/17290256/get-google-map-link-with-latitude-longitude
//https://apps.db.ripe.net/search/query.html?searchtext=83.65.190.82&bflag=false&source=RIPE#resultsAnchor#resultsAnchor
//https://whois.arin.net/rest/nets;q=8.8.8.8?showDetails=true&showARIN=false&showNonArinTopLevelNet=false&ext=netref2
var list = '';
ipAnalyzeServiceList.forEach(function(ipAnalyzeService){
list += '<li class="link"><a href="'+Dashboard._anonymRedirectService+ipAnalyzeService.url+'" target="_blank">'+ipAnalyzeService.name+'</a></li>';
});
return '<div class="input-group-btn dropdown"><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Analyze <span class="caret"></span></button><ul class="dropdown-menu">'+list+'</ul></div>';
};
var _generateAnalyzeAgentButton = function(userAgent){
var link = 'https://udger.com/resources/online-parser?action=analyzev&Fuas='+encodeURIComponent(userAgent);
return '<a class="btn btn-default" role="button" href="'+Dashboard._anonymRedirectService+link+'" target="_blank">Analyze</a>';
};
var newTracksCounter = 0;
trackingReportJson.trackList.forEach(function(track, trackIndex){
if(trackIndex < $('#reportsDiv').children().length)
return;
newTracksCounter++;
if(!Dashboard._isFocused && newTracksCounter!=0)
document.title = '('+newTracksCounter+') '+Dashboard.documentTitle;
var domId = Utils.generateUUID();
$('#reportsDiv').prepend(
$('<div class="list-group-item">').append(
$('<div class="row link" id="'+domId+'_overview_div" title="Click for details">').append(
$('<div class="col-lg-2">').append(
'<h4><span class="label label-default">'+track.time+'</span></h4>'
)
).append(
$('<div class="col-lg-6">').append(
$('<div class="input-group">').append(
'<span class="input-group-addon">Remote IP: </span>'
).append(
$('<input type="text" class="form-control" value="'+track.ip+(track.port?':'+track.port:'')+'" readonly>').click(function(e){
$(this).select();
document.execCommand("copy");
})
).append(
_generateAnalyzeIPButtons(track.ip)
)
)
).append(
$('<div class="col-lg-4">').append(
$('<div class="input-group">').append(
'<span class="input-group-addon">Owner: </span>'
).append(
$('<input type="text" id="'+domId+'_ip_owner_txt" class="form-control" readonly>').click(function(e){
$(this).select();
document.execCommand("copy");
})
)
)
)
.click(function(e){
if (e.target.tagName != 'BUTTON' && e.target.tagName != 'A' && e.target.tagName != 'INPUT'){
$('#'+domId+'_headers_div').toggle();
$('#'+domId+'_headers_div').find('.headerTxt').each(function () {
$(this).css("height", $(this).prop("scrollHeight")+"px");
$(this).css("width", $(this).prop("scrollWidth")+"px");
});
$('#'+domId+'_headers_div').find('.valueTxt').each(function () {
$(this).css("height", $(this).prop("scrollHeight")+"px");
});
}
})
).append(
$('<div class="row" id="'+domId+'_headers_div" style="display:none;">').append(
$('<div class="col-lg-12">').append(
$('<table class="table table-condensed">').append(
$('<tbody>').append(function(){
var ret = [];
ret.push('<tr><th style="vertical-align:middle; white-space:nowrap; width:1%;">Header Fields</th><th style="vertical-align:middle; white-space:nowrap; width:1%;"></th><th></th></tr>');
for(var header in track.headers){
var analysisButton = null;
var headerLowCase = header.toLowerCase();
if(headerLowCase == 'user-agent')
analysisButton = _generateAnalyzeAgentButton(track.headers[header]);
if(headerLowCase == 'x-forwarded-for')
analysisButton = _generateAnalyzeIPButtons(track.headers[header].split(',')[0]);
if(headerLowCase == 'x-real-ip')
analysisButton = _generateAnalyzeIPButtons(track.headers[header]);
//SECURITY FIX 15-11-2018 for XSS Vulnerability reported by elpsycongroo: header visualization inside a textarea avoid content parsing so XSS can not be exploited
ret.push('<tr><td style="vertical-align:middle; white-space:nowrap;"><textarea wrap="off" class="headerTxt" readonly>'+header+'</textarea></td><td style="vertical-align:middle; white-space:nowrap;">'+(analysisButton!=null?analysisButton:'')+'</td><td style="vertical-align:middle;"><textarea wrap="on" class="valueTxt" readonly>'+track.headers[header]+'</textarea></td></tr>');
}
return ret;
}())
)
)
)
).hide().fadeIn(500)
);
Dashboard.services.callWhoisService(track.ip, function(whoisResults){
$('#'+domId+'_ip_owner_txt').val(whoisResults.netName).popover({
placement : 'auto right',
container : 'body',
html : true,
title : 'WHOIS ' + track.ip,
content : function(){
var html = '<pre>'+whoisResults.output+'</pre>';
return html;
}(),
trigger : 'hover click'
});
}, function(error){
Utils.showError(error, $('#trackReportMsgs'));
});
});
}, function(error){
Utils.showError(error, $('#trackReportMsgs'));
});
},
generateTrackingImageUrl : function(){
return Utils.getHost()+Utils.getCurrentPath()+'?op=i&tid='+Dashboard.trackingUUID;
},
generateTrackingLinkUrl : function(linkUrl){
return Utils.getHost()+Utils.getCurrentPath()+'?op=l&tid='+Dashboard.trackingUUID+'&lid='+linkUrl;
},
addCustomHTTPHeader : function(value){
var domId = Utils.generateUUID();
Dashboard._imageCustomHeaderIds[domId]=1;
$('#customHTTPHeaderTable').append(
$('<tr id="'+domId+'_tr">').append(
$('<td>').append(
$('<div class="input-group">').append(
$('<input id="header_'+domId+'_txt" type="text" class="form-control" placeholder="Add custom header here">').val(value)
).append(
$('<div class="input-group-addon link" style="font-size:20px;font-weight:700;">×</div>').click(function(){
$('#'+domId+'_tr').remove();
delete Dashboard._imageCustomHeaderIds[domId];
})
)
)
)
);
},
addDefaultHTTPHeader : function(){
Dashboard.addCustomHTTPHeader('Content-Type: image/png');
Dashboard.addCustomHTTPHeader('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
Dashboard.addCustomHTTPHeader('Cache-Control: post-check=0, pre-check=0');
Dashboard.addCustomHTTPHeader('Pragma: no-cache');
Dashboard.addCustomHTTPHeader('Expires: 0');
Dashboard.addCustomHTTPHeader('P3P: CP="OTI DSP COR CUR IVD CONi OTPi OUR IND UNI STA PRE"');
},
addTrackingLink :function(linkUUID, originalUrl, generatedUrl, shortUrl){
var linkId = linkUUID!=null?linkUUID:Utils.generateUUID();
Dashboard._trackingLinksIds[linkId]=1;
var trackingLink = generatedUrl!=null?generatedUrl:Dashboard.generateTrackingLinkUrl(linkId);
$('#trackingLinksTable').append(
$('<tr id="'+linkId+'_tr">').append(
$('<td>').append(
$('<div class="input-group">').append(
$('<input id="link_'+linkId+'_original_txt" type="text" class="form-control" placeholder="Add the original URL here">')
).append(
'<span class="input-group-addon">Tracking Link Generated URL:</span>'
).append(
$('<input id="link_'+linkId+'_generated_txt" type="text" class="form-control" placeholder="Auto-generated Tracking Link" readonly>').click(function(){
$('#link_'+linkId+'_generated_txt').select();
document.execCommand("copy");
})
).append(
$('<span class="input-group-addon link" title="Copy to clipboard"><span class="glyphicon glyphicon-copy"></span></span>').click(function(){
$('#link_'+linkId+'_generated_txt').select();
document.execCommand("copy");
})
).append(
$('<input id="link_'+linkId+'_short_txt" type="text" class="form-control" placeholder="Auto-generated Shortened Tracking Link" readonly>').click(function(){
$('#link_'+linkId+'_short_txt').select();
document.execCommand("copy");
})
).append(
$('<span class="input-group-addon link" title="Copy to clipboard"><span class="glyphicon glyphicon-copy"></span></span>').click(function(){
$('#link_'+linkId+'_short_txt').select();
document.execCommand("copy");
})
).append(
$('<div class="input-group-addon link" style="font-size:20px;font-weight:700;">×</div>').click(function(){
$('#'+linkId+'_tr').remove();
delete Dashboard._trackingLinksIds[linkId];
})
)
)
)
);
$('#link_'+linkId+'_original_txt').val(originalUrl);
$('#link_'+linkId+'_generated_txt').val(trackingLink);
if(shortUrl!=null)
$('#link_'+linkId+'_short_txt').val(shortUrl);
else{
Dashboard.services.callUrlShortnerService(trackingLink, function(shortUrl){
$('#link_'+linkId+'_short_txt').val(shortUrl);
}, function(error){
$('#link_'+linkId+'_short_txt').val('');
Utils.showError(error, $('#trackingLinksTable'));
});
}
},
generateConfigJson : function(){
return {
uuid : $('#trackUUIDTxt').val(),
trackUUID : Dashboard.trackingUUID,
trackingEnabled : $('#trackingEnabledChk').is(':checked'),
mailId : $('#mailIdTxt').val(),
notificationAddress : $('#notificationMailTxt').val(),
telegramToken: $('#notificationTelegramTokenTxt').val(),
telegramChatId: $('#notificationTelegramChatIdTxt').val(),
trackingImage : $('#trackingImageOriginalUrlTxt').val(),
trackingImageStatusCode : parseInt($('#trackingImageHTTPStatusTxt').val()),
trackingImageCustomHeaderList : function(){
var ret = [];
for(var id in Dashboard._imageCustomHeaderIds)
ret.push($('#header_'+id+'_txt').val());
return ret;
}(),
trackingImageGeneratedUrl : $('#trackingImgUrlTxt').val(),
trackingImageShortUrl : $('#trackingImgShortUrlTxt').val(),
trackingLinks : function(){
var ret = {};
for(var id in Dashboard._trackingLinksIds)
ret[id] = {
original : $('#link_'+id+'_original_txt').val(),
generated : $('#link_'+id+'_generated_txt').val(),
shortened : $('#link_'+id+'_short_txt').val()
};
return ret;
}()
};
},
startBackgroundTrackListUpdate : function(){
var _updateFunction = function(){
if(Dashboard.trackingUUID == '' || Dashboard._trackTimestamp == 0){
if(Dashboard._backgroudTrackListUpdateIntervallInSeconds != 0)
Dashboard._backgroudTrackListUpdateId = setTimeout(_updateFunction, Math.round(Dashboard._backgroudTrackListUpdateIntervallInSeconds)*1000);
return;
}
Dashboard.services.callPingTrackService(Dashboard.trackingUUID, Dashboard._trackTimestamp, function(isValid){
if(isValid===false)
Dashboard.loadTrackingReports(true);
if(Dashboard._backgroudTrackListUpdateIntervallInSeconds != 0)
Dashboard._backgroudTrackListUpdateId = setTimeout(_updateFunction, Math.round(Dashboard._backgroudTrackListUpdateIntervallInSeconds)*1000);
}, function(error){
console.log(error);
//Utils.showError(error, $('#trackReportMsgs'));
//Dashboard.stopBackgroundTrackListUpdate();
if(Dashboard._backgroudTrackListUpdateIntervallInSeconds != 0)
Dashboard._backgroudTrackListUpdateId = setTimeout(_updateFunction, Math.round(Dashboard._backgroudTrackListUpdateIntervallInSeconds)*1000);
});
};
_updateFunction();
},
stopBackgroundTrackListUpdate : function(){
clearTimeout(Dashboard._backgroudTrackListUpdateId);
},
cleanAll : function(){
$('#trackUUIDTxt').val('');
Dashboard.trackingUUID='';
Dashboard._trackTimestamp = 0;
$('trackingEnabledChk').prop('checked', true);
$('#mailIdTxt').val('');
$('#notificationMailTxt').val('');
$('#trackingImageOriginalUrlTxt').val('').trigger('change');
$('#trackingImageHTTPStatusTxt').val('200');
$('#customHTTPHeaderTable').empty();
Dashboard._imageCustomHeaderIds = {};
$('#trackingImgUrlTxt').val('');
$('#trackingImgShortUrlTxt').val('');
$('#trackingLinksTable').empty();
Dashboard._trackingLinksIds = {};
$('#reportsDiv').empty();
},
setCookie : function(){
document.cookie = $('#trackUUIDTxt').val()+"=1";
},
initialize : function(){
$('#uuidLoadBtn').click(function(){
Dashboard.loadUUID();
});
$('#uuidNewBtn').click(function(){
Dashboard.newUUID();
});
$('#uuidDeleteBtn').click(function(){
Dashboard.deleteConfiguration();
});
$('#deleteTracksBtn').click(function(){
Dashboard.deleteTrackingReports();
});
$('#trackUUIDCopyBtn').click(function(){
$('#trackUUIDTxt').select();
document.execCommand("copy");
});
$('#trackingImageOriginalUrlTxt').change(function(){
$('#trackingImageImg').attr('src', $('#trackingImageOriginalUrlTxt').val());
});
$('#trackingImgUrlCopyBtn').click(function(){
Utils.copyToClipboard('<img src="'+$('#trackingImgUrlTxt').val()+'"/>');
});
$('#trackingImgUrlTxt').click(function(){
$('#trackingImgUrlTxt').select();
document.execCommand("copy");
});
$('#trackingImgShortUrlCopyBtn').click(function(){
Utils.copyToClipboard('<img src="'+$('#trackingImgShortUrlTxt').val()+'"/>');
});
$('#trackingImgShortUrlTxt').click(function(){
$('#trackingImgShortUrlTxt').select();
document.execCommand("copy");
});
$('#addCustomHTTPHeaderBtn').click(function(){
Dashboard.addCustomHTTPHeader();
});
$('#trackingImageEmoji1Btn').click(function(){
$('#trackingImageOriginalUrlTxt').val('https://www.facebook.com/images/emoji.php/v9/z6/1/32/1f642.png').trigger('change');
});
$('#trackingImageEmoji2Btn').click(function(){
$('#trackingImageOriginalUrlTxt').val('https://www.facebook.com/images/emoji.php/v9/z11/1/32/1f609.png').trigger('change');
});
$('#trackingImageEmoji3Btn').click(function(){
$('#trackingImageOriginalUrlTxt').val('https://www.facebook.com/images/emoji.php/v9/z78/1/32/1f4e7.png').trigger('change');
});
$('#trackingImageUploadBtn').click(function(e){
e.preventDefault();
$("#trackingImageFileInput").trigger('click');
});
$('#trackingImageFileInput').change(function(e){
Utils.readFileAsDataURL(e.target.files[0], function(content){
$('#trackingImageOriginalUrlTxt').val(content).trigger('change');
});
});
$('#addTrackingLinkBtn').click(function(){
Dashboard.addTrackingLink();
});
$('#saveConfigBtn').click(function(){
Dashboard.saveConfiguration();
});
var uuidParam = Utils.getURLParameter('uuid');
if(uuidParam!=null && uuidParam!=''){
$('#trackUUIDTxt').val(uuidParam);
$('#uuidLoadBtn').trigger('click');
} else {
Dashboard.newUUID();
}
Dashboard.startBackgroundTrackListUpdate();
$(window).focus(function(){
document.title = Dashboard.documentTitle;
Dashboard._isFocused = true;
}).blur(function(){
Dashboard._isFocused = false;
});
}
};
var Utils = {
showError : function(error, parentDom){
console.log(error);
$('<div class="alert alert-danger fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>Error occurred:<br>'+error+'</div>')
.fadeTo(5000, 500)
.appendTo((parentDom!=null)?parentDom:$('#mainContainer'));
},
showSuccess : function(info, parentDom){
console.log(info);
$('<div class="alert alert-success fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'+info+'</div>')
.fadeTo(5000, 500)
.slideUp(500, function(){
$(this).remove();
})
.appendTo((parentDom!=null)?parentDom:$('#mainContainer'));
},
generateUUID : function() {
var d = new Date().getTime();
if (typeof performance !== 'undefined' && typeof performance.now === 'function')
d += performance.now(); //use high-precision timer if available
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
},
copyToClipboard : function(text){
if(window.clipboardData != null){ //IE
window.clipboardData.setData('text', text);
} else {
var listener = function(e) {
var clipboard = e.clipboardData || e.originalEvent.clipboardData;
clipboard.setData('text/plain', text);
clipboard.setData('text/html', text);
clipboard.setData('text', text); //Edge
e.preventDefault();
}
document.addEventListener('copy', listener);
try{
document.execCommand('copy');
} finally {
document.removeEventListener('copy', listener);
}
}
},
getURLParameter : function(sParam){
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
return sParameterName[1];
}
return null;
},
getHost : function(){
var ret = ((window.location.protocol == '')?'http:':window.location.protocol) + '//' + ((window.location.hostname == '')?'127.0.0.1':window.location.hostname) + ((window.location.port != '')?':'+window.location.port:'');
return ret;
},
getCurrentPath : function(){
return window.location.pathname;
},
readFileAsDataURL : function(file, onLoadFunction){
if(!file)
return;
if(!(window.File && window.FileReader && window.FileList && window.Blob)){
alert('The File APIs are not fully supported in this browser.');
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var content = e.target.result;
onLoadFunction(content);
};
reader.readAsDataURL(file);
},
callService : function(op, paramsQueryString, postData, successCallback, failureCallback){
var serviceUrl = Utils.getCurrentPath()+'?op='+op+(paramsQueryString!=null?'&'+paramsQueryString:'');
var ajaxConfig = {
type: 'GET',
url: serviceUrl,
dataType : 'json',
async: true,
success : function(data, status){
if(data.status==0)
successCallback(data);
else
failureCallback('Internal error: ' + data.error);
},
error : function(request, status, error) {
failureCallback('Error contacting the service: ' + serviceUrl + ' : ' + status + ' ' + error);
}
};
if(postData!=null){
ajaxConfig.type = 'POST';
ajaxConfig.processData = false;
ajaxConfig.contentType = 'application/json';
ajaxConfig.data = JSON.stringify(postData);
}
$.ajax(ajaxConfig);
}
};
</script>
<script type="text/javascript">
$(document).ready(Dashboard.initialize);
</script>
<style type="text/css">
@charset "UTF-8";
.slideThree {
width: 150px;
height: 26px;
background: #eaeaea;
position: relative;
border-radius: 50px;
}
.slideThree:before {
content: 'ENABLED';
color: #00b503;
position: absolute;
left: 10px;
z-index: 0;
font: 12px/26px Arial, sans-serif;
font-weight: bold;
}
.slideThree:after {
content: 'DISABLED';
color: #555;
position: absolute;
right: 10px;
z-index: 0;
font: 12px/26px Arial, sans-serif;
font-weight: bold;
text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.15);
}
.slideThree input[type=checkbox] {
visibility: hidden;
}
.slideThree input[type=checkbox]:checked + label {