Thursday, August 27, 2009

How can I make my XAMPP installation more secure?

In the default installation, XAMPP has no passwords set and it is not recommended to run XAMPP with this configuration accessible by others (e. g. on the Internet).
Simply type the following command (as root) to start a simple security check:

/opt/lampp/lampp security
Now you should see the following dialog on your screen (user input is highlighted):

XAMPP: Quick security check...
XAMPP: Your XAMPP pages are NOT secured by a password.
XAMPP: Do you want to set a password? [yes] yes (1)
XAMPP: Password: ******
XAMPP: Password (again): ******
XAMPP: Password protection active. Please use 'lampp' as user name!
XAMPP: MySQL is accessable via network.
XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes] yes
XAMPP: Turned off.
XAMPP: Stopping MySQL...
XAMPP: Starting MySQL...
XAMPP: The MySQL/phpMyAdmin user pma has no password set!!!
XAMPP: Do you want to set a password? [yes] yes
XAMPP: Password: ******
XAMPP: Password (again): ******
XAMPP: Setting new MySQL pma password.
XAMPP: Setting phpMyAdmin's pma password to the new one.
XAMPP: MySQL has no root passwort set!!!
XAMPP: Do you want to set a password? [yes] yes
XAMPP: Write the passworde somewhere down to make sure you won't forget it!!!
XAMPP: Password: ******
XAMPP: Password (again): ******
XAMPP: Setting new MySQL root password.
XAMPP: Setting phpMyAdmin's root password to the new one.
XAMPP: The FTP password for user 'nobody' is still set to 'lampp'.
XAMPP: Do you want to change the password? [yes] yes
XAMPP: Password: ******
XAMPP: Password (again): ******
XAMPP: Reload ProFTPD...
XAMPP: Done.


