Sunday, February 24, 2013
Libsafe installation
When you first install Libsafe, its advisable to use the first method, since if Libsafe causes problems, one can easily unset LD_PRELOAD to stop Libsafe being used.
cd /usr/local/src/
wget http://pubs.research.avayalabs.com/src/libsafe-2.0-16.tgz
tar -xzvf libsafe-2.0-16.tgz
cd libsafe-2.0-16/
make
yes y | make install
Now that Libsafe has been built and installed, we need to ensure that it intercepts all function calls to the standard C library. We can do this in two ways.
1) We can set the environmental variable LD_PRELOAD e.g. (in bash):
$ LD_PRELOAD=/lib/libsafe.so.2 $ export LD_PRELOAD
To set this on a system-wide basis, just add this to e.g. /etc/profile (or maybe /etc/profile.local)
2) Alternatively, we can add a line to /etc/ld.so.preload
echo '/lib/libsafe.so.2' >> /etc/ld.so.preload
This will ensure that Libsafe is used for all programs, and cannot be disabled by a normal user (unlike environmental variables).
Problems with Libsafe
At this point the reader will no doubt be wondering why Libsafe isn't included by default with all Linux distributions; unfortunately, Libsafe doesn't always work, and worse still, can even cause extra problems.
Because of certain assumptions made about the stack, Libsafe will only work with x86 processors.
Programs that have been linked against libc5 won't work with Libsafe.
If a program has been compiled without a stack pointer (i.e. by using the -fomit-frame-pointer option in GCC or perhaps due to an optimizer), then Libsafe won't be able to catch any overflows.
Libsafe won't catch overflows in statically compiled programs since Libsafe works by intercepting calls to shared libraries.
If a function is included inline, then for the same reason as above Libsafe won't catch overflows.
And of course, since Libsafe only works with a limited set of functions, it won't catch buffer overflows which involve other (user-defined) functions !
from http://www.symantec.com/connect/articles/protecting-systems-libsafe
Tuesday, February 19, 2013
Linux Sed Command
Linux Sed Command
Substitution sed 's/<oldstring>/<newstri ng>/g' <file>
Deletion sed '<start>,<end>d' < file>
Let's start with a substitution example. If you want to change all occurrences of lamb to ham in the poem.txt file in the grep example, enter this:
sed 's/lamb/ham/g' poem.txt
Mary had a little ham
Mary fried a lot of spam
Jack ate a Spam sandwich
Jill had a ham spamwich
In the quoted string, the "s" means substitute, and the "g" means make a global change. You can also leave off the "g" (to change only the first occurrence on each line) or specify a number instead (to change the first n occurrences on each line).
Now let's try an example involving deletion of lines. The values for start and end can be either a line number or a pattern to match. All lines from the start line to the end line are removed from the output. This example will delete starting at line 2, up to and including line 3:
sed '2,3d' poem.txt
Mary had a little lamb
Jill had a lamb spamwich
This example will delete starting at line 1, up to and including the next line containing Jack:
sed '1,/Jack/d' poem.txt
Jill had a lamb spamwich
The most common use of sed is to change one string of text to another string of text. But I should mention that the strings that sed uses for search and delete are actually regular expressions. This means you can use pattern matching, just as with grep. Although you'll probably never need to do anything like this, here's an example anyway. To change any occurrences of lamb at the end of a line to ham, and save the results in a new file, enter this:
sed 's/lamb$/ham/g' poem.txt > new.file
Since we directed output to a file, sed didn't print anything on the screen. If you look at the contents of new.file it will show these lines:
Mary had a little ham
Mary fried a lot of spam
Jack ate a Spam sandwich
Jill had a lamb spamwich
Use the man sed command for more information on using sed.
Connecting wireless through command line
ifconfig wlan0 up
You won’t see any feedback unless there is a problem.
The next step is to scan for your wireless network to make sure it is available. Do this with the following command:
iwlist wlan0 scan
With this command you will see output like the following:
Cell 01 - Address: 00:21:43:4E:9B:F0
ESSID:"HAIR STROBEL"
Mode:Master
Channel:5
Frequency:2.432 GHz (Channel 5)
Quality=100/100? Signal level:-45 dBm? Noise level=-95 dBm
Encryption key:on
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s
6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
36 Mb/s; 48 Mb/s; 54 Mb/s
Extra:tsf=000002f1d9be01b7
So you know this network is available. From the above output you can also see this network is employing WPA2, so you will need a passkey. If you don’t know that passkey, you are out of luck (which would be the case no matter if you were using a front end in Linux, Windows, or Mac.)
Now it’s time to configure your connection. To do this issue the command:
iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY
Where NETWORK_ID is the ESSID of the network with which you want to connect and WIRELESS_KEY is the security key needed to connect to the wireless access point.
Note: iwconfig defaults to using a HEX key. If you want to use an ascii key you will have to add the “s:” prefix to your key like so:
iwconfig wlan0 essid NETWORK_ID key s:WIRELESS_KEY
Now that you have your configuration set, it’s time to get an IP address with the help of dhclient. Issue the command:
dhclient wlan0
If no output is reported there are no errors. You should now be up and running.
Make it a script
Of course who wants to type out all of those commands. Instead of doing this you could create a script for this like so:
#! /bin/bash
ifconfig wlan0
iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY
dhclient wlan0
Where NETWORK_ID is the actually essid of the network and WIRELESS_KEY is the security key for that network. Save this script with the filename wireless_up.sh and then make this script executable with the command:
chmod u+x wireless_up.sh
You can make this a global command by placing this script in /usr/local/bin. You can now issue the command wireless_up.sh from anywhere in your directory structure and it will run, connecting you to the configured wireless access point.
sudo iwconfig wlan0 freq 2.422G
Or by running:
sudo iwconfig wlan0 channel 3ifconfig wlan0 down
iwconfig wlan0 mode managed
ifconfig wlan0 up
iwconfig wlan0 channel 3
iwconfig wlan0 key xxxxxxxxxx
iwconfig wlan0 key restricted
iwconfig wlan0 essid "Blah Blah Foo Bar"
iwconfig wlan0 ap xx:yy:zz:aa:bb:cc
sleep 5
dhcpcd -d wlan0
Hosts file in linux and windows
The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system's Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network.
In some operating systems, the hosts file's content is used preferentially to other methods, such as the Domain Name System (DNS), but many systems implement name service switches (e.g., nsswitch.conf for Linux and Unix) to provide customization. Unlike the DNS, the hosts file is under the direct control of the local computer's administrator
Operating System | Version(s) | Location |
---|---|---|
Unix, Unix-like, POSIX | /etc/hosts [2] | |
Microsoft Windows | 3.1 | %WinDir%\HOSTS |
95, 98/98SE, Me | %WinDir%\hosts [3] | |
NT, 2000, XP (x86 & x64),[4] 2003, Vista, 7 and 8 | %SystemRoot%\system32\drivers\etc\hosts [5] | |
Windows Mobile | Registry key under HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts | |
Apple Macintosh | 9 and earlier | |
Mac OS X 10.0 – 10.1.5 [6] | (Added through NetInfo or niload) | |
Mac OS X 10.2 and newer | /etc/hosts (a symbolic link to /private/etc/hosts )[6] | |
Novell NetWare | SYS:etc\hosts | |
OS/2 & eComStation | "bootdrive":\mptn\etc\ | |
Symbian | Symbian OS 6.1–9.0 | C:\system\data\hosts |
Symbian OS 9.1+ | C:\private\10000882\hosts | |
MorphOS | NetStack | ENVARC:sys/net/hosts |
AmigaOS | 4 | DEVS:Internet/hosts |
Android | /etc/hosts (a symbolic link to /system/etc/hosts ) | |
iOS | iOS 2.0 and newer | /etc/hosts (a symbolic link to /private/etc/hosts ) |
TOPS-20 | ||
Plan 9 | /lib/ndb/hosts | |
BeOS | /boot/beos/etc/hosts [7] | |
Haiku | /boot/common/settings/network/hosts [7] | |
OpenVMS | UCX | UCX$HOST |
TCPware | TCPIP$HOST |
UNDERSTANDING SSL FOR CPANEL AND WHM
SSL (Secure Sockets Layer) is essential for securing online communications. When you access your WHM (WebHost Manager) or cPanel, you're logging into powerful administrative interfaces. Without SSL, your login credentials and all data exchanged could be vulnerable to interception. Enabling SSL encrypts this traffic, protecting your sensitive information.
WHY SECURE WHM AND CPANEL?
Data Protection: Encrypts your username, password, and all administrative commands.
Trust and Reliability: Ensures that you are connecting to the legitimate server and not an imposter.
Compliance: Many hosting providers and best practices recommend or require SSL for administrative interfaces.
HOW TO ENABLE SSL THROUGH WHM
The easiest way to secure your WHM, cPanel, and Webmail services is directly through the WHM interface.
Log in to WHM: Access your WebHost Manager using your root or reseller credentials.
Navigate to Service SSL Certificates: In the WHM search bar, type "SSL" and select "Manage Service SSL Certificates."
Select cPanel/WHM/Webmail Service: On the "Manage Service SSL Certificates" page, you will see various services listed. Locate and click on "cPanel/WHM/Webmail Service."
Install an Existing Certificate or Generate a New One:
If you have an SSL certificate already issued for your hostname, you can upload it here.
WHM also provides options to generate a self-signed certificate, which is sufficient for encrypting traffic for your administrative interfaces, though it might show a browser warning because it's not issued by a trusted Certificate Authority. For public-facing sites, a CA-issued certificate is required.
Review and Apply: Follow the on-screen prompts to install or generate the certificate. WHM will handle the configuration for these services.
BACKEND FILE LOCATION
For those who manage their servers at a deeper level, the primary SSL certificate file for cPanel, WHM, and Webmail services is typically located at:
/var/cpanel/ssl/cpanel/cpanel.pem
This file contains the certificate, private key, and certificate authority (CA) bundle that secures these specific services. However, for most users, interacting with this file directly is unnecessary as WHM automates the process.
Monday, February 18, 2013
Moving MySQL on cPanel: A Simple Guide
There are times you might need to change where your MySQL databases are stored on your cPanel server. Maybe your current disk is full, or you want to put your databases on a faster storage device. Whatever the reason, moving MySQL is straightforward and won't break your cPanel.
STEP 1: BACK UP YOUR DATA
Always back up your data before making any big changes. It's like saving your game progress before a big boss fight.
One easy way to create a backup:
tar -cvf mysql.tar /var/lib/mysql
This command creates a compressed file called mysql.tar
that contains all your MySQL data.
STEP 2: TELL MYSQL ABOUT THE NEW LOCATION
You need to update MySQL's main configuration file, my.cnf
, to point to the new data directory.
Open the file
/etc/my.cnf
.Find the section labeled
[mysqld]
.Add or change the
datadir
line to reflect your new path.
For example, if you're moving MySQL from /var/lib/mysql
to /home2/mysql
, you would add this line:
datadir=/home2/mysql
Do NOT restart MySQL yet!
STEP 3: MOVE THE DATA
Now it's time to copy your existing MySQL data to the new location. We'll use rsync
for this, which is good for copying files efficiently.
It's best to stop MySQL, copy the data, and then start it again. If you have a very large database and the copy will take a long time, you can run rsync
multiple times while MySQL is still running. However, the final copy must be done with MySQL stopped to ensure data consistency, especially if you use InnoDB tables.
Here's the command to sync, using our example of moving to /home2/mysql
:
rsync -av /var/lib/mysql /home2
Next, you need to create a link so cPanel and other applications can find the MySQL socket file in its new home:
ln -sf /home2/mysql/mysql.sock /tmp
STEP 4: RESTART MYSQL
Since you've already updated the my.cnf
file, all you need to do now is restart the MySQL service. It will automatically start using the new data directory.
After restarting, your MySQL databases should be running smoothly from their new location.
Saturday, February 16, 2013
update RVSiteBuilder
For cPanel
Go to root WHM / Add-ons / RVSiteBuilder Manager. On the Manager homepage, if you are not on the latest version, it will show you the link 'Upgrade to latest version'. Following the link will upgrade your RVSiteBuilder.
If you cannot access to RVSiteBuilder Manager interface, you can update using command line here.
perl /usr/local/cpanel/whostmgr/docroot/cgi/rvsitebuilderinstaller/autoinstaller.cgi