forked from wedaa/LongTail-Log-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LongTail.pl
executable file
·4219 lines (3761 loc) · 175 KB
/
LongTail.pl
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
#!/usr/bin/perl
############################################################################
#
# Design note: I am PERFECTLY willing to trade using more disk space in
# order to speed things up.
#
# This is my crontab entry
# 05 * * * * /usr/local/etc/LongTail.pl >> /tmp/LongTail.pl.out 2>> /tmp/LongTail.pl.out
#
# You need to have /usr/local/etc/whois.pl installed also. Sure, I could
# have a faster mysql backend, but I don't NEED it.
#
# I am assuming your /var/log/messages file is really called messages, or
# messages<something>. .gz files are ok too.
#
# you can also call this program with a hostname (from the messages files)
# so that you can analyze different hosts separately, each in
# /honey/<HOSTNAME>/ directories.
#
# Examples:
# gets all hosts and looks for all ssh activity
# /usr/local/etc/LongTail.pl
#
# gets all hosts and looks for all ssh activity
# /usr/local/etc/LongTail.pl ssh
#
# gets all hosts and looks for all ssh only on port 22 activity
# /usr/local/etc/LongTail.pl 22
#
# gets all hosts and looks for all ssh only on port 2222 activity
# /usr/local/etc/LongTail.pl 2222
#
# gets all hosts and looks for telnet activity
# /usr/local/etc/LongTail.pl telnet
#
# If you are looking for a specific host, you MUST include the protocol
# to search for
# gets all hosts and looks for all ssh activity
# /usr/local/etc/LongTail.pl ssh HOSTNAME
#
# gets all hosts and looks for all ssh only on port 22 activity
# /usr/local/etc/LongTail.pl 22 HOSTNAME
#
# gets all hosts and looks for all ssh only on port 2222 activity
# /usr/local/etc/LongTail.pl 2222 HOSTNAME
#
# gets all hosts and looks for telnet activity
# /usr/local/etc/LongTail.pl telnet HOSTNAME
#
#
# LongTail.pl is not fully tested yet :-)
#
############################################################################
# This reads /usr/local/etc/LongTail.config. If your file isn't there,
# then this is the only place you need to edit.
############################################################################
## Touch a file
sub touch {
my $now = time;
my $file=shift;
local (*TMP);
utime ($now, $now, $file)
|| open (TMP, ">>$file")
|| warn ("Couldn't touch file: $!\n");
}
sub commify {
my ( $sign, $int, $frac ) = ( $_[0] =~ /^([+-]?)(\d*)(.*)/ );
my $commified = (
reverse scalar join ',',
unpack '(A3)*',
scalar reverse $int
);
return $sign . $commified . $frac;
}
sub read_local_config_file {
if ( -e "$CONFIG_FILE" ) {
open (INPUT, "$CONFIG_FILE");
while (<INPUT>){
chomp;
$_ =~ s/#.*//;
$_ =~ s/\s//g;
$_ =~ s/"//g;
if (/^$/){next;}
if (! /=/){next;}
#print "$_\n";;
($variable,$value)=split(/=/,$_);
#if ( $DEBUG == 1 ) { print "DEBUG-variable=$variable,value=$value\n" ; }
if ($variable eq "PUBLIC_WEBSERVER"){$PUBLIC_WEBSERVER=$value;next;}
if ($variable eq "MIDNIGHT"){$MIDNIGHT=$value;next;}
if ($variable eq "GRAPHS"){$GRAPHS=$value;next;}
if ($variable eq "KIPPO"){$KIPPO=$value;next;}
if ($variable eq "LONGTAIL"){$LONGTAIL=$value;next;}
if ($variable eq "PATH_TO_VAR_LOG"){$PATH_TO_VAR_LOG=$value;next;}
if ($variable eq "LOGFILE"){$LOGFILE=$value;next;}
if ($variable eq "PATH_TO_VAR_LOG_HTTPD"){$PATH_TO_VAR_LOG_HTTPD=$value;next;}
if ($variable eq "DEBUG"){$DEBUG=$value;next;}
if ($variable eq "DO_SSH"){$DO_SSH=$value;next;}
if ($variable eq "DO_HTTPD"){$DO_HTTPD=$value;next;}
if ($variable eq "OBFUSCATE_IP_ADDRESSES"){$OBFUSCATE_IP_ADDRESSES=$value;next;}
if ($variable eq "OBFUSCATE_URLS"){$OBFUSCATE_URLS=$value;next;}
if ($variable eq "PASSLOG"){$PASSLOG=$value;next;}
if ($variable eq "PASSLOG2222"){$PASSLOG2222=$value;next;}
if ($variable eq "TMP_DIRECTORY"){$TMP_DIRECTORY=$value;next;}
if ($variable eq "SCRIPT_DIR"){$SCRIPT_DIR=$value;next;}
if ($variable eq "HTML_DIR"){$HTML_DIR=$value;next;}
if ($variable eq "SSH_HTML_TOP_DIR"){$SSH_HTML_TOP_DIR=$value;next;}
if ($variable eq "SSH22_HTML_TOP_DIR"){$SSH22_HTML_TOP_DIR=$value;next;}
if ($variable eq "SSH2222_HTML_TOP_DIR"){$SSH2222_HTML_TOP_DIR=$value;next;}
if ($variable eq "TELNET_HTML_TOP_DIR"){$TELNET_HTML_TOP_DIR=$value;next;}
if ($variable eq "RLOGIN_HTML_TOP_DIR"){$RLOGIN_HTML_TOP_DIR=$value;next;}
if ($variable eq "FTP_HTML_TOP_DIR"){$FTP_HTML_TOP_DIR=$value;next;}
if ($variable eq "CONSOLIDATION"){$CONSOLIDATION=$value;next;}
if ($variable eq "PROTECT_RAW_DATA"){$PROTECT_RAW_DATA=$value;next;}
if ($variable eq "NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA"){$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA=$value;next;}
}
close (INPUT);
}
}
sub check_config {
if ( $DEBUG == 1 ) { print "DEBUG-in check_config\n" ; }
if ( ! -d "$PATH_TO_VAR_LOG" ){
print "$PATH_TO_VAR_LOG does not exist, exiting now\n";
exit;
}
if ( ! -e "$PATH_TO_VAR_LOG/$LOGFILE" ){
print "$PATH_TO_VAR_LOG/$LOGFILE does not exist, exiting now\n";
exit;
}
if ( ! -d "$PATH_TO_VAR_LOG_HTTPD" ){
print "$PATH_TO_VAR_LOG_HTTPD does not exist, exiting now\n";
exit;
}
if ( ! -d "$SCRIPT_DIR" ){
print "Can not find SCRIPT_DIR: $SCRIPT_DIR, exiting now\n";
exit;
}
if ( ! -d "$HTML_DIR" ){
print "Can not find HTML_DIR: $HTML_DIR, exiting now\n";
exit;
}
if ( ! -d "$TMP_DIRECTORY" ){
print "Can not find TMP_DIRECTORY $TMP_DIRECTORY, exiting now\n";
exit;
}
if ( ! -r "$PATH_TO_VAR_LOG/$LOGFILE" ){
print "Can not read $PATH_TO_VAR_LOG/$LOGFILE, please check file permissions\n";
print "Exiting now\n";
exit;
}
$rsyslog_format_check=`tail -1 $PATH_TO_VAR_LOG/$LOGFILE |awk '{print $1}'`;
chomp $rsyslog_format_check;
$rsyslog_format_check_exit=0;
if ( $rsyslog_format_check eq "Jan" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Feb" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Mar" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Apr" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "May" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Jun" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Jul" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Aug" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Sep" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Oct" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Nov" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check eq "Dec" ){ $rsyslog_format_check_exit=1 ; }
if ( $rsyslog_format_check_exit == 1 ){
print "$PATH_TO_VAR_LOG/$LOGFILE file appears to have the wrong style data stamp (monthName vs YYYY-MM-DD format) Please see the README again.\n";
print "rsyslog format line should be \"\$ActionFileDefaultTemplate RSYSLOG_FileFormat\"\n";
print "You will have to edit $PATH_TO_VAR_LOG/$LOGFILE by hand to fix the formating or start with a fresh $PATH_TO_VAR_LOG/$LOGFILE file\n";
exit;
}
if ( $DEBUG == 1 ) { print "DEBUG-Done with check_config\n" ; }
}
sub load_exclude_files {
open (FILE, "$SCRIPT_DIR/LongTail-exclude-IPs-ssh.grep ")|| die "Can not read $SCRIPT_DIR/LongTail-exclude-IPs-ssh.grep, exiting now!\n";
while (<FILE>){
chomp;
$_ =~ s/\./\\\./g;
$LongTail_exclude_IPs_ssh_grep{$_}=1;
}
close (FILE);
open (FILE, "$SCRIPT_DIR/LongTail-exclude-accounts.grep ")|| die "Can not read $SCRIPT_DIR/LongTail-exclude-accounts-ssh.grep, exiting now!\n";
while (<FILE>){
chomp;
$_ =~ s/\./\\\./g;
$LongTail_exclude_accounts_ssh_grep{$_}=1;
}
close (FILE);
}
# This sub is called as
# NEW_STRING=$(convert_kippo_to_longtail "$STRING")
# STRING should look like
# 2015-05-10 18:05:31-0400 [SSHService ssh-userauth on HoneyPotTransport,16534,58.218.204.52] login attempt [root/skata1] failed
sub convert_kippo_to_longtail {
$STRING=shift;
$STRING=~ s/ /T/;
$STRING =~ s/.SSHService ssh-userauth on HoneyPotTransport,.*,//;
$STRING =~ s/\]/ /;
$STRING =~ s/\] failed$//;
$STRING =~ s/\[// ;
$STRING =~ s/ / LOCALHOST sshd-22[9999]: IP: /;
$STRING =~ s/login attempt/PassLog: Username:/;
$STRING =~ s/\// Password: /;
return $STRING;
}
sub lock_down_files {
if ( "x$HOSTNAME" eq "x/" ) {
if ( -d "$HTML_DIR" ) {
chdir ("$HTML_DIR");
print "Expect to see chmod warnings until you have run LongTail for at least 24 hours\n";
`find . -name last-7-days-root-passwords.shtml.gz -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name last-7-days-non-root-pairs.shtml -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name last-30-days-root-passwords.shtml.gz -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name last-30-days-non-root-pairs.shtml -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name historical-root-passwords.shtml.gz -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name historical-non-root-pairs.shtml -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA | xargs chmod go-r`;
`find . -name todays_password -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name current-root-passwords.shtml.gz -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name current-non-root-passwords.shtml -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA | xargs chmod go-r`;
`find . -name current-account-password-pairs.data.gz -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA -o -name current-admin-passwords.shtml -mtime -$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA | xargs chmod go-r`;
}
}
}
############################################################################
# Assorted Variables, you should probably edit /usr/local/etc/LongTail.config
# though... Otherwise when you install a new version you'll lose your
# configuration
#
sub init_variables {
# Is this a public webserver? If so then we need to protect
# certain webpages so they are not seen by the badguys. We
# have to do this in order to hide what the current "Hot" or
# "Desirable" account and password combinations are
#
# Do not assume that just because your page isn't indexed
# by Google that your webpage is private.
#
# Set it to 1 if it is public, or 0 if it is private.
$PUBLIC_WEBSERVER=1;
# Do you want Pretty graphs using jpgraph? Set this to 1
# http://jpgraph.net/ JpGraph - Most powerful PHP-driven charts
$GRAPHS=1;
# Which honeypot are you running? Uncomment only ONE of the following
#$KIPPO=1 ; $LONGTAIL=0; # This is for the Kippo honeypot
$KIPPO=0 ; $LONGTAIL=1; # This is for the LongTail honeypot
#Where is the messages file? Uncomment only ONE of the following
$PATH_TO_VAR_LOG="/var/log/" ;# Typically for messages file from ryslog
#$PATH_TO_VAR_LOG="/usr/local/kippo-master/log/" ;# One place for kippo
#$PATH_TO_VAR_LOG="/var/log/kippo/" ;# another place for kippo
if ( ! -d $PATH_TO_VAR_LOG ) {
print "$PATH_TO_VAR_LOG does not exist, exiting now\n";
exit;
}
# What is the name of the default log file
$LOGFILE="messages";
#$LOGFILE="kippo.log";
if ( ! -e "$PATH_TO_VAR_LOG/$LOGFILE" ) {
print "$PATH_TO_VAR_LOG/$LOGFILE does not exist, exiting now\n";
exit;
}
#Where is the apache access_log file?
$PATH_TO_VAR_LOG_HTTPD="/var/log/httpd/";
if ( ! -d "$PATH_TO_VAR_LOG_HTTPD" ) {
print "$PATH_TO_VAR_LOG_HTTPD does not exist, exiting now\n";
exit;
}
# Do you want debug output? Set this to 1
$DEBUG=1;
# Do you want ssh analysis? Set this to 1
$DO_SSH=1;
# Do you want httpd analysis? Set this to 1
$DO_HTTPD=1;
# Do we obfuscate/rename the IP addresses? You might want to do this if
# you are copying your reports to a public site.
# $OBFUSCATE_IP_ADDRESSES=1 ;will hide addresses
# $OBFUSCATE_IP_ADDRESSES=0; will NOT hide addresses
$OBFUSCATE_IP_ADDRESSES=0;
# $OBFUSCATE_URLS=1 will hide URLs in the http report
# $OBFUSCATE_URLS=0 will NOT hide URLs in the http report
# This may not work properly yet.
$OBFUSCATE_URLS=0;
# These are the search strings from the "LogIt" sub in auth-passwd.c
# and are used to figure out which ports are being brute-forced.
# The code for PASSLOG2222 has not yet been written.
$PASSLOG="PassLog";
$PASSLOG2222="Pass2222Log";
# Where do we put the temporary files
$TMP_DIRECTORY="/data/tmp";
# Where are the scripts we need to run?
$SCRIPT_DIR="/usr/local/etc/";
if ( ! -d $SCRIPT_DIR ) {
print "Can not find SCRIPT_DIR: $SCRIPT_DIR, exiting now\n";
exit;
}
# Where do we put the reports?
$HTML_DIR="/var/www/html";
if ( ! -d $HTML_DIR ) {
print "Can not find HTML_DIR: $HTML_DIR, exiting now\n";
exit;
}
# What's the top level directory?
$SSH_HTML_TOP_DIR="honey"; #NO slashes please, it breaks sed
$SSH22_HTML_TOP_DIR="honey-22"; #NO slashes please, it breaks sed
$SSH2222_HTML_TOP_DIR="honey-2222"; #NO slashes please, it breaks sed
$TELNET_HTML_TOP_DIR="telnet"; #NO slashes please, it breaks sed
$RLOGIN_HTML_TOP_DIR="rlogin"; #NO slashes please, it breaks sed
$FTP_HTML_TOP_DIR="ftp"; #NO slashes please, it breaks sed
# This is for my personal debugging, just leave them
# commented out if you aren't me.
#$PATH_TO_VAR_LOG="/home/wedaa/source/LongTail/var/log/";
#$PATH_TO_VAR_LOG_HTTPD="/home/wedaa/source/LongTail/var/log/httpd/";
# Is this a consolidation server? (A server that
# processes many servers results AND makes individual
# reports for each server).
$CONSOLIDATION=0;
# What hosts are protected by a firewall or Intrusion Detection System?
# This is used to set the current-attack-count.data.notfullday flag
# in those directories to help "normalize" the data
if ( `hostname` eq "longtail.it.marist.edu" ) {
$HOSTS_PROTECTED="erhp erhp2";
$BLACKRIDGE="blackridge";
$RESIDENTIAL_SITES="shepherd";
$EDUCATIONAL_SITES="syrtest edub edu_c";
$CLOUD_SITES="cloud_v cloud_c";
$BUSINESS_SITES="";
}
else {
$HOSTS_PROTECTED="";
$BLACKRIDGE="";
$RESIDENTIAL_SITES="";
$EDUCATIONAL_SITES="";
$CLOUD_SITES="";
$BUSINESS_SITES="";
}
# Do we protect the raw data, and for how long?
# $PROTECT_RAW_DATA=1 will protect raw data
# $PROTECT_RAW_DATA=0 will NOT protect raw data
$PROTECT_RAW_DATA=1;
$NUMBER_OF_DAYS_TO_PROTECT_RAW_DATA=90;
############################################################################
# You don't need to edit after this.
#
$TODAY_AT_START_OF_RUNTIME=`date`;
$YEAR=`date +%Y`;
chomp $YEAR;
$HOUR=`date +%H` ;# This is used at the end of the program but we want to know it NOW
chomp $HOUR;
$START_HOUR=`date +%H`; # This is used at the end of the program but we want to know it NOW
chomp $START_HOUR;
$YEAR_AT_START_OF_RUNTIME=`date +%Y`;
chomp $YEAR_AT_START_OF_RUNTIME;
$MONTH_AT_START_OF_RUNTIME=`date +%m`;
chomp $MONTH_AT_START_OF_RUNTIME;
$DAY_AT_START_OF_RUNTIME=`date +%d`;
chomp $DAY_AT_START_OF_RUNTIME;
$REBUILD=0;
$MIDNIGHT=0;
$ONE_AM=1;
# Load the IP addresses we have seen here
open (INPUT, "tail -9999 $SCRIPT_DIR/ip-to-country|");
while (<INPUT>){
if (/UNKNOWN/){next;}
chomp;
($ip,$country)=split(/ /,$_,2);
$IP_ADDRESS{$ip}=$country;
}
close (INPUT);
}
############################################################################
# Lets make sure we can write to the directory
#
sub is_directory_good {
my $dir=shift;
if ( ! -d "$dir" ) {
print "$dir is not a directory, exiting now \n";
exit
}
if ( ! -w "$dir" ) {
print "I can't write to $dir, exiting now\n";
exit;
}
}
############################################################################
# Lets make sure we can write to the directory
#
sub is_file_good {
my $file=shift;
if ( ! -e "$file" ) {
print "DANGER DANGER DANGER\n";
print "$file does not exist, exiting now \n";
exit;
}
if ( ! -w $file ) {
print "DANGER DANGER DANGER\n";
print "I can't write to $file, exiting now\n";
exit;
}
}
############################################################################
# Change the date in index.shtml
sub change_date_in_index {
my $DATE=$datestring=localtime();
print $datestring;;
my $dir=shift;
print "DEBUG in change_date_in_index, dir is $dir";
&is_file_good ("$dir/index.shtml");
&is_file_good ("$dir/index-long.shtml");
&is_file_good ("$dir/graphics.shtml");
`sed -i "s/updated on..*\$/updated on $DATE/" $dir/index.shtml`;
`sed -i "s/updated on..*\$/updated on $DATE/" $dir/index-long.shtml`;
`sed -i "s/updated on..*\$/updated on $DATE/" $dir/graphics.shtml`;
}
############################################################################
# Make a proper HTML header for assorted columns
#
sub make_header {
# first argument, the full path including the filename you want to write to
# second argument, the title of the web page
# Third argument, text for description
# Other arguments are the column headers
# NOTE: This destroys $MAKE_HEADER_FILENAME before adding to it.
my $tmp;
my $MAKE_HEADER_DATE;
my $MAKE_HEADER_FILENAME;
my $TITLE;
my $DESCRIPTION;
$MAKE_HEADER_DATE=`date`;
chomp $MAKE_HEADER_DATE;
# if ( "$#" == "0" ) {
# print "You forgot to pass arguments, exiting now\n";
# exit 1;
# }
$MAKE_HEADER_FILENAME=shift;
&touch ($MAKE_HEADER_FILENAME);
if ( ! -w $MAKE_HEADER_FILENAME ) {
print "Can't write to $MAKE_HEADER_FILENAME, exiting now\n";
exit;
}
$TITLE= shift;
$DESCRIPTION= shift;
open (FILE, ">$MAKE_HEADER_FILENAME") || die "Can not write to $MAKE_HEADER_FILENAME\n";
print (FILE "<HTML><!--HEADERLINE -->\n" );
print (FILE "<HEAD><!--HEADERLINE -->\n" );
print (FILE "<META http-equiv=\"pragma\" content=\"no-cache\"><!--HEADERLINE -->\n" );
print (FILE "<TITLE>LongTail Log Analysis $TITLE</TITLE> <!--HEADERLINE -->\n" );
print (FILE "<style> /* HEADERLINE */ \n" );
print (FILE ".td-some-name /* HEADERLINE */ \n" );
print (FILE "{ /* HEADERLINE */ \n" );
print (FILE " white-space:nowrap; /* HEADERLINE */ \n" );
print (FILE " vertical-align:top; /* HEADERLINE */ \n" );
print (FILE "} /* HEADERLINE */ \n" );
print (FILE "</style> <!--HEADERLINE --> \n" );
print (FILE "</HEAD><!--HEADERLINE -->\n" );
print (FILE "<BODY BGCOLOR=#00f0FF><!--HEADERLINE -->\n" );
print (FILE "<!--#include virtual=\"/$HTML_TOP_DIR/header.html\" --> <!--HEADERLINE --> \n" );
print (FILE "<H1>LongTail Log Analysis</H1><!--HEADERLINE -->\n" );
print (FILE "<H3>$TITLE</H3><!--HEADERLINE -->\n" );
print (FILE "<P>$DESCRIPTION <!--HEADERLINE -->\n" );
print (FILE "<P>Created on $MAKE_HEADER_DATE<!--HEADERLINE -->\n" );
print (FILE "<TABLE border=1><!--HEADERLINE -->\n" );
print (FILE "<TR><!--HEADERLINE -->\n" );
while ( $tmp=shift ) {
#print "DEBUG make_header columns now, this column is $tmp\n";
print (FILE "<TH>$tmp</TH><!--HEADERLINE -->\n" );
}
print (FILE "</TR><!--HEADERLINE -->\n" );
close (FILE);
}
############################################################################
# Make a proper HTML footer for assorted columns
#
sub make_footer {
# One argument, the full path including the filename you want to write to
# if ( "$#" == "0" ) {
# print "You forgot to pass arguments, exiting now\n";
# exit 1;
# }
$MAKE_FOOTER_FILENAME=shift;
&touch ($MAKE_FOOTER_FILENAME);
if ( ! -w $MAKE_FOOTER_FILENAME ) {
print "Can't write to $MAKE_FOOTER_FILENAME, exiting now\n";
exit 1;
}
open (FILE, ">> $MAKE_FOOTER_FILENAME");
print (FILE "\n" );
print (FILE "</TABLE><!--HEADERLINE -->" );
print (FILE "<!--#include virtual=\"/$HTML_TOP_DIR/footer.html\" --> <!--HEADERLINE --> ");
print (FILE "</BODY><!--HEADERLINE -->" );
print (FILE "</HTML><!--HEADERLINE -->" );
}
############################################################################
# Count ssh attacks and modify $HTML_DIR/index.html
#
# Called as count_ssh_attacks $HTML_DIR $PATH_TO_VAR_LOG "messages*"
#
sub count_ssh_attacks {
use List::Util qw(max min sum);
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks now\n" ; }
$TMP_HTML_DIR=shift;
$PATH_TO_VAR_LOG=shift;
$MESSAGES=shift;
$ORIGINAL_DIRECTORY=`pwd`;
chomp $ORIGINAL_DIRECTORY;
$TMP_DATE=`date +%Y-%m-%d`;
chomp $TMP_DATE;
$TMP_YEAR=`date +%Y`;
chomp $TMP_YEAR;
$TMP_MONTH=`date +%m`;
chomp $TMP_MONTH;
$TMP_DAY=`date +%d`;
chomp $TMP_DAY;
#
# Lets make sure we have one for today and this month and this year
$TMP_DIR=$TMP_HTML_DIR;
if ( ! -d "$TMP_DIR" ) { `mkdir $TMP_DIR ; chmod a+rx $TMP_DIR;` }
$TMP_DIR="$TMP_HTML_DIR/historical";
if ( ! -d "$TMP_DIR" ) { `mkdir $TMP_DIR ; chmod a+rx $TMP_DIR;` }
$TMP_DIR="$TMP_HTML_DIR/historical/$TMP_YEAR";
if ( ! -d "$TMP_DIR" ) { `mkdir $TMP_DIR ; chmod a+rx $TMP_DIR;` }
$TMP_DIR="$TMP_HTML_DIR/historical/$TMP_YEAR/$TMP_MONTH";
if ( ! -d "$TMP_DIR" ) { `mkdir $TMP_DIR ; chmod a+rx $TMP_DIR;` }
$TMP_DIR="$TMP_HTML_DIR/historical/$TMP_YEAR/$TMP_MONTH/$TMP_DAY";
if ( ! -d "$TMP_DIR" ) { `mkdir $TMP_DIR ; chmod a+rx $TMP_DIR;` }
$list="$HOSTS_PROTECTED $BLACKRIDGE";
while ($list =~ s/ / /g){}
$count=@my_word_list=split(/ /,$list);
#print "count is $count\n";
if ($count >0){
foreach (@my_word_list) {
chomp;
$dir=$_;
if ( "x$HOSTNAME" eq "x$dir" ) {
&touch ("$TMP_HTML_DIR/historical/$TMP_YEAR/$TMP_MONTH/$TMP_DAY/current-attack-count.data.notfullday");
#print "$TMP_HTML_DIR/historical/$TMP_YEAR/$TMP_MONTH/$TMP_DAY/ \n";
}
}
}
#
# Why did I add this line?
# This makes sure the current day exists and is set to no data ?
# But why am I creating this file later?
# So I commented out the if statement so I ALWAYS clear the current data.
#if ( ! -e "$TMP_HTML_DIR/historical/$TMP_YEAR/$TMP_MONTH/$TMP_DAY/current-raw-data.gz" ) {
`echo "" |gzip -c > $TMP_HTML_DIR/historical/$TMP_YEAR/$TMP_MONTH/$TMP_DAY/current-raw-data.gz`;
`chmod a+r $TMP_HTML_DIR/historical/$TMP_YEAR/$TMP_MONTH/$TMP_DAY/current-raw-data.gz`;
#}
#
# TODAY
#
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks/TODAY now:" ; $DEBUG_DATE=`date`; print "$DEBUG_DATE"; }
# WHY WAS THIS HERE? 2015-12-29 chdir ("$PATH_TO_VAR_LOG");
chdir ("$HTML_DIR");
if ( "x$HOSTNAME" eq "x/" ) {
if ( $LONGTAIL == 1 ) {
$TODAY=`$SCRIPT_DIR/catall.sh $PATH_TO_VAR_LOG/$MESSAGES |grep $PROTOCOL |grep "$TMP_DATE" | grep -F -vf $SCRIPT_DIR/LongTail-exclude-IPs-ssh.grep | grep -F -vf $SCRIPT_DIR/LongTail-exclude-accounts.grep |egrep Password|wc -l`;
chomp $TODAY;
}
if ( $KIPPO == 1 ) {
$TODAY=`$SCRIPT_DIR/catall.sh $PATH_TO_VAR_LOG/$MESSAGES |grep ssh |grep "$TMP_DATE" | grep -F -vf $SCRIPT_DIR/LongTail-exclude-IPs-ssh.grep | grep -F -vf $SCRIPT_DIR/LongTail-exclude-accounts.grep |egrep login\ attempt|wc -l`;
chomp $TODAY;
}
}
else { # We were passed a hostname. This should never happen with Kippo
if ( $KIPPO == 1 ) {
print "LongTail is only for single instances of Kippo. You passed a hostname to LongTail.pl";
print "Exiting now\n";
exit;
}
$TODAY=`$SCRIPT_DIR/catall.sh $PATH_TO_VAR_LOG/$MESSAGES |grep $PROTOCOL |awk '\$2 == \"$HOSTNAME\" {print}' |grep "$TMP_DATE" | grep -F -vf $SCRIPT_DIR/LongTail-exclude-IPs-ssh.grep | grep -F -vf $SCRIPT_DIR/LongTail-exclude-accounts.grep |egrep Password|wc -l`;
chomp $TODAY;
}
`echo $TODAY > $TMP_HTML_DIR/current-attack-count.data`;
print "\n\nDEBUG TODAY is $TODAY\n\n";
if ( $START_HOUR == $MIDNIGHT ) {
#
# THIS MONTH
#
chdir ("$TMP_HTML_DIR/historical/");
if ( $DEBUG == 1 ) {
print "Its midnight, doing midnight stuff\n";
print "\n\nDEBUG Tried to chdir to $TMP_HTML_DIR/historical/\n\n";
}
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks-This Month now\n" }
$TMP=0;
open (FIND, "find $TMP_YEAR/$TMP_MONTH -name current-attack-count.data|");
while (<FIND>){
chomp;
open (FILE, "$_");
while (<FILE>){
chomp;
$COUNT=$_;
}
close (FILE);
$TMP+=$COUNT;
}
close (FIND);
$THIS_MONTH=$TMP + $TODAY ;
# OK, this may not be 100% secure, but it's close enough for now
if ( $DEBUG == 1 ) { print "DEBUG this month statistics;" ;$DEBUG_DATE=`date`; print "$DEBUG_DATE"; }
#
# So there's a problem if it's the first day of the month and there's
# No real statistics yet.
#
if ( -e "$TMP_YEAR/$TMP_MONTH" ) {
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks/This Month/Statistics now\n" ; }
@a=();
$tmp_count=0;
open (FIND, "find $TMP_YEAR/$TMP_MONTH/*/current-attack-count.data|");
while(<FIND>){
open (FILE, $_);
while (<FILE>){
$sqsum+=$_*$_; push(@a,$_)
}
close (FILE);
$tmp_count++;
};
if ($tmp_count>0){
$n=@a;$s=sum(@a);$a=$s/@a;$m=max(@a);$mm=min(@a);$std=sqrt($sqsum/$n-($s/$n)*($s/$n));$mid=int @a/2;@srtd=sort { $a <=> $b } @a;if(@a%2){$med=$srtd[$mid];}else{$med=($srtd[$mid-1]+$srtd[$mid])/2;}; $n;
$MONTH_COUNT=$n;;
$MONTH_SUM=$s;;
$MONTH_AVERAGE=$a;
$MONTH_STD=$std;
$MONTH_MEDIAN=$med;
$MONTH_MAX=$m;
$MONTH_MIN=$mm;
$MONTH_AVERAGE=sprintf "%.2f",$MONTH_AVERAGE;
$MONTH_STD=sprintf "%.2f",$MONTH_STD;
} else {
$MONTH_COUNT=1;
$MONTH_SUM=$TODAY;
$MONTH_AVERAGE=$TODAY;
$MONTH_STD=0;
$MONTH_MEDIAN=$TODAY;
$MONTH_MAX=$TODAY;
$MONTH_MIN=$TODAY;
#MONTH_AVERAGE=`printf '%.2f' 0`
$MONTH_STD=0;
}
} else {
$MONTH_COUNT=1;
$MONTH_SUM=$TODAY;
$MONTH_AVERAGE=$TODAY;
$MONTH_STD=0;
$MONTH_MEDIAN=$TODAY;
$MONTH_MAX=$TODAY;
$MONTH_MIN=$TODAY;
#MONTH_AVERAGE=`printf '%.2f' 0`
$MONTH_STD=0;
}
$MONTH_COUNT=&commify("$MONTH_COUNT");
$MONTH_SUM=&commify("$MONTH_SUM");
$MONTH_AVERAGE=&commify("$MONTH_AVERAGE");
$MONTH_STD=&commify("$MONTH_STD");
$MONTH_MEDIAN=&commify("$MONTH_MEDIAN");
$MONTH_MAX=&commify("$MONTH_MAX");
$MONTH_MIN=&commify("$MONTH_MIN");
#
# LAST MONTH
#
print "DEBUG trying to chdir to $TMP_HTML_DIR/historical/\n";
chdir ("$TMP_HTML_DIR/historical/");
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks/Last Month now \n" }
#
# Gotta fix this for the year boundary
#
$TMP_LAST_MONTH=`date "+%m" --date="last month"`;
chomp $TMP_LAST_MONTH;
$TMP_LAST_MONTH_YEAR=`date "+%Y" --date="last month"`;
chomp $TMP_LAST_MONTH_YEAR;
$TMP=0;
print "DEBUG LAST MONTH $TMP_LAST_MONTH $TMP_LAST_MONTH_YEAR\n";
if ( -d $TMP_LAST_MONTH_YEAR/$TMP_LAST_MONTH ){
open (FIND, "find $TMP_LAST_MONTH_YEAR/$TMP_LAST_MONTH -name current-attack-count.data|") ||
die "Can't run find $TMP_LAST_MONTH_YEAR/$TMP_LAST_MONTH -name current-attack-count.data, exiting now\n";
while (<FIND>){
chomp;
open (FILE, "$_");
while (<FILE>){
chomp;
$COUNT=$_;
}
close (FILE);
$TMP+=$COUNT;
}
close (FIND);
}
$LAST_MONTH=$TMP;
# OK, this may not be 100% secure, but it's close enough for now
if ( $DEBUG == 1 ) { print "DEBUG Last month statistics :" ;$DEBUG_DATE=`date`; print "$DEBUG_DATE"; ; }
#
# So there's a problem if it's the first day of the month and there's
# No real statistics yet.
#
#
# Gotta do the date calculation to figure out "When" is last month
#
print "DEBUG-1\n"; `$date`;
if ( -d "$TMP_LAST_MONTH_YEAR/$TMP_LAST_MONTH" ) {
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks/Last Month/statistics now:" ;$DEBUG_DATE=`date`; print "$DEBUG_DATE"; }
@a=();
open (FIND, "find $TMP_LAST_MONTH_YEAR/$TMP_LAST_MONTH/*/current-attack-count.data|");
while(<FIND>){
open (FILE, $_);
while (<FILE>){
$sqsum+=$_*$_; push(@a,$_)
}
close (FILE);
}
close (FIND);
$n=@a;
$s=sum(@a);
if ( @a) {$a=$s/@a }else{$a="NA";}
$m=max(@a);
$mm=min(@a);
if ($n){$std=sqrt($sqsum/$n-($s/$n)*($s/$n))}else{$std="NA";}
$mid=int @a/2;
@srtd=sort { $a <=> $b } @a;
if(@a%2){$med=$srtd[$mid];}else{$med=($srtd[$mid-1]+$srtd[$mid])/2;}
$LAST_MONTH_COUNT=$n;
$LAST_MONTH_SUM=$s;
$LAST_MONTH_AVERAGE=$a;
$LAST_MONTH_STD=$std;
$LAST_MONTH_MEDIAN=$med;
$LAST_MONTH_MAX=$m;
$LAST_MONTH_MIN=$mm;
#
# Now we "clean up" the average and STD deviation
$LAST_MONTH_AVERAGE=sprintf "%.2f",$LAST_MONTH_AVERAGE;
$LAST_MONTH_STD=sprintf "%.2f",$LAST_MONTH_STD;
}
else {
$LAST_MONTH_COUNT="N/A";
$LAST_MONTH_SUM="N/A";
$LAST_MONTH_AVERAGE="N/A";
$LAST_MONTH_STD="N/A";
$LAST_MONTH_MEDIAN="N/A";
$LAST_MONTH_MAX="N/A";
$LAST_MONTH_MIN="N/A";
$LAST_MONTH_STD="N/A";
}
$LAST_MONTH_COUNT=&commify( $LAST_MONTH_COUNT );
$LAST_MONTH_SUM=&commify( $LAST_MONTH_SUM );
$LAST_MONTH_AVERAGE=&commify( $LAST_MONTH_AVERAGE );
$LAST_MONTH_STD=&commify( $LAST_MONTH_STD );
$LAST_MONTH_MEDIAN=&commify( $LAST_MONTH_MEDIAN );
$LAST_MONTH_MAX=&commify( $LAST_MONTH_MAX );
$LAST_MONTH_MIN=&commify( $LAST_MONTH_MIN);
#
# THIS YEAR
#
# This was tested and works with 365 files :-)
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks/This Year now\n" }
$TMP=0;
open (FIND, "find $TMP_YEAR -name current-attack-count.data|");
while (<FIND>){
chomp;
open (FILE, "$_");
while (<FILE>){
chomp;
$COUNT=$_;
}
close (FILE);
$TMP+=$COUNT;
}
$THIS_YEAR=`expr $TMP + $TODAY`;
if ( $DEBUG == 1 ) { print "DEBUG this year statistics \n" ; }
# OK, this may not be 100% secure, but it's close enough for now
@a=();
open (FIND, "find $TMP_YEAR/ -name current-attack-count.data|");
while(<FIND>){
open (FILE, $_);
while (<FILE>){
$sqsum+=$_*$_; push(@a,$_)
}
close (FILE);
}
close (FIND);
$n=@a;
$s=sum(@a);
if ( @a) {$a=$s/@a }else{$a="NA";}
$m=max(@a);
$mm=min(@a);
if ($n){$std=sqrt($sqsum/$n-($s/$n)*($s/$n))}else{$std="NA";}
$mid=int @a/2;
@srtd=sort { $a <=> $b } @a;
if(@a%2){$med=$srtd[$mid];}else{$med=($srtd[$mid-1]+$srtd[$mid])/2;}
$YEAR_COUNT=$n;
$YEAR_SUM=$s;
$YEAR_AVERAGE=$a;
$YEAR_STD=$std;
$YEAR_MEDIAN=$med;
$YEAR_MAX=$m;
$YEAR_MIN=$mm;
$YEAR_AVERAGE=sprintf "%.2f",$YEAR_AVERAGE;
$YEAR_STD=sprintf "%.2f",$YEAR_STD;
$YEAR_COUNT=&commify( $YEAR_COUNT );
$YEAR_SUM=&commify( $YEAR_SUM );
$YEAR_AVERAGE=&commify( $YEAR_AVERAGE );
$YEAR_STD=&commify( $YEAR_STD );
$YEAR_MEDIAN=&commify( $YEAR_MEDIAN );
$YEAR_MAX=&commify( $YEAR_MAX );
$YEAR_MIN=&commify( $YEAR_MIN );
#
# EVERYTHING
#
# I have no idea where this breaks, but it's a big-ass number of files
$TMP=0;
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks-everything \n" ; }
open (FIND, "find . -name current-attack-count.data|");
while (<FIND>){
chomp;
open (FILE, "$_");
while (<FILE>){
chomp;
$COUNT=$_;
}
close (FILE);
$TMP+=$COUNT;
}
$TOTAL= $TMP + $TODAY;
# OK, this may not be 100% secure, but it's close enough for now
if ( $DEBUG == 1 ) { print "DEBUG ALL statistics\n" ; }
if ( $DEBUG == 1 ) { print "DEBUG-in count_ssh_attacks-everything-statistics\n" ; }
@a=();
open (FIND, "find . -name current-attack-count.data|");
while(<FIND>){
open (FILE, $_);
while (<FILE>){
$sqsum+=$_*$_; push(@a,$_)
}
close (FILE);
}
close (FIND);
$n=@a;
$s=sum(@a);
if ( @a) {$a=$s/@a }else{$a="NA";}
$m=max(@a);
$mm=min(@a);
if ($n){$std=sqrt($sqsum/$n-($s/$n)*($s/$n))}else{$std="NA";}
$mid=int @a/2;
@srtd=sort { $a <=> $b } @a;
if(@a%2){$med=$srtd[$mid];}else{$med=($srtd[$mid-1]+$srtd[$mid])/2;}
$EVERYTHING_COUNT=$n;
$EVERYTHING_SUM=$s;
$EVERYTHING_AVERAGE=$a;
$EVERYTHING_STD=$std;
$EVERYTHING_MEDIAN=$med;
$EVERYTHING_MAX=$m;
$EVERYTHING_MIN=$mm;
$EVERYTHING_AVERAGE=sprintf "%.2f",$EVERYTHING_AVERAGE;
$EVERYTHING_STD=sprintf "%.2f",$EVERYTHING_STD;
$EVERYTHING_COUNT=&commify( $EVERYTHING_COUNT );
$EVERYTHING_SUM=&commify( $EVERYTHING_SUM );
$EVERYTHING_AVERAGE=&commify( $EVERYTHING_AVERAGE );
$EVERYTHING_STD=&commify( $EVERYTHING_STD );
$EVERYTHING_MEDIAN=&commify( $EVERYTHING_MEDIAN );
$EVERYTHING_MAX=&commify( $EVERYTHING_MAX );
$EVERYTHING_MIN=&commify( $EVERYTHING_MIN );
#
# Normalized data
#
# I have no idea where this breaks, but it's a big-ass number of files
chdir ("$TMP_HTML_DIR/historical/");
# OK, this may not be 100% secure, but it's close enough for now
if ( $DEBUG == 1 ) { print "DEBUG ALL Normalized statistics \n" }
@a=();
open (FIND, "find . -name current-attack-count.data|");
while(<FIND>){
chomp;
if ( ! -e "$_.notfullday" ) {
open (FILE, $_);
while (<FILE>){
$sqsum+=$_*$_; push(@a,$_)
}
close (FILE);
}
}
close (FIND);
$n=@a;
$s=sum(@a);
if ( @a) {$a=$s/@a }else{$a="NA";}
$m=max(@a);
$mm=min(@a);
if ($n){$std=sqrt($sqsum/$n-($s/$n)*($s/$n))}else{$std="NA";}
$mid=int @a/2;
@srtd=sort { $a <=> $b } @a;
if(@a%2){$med=$srtd[$mid];}else{$med=($srtd[$mid-1]+$srtd[$mid])/2;}
$NORMALIZED_COUNT=$n;
$NORMALIZED_SUM=$s;
$NORMALIZED_AVERAGE=$a;
$NORMALIZED_STD=$std;
$NORMALIZED_MEDIAN=$med;
$NORMALIZED_MAX=$m;
$NORMALIZED_MIN=$mm;
$NORMALIZED_AVERAGE=sprintf "%.2f",$NORMALIZED_AVERAGE;
$NORMALIZED_STD=sprintf "%.2f",$NORMALIZED_STD;
$NORMALIZED_COUNT=&commify( $NORMALIZED_COUNT );
$NORMALIZED_SUM=&commify( $NORMALIZED_SUM );
$NORMALIZED_AVERAGE=&commify( $NORMALIZED_AVERAGE );
$NORMALIZED_STD=&commify( $NORMALIZED_STD );
$NORMALIZED_MEDIAN=&commify( $NORMALIZED_MEDIAN );
$NORMALIZED_MAX=&commify( $NORMALIZED_MAX );
$NORMALIZED_MIN=&commify( $NORMALIZED_MIN );
$THIS_MONTH=&commify( $THIS_MONTH);
$THIS_YEAR=&commify( $THIS_YEAR);
$TOTAL=&commify( $TOTAL);
chomp $THIS_MONTH;
print "ASDF-1\n";
`sed -i 's/Login Attempts This Month.*\$/Login Attempts This Month:--> $THIS_MONTH/' $TMP_HTML_DIR/index.shtml`;