Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
rushipkar90 / innodb recovery
Created January 8, 2016 04:30
Entire innodb recovery process
To find out Innodb databases
================
mysql -N mysql -e "SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'innodb';" | awk '{print $1}' | sort | uniq > /usr/local/src/innodb_databases-08012016.txt
find /var/lib/mysql -name "*.ibd"|awk -F / '{print $5}'|sort -n|uniq > /usr/local/src/innodb_databases-08012016.txt
MySQL variables used are
-e, --execute=name Execute command and quit. (Disables --force and history file.)
-N, --skip-column-names Don't write column names in results.
================
@rushipkar90
rushipkar90 / cleanup.sh
Created January 10, 2016 23:41
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 {} \;
@rushipkar90
rushipkar90 / Fix Single cPanel account Permissions.txt
Last active February 13, 2016 05:08
Fix Single cPanel account Permissions
# Original Script Source: http://repo.arvixe.com/perk/perms.txt
#Run it as from the location /home/user/public_html ONLY: curl downloadURL | bash
#!/bin/bash
SC="Permissionairy"
VSN=".0991"
UN=$(pwd | cut -d / -f3)
@rushipkar90
rushipkar90 / xmlrpc attack investigation
Last active May 23, 2023 06:39
Outbound xmlrpc attack
#If you are receiving complaints against your server for outgoing xmlrpc brute-force attack, then you can easily find-out culprit account by using below steps:
1) Run below command in 'Screen', it will dump all the monitored logs to /home/logs/tcpdump14022016 file.
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' > /home/logs/tcpdump14022016
2) Set up below crons on the server. You can either set up these crons in the server crons i.e at crontab -e or you can set it up at /etc/cron.d/filename, for e.g. as in below case filename is "dumplogs".
root@test[/etc/cron.d]# cat dumplogs
* * * * * root /home/logs/writelogs.sh
* * * * * root sleep 30; /home/logs/writelogs.sh
@rushipkar90
rushipkar90 / Multipleaccountdetails
Created March 9, 2016 06:35
Multipleaccountdetails
#/bin/bash
echo > accountdetails;
#soho_accounts.txt must exists with list of cpanel usernames
for i in `cat soho_accounts.txt` ; do
{
#read -p "Enter the Post Migration username : " prompt
echo "(===========================" >> accountdetails;
echo "----- Account Size -----" >> accountdetails;
echo "===========================" >> accountdetails;
du -sh /home/$i >> accountdetails;
@rushipkar90
rushipkar90 / domlogs
Created July 8, 2016 12:28
domlogs.txt
for i in `cut -d: -f1 /etc/trueuserdomains`;do echo "$i= `cut -d' ' -f1 /usr/local/apache/domlogs/$i|wc -l`" >> /usr/local/src/file;done
@rushipkar90
rushipkar90 / upgradephp.sh
Created September 5, 2016 21:03
PHP Upgrade Script
#/bin/bash
set -x
echo > /usr/local/src/customphpini.txt;
echo > /usr/local/src/commentphp.txt;
thetime=`date +"%Y-%m-%d-%S"`;
php -m > /usr/local/src/modules.txt
echo "================================" >> /usr/local/src/modules.txt
/usr/local/apache/bin/apachectl -M >> /usr/local/src/modules.txt
cp -ar /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf_$thetime;
cp -ar /usr/local/lib/php.ini /usr/local/lib/php.ini_$thetime;
@rushipkar90
rushipkar90 / upgradephp_new.sh
Last active September 9, 2016 22:45
Upgradephp along with extensions
#/bin/bash
set -x
echo > /usr/local/src/customphpini.txt;
echo > /usr/local/src/commentphp.txt;
echo > /usr/local/src/oldextensions.txt;
echo > /usr/local/src/newextension.txt;
oldextension=`php -i | grep -w "extension_dir =" | grep -v "sqlite" | awk '{print $3}'`;
ls -la $oldextension | awk '{print $9}' | grep -v "./" | grep -v "../" | grep -v '^$' > /usr/local/src/oldextensions.txt;
thetime=`date +"%Y-%m-%d-%S"`;
php -m > /usr/local/src/modules.txt
@rushipkar90
rushipkar90 / spamemails.sh
Created November 17, 2016 11:25
spamemails.sh
#!/bin/bash
pprocess=`ps -ef | grep "spamemails.sh" | grep -v "grep" | wc -l`;
if [ "$pprocess" -le 2 ]
then
{
sh /usr/local/src/newmalicious.sh >> /usr/local/src/permupdates.txt;
}
fi
@rushipkar90
rushipkar90 / postfix commands
Created March 30, 2017 04:04
postfix commands
Ref Links:
=============
https://jvulinux.wordpress.com/2014/12/26/commands-to-check-spamming-in-postfix-mail-server/
https://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html
=============
Commands to check spamming in POSTFIX mail server
1. To see the mail queue: