Categories
HowTos Linux Troubleshootings

How to install mcrypt php extension on CentOS 6

Today a developer friend requested to trouble php mcrypt extension on his newly ordered VPS. Most of the time VPS by default comes up with very basic packages. For example, to build and add mcrypt php extension to existing php installation. You would required gcc, make, libtool, libmcrypt, libmcrypt-devel and may other packages.

mcrypt php extension necessary configuration & compilation : 

View current php version
php -v

Output :
PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with the ionCube PHP Loader v4.0.14, Copyright (c) 2002-2011, by ionCube Ltd.

Categories
Penetration Testing Web Application Penetration Testing

PHP Backdoor Hookworm Stealth

HookWorm Stealth is an old PHP Backdoor just like c99Shell created by Justin Klein Keane as Proof of concept.

HookWorm Stealth provides less features than c99Shell but it’s activity can’t be track easily like c99Shell. it uses Cookies to leave no TRACE in Web server access log.

HookWorm Stealth PHP Backdoor Features :

  • Find .htaccess
  • Find open ports on remote system
  • Search for writable files or directories
  • and many more.

Download HookWorm Stealth from  http://www.madirish.net/sites/default/files/hookworm.php.tar.gz

When you get access of remote web server SHELL, the access log of web server will throw /index.php 200 OK status code that’s a normal good HTTP request.

To read further about HookWorm Stealth, go to the author blog

Categories
HowTos Linux Troubleshootings

iconv php extension installation without recompiling PHP

Overview :
Installing a single php extension without recompiling PHP is never been a difficult job but most of the people doesn’t know it which leads to re-compile whole php.. In this article i will explain how can you add new php extension without recompiling whole php.

In our example, i will tell you how can you add iconv php extension without recompiling PHP.

A sample error for iconv php extension which was not installed
Fatal error: Call to undefined function iconv() in /some/path/file.php line 12

iconv php extension necessary configuration & compilation :
View current php version
php -v

Output :
PHP 5.2.13 (cli) (built: Jun 23 2010 04:49:30)
Copyright (c) 1997-2010 The PHP Group

Downloading the same php version source code from php.net
cd /tmp/
wget http://museum.php.net/php5/php-5.2.13.tar.bz2
tar -jxf php-5.2.13.tar.bz2
cd php-5.2.13/ext/iconv

Prepare php extension to compile it.
phpize

Output :
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

aclocal
./configure
make
make install

You can can see iconv php extension is installed under php extensions directory:
ls /usr/local/lib/php/extensions/no-debug-non-zts-20060613/iconv.so

Enable iconv PHP extension in php.ini
echo "extension=iconv.so" >> /usr/local/lib/php.ini

Verify iconv :
php -i | grep -i "iconv support"

Output:
iconv support => enabled

Categories
HowTos Linux

Running Apache with Multiple PHP Versions

php5Running multiple php version e.g php4 & php5 required some times for old style applications that is dependant on php4 but applications like wordpress you are required to have php5. Let see how we tackle this problem.

In my scenario, i have CentOS 5 running on my server with apache2. I will be installing php4 in CGI mode and php5 as standalone module for apache. You can use the following method for debian distro too.

Installing apache2 & php5

yum install httpd
yum install php

php4 Installation PHP4

Now download the source code of php4, you can chose nearest php4 mirror from here.

wget http://www.php.net/get/php-4.4.9.tar.gz/from/ar.php.net/mirror
tar -zxvf php-4.4.9.tar.gz
cd php-4.4.9

Note : do not add support for apxs2, it will break up the php5 as module for apache2

./configure –prefix=/usr/local/php4
make
make install
cp -v php.ini-recommended /usr/local/php/etc/php.ini

Configuring php4 as CGI script for Apache.

ln –s /usr/local/php4/bin/php /var/www/html/cgi-bin/php
chmod 755 /var/www/html/cgi-bin/php

Configuring Apache for php4

cp –av /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php4.conf

Update these :

vi /etc/httpd/conf.d/php4.conf

Action php4-script /cgi-bin/php
AddHandler php4-script .php4
AddType text/html .php
DirectoryIndex index.php4

Categories
HowTos Linux

How to install Memcache on CPanel / WHM running CEntOS

PHP

Few days back I was working for a client where I had to transfer one application to a new server. Application had memcache php extension need and the following error appeared in apache error log ;

PHP Fatal error: Class ‘Memcache’ not found in

If you are having difficulties in same situation you should stay away from recompiling your php using /scripts/easyapache – BAD IDEA.

Solution is simple, build memcache and include it in php.ini. Let see, how we do it.

Step 1 – Download memcache

mkdir repo
cd repo
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar -xvfz memcache-3.0.6.tgz

Step 2 – Compilation & installation

cd memcache-3.0.6
phpize

you should see something like this;

Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

./configure
make
make install

Step 3 – Load in php.ini

Enable memcache in php.ini.

echo "extension=memcache.so" >> /usr/local/lib/php.ini
service httpd restart