|
|
|
@ -17,31 +17,42 @@ function HL { |
|
|
|
echo -e "$BLUE============================================================================$RST" |
|
|
|
echo -e "$BLUE============================================================================$RST" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function procList { |
|
|
|
|
|
|
|
ps aux | awk '{ print $11 }' | sort | uniq | egrep -v '^\[' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function portList { |
|
|
|
|
|
|
|
netstat -lpn | egrep "(tcp.*LISTEN|udp)" | sort | uniq | awk '{split($NF,arr,"/"); print $1 " " $4 " " arr[2]}' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function firewallRules { |
|
|
|
|
|
|
|
(/sbin/iptables -L -n; echo -e "\n#NAT\n"; /sbin/iptables -L -nt nat) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function routingTable { |
|
|
|
|
|
|
|
/sbin/ip route |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function makeSnap { |
|
|
|
function makeSnap { |
|
|
|
FOLDER=~/server_states/state_$(date '+%Y%m%d_%H%M%S') |
|
|
|
FOLDER=~/server_states/state_$(date '+%Y%m%d_%H%M%S') |
|
|
|
mkdir -p $FOLDER |
|
|
|
mkdir -p $FOLDER |
|
|
|
ps aux | awk '{ print $11 }' | sort | uniq | egrep -v '^\[' > $FOLDER/ps.out |
|
|
|
procList > $FOLDER/ps.out |
|
|
|
netstat -lpn | egrep "(tcp.*LISTEN|udp)" | sort | uniq | awk '{split($NF,arr,"/"); print $1 " " $4 " " arr[2]}' > $FOLDER/netstat.out |
|
|
|
portList > $FOLDER/netstat.out |
|
|
|
(/sbin/iptables -L -n; echo -e "\n#NAT\n"; /sbin/iptables -L -nt nat) > $FOLDER/iptables.out |
|
|
|
firewallRules > $FOLDER/iptables.out |
|
|
|
/sbin/iptables-save > $FOLDER/iptables-save.out |
|
|
|
/sbin/iptables-save > $FOLDER/iptables-save.out |
|
|
|
mount > $FOLDER/mount.out |
|
|
|
mount > $FOLDER/mount.out |
|
|
|
/sbin/ip route > $FOLDER/routing.out |
|
|
|
routingTable > $FOLDER/routing.out |
|
|
|
msg "Written state snapshot to $FOLDER" |
|
|
|
msg "Written state snapshot to $FOLDER" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function compare { |
|
|
|
function compare { |
|
|
|
FOLDER=~/server_states/$(ls ~/server_states/ | tail -n 1) |
|
|
|
FOLDER=~/server_states/$(ls ~/server_states/ | tail -n 1) |
|
|
|
msg "Comparing with snap $FOLDER" |
|
|
|
msg "Comparing with snap $FOLDER" |
|
|
|
echo -e "$GREEN\nProcesses diff$RST"; HL |
|
|
|
echo -e "$GREEN\nProcesses diff$RST"; HL; procList | diff - $FOLDER/ps.out | colorDiff |
|
|
|
ps aux | awk '{ print $11 }' | sort | uniq | egrep -v '^\[' | diff - $FOLDER/ps.out | colorDiff |
|
|
|
echo -e "$GREEN\nOpened ports diff$RST"; HL; portList | diff - $FOLDER/netstat.out | colorDiff |
|
|
|
echo -e "$GREEN\nOpened ports diff$RST"; HL |
|
|
|
echo -e "$GREEN\nFirewall rules diff$RST"; HL; firewallRules | diff - $FOLDER/iptables.out | colorDiff |
|
|
|
netstat -lpn | egrep "(tcp.*LISTEN|udp)" | sort | uniq | awk '{split($NF,arr,"/"); print $1 " " $4 " " arr[2]}' | diff - $FOLDER/netstat.out | colorDiff |
|
|
|
echo -e "$GREEN\nMounts diff$RST"; HL; mount | diff - $FOLDER/mount.out | colorDiff |
|
|
|
echo -e "$GREEN\nFirewall rules diff$RST"; HL |
|
|
|
echo -e "$GREEN\nRouting table diff$RST"; HL; routingTable | diff - $FOLDER/routing.out | colorDiff |
|
|
|
(/sbin/iptables -L -n; echo -e "\n#NAT\n"; /sbin/iptables -L -nt nat) | diff - $FOLDER/iptables.out | colorDiff |
|
|
|
|
|
|
|
echo -e "$GREEN\nMounts diff$RST"; HL |
|
|
|
|
|
|
|
mount | diff - $FOLDER/mount.out | colorDiff |
|
|
|
|
|
|
|
echo -e "$GREEN\nRouting table diff$RST"; HL |
|
|
|
|
|
|
|
/sbin/ip route | diff - $FOLDER/routing.out | colorDiff |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function printHelp { |
|
|
|
function printHelp { |
|
|
|
|