Posts

Showing posts from May, 2014

Installing Oracle VM Server and Manager

Oracle may not be the biggest virtualization player, but its enterprise virtualization product, Oracle VM, is simple to install if you have all the right components.

How to get PHP scripts working in HTML files

You can't run PHP in .html files because the server does not recognize that as a valid PHP extension unless you tell it to. To do this First, create a blank text file and name it ".htaccess" file in your root web directory and add this line to it: AddType application/x-httpd-php .htm .html This will tell Apache to process files with an .htm or .html file extension as PHP files.Next, open the file with a simple text editor like the "vi Editor" and Paste the following line into the file AddType application/x-httpd-php .html .htm If this does not work, please remove the line above from your file and paste this alternative line into it, for PHP5: AddType application/x-httpd-php5 .html .htm Now Create a file named hellotest.html and put it in your web server's root directory (DOCUMENT_ROOT) with the following content: Example #1 our first PHP script: hellotest.html <html>  <head>   <title>PHP Test</title>  </he

cPanel or WHM Accounting Logs:

Location :  /var/cpanel/accounting.log Description : Contains a list of accounting functions performed through WHM, including account removal and creation.. cPanel error logs: Location :  /usr/local/cpanel/logs/error_log Description : cPanel logs any error it incurs here. This should be checked when you encounter errors or strange behavior in cPanel/WHM... Client Information, Requested URL Logs: Location :  /usr/local/cpanel/logs/access_log Description : General information related to access cPanel requests is logged here. Bandwidth Logs: Location :  /var/cpanel/bandwidth Description : Files contain a list of the bandwidth history for each account. Each named after their respective user. Apache Access Logs: Location :  /usr/local/apache/logs/access_log Description : Complete web server access log records all requests processed by the server. Message Reception and Delivery: Location :  /var/log/exim_mainlog or /var/log/exim/mainlog Description : Recei

How to reduce SYN flooding using sysctl.conf

Linux has a nice file for setting up kernel value at boot time. This file can be found in   /etc/sysctl.conf   If you open and edit, you will find many values you can transform to improve security on your server. I think the most important value you can set to secure your TCP connection is:   net.ipv4.tcp_syncookies=1   Another thing you can do is reduce the timeout value from 60 to 30 seconds, this is not TCP standard at all to do that, but at least, the connection refresh will be faster than default. Note: keep in mind this reduces impact of SYN flooding, it will not stop them completely. Make sure you don’t set this value too low over wise it could create TCP loss packet situation.   net.netfilter.nf_conntrack_tcp_timeout_syn_recv=30 Last thing you can make is to create Iptables entry to limit them on your server. # create new chains iptables -N syn-flood # limits incoming packets iptables -A syn-flood -m limit --limit 10/second --limit-burst 50 -j RETURN # log attacks iptables -A

How to detect SYN attack

How to detect SYN attack? During a SYN attack, the attacker is opening lots of connections to you server but never completes the TCP connection establishment process. The state of each connection will stay SYN_RECV. This is how to count such connections: # netstat -anutp | grep SYN_RECV | wc -l If the number is >30, it is likely that you are under a SYN attack. However, I do not recommend to use netstat in automated scripts to monitor traffic. When you are under a real SYN attack, it may run too long and drain lots of CPU resources. 2) You can monitor live bandwidth of the attack using vnstat: # vnstat -l -i eth0 It is a very useful tool that will definitely help you understand how powerful the attack is. 3) I also recommend you to install an advanced analogue of top called htop and also monitor how the attack affects your CPU resources. Launch htop: # htop Press F2, go to 'Display options' and choose 'Display threads in a different color'. You will see system inte

How to Redirect page without browser address changing

Redirect page without changing the domain name in browser http://en.wikipedia.org/wiki/URL_redirection Preserve domain name after redirect all client requests on host A to host B. Create index.html page in documnet root of hostA Frame redirects <frameset rows="100%">   <frame src="http://www.example.com/"> </frameset> <noframes>   <body>Please follow <a href="http://www.example.com/">link</a>!</body> </noframes> Rewrite/Redirect Rule . http://tomclegg.net/rewriterule http://httpd.apache.org/docs/1.3/misc/rewriteguide.html www.example.com : hostB

How to add swap space in centos

Add system swap space for virtual memory paging: Swap space may be a swap partition, a swap file or a combination of the two. One should size swap space to be at least twice the size of the computer's RAM. (but less than 2GB)    dd if=/dev/zero of=/swapfile bs=1024 count=265032  - Create file filled with zeros of size 256Mb    mkswap /swapfile          - Create swap file    swapon /swapfile          - Begin use of given swap file. Assign a priority with the "-p" flag.    swapon -s                 - List swap files    cat /proc/swaps           - Same as above     This example refers to a swap file. One may also use a swap partition. Make entry to /etc/fstab to permanently use swap file or partition. /swapfile               swap                    swap    defaults        0 0     Note: To remove the use of swap space, use the command swapoff. If using a swap partition, the partition must be unmounted.

How to find word in Linux

●     Search and list all files from current directory and down for the string ABC: find ./ -name "*" -exec grep -H ABC {} \; find ./ -type f -print | xargs grep -H "ABC" /dev/null egrep -r ABC * ●     Find all files of a given type from current directory on down: find ./ -name "*.conf" –print ●     Find all user files larger than 5Mb: find /home -size +5000000c -print ●     Find all files owned by a user (defined by user id number. see /etc/passwd) on the system: (could take a very long time) find / -user 501 -print ●     Find all files created or updated in the last five minutes: (Great for finding effects of make install) find / -cmin -5 ●     Find all users in group 20 and change them to group 102: (execute as root) find / -group 20 -exec chown :102 {} \; ●     Find all suid and setgid  executable : find / \( -perm -4000 -o -perm -2000 \) -type f -exec ls -ldb {} \; find / -type f -perm +6