Archive for the tag 'Script'

SBDavid

Running CGI script from any directory

Running CGI script from any directory

In order to force apache to allow cgi script to run, simply create a file called .htaccess inside the directory in which you wish to run the scripts. Insert the following text into the .htaccess file:

Options +ExecCGI
AddHandler cgi-script .cgi .pl

Script to enable SpamAssassin for new accounts

By default (if enabled), DA gives the User the option to enable spamassassin, but it is not turned on by default.

The above script can be used to also enable spamassassin for all existing accounts. You can create another simple script to do it called (for example) spam.sh with the following code:

#!/bin/sh
for i in `ls /usr/local/directadmin/data/users`; do
{
username=$i spam=ON /usr/local/directadmin/scripts/custom/user_create_post.sh
};
done;
exit 0;

Save this new spam.sh script, chmod it to 755, and run it once.

You can change the time zone within a php script. Here is a sample code:

With the php tags enter the following

putenv(”TZ=Europe/Amsterdam”);

You can set the timezone in .htaccess as well. Add the line:

SetEnv TZ America/Indianapolis

List of timezones is here: http://us.php.net/manual/en/timezones.php

SBDavid

How to Encrypt Shell Script

How to Encrypt Shell Script

We all know that anyone can read shell script.Think if any one gets access to the shell script which has root password and all stored in it. Its really a security risk. Now we have a solution for that ie all this risk can be avoided if the shell script is encrypted and then executed. The utility used for that is called shc

I will explain how to install it and then use it for the encrypting purpose

1) Download from http://www.datsi.fi.upm.es/~frosal/sources/shc-3.7.tgz

wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.7.tgz

2) Untar it

tar -xzvf shc-X.X.tgz

3) To install it follow the below given steps

cd shc-X.X/
make
make install

4) After install it will create a binary called shc, use it to encrypt the shell scripts
5) Write a shell script, lets call it heloworld.sh

#!/bin/bash
echo ” Helo world ”

6) To test shc execute the command

shc -f heloworld.sh

Option -f is used to encrypt
7) Now you will get an encrypted version of the script. It will be named something like heloworld.sh.x
8) Its an encrypted version and you can execute it as you wish

eg ./heloworld.sh.x

9) You have an encrypted shell script.

« Prev