Skip to main content

Posts

Multiple variable using array in for loop; cPanel user IP address change

I always wonder how to assign multiple variables in for loop. Suppose I want to change the IP address of some users listed. [root@server4 ~]# cat test1 user1 user2 user3 user4 user5 [root@server4 ~]# cat test2 190.10.20.1 20.1.1.2 30.12.13.13 13.23.23.12 32.12.12.1 test1 are my users and test2 contains IP address that I want to assign [root@server4 ~]# xargs < test1 user1 user2 user3 user4 user5 [root@server4 ~]# xargs < test2 190.10.20.1 20.1.1.2 30.12.13.13 13.23.23.12 32.12.12.1 Now I am going define array [root@server4 ~]# a=(user1 user2 user3 user4 user5) [root@server4 ~]# b=(190.10.20.1 20.1.1.2 30.12.13.13 13.23.23.12 32.12.12.1) [root@server4 ~]# c=${#a[@]}  #length of array Lets see if it works [root@server4 ~]# for ((i=0;i<c;i++));do echo "${a[i]} ${b[i]}"; done user1 190.10.20.1 user2 20.1.1.2 user3 30.12.13.13 user4 13.23.23.12 user5 32.12.12.1 what if we implement ...

Adding new php module through EA

Adding a new module(mhash added here) through EA wget  http://mhash.sourceforge.net/  select and download unbunzip2 downloaded file ./configure --prefix=/opt/mhash make make install vi /etc/ld.so.conf.d/mhash.conf /opt/mhash/lib add this touch and add --with-mhash=/opt/mhash in /var/cpanel/easy/apache/rawopts/all_php5 /scripts/easyapache --build

MYSQL TO MARIA DB SWITCH

What is MariaDB ? MariaDB is a binary drop in replacement of the same MySQL version (for example MySQL 5.1 -> MariaDB 5.1, MariaDB 5.2 & MariaDB 5.3 are compatible. MySQL 5.5 will be compatible with MariaDB 5.5). What this means is that: * Data and table definition files (.frm) files are binary compatible. * All client APIs, protocols and structs are identical. * All filenames, binaries, paths, ports, sockets, and etc… should be the same. * All MySQL connectors (PHP, Perl, Python, Java, .NET, MyODBC, Ruby, MySQL C connector etc) work unchanged with MariaDB. * The mysql-client package also works with MariaDB server. * The shared client library is binary compatible with MySQL’s client library. *There are some installation issues with PHP5 that you should be aware of ( REF:https://mariadb.com/kb/en/installation-issues-with-php5 ). #mysqldump --all-databases --routines --triggers > /home/db_dump/alldb.sql # service mysql stop # cp -r /var/lib/mysql/my...

MOUNT AND UMOUNT

To mount all file system mentioned in the /etc/fstab use mount -a The mountpoint can be binded to a new directory. So that you would be able to access the contents of a filesystem via more than one mountpoints at the same time. mount -B /mydir /mnt Mount allows you to access the contents of a mount point from a new mount point. Its nothing but move a mounted tree to another place. mount -M /mydir /mnt mount -n this wont update the data in /etc/mtab Lazy umount  umount -l  /mydir Forcefully umount -f /mydir to see the process holding the directory fuser -cu /mydir Mount an ISO image to a directory # mount -t iso9660 -o loop pdf_collections.iso /mnt # cd /mnt # ls perl/ php/ mysql/

FSCK file system check commands

How to perform fsck  It is simple. Umount the partition and issue the below command e2fsck -y /dev/hda1 Run fsck on all file system e2fsck -A -y Exclude the root with option R e2fsck -AR -y Specify the file system type using t fsck -AR -t ext2 -y Donot execute fsck on mounted partitions e2fsck -M /dev/hda1

INODE,METADATA,SUPERBLOCK

INODE A data structure that stores the below information about a file ---------------------------------- Size of file Device ID User ID of the file Group ID of the file The file mode information and access privileges for owner, group and others File protection flags The timestamps for file creation, modification etc link counter to determine the number of hard links Pointers to the blocks storing file’s contents ------------------------------------------------ Inode doesnot store the file name and it is stored seperately, greatest advantage is hardlink can be created for different file name sharing same inode. Meta data =========== Its data about a data. Suppose you own a vehicle there are registration and other details of the vehicle that is not the part of it. Metadata gives info like File name Owner Creation date Location on storage medium SUPER BLOCK ============ Metadata describes the structure of the file system. Most comm...

Modsecurity block rule for XMLRPC and wp-login attack

SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134  <Locationmatch "/wp-login.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"  SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"  SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"  SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"  </Locationmatch>  SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000234  <Locationmatch "/xmlrpc.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000235,msg:'ip address blocked for 5 m...