Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
rushipkar90 / quickcheck-spamming.sh
Created September 25, 2015 16:21
quickcheck-spamming.sh
#/bin/bash
echo > /usr/local/src/temp_eximlog
echo > /usr/local/src/maliciousresults
echo > /usr/local/src/maliciousfiles
a=`date --date="3 hours ago" +%Y-%m-%d\ %H`
b=`date +%Y-%m-%d\ %H`
awk -v s="$a" -v e="$b" '$0~s,$0~e' /var/log/exim_mainlog >> /usr/local/src/temp_eximlog
cat /usr/local/src/temp_eximlog | awk '{print $3}' | grep /home | sort | uniq -c | sort -nr > scanmaillogdir.txt
for i in `cat /usr/local/src/scanmaillogdir.txt | cut -d= -f2` ; do
find $i -type f -name '*.php' -exec egrep -q 'yMxbgVDJ96|wUu2jGoB|$xYEzDu6r3EZT|$ZR2%tuMpYFr|$knmui74|x47LOBA|EWnBCG-hUfK|vC82XHO|rOqYibX4WA|ALaEJ!Pw|vHHEE8M|v08X2QH|vO5CQ7A|qjyxw29' {} \; -print >> /usr/local/src/maliciousfiles
@rushipkar90
rushipkar90 / versioncheck.sh
Created September 25, 2015 16:22
versioncheck.sh
find /home/*/public_html/ -type f -iwholename "*/wp-includes/version.php" -exec grep -H "\$wp_version =" {} \; > wordpress.txt
find /home/*/public_html/ -type f \( -iwholename '*/libraries/joomla/version.php' -o -iwholename '*/libraries/cms/version.php' -o -iwholename '*/libraries/cms/version/version.php' \) -print -exec perl -e 'while (<>) { $release = $1 if m/ \$RELEASE\s+= .([\d.]+).;/; $dev = $1 if m/ \$DEV_LEVEL\s+= .(\d+).;/; } print qq($release.$dev\n);' {} \; > joomla.txt
find /home/*/public_html/ -type f -iwholename "*/modules/system/system.info" -exec grep -H "version = \"" {} \; > drupal.txt
@rushipkar90
rushipkar90 / add_mailchannels_spf.sh
Created September 25, 2015 16:24
add_mailchannels_spf.sh
#!/bin/bash
LIST=$1
LOG=spf_add.log
date > $LOG
lecho() {
echo $@ 2>&1 | tee -a $LOG
}
backup_zones(){
FILE=$(hostname)-$(date +%s)-zones.tgz
tar czf $FILE /var/named/*.db
@rushipkar90
rushipkar90 / auto_terminate.sh
Created September 25, 2015 16:24
auto_terminate.sh
#!/bin/bash
# Directory to store log files in
DST=/root/autotermination_logs
# Create DST if it doesn't exist
if [ ! -d "$DST" ]; then
mkdir -p $DST
fi
@rushipkar90
rushipkar90 / bandwidthusage.pl
Created September 25, 2015 16:25
bandwidthusage.pl
#!/usr/bin/perl
use lib '/root/sysutils/modules';
use XML::Simple;
use Data::Dumper;
use XMLAPIRequest;
chomp(my $hostname = `hostname`);
$xmlapi = XMLAPIRequest->new(
'HOSTNAME' => $hostname
@rushipkar90
rushipkar90 / check_bw.sh
Created September 25, 2015 16:25
check_bw.sh
#!/bin/bash
# Display bandwidth usage
# By [email protected] 2012/04/17
if [ $# -lt 2 ];
then echo "Error: wrong number of arguments";
echo "Usage: $0 <username or site name> <traffic type> <month> <year> e.g. $0 stupi402 imap 4 2012"
echo "If no month and/or year are specified, script will display data for current month/year.";
echo "Also Please note that cPanel doesn't seem to save per-domain bandwidth for imap, ftp, pop and smtp."
exit 1;
@rushipkar90
rushipkar90 / check_domains_ns.pl
Created September 25, 2015 16:26
check_domains_ns.pl
#!/usr/local/cpanel/3rdparty/perl/514/bin/perl
#use strict;
use warnings;
use YAML::Tiny;
use Data::Dumper;
my $username = $ARGV[0];
my @dnsservers = ("8.8.8.8","8.8.4.4");
@rushipkar90
rushipkar90 / check-server-bandwidth.pl
Created September 25, 2015 16:26
check-server-bandwidth.pl
#!/usr/local/cpanel/3rdparty/perl/514/bin/perl
use RRDs;
use Getopt::Long;
my $server;
my $direction;
GetOptions(
"server=s" => \$server,
"direction=s" => \$direction,
);
@rushipkar90
rushipkar90 / cleanrootmail.sh
Created September 25, 2015 16:27
cleanrootmail.sh
#!/bin/sh
/usr/sbin/exiqgrep -i -r root@`hostname`| xargs /usr/sbin/exim -Mrm > /dev/null
@rushipkar90
rushipkar90 / cleanup.sh
Created September 25, 2015 16:27
cleanup.sh
#!/bin/sh
ionice -c3 find /home/*/fantastico_backups/ -name 'backup*' -mtime +15 -exec rm {} \;
ionice -c3 find /home/*/fantastico_backups/ -name '.backup*' -mtime +15 -exec rm {} \;
ionice -c3 find /home/*/tmp/Cpanel_Form_file.upload.* -mtime +0 -exec rm {} \;
ionice -c3 find /home/*/mail/*/*/.Trash/cur/* -type f -mtime +6 -exec rm {} \;
ionice -c3 find /home/*/mail/*/*/.Trash/new/* -type f -mtime +6 -exec rm {} \;
ionice -c3 find /home/*/mail/.Trash/cur/* -type f -mtime +6 -exec rm {} \;
ionice -c3 find /home/*/mail/.Trash/new/* -type f -mtime +6 -exec rm {} \;