Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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
@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 / 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 / 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