Sunday, May 25, 2008

Nobody Prevention Script

A big problem today is the abundance of Spammers listing as "Nobody".

This tutorial will outline how to properly set it up on Cpanel based systems.

root@yourserver [~]# mv /usr/sbin/sendmail /usr/sbin/sendmail.real
// backup your existing sendmail in the event of an error.

root@yourserver [~]# pico /usr/sbin/sendmail
// Open this badboy up, now paste the code below into it.

Code:

#!/usr/local/bin/perl

# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, ">>/var/log/formmail.log") || die "Failed to open file ::$!";
my $uid = $>;
my @info = getpwuid($uid);
if($REMOTE_ADDR) {
print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME \n";
}
else {

print INFO "$date - $PWD - @info\n";

}
my $mailprog = '/usr/sbin/sendmail.real';
foreach (@ARGV) {
$arg="$arg" . " $_";
}

open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!\n";
while ( ) {
print MAIL;
}
close (INFO);
close (MAIL);

Now save the work above...

root@yourserver [~]# chmod +x /usr/sbin/sendmail
// make sendmail executable

root@yourserver [~]# echo > /var/log/formmail.log

root@yourserver [~]# chmod 755 /var/log/formmail.log (If no work change to chmod 777)

root@yourserver [~]# pico /var/log/formmail.log
// above is where all the data is stored, it may take up to a couple hours for it to begin filling with data. However if you notice an extreme amount of instances of a user sending mail, it may be spam. In the past without this script it would list them as "Nobody". With the script in place it lists the user and where the mail is being setn from.
--------------------------------------------------------------------------
As always it's a good idea to routinely check who and how many perl processes are running as this is also another large gateway for outgoing spam.

root@yourserver [~]# ps aux | grep perl
// if you see a user with one to many perl processes running, and nothing much going on at his site, in most cases that i've seen this is the source of spam.
__________________

Saturday, April 12, 2008

I am not able to use WGET ?

cp /usr/bin/wget /usr/bin/mywget

chmod 751 /usr/bin/mywget

How to remove the blocked ip using iptables

  1. First check that ip is blocked or not
  2. iptables –L –n | grep

DROP all -- 125.99.10.123 216.240.157.91

  1. to unblock the ip give the command

iptables -D INPUT -s 125.99.10.123 -d 216.240.157.91 -j DROP

Now the ip is unblocked.

- How to block the IP using iptables

=>

/sbin/iptables -A INPUT -s 81.91.64.167 -j DROP

Awstats just disappeared from the cpanel

  1. Login to the WHM of the server for that domain.
  2. Go to Server configuration->Tweak setting
  3. Just click on the “Awstats stats” option in Stats program.
  4. It will take 1-2 hours to reflect the changes.
Now login to the cpanel of the user and you can see the awstats option in Web FTP/stats.

How to make empty file?

echo –n >filename

OR

cat > filename (then press Ctl+d. The file will be be empty)

How directly run webstat through IE ( i.e domainname.com/webstat)

cd /home/username/public_html

ln -s ../tmp/webalizer webstat

cd ..

chmod 755 tmp

cd tmp

chmod 755 webalizer

Client only wants horde to work for the mail and not neomail or roundcube or squirrelmail. The soution is as follows:

1)create subdomain name

2)add these in .htaccess

RewriteEngine on

RewriteCond %{HTTP_HOST} ^email.cedenar.com.co$ [OR]

RewriteCond %{HTTP_HOST} ^www.email.cedenar.com.co$

RewriteRule ^(.*)$ http://email.cedenar.com.co:2095/horde/login.php [R=301,L]

3)create a test email account and check it.

How to check the mail queuefor the particular account on the server

exim –bp | exiqsumm > spamm.txt

After executing this a command you will get the result in spamm.txt file. This command takes time for execussion. Execute this command when the load of the server is below 5.

How to enable port 26 for SMTP on the server

Please refer the following steps :

1. Login to server WHM. Go to Main >> Service Configuration >> Service Manager
2. At the botom add the number 26 at "exim on another port"
3. In /etc/apf/conf.apf add the port 26 at this line "EG_TCP_CPORTS"
4. apf –r

How to set limit to remove the Frozen Maiils Automatically ?

vi /etc/exim.conf

timeout_frozen_after = 8d ( 8 Days )

/scripts/restartsrv_exim

How to install squirrelmail lanuage package

cd /usr/local/cpanel/base/3rdparty/squirrelmail
wget http://switch.dl.sourceforge.net/sourceforge/squirrelmail/all_locales-1.4.5-20050904.tar.gz
tar -xvzf all_locales-1.4.5-20050904.tar.gz

OR

wget http://easynews.dl.sourceforge.net/sourceforge/squirrelmail/all_locales-1.4.5-20050904.tar.gz

tar -xvzf all_locales-1.4.5-20050904.tar.gz

