środa, 6 maja 2015
Packt celebrates International Day Against DRM, May 6th 2015
Packt Publishing firmly believes that you should be able to read and interact with your content when you want, where you want, and how you want – to that end they have been advocates of DRM-free content since their very first eBook was published back in 2004.
This year, to demonstrate their continuing support for Day Against DRM, Packt is offering all its DRM-free content at $10 for 24 hours only on May 6th – with more than 3000 eBooks and 100 Videos available across the publisher’s website www.packtpub.com, there’s plenty to discover, whatever you’re interested in.
“Our top priority at Packt has always been to meet the evolving needs of developers in the most practical way possible, while at the same time protecting the hard work of our authors. DRM-free content continues to be instrumental in making that happen, providing the flexibility and freedom that is essential for an efficient and enhanced learning experience. That’s why we’ve been DRM-free from the beginning – we’ll never put limits on the innovation of our users.”
– Dave Maclean, CEO
Advocates of Day Against DRM are invited to spread the word and celebrate on May 6th by exploring the full range of DRM-free content at www.packtpub.com - all eBooks and Videos will be $10 for 24 hours, including the latest hot titles.
wtorek, 23 grudnia 2014
$5 EBOOK BONANZA – EVERY TITLE, EVERY TOPIC
With all $5 products available in a range of formats and DRM-free, customers will find great value content delivered exactly how they want it across Packt’s website this Christmas and New Year. From Thursday 18th December, every eBook and video will be available on the publisher’s website for just $5 until 6th January.
More info : http://bit.ly/1uW4pQG
czwartek, 7 sierpnia 2014
Apache stats for bots
Last time my server got overload due to heavy queries from bots.
I needed to know which bot is so malicious.
I wrote simple script to parse apache logs to search boot.
#!/usr/bin/perl
use File::Basename;
use Time::Piece;
use Term::ANSIColor qw(:constants);
if (-T $plik){
open(PLIK,"$plik")||die "nie mozna otwoprzyc pliku: $plik!!!\n";
}
elsif(-B $plik){
open(PLIK,"zcat $plik |")||die "nie mozna otwoprzyc pliku: $plik!!!\n";
}
else {
print "Pliku: $plik nie mozna otworzyc\n";
exit;
}
while(defined($log=)){
my ($host,$date,$reqtype,$url,$proto,$status,$size,$referrer,$agent) = $log =~
m/^(\S+) - - \[(\S+ [\-|\+]\d{4})\] "(GET|POST)\s(.+)\sHTTP\/(\d.\d)" (\d{3}) (\d+|-) "(.*?)" "([^"]+)"$/;
if ($status eq "200" && $reqtype eq "GET" && $agent =~ m/bot/i){
my $dt = Time::Piece->strptime($date, '%d/%b/%Y:%H:%M:%S %z');
$date= $dt->strftime('%Y-%m-%d');
$slugnumber{$agent}{$date}{$host}++;
$bot{$agent}++;
}
}
close(PLIK);
foreach $klucz (sort keys %slugnumber){
print "\n================================================\n";
print BOLD,BLUE,"\n $klucz \n",RESET;
foreach $data (keys %{ $slugnumber{$klucz} }){
print BOLD,BLUE,"\n $data \n",RESET;
foreach $ipek (keys %{ $slugnumber{$klucz}{$data} }){
print "$klucz $data [$ipek] : $slugnumber{$klucz}{$data}{$ipek}\n"
}
}
}
Below is output:
testing> perl ipstats.pl /var/log/apache/access.log
================================================
Yeti/1.1 (Naver Corp.; http://help.naver.com/robots/)
2014-08-05
Yeti/1.1 (Naver Corp.; http://help.naver.com/robots/) 2014-08-05 [125.209.211.199] : 1
2014-08-04
Yeti/1.1 (Naver Corp.; http://help.naver.com/robots/) 2014-08-04 [125.209.211.199] : 1
================================================
msnbot/2.0b (+http://search.msn.com/msnbot.htm)
2014-08-05
msnbot/2.0b (+http://search.msn.com/msnbot.htm) 2014-08-05 [65.55.213.247] : 10
msnbot/2.0b (+http://search.msn.com/msnbot.htm) 2014-08-05 [65.55.213.243] : 4
msnbot/2.0b (+http://search.msn.com/msnbot.htm) 2014-08-05 [65.55.213.242] : 2
środa, 25 czerwca 2014
Grep - get first and last line
Last time I had to search my logs for certain message. I needed to connect this with user login/logout time.
I needed estimated time of "start" and "end " occurences in logs ( logs which contains huge messages with different time and same message).
I used sed and grep to this:
root@testing:~# for i in `ls /var/log/syslog/syslog*`;do zgrep 'port 1099' $i | sed -n '1p;$p'; done;
Jun 25 08:18:01 testing sshd[33286]: error: connect_to x.y.z.c port 1099: failed.
Jun 25 11:30:52 testing sshd[45831]: error: connect_to x.y.z.d port 1099: failed.
Jun 24 07:55:04 testing sshd[64527]: error: connect_to x.y.z.d port 1099: failed.
Jun 24 11:53:13 testing sshd[64527]: error: connect_to x.y.z.c port 1099: failed.
Jun 23 08:59:52 testing sshd[34130]: error: connect_to x.y.z.c port 1099: failed.
Jun 23 15:28:38 testing sshd[34130]: error: connect_to x.y.z.d port 1099: failed.
Jun 20 08:24:51 testing sshd[64526]: error: connect_to x.y.z.c port 1099: failed.
Jun 20 10:55:46 testing sshd[7805]: error: connect_to x.y.z.c port 1099: failed.
poniedziałek, 16 czerwca 2014
czwartek, 12 czerwca 2014
Check SSL expiration date
Recently I needed to check out my domains due to SSL expiration date.
I used script below - it frees up time.
How does it work ?
I need file which contains domeins in form : address:port
In loop I check every domain with parameter "-enddate" (certificate expiration date) using openssl.
I change dates to timestamp and subtract expiration date from date "now+30days".
If result timestamp is lower than daystimestamp (which is number of days in seconds) it warnings me that certificate will expire soon.
shamrock@alucard:~$ cat check_ssl_expiration.sh
days=30
daystimestamp=`expr $days \* 86400`
for domain in `cat domeny.txt`
do
expire=`echo | openssl s_client -connect $domain 2>/dev/null | openssl x509 -noout -enddate | awk -F \= '{print $2}'`
out=`date -d "$expire" "+%s"`
in=`date --date="$days days" "+%s"`
res=`expr $out - $in`
if [ $res -lt 0 ]; then
echo "ALARM !!! DOMAIN $domain EXPIRED ON $expire"
elif [ $res -lt $daystimestamp ]; then
echo "ALARM !!! DOMAIN $domain WILL EXPIRE ON $expire"
else
echo "$domain WILL EXPIRE ON $expire"
fi
done
Usage:
shamrock@alucard:~$ bash check_ssl_expiration.sh
poczta.onet.pl:443 WILL EXPIRE ON Oct 14 06:10:33 2014 GMT
ALARM !!! DOMAIN some.kind.of.mons.tr:443 EXPIRE ON Jul 3 13:19:18 2013 GMT
File contains domains:
shamrock@alucard:~$ cat domeny.txt
poczta.onet.pl:443
some.kind.of.mons.tr:443
Etykiety:
bash,
expiration date,
openssl,
openssl verify,
script,
ssl,
validation ssl certificate
poniedziałek, 5 maja 2014
Subskrybuj:
Posty (Atom)

