Showing posts with label Basic-Security. Show all posts
Showing posts with label Basic-Security. Show all posts

How To Generate Randum Password

0 comments

Some times when creating bulk users, admins are forced to create complex passwords. But how to do it? How many you can set manually? Let me put it in this way. For one or two users we can think for a random password and assign to them. But if its 100 users? Naaa.. I cannot think for 100 passwds.

So leave this job to Linux to create random passwords.
you use below command to generate random passwords

< /dev/urandom tr -dc A-Na-n1-9_ head -c8
This will just generate random
8 lenght password

For example :
See just typing the above command will generate a random password

root@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8 57fg67gKroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8 FN8ahe8broot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8 eLhLLNCGroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8 FK3CC9GNroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8 cA8H24Mlroot@ps6061:~# < /dev/urandom tr -dc A-Na-n1-9_ head -c8
9eDL39I_root@ps6061:~#

Here is a script written by me to automate entire 20 user account creation.
#!/bin/bash
#Author:Surendra Kumar Anne
#Purpose:To automate user creation
#Date/Time:29-01-2010.19:10
mkdir -p /home/admin/useraccounts
for (( i=0; i<=20; i++ )) do useradd user$i < /dev/urandom tr -dc A-Na-n1-9_ head -c8 > /tmp/passwd.txt
cat /tmp/passwd.txt passwd --stdin user$i
echo -e "Username:user$i" > /home/admin/useraccounts/user$i
echo -e "password:" >> /home/admin/useraccounts/user$i
cat /tmp/passwd.txt >> /home/admin/useraccounts/user$i
done
rm -rf /tmp/passwd.txt

Note :
When password generating I have just created a password which will not contain o(small ooo), O(capital OO), 0(zero). This is to remove confusions for users. Some times user will get confusion when using these characters. If you want all the characters from a to z, A to Z, and 0-9 just use below code
.

