Linux and Windows System Administrators Stuffs

September 22, 2009

Send mail via telnet / test for open relay

Filed under: Linux, Send Mail, Troubleshooting — Tags: — siva2009 @ 8:13 pm

First, determine the MX for the domain in question:

nslookup
set type=mx
mydomain.com

should return something like:Server: ns2.mydom.com
Address: 192.168.1.254
mydomain.com preference = 10, mail exchanger = mx.mydomain.com
mydomain.com nameserver = ns.mydomain.com
mx.mydomain.com.com internet address = 1.1.1.1
mx2.mydomain.com internet address = 1.1.1.2

The last two lines tell you about the mail server (MX = Mail Exchange). In this case, 1.1.1.1 and 1.1.1.2.

So, armed with this knowledge,

telnet 1.1.1.1 25

Server responds with: 220 mx.mydomain.com SMTP
HELO

Server responds with: 250 OK
MAIL FROM:user@mydomain.com

Server responds with: 250 Address Ok.
RCPT TO:user@otherdomain.com

Server responds with: 250 user@otherdom.com OK
DATA

Server Responds (or may not): 354 Enter Mail
Enter message, then on a new line,
.

exit

The message should now be sent. By modifying the MAIL FROM and RCPT TO lines, you can test for open relay.

Linux find command explain with examples

Filed under: Interview Questions, Linux, Solaris — Tags: — siva2009 @ 7:51 pm

To find all files ending with .html:

find / -name \*.html -print

The character causes the shell to ignore the following character, in this case an asterisk. To find a file that starts with project:

find / -name project\* -print

Multiple wildcards can be used in the same find command. The following command finds all files with the word maybe in it:

find / -name \*maybe\* -print

The backslash \ character is important. It tells the shell not to treat the wildcard character as a wildcard when interpreting the command line arguments.

To find all empty files on the entire system,

find / -size 0 -print

To find all empty files from the current directory down,

find . -size 0 -print

To find all empty files on the entire system,

find / -size 0 -print

To find all empty files from the current directory down,

find . -size 0 -print

To find all files with zero length and ask if they should be deleted:

find / -size 0 -ok rm {} \;

The backslash \ is important because it tells the shell to ignore the semicolon symbol which usually separates commands on a single command line.

Disable ICMP echo (ping) responses in Linux

Filed under: Hacking, Linux — siva2009 @ 7:42 pm

Many malicious attacks begin with a ping scan. Disabling ICMP echo requests prevents your system’s discovery with a ping.

As superuser, add the following lines to /etc/sysctl.conf

net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_echo_ignore_all = 1

Then run the following command to cause the change to take effect immediately:

sysctl -p

September 12, 2009

Installing Apache Tomcat on Windows

Filed under: Tomcat, Windows — siva2009 @ 7:24 am

Installing Apache Tomcat on Windows

September 9, 2009

Crontab – Very Simple – Easy Guide

Filed under: Linux — siva2009 @ 5:10 am

CronTab

The cron daemon is a long-running process that executes commands at specific dates and times. You can use this to schedule activities, either as one-time events or as recurring tasks.

To schedule one-time only tasks with cron, use at or batch. For more information, see the man pages for at and batch.

For commands that need to be executed repeatedly (e.g., hourly, daily, or weekly), use crontab, which has the following options:

crontab -a filename Install filename as your crontab file. On many systems, this command is executed simply as crontab filename (i.e., without the -a option).
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Displays the last time you edited your crontab file. (This option is only available on a few systems.)
crontab -u user Used in conjunction with other options, modify or view the crontab file of user. When available, this option can only be used by administrators.

The crontab command creates a crontab file containing commands and instructions specifying when cron should execute them. Each entry in a crontab file consists of six fields, specifying in the following order:

  minute(s) hour(s) day(s) month(s) weekday(s) command(s)

The fields are separated by spaces or tabs. The first five are integer patterns and the sixth is the command to be executed. The following table briefly describes each of the fields.