How to detect spam

tail -f /var/log/exim_mainlog|grep /tmp

tail –f /var/logs/exim_mainlog |grep public_html

tail –f /var/logs/exim_mainlog |grep sendmail

check mail queue

How to configure Logwatch on the server?

vi /etc/log.d/logwatch.conf

Scroll to MailTo =

Replace the lines with

MailTo = root

to

MailTo = support@udsquare.net,wlu@gazzin.com

also change the line

details=Low

to

details=High

How to set _globals off/on?

Just create a .htaccess file in the folder where the script is, and write only this

"php_flag register_globals off"

1

It works for me.

OR

You can also do it this way:

php_value register_globals 0 --------------- for Off

php_value register_globals 1 --------------- for On

This too works.

OR

In general what ever function you want to enable or disable, this is the general format:

php_value function 0 or 1 ---------------for disable or enable respectively.

How to increase ftp upload limit?

a) first check the ftp running ie pure-ftp or pro-ftp.

b) likewise edit the file proftpd.conf or pure-ftpd.conf .

c) edit pure-ftpd.conf

d) search for word “quota”

1. uncomment it and it is in the format 1000:10

The first number is the max number of files. The second number is the max size of megabytes. So 1000:10 limits every user to 1000 files and 10 Mb.

How to trace the DDOS attack on the server ?

1. Your should have following setting at the time of DDOS attack in httpd.conf:

TimeOut = 20

KeepAlive Off

MaxClients 384

MinSpareServers 20

MaxSpareServers 25

2. in /usr/local/ddos/ddos.conf

NO_OF_CONNECTIONS=20

3. You should have 7 SSH session and 1 WHM at the time of DDOS.

4. Check the domlogs to trace out a particular website for the DDOS. Use the following command to check the latest updated domlog file for the website.

ll -lt |less

5. You should keep the following command to check the DDOS.

top, access_logs, error_logs,

ps aux | grep php

check the apache status in the WHM

cd /root/nobody_check

./apachetrace

cd /tmp

ls and check suspected scripts.

6. If necessary reboot the server. This will kill the http process which is causing the DOS. When the server is up, that process will start again and at that time you can trace it and kill it.

7. You can change the permission of the suspected domain. Make the DNS changes to 127.0.0.1 . please use TTL 20 for fast dns propagation. Don't set the redirectio for the website in httpd.conf.

8. After the DDOS attacker is trace down, don't forget to revert back the changes make to https.conf.

9. Suspend the suspected domain and mail the client about this.

check queue by whm

if queue is high I will check queue by whm

I will scroll bottom I will see which domain is most of time or aol

If I find any I will click on id I will see his email headers so we ill get spammer.

I know all mails are not spamer in such case we will delete mails. Only

Tail –f /var/log/exim_mainlog |grep sendmail

Tail –f /var/log/exim_mainlog |grep tmp

Tail –f /var/log/exim_mainlog |grep public_html

Tail –f /var/log/exim_mainlog |grep hostname


Or

Cd /var/spool/cron

Check if someone is sending mail or bulk list.

2)check aol mails

if we find continuously mails from AOL

logged at server

check mail queue who is sending mail to AOL id check header and suspend the account.

As per apache load.

Ps auw |grep nobody

We check is there any old or bad process kill it

We check apache status.

We check access_logs

We check domlogs of domain

For control

1)cap domain name for ip limit

2)if ddos 127.0.0.1 update client

3)if accessing only one file redirect it

4)if ~access ban by mod_sec

in ddos we used following method

In DDOS ON mode usually the best setting is

/usr/local/ddos/ddos.conf

NO_OF_CONNECTIONS=100

/etc/httpd/conf/httpd.conf

Timeout =10

KeepAlive = OFF

mod_evasive = uncomment

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

In DDOS OFF mode

/usr/local/ddos/ddos.conf

NO_OF_CONNECTIONS=650

/etc/httpd/conf/httpd.conf

Timeout =50

KeepAlive = On

mod_evasive = comment

Ddos mode should be off when attack stop.

We check proc/pid too

mysqladmin processlist

if one database again and again we suspend him.

Cpanel default page

When you dive domain name on the browser, it give you cpanel’s default page.

1. login to the shell.

2. killall nobody.

3. /scripts/restartsrv_httpd

4. then the error is solved.

If you are still getting the error please you have to check the error_logs for the apache.

Unable to Publish web using http:// but can publish using ftp://

Unable to Publish web using http:// but can publish using ftp://

/scripts/initfpsuexec

How to suspend anyone using .htaccess

RedirectMatch .* http://caglewebcreations.com/suspended.page/

Options -Includes -Indexes –ExecCGI

Turning safe mode on or off for a single account

In their www directory add / edit the .htaccess with following lines

php_value safe_mod 0


0=off

1=on