< /dev/urandom tr -dc A-Za-z0-9_ head -c8

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Use IPtables to Block ICMP (Internet Control Message Protocol) Requests?

    0 comments

    How to use IPtables to block ICMP (Internet Control Message Protocol) requests?
    Ans : To do this we have understand why we require this thing should be done.
    When Hackers try to hack in to any machine first thing they will do is a basic ping test.

    Code :
    #ping target-machine

    If this is succeed they will come to a conclusion that system is up and they can go forward and they can do DDOS attacks or try to find some other open ports using NMAP command.

    Code :
    #nmap target-machine
    So if you are exposing a machine to outer world from your network, first disable incoming ping requests to your machine as follows.

    So this can be done by two ways through IPtables
    1. Reject the ICMP packets.
    2. Drop the ICMP packets.

    In the above mentioned methods best thing is to drop the ICMP packets, by doing this we are not giving any clue to hacker whether the system is alive or not. Where as if we do reject definitely hacker will come to know that ICMP packets are blocked and the system is live.

    Step1 : Executing following command to drop all the incoming ICMP packets
    #iptables –A INPUT –p icmp --icmp-type echo-request –j DROP
    Let me explain this command
    -A is to append this rule to already existing one.
    INPUT specifies that it’s a

    Step2 : Save this changes to IPtables file (/etc/sysconfig/iptables), restart the IPtables service and check your IPtables status whether your IPtables chain is updated or not.
    #service iptables save
    #service iptables restart
    #iptables –L

    How to allow icmp ping request in case you want them,First we have to remove the rule which we created for blocking the icmp ping.
    #iptables –D INPUT –p icmp --icmp-type echo-request –j DROP

    Then execute the following commands
    #iptables –A INPUT –p icmp --icmp-type echo-request –j ACCEPT
    #service iptables save
    #service iptables restart

    Some points to be noted
    What are the methods used by hackers using this ICMP ping?
    Though these are old denial-of-service attack (DoS attack), worth to learn them
    Ping flood
    Smurf attack
    Ping to death

    Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • SNORT(IDS/IPS) Configuration and Implemenation

    0 comments

    Lets start how to install SNORT which is An Intrusion detection system (IDS) and an Intrusion Prevention System (IPS). We tested installation of SNORT on RHEL5.
    Step1 : Download following packages
    libpcap-1.0.0.tar.gz
    pcre-8.00.tar.gz
    libnet-1.0.2a.tar.gz (This is optional package if you want SMB popup alerts on window’s machines.)
    snort-2.8.5.1.tar.gz
    acid-0.9.6b23.tar.gz
    Note : Don’t try to install SNORT through rpm packages, try to install them from source packages because there will be so many dependencies. And install the above packages in the same order to resolve dependencies.
    Step2 : Untar packages one by one.
    #tar xvfz packagename.tar.gz
    Step3 : Change the directory to libpcap-1.0.0 and Just run ./configure shell script, this will check system attributes and generate make file, which is used to install libpcap package as following.
    #cd libpcap-1.0.0
    #./configuration
    #make
    #make install
    Note : If anything goes wrong please search that error message in google..
    Step4 : After installing libpcap install pcre package for doing regular expression query in checking the packet capture to match multiple entries. First change the directory to pcre-8.00 then start executing following commands
    #cd ../pcre-8.00
    #./configure
    #make
    #make check
    #make install
    Step5 : Now install libnet package..
    #cd ../libnet-1.0.2a
    #./configure
    #make
    #make check
    #make install
    Step6 : Now install the important package in our game of implementing IDS/IDP ie our SNORT package. Just follow below commands to install SNORT. You have to be careful in this step because we can install SNORT in standalone system or a complete system with DB/web server/acid support. If you are planning to install SNORT in standalone just execute ./configure after changing to snort-2.8.5.1 directory. But here I am going to build a complete SNORT system will all the capabilities. Before that we should know what are the content of snort source directory. Please get some knowledge on it and read the required readme files in doc/ folder.
    Note : Before installing SNORT do the following things (Before installation you can do this).
    1. Make sure that you copy etc/ content in source directory to /etc directory
    2. Create /var/log/ snort directory for snort logging activity (remember we have to mention this path in main configuration file, in our case it will be /etc/snort/etc/snort.conf.
    3. Create /etc/snort/rules directory for creating rules files for snort.
    #mkdir /etc/snort
    # cp -ar ./etc /etc/snort/
    #mkdir /var/log/snort
    # mkdir /etc/snort/rules
    Now start installing SNORT
    # ./configure --with-mysql --with-snmp --enable-smbalerts --enable-flexresp
    #make
    #make check
    #make install
    Hmm..! good we are done with the installation of SNORT
    So in the next post I will show you how to configure, integrate SNORT with Mysql and ACID.
    Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Take The Backup Of MBR(Master Boot Recorder)

    2 comments

    1.How to take the backup and restore MBR? Why do you require to take the backup of your MBR?
    Ans :
    MBR (Master Boot Recorder) is a vital part of your hard disk which contains booting information, without it its difficult to boot the system. Suppose you have windows and Linux duel boot on your machine and as you know windows is more prone to virus attacks. So it’s always better to backup your MBR to be in safe place.


    2. How to take backup of your MBR?
    Ans :
    Using dd command (dataset definition). Here are the steps to take backup of you MBR and keep it in safe place to restore your system if it get corrupted.
    #dd if=/dev/hdx of=/safe/location bs=512 count=1


    Let me explain the above command how it will work.
    “If”
    in the command is nothing but to specify Input File, here we are specifying our input file as hard disk(if the hard disk is /dev/hda it is primary master, so for general purpose I given 'x'). “of” in the command is nothing but to specify Output File, here we are specifying our output file as /safe/location. Then “bs” this is nothing but block size to write in to hard disk. And then “count” nothing but how many times you want to write date this many block sizes. Here in this example count=1 that means first 512 bytes of the hard disk is copied to the specified location.


    3.How to restore the MBR?
    #dd if=/safe/location of=/dev/hdx bs=512 count=1


    Note : Please replace “hdx” with your hard disk name.
    This is bit complex,
    Is there any other way to restore MBR?
    Yes, if you have Linux or Windows bootable CD, we can easily restore your MBR if you forgot to take backup(And this method is very much easy to do restoration of MBR when compared to previous method).


    Method1 : With Redhat Linux bootable CD.
    For this you have to boot your system to rescue mode, then mount your file system to rescue mode and execute below command to restore your MBR
    #grub-install /dev/hdx


    Note : Please replace hdx with your hard disk name. After that you just reboot your system. Your system will be live and working.

    Method2 : With Windows XP bootable CD.
    Step1 : Boot the system with XP bootable cd
    Step2 : Press f8 to go to repair mode in Windows
    Step3 : Once you got the c drive prompt just type below command
    Fixmbr
    This command will fix the MBR record.


    Some FAQ’s
    1. What is the MBR size?
    Ans :
    MBR size is just 512 bytes.


    2.What MBR conations?
    Ans :
    Mainly MBR can be divided in two parts
    a.Boot loader information block(which is of 448 bytes)
    b. Partition table information(which is of just 64 bytes)


    3.How many partition we can create on a hard disk?
    Ans :
    Totally we can create four partitions as below
    a.Four primary parathions.
    b.Three primary and one extended partition.
    c.Two primary and one extended parathion.
    d.One primary and one extended parathion.


    Note : In extended parathion we can create logical partitions up to 24 in number.

    4.Why we cannot create more then 4 partition as mention above?
    Ans :
    In MBR, the partition table info is just stored in 64 bytes, and one parathion information to store in MBR requires 16 bytes of space. So at most you can create only 4 partitions as mention above.


    Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Use VNSTAT To Monitor Bandwidth Usage.

    0 comments

    There are so many tools to monitor network such as MRTG, now I am going to explain such tool which monitors bandwidth for a system, ie vnstat(view network statistics). Its very much easy to install and configure.

    This tool can give you full details about how much bandwidth used on the basics of,

    Per month.

    Per week.

    Per day.

    Per hour.

    Per second.

    Even we can see live traffic. This is awesome tool .

    So all the tools will not only have advantages but also disadvantages, here are they:
    1)Can not monitor multiple interfaces at a time.
    2)Can not monitor remote host.
    3)Can not monitor per host statistics(which is verymuch useful to find the network hogger, if you want per host bandwidth analyser then use iptables counters for it).

    Before configuring vnstat, one thing we have to keep in mind that vnstat is a aggregating tool which is required to run at regular intervals to monitor network bandwidth. So by default when we install vnstat a cron job is created at /etc/cron.d folder.

    Step1 : installing vnstat

    #rpm –ivh vnstat-1.6-2.fc9.i386.rpm

    Step2 : Configuring vnstat.
    As I mention earlier that vnstat is an aggregate tool so it should run background by using crontab, So first edit the cron job

    Vi /etc/cron.d/vnstat
    */5 * * * * vnstat /usr/sbin/vnstat.cron
    Add the above line to the file, then save it and exit.

    Step3 : Specifying which interface to monitor

    #vnstat –I interfacename

    Example :
    [root@test ~]# vnstat -i eth0
    Error :
    Unable to read database "/var/lib/vnstat/eth0".
    eth0: Not enough data available yet.

    Don’t worry about error intitially it will show error because it’s the first time you are executing that command, so it has to create DB.

    Step4 : Monitoring bandwidth with different intervals

    Type1 : For live traffic

    #vmstat –l
    -l is nothing but live
    Example:
    [root@test ~]# vnstat -l
    Monitoring eth0... (press CTRL-C to stop)
    rx: 8.32 kB/s 30 p/s tx: 0.19 kB/s 0 p/s
    eth0 / traffic statistics
    rx tx
    --------------------------------------+----------------------------------------
    bytes 206 kB 4 kB
    --------------------------------------+----------------------------------------
    max 11.19 kB/s 0.24 kB/s
    average 7.96 kB/s 0.19 kB/s
    min 6.35 kB/s 0.11 kB/s
    --------------------------------------+----------------------------------------
    packets 695 16
    --------------------------------------+----------------------------------------
    max 61 p/s 2 p/s
    average 26 p/s 0 p/s
    min 9 p/s 0 p/s
    --------------------------------------+----------------------------------------
    time 26 seconds

    Type2 :For monitoring traffic per second

    #vmstattr 5
    This command will monitor bandwidth for 5 seconds and give you the output.

    Type3 : For hourly

    #vmstat –h

    Example :
    [root@test ~]# vnstat -h
    eth0 21:00
    ^ r
    r
    r
    r
    r
    r
    r
    r
    r
    r
    -+--------------------------------------------------------------------------->
    22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21
    h rx (kB) tx (kB) h rx (kB) tx (kB) h rx (kB) tx (kB)
    22 0 0 06 0 0 14 0 0
    23 0 0 07 0 0 15 0 0
    00 0 0 08 0 0 16 0 0
    01 0 0 09 0 0 17 0 0
    02 0 0 10 0 0 18 0 0
    03 0 0 11 0 0 19 0 0
    04 0 0 12 0 0 20 12,614 41
    05 0 0 13 0 0 21 0 0
     
    Type4:For dialy

    #vmstat –d
    Example :
    [root@test ~]# vnstat -d
    eth0 / daily
    day rx tx total
    ------------------------+-------------+----------------------------------------
    09.09. 12.32 MB 41 kB 12.36 MB %%%%%%%%%%%%%%%%%%%%%%%%%
    ------------------------+-------------+----------------------------------------
    estimated -- -- --

    Type5 : For weekly

    #vmstat –w

    Example :
    [root@test ~]# vnstat -w
    eth0 / weekly
    rx tx total
    ----------------------------+---------------+--------------
    last 7 days 12.32 MB 41 kB 12.36 MB
    current week 12.32 MB 41 kB 12.36 MB
    ----------------------------+---------------+--------------
    estimated -- -- --

    Type6 : For monthly
    #vmstat –m
    Example :
    [root@test ~]# vnstat -m
    eth0 / monthly
    month rx tx total
    -------------------------+--------------+--------------------------------------
    Sep '09 12.32 MB 41 kB 12.36 MB %%%%%%%%%%%%%%%%%%%%%%
    -------------------------+--------------+--------------------------------------

    Please comment your thoughts about VNSTAT.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • 10 Commandments !! U like it for sure!!

    0 comments

    This is a guest post by Praveen

    10 COMMANDMENTS !! U LIKE IT FOR SURE !!


    =>1 People are illogical, unreasonable, and self-centered. Love them anyway.

    =>2 If you do good, people will accuse you of selfish, ulterior motives. Do good anyway.

    =>3 If you are successful, you will win false friends and true enemies. Succeed anyway.

    =>4 The good you do today, will be forgotten tomorrow. Do good anyway.

    =>5 Honesty and frankness make you vulnerable. Be honest and frank anyway.

    =>6 The smallest men and women with the smallest minds can shoot down the biggest men and women with the biggest ideas. Think big anyway.

    =>7 People favor underdogs, but follow only top dogs. Fight for a few underdogs anyway.

    =>8 What you spend years building may be destroyed overnight. Build anyway.

    =>9 People really need help, but may attack you if you do help them. Help people anyway.

    =>10 Give the world the best you have and you’ll get kicked in the teeth. Give the world the best you have anyway.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Disabling SELinux

    0 comments

    Some basics of SELinux :
    How to disable SElinux?
    SElinux is a security feature which was shipped with RHEL5, it is much secure than any other security priviously such as PAM and Initd




    Here we are going to see some basics of SElinux.

    Step1:Seeing whether SELinux is enabled or not ?

    #getenforce

    Step2:To see SELinux status in elaborated way you can use sestatus
    #sestatus
    SElinux status : enabled
    SELinux mount : /selinux
    Current mode : enforcing
    Mode from config file : enforcing
    Policy version : 21
    Policy from config file : targeted

    From the above output we can see that SElinux is enabled and its in enforced mode.
    and to see detailed status you can use -b option, this will give which service are SElinux enabled and which services are disabled.

    setenforce
    /etc/grub.conf and /etc/selinux/config

    Step3:disabling SElinux
    We can do it in two ways
    1)Perminant way : edit /etc/selinux/config

    change the status from enable to disable and selinux type from strict to targeted, after changes are made we have to restart, if the server's are in production and don't want to restart the server follow the temporary way of disabling it.

    2)Temporary way : echo 0 > /selinux/enforceFor your info if you want to enable it again, try below commandecho 1 > /selinux/enforce.
    Selinux is a vast subject and can not deal in one post, see for my other posts regarding Selinux.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here