Field Value Description
minute 0-59 The exact minute that the command sequence executes
hour 0-23 The hour of the day that the command sequence executes
day 1-31 The day of the month that the command sequence executes
month 1-12 The month of the year that the command sequence executes
weekday 0-6 The day of the week that the command sequence executes. Sunday=0, Monday = 1, Tuesday = 2, and so forth.
command Special The complete sequence of commands to be executed. The command string must conform to Bourne shell syntax. Commands, executables (such as scripts), or combinations are acceptable.

Each of the patterns from the first five fields may be either an asterisk (meaning all legal values) or a list of elements separated by commas. An element is either a number or an inclusive range, indicated by two numbers separated by a minus sign (10-12). You can specify days with two fields: day of the month and day of the week. If you specify both of them as a list of elements, cron will observe both of them. For example:

  0 0 1,15 * 1 /mydir/myprogram

The cron daemon would run the program myprogram in the mydir directory on the first and fifteenth of each month, as well as on every Monday. To specify days by only one field, the other field should be set to *. For example:

  0 0 * * 1 /mydir/myprogram

The program would then only run on Mondays.

If a cron job specified in your crontab entry produces any error messages when it runs, you will get a mail message reporting the errors.

For more information, consult the following relevant man pages:

  man crontab man cron man at man batch

Note: On some systems, you must get permission from the system administrator before you can submit job requests to cron. On many shared systems, because there is only one crontab file, only the administrator has access to the crontab command.

September 8, 2009

How to limit mail attachment size for Sendmail

Filed under: Linux, Linux Mail Server, Send Mail — Tags: , , — siva2009 @ 12:58 am

This little document is going to briefly show how to limit the size of incoming mail attachments. In order to this you are going to have to be familiar with Vi editing (see Basic Vi editing for an introduction).

First off telnet on to your mail server and log on as root or su. Next change to /etc directory. In that directory you should find a file called sendmail.cf (if you can’t find it, try typing whereis sendmail.cf, this should return a list of files with the word sendmail in it and hence you should be able to locate it that way). Prior to editing it, make a backup copy of it. Now you can type vi sendmail.cf.

Now scroll down this file until you find an entry that looks something like this:
# maximum message size
# 0 MaxMessageSize=1000000
In order to limit the size of messages simply uncomment the last line so that it reads:
0 MaxMessageSize=1000000
Furthermore you can specify the maximum message size by editing the value bit. Once done, save the changes and exit.

The final step involves stopping and restarting the server so that the changes can take effect (check your /etc/rc.d/init.d/ directory).

September 2, 2009

Recovering forgotten Windows XP administrator Password

Filed under: Hacking, Troubleshooting, Windows — siva2009 @ 8:16 pm

Please Do the Following steps for Reseting administrator password in Win Xp

1. Place your Windows XP CD in your cd-rom and start your computer (it’s assumed here that your XP CD is bootable – as it should be – and that you have your bios set to boot from CD)

2. Keep your eye on the screen messages for booting to your cd Typically, it will be “Press any key to boot from cd”

3. Once you get in, the first screen will indicate that Setup is inspecting your system and loading files.

4. When you get to the Welcome to Setup screen, press ENTER to Setup Windows now

5. The Licensing Agreement comes next – Press F8 to accept it.

6. The next screen is the Setup screen which gives you the option to do a Repair.

It should read something like “If one of the following Windows XP installations is damaged, Setup can try to repair it”

Use the up and down arrow keys to select your XP installation (if you only have one, it should already be selected) and press R to begin the Repair process.

7. Let the Repair run. Setup will now check your disks and then start copying files which can take several minutes.