(1) Setting a password will protect the XAMPP demo pages (http://localhost/xampp/) using this password. The user name is 'lampp'!

After calling this command your XAMPP installation should be "secure".

After I rebooted my Linux box XAMPP stopped running! How can I fix this?

There is no real standard way to configure the boot process of a Linux system, but most of them should allow you to start XAMPP at boot time using the following steps.


First, find out your default runlevel.
Simply type egrep :initdefault: /etc/inittab.
You should now see a line containing a number between two colons.
In most cases 3 or 5 (2 if you're using Debian).

Go into the directory which configures this runlevel. If for example your runlevel is 3, then you have to change into the /etc/rc.d/rc3.d directory:
cd /etc/rc.d/rc3.d

If your system didn't provide /etc/rc.d/rc3.d please try also /etc/init.d/rc3.d and /etc/rc3.d.

Now carry out the actual configuration by typing:
ln -s /opt/lampp/lampp S99lampp
ln -s /opt/lampp/lampp K01lampp


Now XAMPP should start and stop automatically if you boot or shutdown your machine.

Monday, August 24, 2009

How-to: Install Oracle Instant Client and PHP OCI8 module

If you want to connect to an Oracle database with PHP, you can use Oracle's Instant Client and the oci8 module from pear.
Download the Basic and the SDK packages from http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html. At the time of this writing, the filenames are instantclient-basic-linux32-10.2.0.1-20050713.zip and instantclient-sdk-linux32-10.2.0.1-20050713.zip.

Unzip these files in a new directory, e.g. /opt/oracle/instantclient.

mkdir -p /opt/oracle/instantclient
cd /opt/oracle/instantclient
unzip instantclient-basic-linux32-10.2.0.1-20050713.zip
unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip
echo /opt/oracle/instantclient >> /etc/ld.so.conf
ldconfig


The previous two lines are supposed to create symlinks named libclntsh.so and libocci.so which we will need later. In my case these symlinks were not created by ldconfig, so I created them manually.


ln -s libclntsh.so.10.1 libclntsh.so
ln -s libocci.so.10.1 libocci.so

mkdir -p /usr/local/src
cd /usr/local/src
pear download oci8
tar xzf oci8-1.1.1.tgz
cd oci8-1.1.1
phpize
./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient
make
make install

The oci8-1.1.1.tgz filename will of course change for newer releases.
To enable the oci8 module in the php.ini (/etc/php5/apache2/php.ini and /etc/php5/cli/php.ini), add a line
extension=oci8.so (put this line after the examples starting with ;extension).

Now stop and start Apache. You should see the oci8 module in the output of phpinfo().
For above solution you can follow this link http://ubuntuforums.org/archive/index.php/t-92528.html
================================================================================

Or 2nd Method:--

Prerequisites
________________________________________
Using Pear to build oci8 :: needed software
List of software that must be installed before:
(This software can be found in openSuSE-10.2 CD/DVD/repos)
autoconf
php5-5.2.0-12
apache2-mod_php5-5.2.0-12
php5-pdo-5.2.0-10
php5-devel-5.2.0-12
php5-pear-5.2.0-12
Procedures
Install oracle instant client zips
________________________________________
Note: If you have oracle server and Apache/php in one machine, skip this step and go to the next section. This section is only for people who need connected to different Oracle server machine
Download instant client for Oracle, here, based on your machine, x86 or x86_64, or others than that.
Let say that you save or copying them in /opt/oracle/ directories
unzip instant client library and sdk
$ cd /opt/oracle
$ unzip instantclient-basic-linux-*.zip
$ unzip instantclient-sdk-linux-*.zip
make softlink for libclntsh.so.10.1
$ cd /opt/oracle/instantclient_10_2
$ ln -s libclntsh.so.10.1 libclntsh.so
Setting oracle environment
________________________________________
Note: If you want to install oci8 in different machine other than your oracle server, skip this step.
If you want to install oci8 in oracle server, the same machine where you installed oracle database and Apache/PHP, you must follow this step.
first test whether the ORACLE_HOME is exist
$ echo $ORACLE_HOME
if above command print an output to some directory, skip this step.
if the first step does not print output, set ORACLE_HOME to the directory where you installed oracle database, i will assume that you using bash as console.
$ ORACLE_HOME=/path/to/oracle/database/server
$ export ORACLE_HOME
Build/install/enable oci8 module
________________________________________
Download oci8 here
Let say you save or copying them in /opt/oracle directories.
follow this command,
$ cd /opt/oracle
$ pear5 install oci8-1.2.3.tgz or pecl install oci8-1.2.3.tgz
above command will print an output,
...
10 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Please provide the path to ORACLE_HOME dir. Use 'instantclient,/path/to/instant/client/lib'
if you're compiling against Oracle Instant Client [autodetect] :

oci8 installation will ask you where the path instantclient directory. If you using instantclient fill them with directories where you unzip instantclient in previous section. i.e: ‘ instantclient,/opt/oracle/instantclient_11_1’

if you using oracle server, and have set ORACLE_HOME environment, just press enter
and then, building continues ...
building in /var/tmp/pear-build-root/oci8-1.2.3
running: /tmp/pear/cache/oci8-1.2.3/configure --with-oci8=instantclient,/opt/instantclient_10_2
checking for grep that handles long lines and -e... /usr/bin/grep
---------------------------------------------------------------------
Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).
running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-oci8-1.2.3" install

Installing shared extensions:
/var/tmp/pear-build-root/install-oci8-1.2.3/usr/lib64/php5/extensions/running:
/var/tmp/pear-build-root/install-oci8-1.2.3/usr/lib64/php5/extensionsld process completed successfully
Installing '/var/tmp/pear-build-root/install-oci8-1.2.3//usr/lib64/php5/extensions/oci8.so'
install ok: channel://pecl.php.net/oci8-1.2.3

You should add "extension=oci8.so" to php.ini
edit php.ini, using your favorite editor, add "extension=oci8.so" remember to add it to the global scope, buy editing the file: /etc/profile
you need to add:
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_1:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

verify connection to remote 10g2 db. Write some script for php to check connection to database. This is the simple-example template, edit "OCILogon" and "$query" to meet your database user and table.

$conn = OCILogon("dbuser", "dbpasswd", "//dbserver.host.net/DB");
$query = 'select table_name from user_tables';
$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
while ($succ = OCIFetchInto($stid, $row)) {
foreach ($row as $item) {
echo $item." ";
}
echo "
\n";
}
OCILogoff($conn);
?>

then run phpdb2.php script
$ php phpdb2.php

For above solution you can follow this link http://en.opensuse.org/Howto_build_oci8_extension_module_for_php

================================================================================

Or 3rd method
(If you are using RHEL4.0 and PHP4.x.x is running):-
Then Install Xampp because it contains AMPP (Apache MySQL, PHP, Perl) package.
Visit this link http://www.ibm.com/developerworks/linux/library/l-xampp/

How to install Xampp?
Untar latest Xampp tar to /opt using the following command:

tar xvfz xampp-linux-1.4.7.tar.gz -C /opt

That's it! XAMPP is now installed in /opt/lampp. Any previous installations that were in /opt have been overwritten. If you are running an older version of XAMPP and don't want to download the entire package again, Apache Friends has an upgrade package available for download.

Now that everything is installed, let's start the new daemons. Change your current working directory to /opt/lampp (cd /opt/lampp) and enter the following:

./lampp start

You should see the following:
Starting XAMPP for Linux 1.4.7...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
XAMPP is now up and running. The best way to verify this is to open a browser and type localhost in the address bar and hit the Enter key. You should be redirected to the XAMPP welcome page.

Follow this link:- http://www.ibm.com/developerworks/linux/library/l-xampp/

Then Download the Basic and the SDK packages from http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html .
instantclient-basic-linux32-10.2.0.1-20050713.zip and instantclient-sdk-linux32-10.2.0.1-20050713.zip.

Unzip these files in a new directory, e.g. /opt/oracle/instantclient.

mkdir -p /opt/oracle/instantclient
cd /opt/oracle/instantclient
unzip instantclient-basic-linux32-10.2.0.1-20050713.zip
unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip
echo /opt/oracle/instantclient >> /etc/ld.so.conf
ldconfig

ln -s libclntsh.so.10.1 libclntsh.so
ln -s libocci.so.10.1 libocci.so

mkdir -p /usr/local/src
cd /usr/local/src
pear download oci8 or pecl download oci8
tar xzf oci8-1.1.1.tgz
cd oci8-1.1.1
phpize
./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient
make
make install

To enable the oci8 module in the php.ini (/opt/lampp/etc/php.ini), add a line
extension=oci8.so (put this line after the examples starting with; extension).

Now stop and start lampp You should see the oci8 module in the output of phpinfo().

Done!!!!!!!!!!! Enjoy

Tuesday, August 4, 2009

Disable root SSH logins to protect against root exploits

1. Before below steps create one local user
2. Login as root.
3. Open /etc/ssh/sshd_config
4. Search PermitRootLogin yes
and replace it with

#PermitRootLogin yes
PermitRootLogin no

5. Enter /etc/init.d/sshd restart

We can change SSH port also from this file /etc/ssh/sshd_config .

Friday, July 31, 2009

Enabling phpMyAdmin once you change root password or permission or privileges on mysql database

[path of xampp installation] /htdocs/xampp/phpmyadmin/config.inc.php

$cfg['Servers'][$i]['password'] = ' '; // MySQL password

Change this so that it’ll reflect your current mysql password.

$cfg['Servers'][$i]['password'] = ‘your_password_here‘; // MySQL password

Don’t forget to save it aight?!

In order to keep your database safe from the outside world, it's wise to add a password to your MySQL database. You can do this by clicking on the "PHPmyadmin" link on the WAMP homepage under Tools or by going to http://localhost/phpmyadmin/. To change your password, click on the "Privileges" link, then click the edit privileges icon for the user called, "root" (there should be no other users. If for some reason there are and you didn't put them there, go ahead and delete them. On the "Edit Privileges" page, go to the "Change password" box, then change and save the password.

To continue using PHPmyadmin, we need to update your password in the config file. Open C:\wamp\phpmyadmin\config.inc.php in your favorite text editor (or just Notepad) and change:

$cfg['Servers'][$i]['password'] = '';

to

$cfg['Servers'][$i]['password'] = 'yournewpassword';

Replacing yournewpassword with the password you just created with PHPmyadmin.

Mysql User creation and permission on DB through CMD

/etc/my.cnf file contains info about mysql. In which we can define port and directory for mysql.

# /opt/lampp/bin/mysql -u root –p <------- It will ask password

1. Mysql> CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass1';

2. Mysql> grant all privileges on database.* to user1@" localhost " identified
by ' pass1';

3. flush privileges;

Viewing Your New MySQL Databases

4. # mysql -u user1 -p pass1

5. Mysql> show databases;

Helping site:- http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch34_:_Basic_MySQL_Configuration

Thursday, July 9, 2009

Linux syslog server & window agent

To configure a syslog log server... follow thses steps.
Edit syslog.conf

#vi /etc/syslog.conf

#for window use this setting
local7.* /var/log/win2k/win.log

save the file.

(manullay create dir & file... win2k/win.log)

After that Edit /etc/sysconfig/syslog

#vi /etc/sysconfig/syslog

Find term SYSLOGD_OPTIONS... use following term to allow remote host connect to server.

SYSLOGD_OPTIONS="-m 0 -r -x"

Save the file & restart the services.

#service syslog restart

or

#/etc/init.d/syslog restart


After that download Syslog agent for window.
use following link for download.

http://www.syslogserver.com/download.html (download Datagram SyslogAgent )

or

http://www.intersectalliance.com/projects/SnareWindows/index.html#Download

I tried both and both are working for me.

I guide you few steps for Snare, follow these.

After installation.

– Click start, programs, Intersect Alliance, Snare for Windows
– Network Configuration
– Destination Snare Server address (set this to the linux server ip address).
– Destination Port: 514
– SYSLOG Facility: Local7
– SYSLOG Priority: Information

Click Change Configuration.

Click Apply the Latest Audit Configuration (on the left hand side).
Ok, the Windows part is done.




Now do some changes in your window box....all log are captured in syslog server.
You can check the file through

#less /var/log/win2k/win.log


Hope this work for you. Enjoy...