rename pdf with creation date

mv /path/to/pdf/file.pdf /path/to/pdf/$( awk -F':' '/\/CreationDate/ {print  substr($2,"",length($2)-8)}' /path/to/pdf/file.pdf ).pdf
Advertisements

nmap

discover all IPs connected in the network

nmap -sP 192.168.0.0/24 | egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort -n -t . -k 4

get information from hosts through windows sharing

nmap -script smb-os-discovery -p 445 -open 192.168.0.0/24

show hosts with port 631 open

nmap 192.168.0.0/24 -p 631 -open | awk '/)$/ {print $NF}'

Limits two simultaneous connections on port 80 to each host connected to the network

nmap -sP 192.168.0.0/24 | egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort -n -t . -k 4 | xargs -I% iptables -A INPUT -s % -p tcp --dport 80 -m connlimit --connlimit-above 2 -j DROP

header and footer with awk

insert header before output file

awk 'BEGIN { print "###\nheader\n###" } { print }' /etc/passwd

insert footer before output file

awk '{ print } END { print "###\nfooter\n###" }' /etc/passwd

insert header and footer between output file

awk 'BEGIN { print "###\nheader\n###" } { print } END { print "###\nfooter\n###" }' /etc/passwd

insert header before output match

awk 'BEGIN { print "###\nheader\n###" } /www-data/ { print }' /etc/passwd

insert footer before output match

awk '/www-data/ { print } END { print "###\nfooter\n###" }' /etc/passwd

insert header and footer between output match

awk 'BEGIN { print "###\nheader\n###" } /www-data/ { print } END { print "###\nfooter\n###" }' /etc/passwd