Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
rushipkar90 / hrmailscript.sh
Last active November 12, 2015 08:18
hrmailscript.sh
#!/bin/bash
echo > /usr/local/src/temp_eximlog
echo > /usr/local/src/topsender.txt
echo > /usr/local/src/topsenderscript.txt
a=`date --date="1 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 | grep dovecot | awk {'print $8, $9, $10, $11}' | replace "A=dovecot_plain:" "+" | grep "+" | cut -d "+" -f2 | awk '{print $1}' | sort | uniq -c | sort -nr > /usr/local/src/mailauths.txt
IFS=$'\n'
@rushipkar90
rushipkar90 / scanmailqueue-indi.sh
Last active November 11, 2015 07:57
scanmailqueue-indi.sh
#/bin/bash
freshclam;
echo > /usr/local/src/mailscamsind.txt;
echo > /usr/local/src/maliciousfilesind;
echo > /usr/local/src/permissionupdatedind;
echo > /usr/local/src/scanclamfile.log;
echo > /usr/local/src/scanclam.log;
#tail -10000 /var/log/exim_mainlog | grep -w "cwd" | grep -v "exim" | grep -v "root" | grep -vw "/" | cut -d= -f2 | awk '{print $1}' | sort | uniq -c | sort -rn >> /usr/local/src/mailscams.txt
#for i in `head -5 /usr/local/src/mailscams.txt | awk '{print $2}' | grep -v '^$'`; do
i=$1
@rushipkar90
rushipkar90 / Network Monitoring commands.txt
Created November 15, 2015 13:53
Network Monitoring commands
Reference URL: http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
top -cd2
vmstat 3 ---The command vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity
vmstat -m ---Display Memory Utilization Slabinfo
vmstat -a ---Get Information About Active / Inactive Memory Pages
mpstat ---Display the utilization of each CPU individually using mpstat
w ---Find Out Who Is Logged on And What They Are Doing
uptime ---Tell How Long The System Has Been Running
@rushipkar90
rushipkar90 / testemailaccount.sh
Created November 20, 2015 00:08
testemailaccount.sh
#/bin/bash
echo > mailaccounts.txt;
CP_ACCOUNTS=`ls -1A /var/cpanel/users/ | grep -v "root" | grep -v "system"`
for user in `echo -n $CP_ACCOUNTS`
do
domain=`grep -i ^dns /var/cpanel/users/$user |cut -d= -f2`;
maindomain=`cat /etc/trueuserdomains | grep "$user" | cut -d : -f1`;
homedir=`cat /var/cpanel/userdata/"$user"/"$maindomain" | grep homedir | cut -d / -f2`;
for dom in `echo -n "$domain"`
@rushipkar90
rushipkar90 / updatetestpassword.sh
Created November 20, 2015 00:08
updatetestpassword.sh
#/bin/bash
echo > testpasswd;
genpasswd() {
tr -dc A-Za-z0-9_ < /dev/urandom | head -c 12 | xargs
}
cat /dev/null > mailaccounts.txt
CP_ACCOUNTS=`ls -1A /var/cpanel/users/ | grep -v "root" | grep -v "system"`
@rushipkar90
rushipkar90 / modsec2.user.conf
Last active August 15, 2016 09:36
modsec2.user.conf
# /usr/local/apache/conf/modsec2.user.conf
# Deprecated due to security issues so it should be off: http://blog.modsecurity.org/2008/08/transformation.html
SecCacheTransformations Off
# Check Content-Length and reject all non numeric ones
SecRule REQUEST_HEADERS:Content-Length "!^\d+$" "deny,log,auditlog,msg:'Content-Length HTTP header is not numeric', severity:'2',id:'1234123444'"
# Do not accept GET or HEAD requests with bodies
@rushipkar90
rushipkar90 / Bots investigation
Created December 13, 2015 03:32
Bots investigation
Refer: http://www.inmotionhosting.com/support/website/server-usage/identify-and-block-bad-robots-from-website
How to identify bad bot for a domain
============
cd /home/xyystgkp/access-logs
cat justforflorida.com | awk -F\" '{print $6}' | sort | uniq -c | sort -n
>>
36 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
71 Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)
95 WordPress/3.5.1; http://justforflorida.com/florida
@rushipkar90
rushipkar90 / Centos7 & RHEL7 notes
Created December 15, 2015 16:25
Centos7 & RHEL7 notes
How to configure a static IP address on CentOS 7/ RHEL 7
====================
http://ask.xmodulo.com/configure-static-ip-address-centos7.html
====================
How to install MySQL Server 5.6 on CentOS 7 / RHEL 7
==========
http://sharadchhetri.com/2014/07/31/how-to-install-mysql-server-5-6-on-centos-7-rhel-7/
https://www.linode.com/docs/databases/mysql/how-to-install-mysql-on-centos-7
@rushipkar90
rushipkar90 / dumpmysql-innodb.sh
Last active December 30, 2022 18:25
To dump all the innodb databases present on the server - dumpmysql-innodb.sh
#/bin/bash
for i in `cat /usr/local/src/innodb_databases-08012016.txt`; do
mysqldump -ER $i > /home/mysqldump-08012016/$i.sql;
done
//Before executing above script, file innodb_databases-08012016.txt which contains list of all the innodb databases must be present
on the location. To get the list of all innodb databases, use below commands
To find out Innodb databases
@rushipkar90
rushipkar90 / restoreinnnodb.sh
Created January 8, 2016 04:29
To recover the all the innodb databases from MysqlDump - restoreinnnodb.sh
#/bin/bash
for i in `cat /usr/local/src/innodb_databases-08012016.txt`; do
echo $i;
echo "/var/lib/mysql/$i"
#ls -la /home/mysqlbackup/$i.sql
mv /var/lib/mysql/$i /home/sachinn/mysqlrestore;
mysqladmin create $i;
mysql $i < /home/mysqldump-08012016/$i.sql;
done