8. Shortly after the Copying Files stage, you will be required to reboot. (this will happen automatically – you will see a progress bar stating “Your computer will reboot in 15 seconds”

9. During the reboot, do not make the mistake of “pressing any key” to boot from the CD again! Setup will resume automatically with the standard billboard screens and you will noticeInstalling Windows is highlighted.

10. Keep your eye on the lower left hand side of the screen and when you see the Installing Devices progress bar, press SHIFT + F10. This is the security hole! A command console will now open up giving you the potential for wide access to your system.

11. At the prompt, type NUSRMGR.CPL and press Enter. Voila! You have just gained graphical access to your User Accounts in the Control Panel.

12. Now simply pick the account you need to change and remove or change your password as you prefer. If you want to log on without having to enter your new password, you can typecontrol userpasswords2 at the prompt and choose to log on without being asked for password. After you’ve made your changes close the windows, exit the command box and continue on with the Repair (have your Product key handy).

13. Once the Repair is done, you will be able to log on with your new password (or without a password if you chose not to use one or if you chose not to be asked for a password). Your programs and personalized settings should remain intact.

August 31, 2009

Catch the Spam Tagged emails in spamassassin

Catching spam mails into other mail accounts

In below example i have catched the all spam tagged emails for the domain siva.com into spammailbox@siva.com.

OPen the procmailc file in /etc

# nano /etc/procmailrc

# Catch the Spam Tagged Mail
:0:
* ^X-Spam-Flag: YES
! spammailbox@siva.com

addd the above entry in last ..

Thats it ….

August 8, 2009

Securing Your /tmp Partition to prevent from hackers

Filed under: Server Security — Tags: , , , — siva2009 @ 4:43 am

Securing your /tmp directory could save you from an un-updated PHP script, where someone attempts to write an executable program with malicous code too.

I AM NOT RESPONSIBLE FOR ANY PROBLEMS THIS MAY CAUSE

that being said, lets get to it:

cd /dev

Create 500MB file for our /tmp partition. If you need more space, make count size larger.

dd if=/dev/zero of=tmpMnt bs=1024 count=500000

Make an extended filesystem for our tmpMnt file

/sbin/mke2fs /dev/tmpMnt

Backup your /tmp dir- I had mysql.sock file that I needed to recreate the symbolic link for. Other programs may use it to store cache files or whatever.

cd /
cp -pR /tmp /tmp_backup

Mount the new /tmp filesystem with noexec

mount -o loop,noexec,nosuid,rw /dev/tmpMnt /tmp
chmod 0777 /tmp

Copy everything back to new /tmp and remove backup

cp -pR /tmp_backup/* /tmp/

Now we need to add this to fstab so it mounts automatically on reboots.

pico -w /etc/fstab

You should see something like this:

/dev/hda3               /                       ext3    defaults,usrquota        1 1
/dev/hda1               /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
/dev/hda2               swap                    swap    defaults        0 0

At the bottom add:

/dev/tmpMnt             /tmp                    ext2    loop,noexec,nosuid,rw  0 0

(Each space is a tab)
Save it!

Ctrl + X and Y

Your done- /tmp is now mounted as noexec. You can sleep a little bit safer tonight. I created a hello world c++ and compiled it then moved it to /tmp. Upon trying to run it (even chmod +x’ed), it gives the following error:

bash: ./a.out: Permission denied

good luck! if it is causing problems with any of your software, you could remove the entry from fstab, reboot and then delete /tmp and recreate it to bring it back to normal.

*Source:  http://webhostgear.com*

July 29, 2009

Installing and Configure Subversion, WebDav Protocol with SSL Encryption (https ://) On Ubuntu Server

Subversion:-

Subversion is an open-source version control system. Using subversion you can record the history of source files and directories. It manages file and directories over time. A tree of files is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to files and directories.

Installation Package:-

ü      Subversion

ü      Subversion-tools

ü      Apache2

ü      Libapache2-svn

ü      Ssl-cert

ü      Openssl

The following commands:

$ sudo apt-get installs subversion subversion-tools apache2 libapache2-svn ssl-cert openssl

Create a Subversion Repository:-

The following commands:

   $ sudo mkdir /home/svn
   $ cd /home/svn
   $ sudo mkdir repos 
   $ sudo addgroup subversion       
 
   $ sudo adduser sureshkumar subversion
 
  
 $ sudo chown –R www-data:subversion /home/svn/repos
 
 
 
   $ sudo chmod –R g+rws /home/svn/repos
 
 

The subversion repository can be created using the following command:

   $ sudo svnadmin create /home/svn/repos

Creating Certificates for https:-

Generating a Certificate Signing Request (CSR)

To generate the keys for the Certificate Signing Request (CSR) run the following command from a terminal prompt:

$ openssl genrsa -des3 -out server.key 1024

To create the CSR:-

            run the following command at a terminal prompt:
$ openssl req -new -key server.key -out server.csr
 
  

Creating a Self-Signed Certificate:-

To create the self-signed certificate, run the following command at a terminal prompt:

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Installing the Certificate:-

You can install the key file server.key and certificate file server.crt, or the certificate file issued by your CA, by running following commands at a terminal prompt:

sudo cp server.crt /etc/ssl/certs
sudo cp server.key /etc/ssl/private
 
 
Now simply configure any applications, with the ability to use public-key cryptography, to use the certificate and key files. For example, Apache can provide HTTPS.

To configure Apache for HTTPS add the following three lines to the /etc/apache2/sites-available/subversion file

SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key

Configure Apache Server (https) the Repository:-

         We need to be sure the right modules are enabled

$ a2enmod dav

$ a2enmod dav_svn

We must set up virtual host for subversion server. File that you can put in /etc/apache2/sites-available/default (original file).so we can copy the original file (default) to duplication file (subversion).

$ sudo cp /etc/apache2/sites-available/default  /etc/apache2/sites-available/subversion.

Edit file $ sudo vim /etc/apache2/sites-available/subversion

 NameVirtualHost 192.170.50.61:443
<VirtualHost 192.170.50.61:443>
      ServerAdmin webmaster@localhost
       #SSLCertificate 
         SSLEngine on
         SSLCertificateFile /etc/ssl/certs/server.crt
         SSLCertificateKeyFile /etc/ssl/private/server.key
  <Location /repos>
        DAV svn
        SVNPath /home/svn/repos
        AuthType Basic
        AuthName "Subversion Repository"
        AuthUserFile /etc/apache2/dav_svn.passwd
      #Required authentication
        Require valid-user
      # Require encryption
        SSLRequireSSL
  </Location>
      ErrorLog /var/log/apache2/error.log
      LogLevel warn
      CustomLog /var/log/apache2/access.log combined
      ServerSignature On
 
</VirtualHost>

Symbolic link:- 
 
Be sure to make a symbolic link to that file in /etc/apache2/sites-enabled:

$ ln –s  /etc/apache2/sites-available/subversion/  /etc/apache2/sites-enabled
 

Open Port Number:-
 
Add "Listen 443" to /etc/apache2/ports.conf:

$ sudo vim /etc/apache2/ports.conf
 
             Listen 443   
 
 
 
Subversion main configuration file:-

Edit /etc/apache2/mods-available/dav_svn.conf configuration file and follow the instructions:

$ sudo vim /etc/apache2/mods-available/dav_svn.conf

  <Location /repos>
        DAV svn
        SVNPath /home/svn/repos
        AuthType Basic
        AuthName "Subversion Repository"
        AuthUserFile /etc/apache2/dav_svn.passwd
        Require valid-user
        SSLRequireSSL
  </Location>

User authentication:-

To add the first user, you can run the following command:

$ sudo htpasswd -c /etc/apache2/dav_svn.passwd suresh
 
 

Note: If you have just installed SVN, the passwd file will not yet exist and needs to be created using the "-c" switch. Adding any users after that should be done without the "-c" switch to avoid overwriting the passwd file.

Direct repository you can run the following command:
 
$ sudo svn co file:///home/svn/repos
 
 

You should start apache service
$ sudo /etc/init.d/apache2 start 
 
Older Posts »

Blog at WordPress.com.