Loading
Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Monday, January 25, 2010

Install CactiEZ on Windows 2008 Hyper-V

CactiEZ (Cacti Made Easy) is a self installing Linux Distribution based off CentOS that sets up and configures a customized Cacti install. Everything is designed to be completely automated and working directly out of the box. This compact distro is loaded with extra features such as Syslog and Netflow data collection, Weathermaps, Reports, Auto Discovery, Router Config backup, Nagios, and much more!

This guide provides instructions for installing CactiEZ as a VM on Windows 2008 Hyper-V.

This contains some fairly detailed instructions so someone new to this setup should have enough info to get completely running.  However, since I know some of you out there are in a hurry here's the Cliff Notes version:
  1. Don't use the default network adapter - DELETE it!
  2. Add a legacy network adapter.
  3. Install CactiEZ.
Full Instructions for Installing CactiEZ on Windows 2008 Hyper-V

Download the CactiEZ ISO - get this started now so it will be done by the time your're ready for it.  By default the CactiEZ ISO is a tarred file so you will have to untar (unzip) it before you can use it.  If you don't already have a Windows-based program that can handle tarred files 7-zip is a great, FREE, utility.  NOTE: in Windows you may have to unzip twice; CactiEZ-v0.6.tar.gz will unzip to CactiEZ-v0.6.tar from which you can extract CactiEZ-v0.6.iso.

Step One: Create the VM on Hyper-V
  • Launch the Windows Hyper-V Manager (Start, All Programs, Administrative Tools, Hyper-V Manager).
  • Select NewVirtual Machine.  Give it a name.  Click Next.
  • Specify memory (RAM).  In this example I'm using 1024 MB.
  • On the "Configure Networking" screen just click Next - we will delete this later anyway.
  • Create a new virtual hard disk using the name, location and size of your choosing.  I created a 10GB virtual HD which should be more than enough for CactiEZ.
  • On the "Installation Options" screen make sure to choose "Install and operating system later."
  • Click Next, uncheck "Start the virtual machine after it is created" and verify your settings, then click Finish.
    At this point if your VM started you will receive a boot failure message.  Don't worry, you can safely ignore this and Turn Off the VM.

    Step Two: Customize VM Settings
    • From Hyper-V Manager right-click your new VM, then select Settings.
    • Remove the current Network Adapter.
    • Click Add Hardware and select Legacy Network Adapter, then Add.
    • On the Legacy Network Adapter select the correct adapter from the Network drop-down list
    • Click OK to save settings.
    Step Three: Install CactiEZ
    • Double-click your VM to open the Virtual Machine Connection window.
    • Click Media, DVD Drive, Insert Disk and browse to your (extracted/unzipped) CactiEZ ISO.
    • Start (Power On) the VM & it will begin the CactiEZ server installation.
    • Select whether to install the 32 or 64-bit version and let her rip.  The CactiEZ installation is almost completely automated so just let it run.  When prompted reboot the VM.
    After the system reboots its IP address will be displayed (assuming you have a DHCP server available on the network).  You can certainly change the IP address to a static one if you'd like (instructions below).


    Step Four: Logon to Your CactiEZ Server
    Now that your server is installed logon through the Virtual Machine Connection window.  The default username and password are root, CactiEZ.

    Once logged on the first thing I did was set a static IP address using:
    netconfig
    With the IP address and related settings set appropriately restart the network using:
    service network restart
    You may also want to synchronize your time using:
    ntpdate -u 0.pool.ntp.org
    And set your timezone with:
    yum install system-config-date
    system-config-date
    See more CactiEZ tips and hints here.

    NOTE: By default CactiEZ installs SSH so you can connect remotely with something like PuTTY.

    Step Five: Connect to and Configure Cacti
    Using a browser connect to your new installation of Cacti using http://<IP Address>.  The default user is 'admin' and the default password is 'admin' as well.  You will be prompted to change the password.

    Now you can knock yourself out configuring and using Cacti.  Here's more logon information from CactiEZ.

    See also

    Ubuntu VM on Windows 2008 Hyper-V

    How the Hell do I get networking to work on a Ubuntu VM on Hyper-V in Windows 2008?

    This is a question I have personally grappled with a few times.  Although I was able to successfully install a Ubuntu 8.10 server on Hyper-V with networking over a year ago I forgot how it was done and pulled my hair out trying to figure it out again the other day.  So I thought I'd jot down a few notes to help me remember.  If this  helps anyone else, that will be great too.

    These instructions are for Ubuntu 9.10 server on Windows 2008 Hyper-V.  As mentioned above this works for Ubuntu 8.10 server as well; and presumably other versions although I haven't verified.

    This contains some fairly detailed instructions so someone new to this setup should have enough info to get completely running.  However, since I know some of you out there are in a hurry here's the Cliff Notes version:
    1. Don't use the default network adapter - DELETE it!
    2. Add a legacy network adapter.
    3. Install Ubuntu.
    Full Instructions for Installing Ubuntu 9.10 Server on Windows 2008 Hyper-V

    Download the Ubuntu 9.10 server ISO - get this started now so it will be done by the time your're ready for it.

    Step One: Create the VM on Hyper-V
    • Launch the Windows Hyper-V Manager (Start, All Programs, Administrative Tools, Hyper-V Manager).
    • Select New, Virtual Machine.  Give it a name.  Click Next.
    • Specify memory (RAM).  In this example I'm using 1024 MB.
    • On the "Configure Networking" screen just click Next - we will delete this later anyway.
    • Create a new virtual hard disk using the name, location and size of your choosing.
    • On the "Installation Options" screen make sure to choose "Install and operating system later."
    • Click Next, verify your settings, then click Finish.
      At this point if your VM started you will receive a boot failure message.  Don't worry, you can safely ignore this and Turn Off the VM.

      Step Two: Customize VM Settings
      • From the VM Window click File, Settings.
      • Remove the current Network Adapter.

      • Click Add Hardware and select Legacy Network Adapter, then Add.
      • On the Legacy Network Adapter select the correct adapter from the Network drop-down list

      • Click OK to save settings.
      Step Three: Install Ubuntu
      • Click Media, DVD Drive, Insert Disk and browse to your Ubuntu ISO.

      • Start (Power On) the VM & it will begin the Ubuntu Server installation.
      • Select your Language, then "Install Ubuntu Server."
      • Select your desired Country and keyboard layout.
      • Enter your desired hostname, then continue.
      • Select your timezone.
      • Partition your disk using the default, "Guided - use entire disk and set up LVM."
        • Select your disk to partition - if you followed these instructions you will only have one.
        • Select YES to write the changes to disks and configure LVM.
      • Follow the prompts to setup users and passwords, creating at lease one user.
      • Select whether or not to encrypt your home directory.
      • If you have a DHCP server on your network your adapter should retrieve and IP address and associated info from that server.  If not, you will be prompted for IP address settings.
      • Choose how to manage upgrades on your system.
      • Choose which software to install (note, depending on which option(s) you select additional questions will be asked during install which aren't covered in this tutorial):
        • Cloud computing cluster
        • Cloud computing node
        • DNS server
        • LAMP server
        • Mail server
        • OpenSSH server - You may want to install this to connect via SSH later.
        • PostgreSQL database
        • Print server
        • Samba file server
        • Tomcat Java server
        • Virtual Machine host
        • Manual package selection
      • At the "Finishing Installation" screen select Continue.
      Step Four: Logon to Your Ubuntu Server
      Now that your server is installed logon through the Virtual Machine Connection window to verify network settings and connectivity.  Type ifconfig to view your network settings.  You should have an interface, eth0, with either a DHCP-assigned address or the one you manually entered during installation.



      You could verify correct network operation by pinging a know good host on your local network and/or a host on the Internet.  In my case I pinged my default gateway and powercram.com.  Both responded with replies.



      Finally, now that my Ubuntu Server is setup and networking is configured properly I will probably never (hopefully) use the Virtual Machine Connection window again, rather I will use my favorite remote connection client, PuTTY.

      Since I neglected to install Open-SSH Server during the Ubuntu installation I had to install it before I could use PuTTY using:
      sudo apt-get install openssh-server



      Recover Root Password In Ubuntu - HowTo

      You can recover/reset/change your root password on Ubuntu if you have physical access to the machine following these simple steps.
      1. Reboot Ubuntu.
      2. At the GRUB menu press ‘e’ (with quotes), which will let you edit GRUB.
      3. Edit the line with your boot command.
      4. Add this command to the very end of the line with the boot command:
        rw init=/bin/bash
      5. Press enter and boot your system, the command, "rw init=/bin/bash" will make your Ubuntu boot with passwordless root shell.
      6. Once you're logged on just change your password with the passwd <username> command. If it is root just type: passswd root.
      7. Reboot your system.

      Change Ubuntu IP Address from DHCP to Static or Vice Versa - HowTo

      The default network setting in Ubuntu (or Debian) is to use DHCP.  Often, however, it is desirable to use a static IP address and settings.  To change your network configuration from DHCP to static follow these steps.

      Open a terminal session and enter:
      sudo nano /etc/network/interfaces
      Two network interfaces should be listed, lo and eth0:
      # This file describes the network interfaces available on your system
      # and how to activate them. For more information, see interfaces(5).

      # The loopback network interface
      auto lo
      iface lo inet loopback

      # The primary network interface
      auto eth0
      iface eth0 inet dhcp

      Change eth0 to your desired settings, such as:
      auto eth0
      iface eth0 inet static
      address 192.168.1.10
      netmask 255.255.255.0
      network 192.168.1.0
      broadcast 192.168.1.255
      gateway 192.168.1.1

      Save the file and close using Ctl+X, Y, Enter.

      Restart the network to apply the new setting, with this command:
      sudo /etc/init.d/networking restart
      Verify your network settings with:
      ifconfig
      See also

      Friday, January 22, 2010

      Use Iperf to Measure Network Throughput (Bandwidth) on Windows or Linux

      Iperf was developed by NLANR/DAST as a modern alternative for measuring maximum TCP and UDP bandwidth performance. Iperf allows the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss.
      • Install iperf on Windows - just download, unzip and run iperf.exe.
      • Install iperf on Ubuntu:
          sudo apt-get install iperf
      Iperf supports several options, but generally you would run it on one device as a "server" and another as a "client."

      To launch iperf in server mode just enter iperf -s at the terminal.  It will report, "Server listening on TCP port 5001. . ."


      From another system launch iperf in client mode with iperf -c <server IP>. By default Iperf will run a 10 second test and report amount of data transferred and bandwidth speed.


      Note: Iperf can be used to test LAN speeds as well as over the Internet.

      Download Iperf and get more information from SourceForge.

      Wednesday, January 20, 2010

      Bandwidth Monitoring Tools for Ubuntu

      • bmon - Bandwidth monitor and rate estimator
      • bwm-ng - Bandwidth Monitor NG (Next Generation), a live bandwidth
        monitor for network and disk IO
      • cbm - displays the current traffic on all network devices
      • iftop - Real-time bandwidth usage information on a specified interface
      • iperf - Tool for measuring maximum TCP and UDP bandwidth performance
      • ibmonitor - interactive bandwidth monitor
      • pktstat - shows the bandwidth being consumed by packets of various kinds in realtime
      • tcptrack - sniffer which displays information about TCP connections
      • MRTG - see traffic load on a network over time in graphical form
      • Cacti - network graphing solution
      Details on each tool.

      bmon
      bmon is a portable bandwidth monitor and rate estimator. It supports various input methods for different architectures. Various output modes exist, including an interactive curses interface, lightweight HTML output, and simple ASCII output. Statistics may be distributed over a network using multicast or unicast and collected at some point to generate a summary of statistics for a set of nodes.

      Install bmon on Ubuntu:
      sudo apt-get install bmon
      To launch bmon just enter bmon at the terminal.



      You can select a specific interface to view traffic details. In the screen shot below I selected eth0, 'g' for graphical statistics and 'd' for detailed statistics.



      bwm-ng
      bwm-ng can be used to monitor the current bandwidth of all or some specific network interfaces or disks (or partitions). It shows total of in and out as well as total of all interfaces/devices.

      Install bwm-ng on Ubuntu:
      sudo apt-get install bwm-ng
      To launch bwm-ng just enter bwm-ng at the terminal.



      cbm
      cbm (Color Bandwidth Meter) displays the current traffic on all network devices.

      Install cbm on Ubuntu:
      sudo apt-get install cbm
      To launch cbm just enter sudo cbm at the terminal.



      iftop
      iftop provides real-time bandwidth usage information on a specified interface, listed by host pairs.

      Install iftop on Ubuntu:
      sudo apt-get install iftop
      To launch iftop just enter iftop at the terminal.

      Iperf
      Iperf was developed by NLANR/DAST as a modern alternative for measuring maximum TCP and UDP bandwidth performance. Iperf allows the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss.

      Install iperf on Ubuntu:
      sudo apt-get install iperf
      Iperf supports several options, but generally you would run it on one device as a "server" and another as a "client."

      To launch iperf in server mode just enter iperf -s at the terminal.  It will report, "Server listening on TCP port 5001. . ."



      From another system launch iperf in client mode with iperf -c <server IP>. By default Iperf will run a 10 second test and report amount of data transferred and bandwidth speed.



      Note: Iperf can be used to test LAN speeds as well as over the Internet.

      ibmonitor
      ibmonitor is an interactive linux console application which shows bandwidth consumed and total data transferred on all interfaces.

      Its main features are:
      • Shows received, transmitted and total bandwidth of each interface
      • Calculates and displays the combined value of all interfaces
      • Displays total data transferred per interface in KB/MB/GB
      • Values can be displayed in Kbits/sec(Kbps) and/or KBytes/sec(KBps)
      • Can show maximum bandwidth consumed on each interface since start of utility
      • Can show average bandwidth consumption on each interface since start of utility
      • The output with all features (max, avg and display in Kbps and KBps) easily fits on a 80x24 console or xterm
      • Can interactively change its output display format depending on key pressed by user.
      Install ibmonitor on Ubuntu"

      First you need to download the latest version:
      wget http://ovh.dl.sourceforge.net/sourceforge/ibmonitor/ibmonitor-1.4.tar.gz
      Extract this file using the following commands
      tar xvfz ibmonitor-1.4.tar.gz
      cd ibmonitor
      If you want to run the application use the following command

      Once you are in ibmonitor folder use
      ./ibmonitor


      pktstat
      pktstat listens to the network and shows the bandwidth being consumed by packets of various kinds in realtime. It understands some protocols (including FTP, HTTP, and X11) and adds a descriptive name next to the entry (e.g., ‘RETR cd8.iso’, ‘GET http://slashdot.org/’ or ‘xclock -fg blue’).

      Install pktstat on Ubuntu:
      sudo apt-get install pktstat
      To launch pktstat just enter pktstat at the terminal.



      tcptrack
      tcptrack is a sniffer which displays information about TCP connections it sees on a network interface. It passively watches for connections on the network interface, keeps track of their state and displays a list of connections in a manner similar to the unix ‘top’ command. It displays source and destination addresses and ports, connection state, idle time, and bandwidth usage.

      Install tcptrack on Ubuntu:
      sudo apt-get install tcptrack
      To launch tcptrack just enter sudo tcptrack -i eth0 at the terminal.

      tcptrack can also take a pcap filter expression as an argument. The format of this filter expression is the same as that of tcpdump and other libpcap-based sniffers. The following example will only show connections from host 10.1.1.2
      tcptrack -i eth0 src or dst 10.1.1.2
      The next example will only show web traffic (ie, traffic on port 80)
      tcptrack -i eth0 port 80
      MRTG
      MRTG (Multi Router Traffic Grapher) is free software for monitoring the traffic load on network links. It allows the user to see traffic load on a network over time in graphical form.  MRTG is used by programs like Cacti to gather and graph stats over time.

      Cacti
      Cacti is a complete network graphing solution designed to harness the power of RRDTool’s data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive,easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.

      Cacti is great for gathering stats over time (using both MRTG and RRDTool) and creating hourly, daily, weekly, monthly and yearly graphs.  These graphs can be invaluable in identifying trends and potential problems.  In fact, just today I used the following graphs to identify a problem on my corporate network:



      Here's another one showing network utilization over time.



      Sunday, January 17, 2010

      How To Edit Linux DNS Configuration Files

      Edit /etc/resolv.conf using a text editor such as nano, vi or gedit:
      nano /etc/resolv.conf
      Or, for Ubuntu:
      sudo nano /etc/resolv.conf
      Add namesevers as necessary:
      nameserver <ip address>
      nameserver <ip address>
      nameserver <ip address>

      Save and close the config file.

      See also Change Ubuntu IP Address from DHCP to Static

      Find the top 10 largest files and directories on Ubuntu

      Unfortunately there is not a simple command in Linux to find the largest files and/or directories. However, combining the following three commands (using pipes) can help you locate the largest files/directories on your file system:
      • du - Estimate file space usage
      • sort - Sort lines of text files or given input data
      • head - Output the first part of files i.e. to display the n largest files/directories
      In Terminal (command prompt) enter the following to list the top 10 largest files/directories:
      sudo du -a / | sort -n -r | head -n 10
      Of course this can be used on various directories as well, like usr or var:
      sudo du -a /usr | sort -n -r | head -n 10
      sudo du -a /var | sort -n -r | head -n 10

      NOTE: This works on all flavors or Linux, UNIX and BSD as well - just drop sudo.

      Saturday, January 16, 2010

      Upgrade Ubuntu Server From 8.10 to 9.10 - How To

      You can use the following steps to easily upgrade Ubuntu Linux server (or workstation) 8.x to 9.10 (latest version as of this posting), either locally or remotely over ssh from a terminal command line.

      Note: Backup important data and configuration files first.

      First, apply latest updates to Ubuntu 8.x using:
      sudo apt-get update
      sudo apt-get upgrade

      Next, install update-manager-core (if it is not already installed):
      sudo apt-get install update-manager-core
      Finally, start the upgrade:
      sudo do-release-upgrade
      And just follow the on-screen instructions to complete the Ubuntu 9.10 upgrade.

      How to update software on Ubuntu / Debian Linux

      Ubuntu (and Debian) software can easily be updated using the apt-get command line tool.

      apt-get can be used from a terminal window as follows:
      • apt-get update: Update is used to resynchronize the package index files from their sources over the Internet.
        To retrieve updated software list, enter:
        sudo apt-get update
      • apt-get upgrade: Upgrade is used to install the newest versions of all packages currently installed on the system.
        Update software, i.e. apply updates:
        sudo apt-get upgrade
      • apt-get install <package-name>: apt-get install can be followed by one or more packages desired for installation. If package is already installed it will try to update to the latest version.
        To upgrade individual software enter apt-get install followed by the software name, as follows:
        sudo apt-get install <package-name>
      apt-get update, apt-get upgrade and apt-get install will all retrieve files over the Internet. The location of update pages is specified in /etc/apt/sources.list (repositories). Unless you need extra repositories for your setup there is no need to modify this file.

      Using Ubuntu Update Manager Tool (GUI)
      The Ubuntu Update Manager Tools works like the Microsoft and Red Hat update manager tools.  In the Ubuntu GUI you will see a little icon in the task bar when updates are available. Just click on it and follow the online instructions.

      You can also start the Update Manager GUI tool by clicking System | Administration | Update Manager.

      Sunday, December 13, 2009

      Building the Perfect Backtrack 4 USB Thumb Drive

      This post will show you how to build a USB thumb drive with the following features:
      • Persistent Changes
      • Nessus and NessusClient installed
      • Encryption configured for storing data
      Tools and Supplies
      1. USB thumbdrive – minimum capacity 4GB
      2. BackTrack 3 CDROM, BackTrack 4 DVD or an additional USB thumbdrive (minimum 2GB) – Used to partition the thumbdrive.
      3. Optional: UNetbootin – A tool to transfer an iso image to a USB drive.
      Download the BackTrack ISO (BackTrack 4 Pre Release is the latest as of this posting)

      This tutorial is based commands executed from BackTrack, so you will have to boot BackTrack 4 first. The easiest way to do this is to boot from the BackTrack 4 DVD, which is a live CD.

      Partition the USB thumbdrive
      First, boot to BackTrack 4. You will have to figure out which drive is the target drive. The following command will show the drives available and you can determine from that which is the new USB drive:
      dmesg | egrep hd.\|sd.
      Partition and format the drive as follows:
      1. The first partition needs to be a primary partition of at least 1.5 GB and set to type vfat. Also remember to make this partition active when you are creating it. Otherwise you might have some boot problems.
      2. The second Partition can be the rest of the thumb drive.
      Below are the steps to take to get the drive partitioned and formatted, and were taken from this video on the Offensive Security website. A ‘#‘ indicates a comment and is not part of the command and user typed commands are blue bold. Note, make sure to delete any existing partitions on the drive first.
      fdisk /dev/sda # use the appropriate drive letter for your system
      # delete existing partitions, of which there may be more than one. 

      Command (m for help): d
      Partition number (1-4): 1 

      # create the first partition 
      Command (m for help): n
      Command action
      e extended
      p primary partition (1-4)
      p
      Partition number (1-4): 1
      First cylinder (1-522, default 1): <enter>
      Using default value 1
      Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): +1500M 

      #create the second partition 
      Command (m for help): n
      Command action
      e extended
      p primary partition (1-4)
      p
      Partition number (1-4): 2
      First cylinder (193-522, default 193): <enter>
      Using default value 193
      Last cylinder, +cylinders or +size{K,M,G} (193-522, default 522): <enter>
      Using default value 522

      # Setting the partition type for the first partition to vfat/fat32 
      Command (m for help): t
      Partition number (1-4): 1
      Hex code (type L to list codes): b
      Changed system type of partition 1 to b (W95 FAT32) 

      # Setting the partition type for the second partition to Linux 
      Command (m for help): t
      Partition number (1-4): 2
      Hex code (type L to list codes): 83 

      # Setting the first partition active 
      Command (m for help): a
      Partition number (1-4): 1 

      Command (m for help): w 
      # now it is time to format the partitions 
      mkfs.vfat /dev/sdb1
      mkfs.ext3 -b 4096 -L casper-rw /dev/sdb2

      Two things to notice above in the format commands:
      1. We are using ext3 instead of ext2
      2. You must include the -L casper-rw portion of the command.
      Being able to use ext3 is great because of journaling. The -L casper-rw option helps to get around the problem where we had to enter the partition name in order to get persistence working.

      Partition and format the drive according the layout above.

      Make it a bootable BackTrack 4 USB thumb drive
      These steps are also taken from the Offensive Security video mentioned above.  They are:
      1. Mount the first partition
      2. Copy the BackTrack files to it
      3. Install grub
      Execute the following commands.
      # mount the first partition, sda1 in my case. 
      mkdir /mnt/sda1
      mount /dev/sda1 /mnt/sda1
       

      # copy the files, you will need to find where the ISO is mounted on your system. 
      cd /mnt/sda1
      rsync -r /media/cdrom0/* .
       

      # install grub 
      grub-install --no-floppy --root-directory=/mnt/sda1 /dev/sda
      Now you have a bootable BackTrack 4 USB thumb drive. Next let's configure persistent changes.

      Persistent Changes
      This is done much differently and more easily than it was in BackTrack 4 Beta or BackTrack 3. First of all, for basic persistence, no configuration is required. There is already a menu option for this, however, it is only for console mode so you will have to make a couple changes:
      1. Change the default boot selection to persistent
      2. Set the resolution for the GUI
      cd /mnt/sda1/boot/grub
      vi menu.lst 

      # change the default line below to ‘default 4' and append ‘vga=0×317' (that’s a zero) to the kernel line to set the resolution to 1024×768 

      # By default, boot the first entry.
      default 4
      .
      .
      .
      title Start Persistent Live CD
      kernel /boot/vmlinuz BOOT=casper boot=casper persistent rw quiet vga=0×317
      initrd /boot/initrd.gz

      :wq
      Reboot and either select “Start Persistent Live CD” or just wait since we set it to auto-boot to persistent mode. To testit, create a file and reboot again. If your file is still there, everything is working.

      Install Nessus
      Download the Ubuntu Nessus and NessusClient packages from nessus.org.

      Again, with BackTrack 4 things are little easier. To install the Nessus server, simply execute the following command to install the package.
      dpkg --install Nessus-4.0.2-ubuntu810_i386.deb
      Things used to be a little bit more complicated for the client, but with the release of the pre-final version, it is just as easy as installing as the server.
      dpkg --install NessusClient-4.0.2-ubuntu810_i386.deb
      Finally it’s time to configure Nessus. Execute each of the following and follow the prompts.
      #create server certificate 
      /opt/nessus/sbin/nessus-mkcert
      This script will now ask you the relevant information to create the SSL
      certificate of Nessus. Note that this information will *NOT* be sent to
      anybody (everything stays local), but anyone with the ability to connect to your Nessus daemon will be able to retrieve this information.
      CA certificate life time in days [1460]:<enter>
      Server certificate life time in days [365]:<enter>
      Your country (two letter code) [FR]:US
      Your state or province name [none]:State
      Your location (e.g. town) [Paris]:City
      Your organization [Nessus Users United]:<enter>
      .
      .
      .
      Congratulations. Your server certificate was properly created.
      .
      . 

      # add user 
      /opt/nessus/sbin/nessus-adduser 
      Login :Admin
      Authentication (pass/cert) : [pass]<enter>
      Login password :
      Login password (again) :
      Do you want this user to be a Nessus ‘admin’ user ? (can upload plugins, etc…) (y/n) [n]:y
      User rules
      ———-
      nessusd has a rules system which allows you to restrict the hosts
      that Me has the right to test. For instance, you may want
      him to be able to scan his own host only.
      Please see the nessus-adduser manual for the rules syntax
      Enter the rules for this user, and enter a BLANK LINE once you are done :
      (the user can have an empty rules set)
      Login : Admin
      Password : ***********
      This user will have ‘admin’ privileges within the Nessus server
      Rules :
      Is that ok ? (y/n) [y]y
      User added
      We want to disable Nessus starting at boot. We are going to do some things a little later than require that Nessus not be running at boot. 

      /usr/sbin/update-rc.d -f nessusd remove
      This command does not remove the Nessus start scripts. It only removes the links that cause Nessus to start at boot time.

      The next thing to do is register the installation so you can get the plugin feed. You need to go here and request
      a key.

      Once you have your key. Execute the following to update your plugins. Please note that there are two dashes before register in the nessus-fetch line below. They can display as one sometimes.
      /opt/nessus/bin/nessus-fetch --register [your feed code here]
      When that is done, and it is going to take a few minutes, you are ready to start the server and client. Be aware that with version 4.0, while the command to start returns quickly, the actual starting of the service may take a minute or two. You may have to reboot before Nessus will work. You can use netstat -na to check that the
      server is listening on port 1241.
      /etc/init.d/nessusd start
      /opt/nessus/bin/NessusClient

      Time to find those vulnerabilities.

      Configure Encryption
      Since BackTrack will be used to poke at peoples networks and systems, with permission of course, it is very important that the information we find be protected. To do this, we are going to setup an encrypted volume that will eventually become our home directory.

      This can be done with the GUI or via command line. We will be using the gui because we need to be able to format the volume with ext3 and, as yet, I have not been able to figure out how to do that via the command line on linux.
      • Launch truecrypt from a terminal window.  
      • When truecrypt opens click the "Create Volume" button.  
      • In the Volume Location field enter the path to your volume, like /work_dir, click next.  
      • Leave the default Encryption Options & click next.  
      • Enter the volume size, say 1GB or so.  
      • Enter and confirm your desired password. 
      •  Select ext3 for the file system type, click next.  
      • Click next on the Cross-Platform Support page leaving the default values.  
      • Click format - you should move your mouse to create randomness for higher security.
      You will get a message that the volume was successful created. Click on the ‘OK’ button, then exit the Truecrypt gui, both the ‘Create Volume’ windows and the main windows, going back to your terminal (command line) window.

      To test the filesystem, execute the following, note the -k ” is two single quotes, not a double quote:
      truecrypt -t -k ” --protect-hidden=no /work_dir /media/truecrypt1
      mount
      cd /media/truecrypt1
      df .

      This will show that the volume is mounted and the amount of disk space you have left. The next step is to have this volume mounted when you log in. This can be done by editing the root user’s .profile file. Add the truecrypt command above to root’s .profile so it looks like this:
      # ~/.profile: executed by Bourne-compatible login shells.
      if [ "$BASH" ]; then
      if [ -f ~/.bashrc ]; then
      . ~/.bashrc
      fi
      fi
      truecrypt -t -k '' --protect-hidden=no /my_secret_stuff /media/truecrypt1
      mesg n

      The next time you reboot you will be asked for the password for the volume and it will be mounted for you.

      Now let's tweak a few tings
      The first thing we are going to do is configure networking to start at boot time. It’s convenient and easy to
      disable later if necessary. All you have to do is execute the following command.
      /usr/sbin/update-rc.d networking defaults
      Next, make sure all the BackTrack tools and the system itself is up-to-date. First execute the following:
      apt-get update
      This is update the software repository information. Next, execute:
      apt-get upgrade
      The system will determine if there is anything that needs to be updated and then prompt you to continue. Individual packages can be updated by including the package name after upgrade.

      Next reset the root user’s home directory during the login process to the mounted truecrypt volume. This will ensure that anything written to the home directory will be encrypted. Enter the following commands:
      cd /media/truecrypt1
      rsync -r –links /root/ .
       

      # add the bold lines below 
      vi /root/.profile 
      # ~/.profile: executed by Bourne-compatible login shells. 
      if [ "$BASH" ]; then
      if [ -f ~/.bashrc ]; then
      . ~/.bashrc
      fi
      fi
      truecrypt -t -k '' --protect-hidden=no /my_secret_stuff /media/truecrypt1 

      export HOME=/media/truecrypt1
      export HISTFILE=/media/truecrypt1/.bash_history
      cd
       

      mesg n 
      :wq
      The next time you reboot, when you are finally in the system, your home directory will be /media/truecrypt1.
      There is one last thing we should do - change nessus to log to the encrypted volume. This is very easy. The
      file that controls this is /opt/nessus/etc/nessus/nessusd.conf. We need to create a place for the log files to go. Execute the following:
      cd /media/truecrypt1
      mkdir -p nessus/logs
       

      Once you have done that, edit the /opt/nessus/etc/nessus/nessusd.conf file and change this:
      .
      .
      .
      # Log file :
      logfile = /opt/nessus/var/nessus/logs/nessusd.messages
      # Shall we log every details of the attack ? (disk intensive)
      log_whole_attack = no
      # Dump file for debugging output
      dumpfile = /opt/nessus/var/nessus/logs/nessusd.dump
      .
      .
      .

      to this:
      .
      .
      .
      # Log file :
      logfile = /media/truecrypt1/nessus/logs/nessusd.messages
      # Shall we log every details of the attack ? (disk intensive)
      log_whole_attack = no
      # Dump file for debugging output
      dumpfile = /media/truecrypt1/nessus/logs/nessusd.dump
      .
      .
      .

      That’s it. Now you have the Perfect Backtrack 4 USB Thumb Drive.

      More BackTrack:

      Saturday, December 12, 2009

      Bypass Windows or Linux Logon With Kon-Boot

      Kon-Boot is an prototype piece of software which allows to change contents of a linux kernel (and now Windows kernel also!!!) on the fly (while booting). In the current compilation state it allows to log into a linux system as 'root' user without typing the correct password or to elevate privileges from current user to root. For Windows systems it allows to enter any password protected profile without any knowledge of the password. It was acctually started as silly project of mine, which was born from my never-ending memory problems :) Secondly it was mainly created for Ubuntu, later i have made few add-ons to cover some other linux distributions. Finally, please consider this is my first linux project so far :) Entire Kon-Boot was written in pure x86 assembly, using old grandpa-geezer TASM 4.0.
      Additional notes:
      Tested Windows versions
      Windows Server 2008 Standard SP2 (v.275)
      Windows Vista Business SP0
      Windows Vista Ultimate SP1
      Windows Vista Ultimate SP0
      Windows Server 2003 Enterprise
      Windows XP
      Windows XP SP1
      Windows XP SP2
      Windows XP SP3
      Windows 7



      Wednesday, December 9, 2009

      Unzip rar files in Ubuntu with unrar

      Often it is necessary to extract files. zip and tar.gz files can be opened directly in Ubuntu (and other flavors of Linux), but rar is not supported by default. You should install and use unrar to extract rar files.
      % sudo apt-get install unrar
      Two useful and probably most used command are:
      % unrar e your-file-name.rar 
      Extracts the rar file in the current directory.
      % unrar l your-file-name.rar 
      Lists the content of the rar file.

      Sunday, December 6, 2009

      Adding Ubuntu to Windows Active Directory


      This is a step by step guide for joining a Ubuntu-based computer to a Windows Active Directory Domain. After a successful join the computer can then be accessed by AD users (as long as they have the required permissions). The Operating System used in this example is Ubuntu 9.04 but this guide should work for all Ubuntu/Debian based systems, even BackTrack 4.

      Configure nsswitch.conf
      First, configure the nsswitch.conf configuration file by adding/modifying the “hosts” line with the “files” and “dns” parameters. It is recommended that “files” should appear before “dns”.
      sudo nano /etc/nsswitch.conf
      Install Likewise Open
      Likewise Open is a free, open source application that joins Linux, Unix, and Mac machines to Microsoft Active Directory and securely authenticates users with their domain credentials.
      URL: http://www.likewise.com/products/likewise_open/index.php
      sudo apt-get install likewise-open
      Note that the following ports should be opened by the firewall
      Port Protocol Use
      53 UDP/TCP DNS
      88 UDP/TCP Kerberos
      123 UDP NTP
      137 UDP NetBIOS Name Service
      139 TCP NetBIOS Session (SMB)
      389 UDP/TCP LDAP
      445 TCP SMB over TCP
      464 UDP/TCP Machine password changes
      3268 TCP Global Catalog search
      Manually registering Domain DNS server (If it is not automatically assigned by DHCP)
      The server could be registered by modifying the /etc/resolv.conf file although this is NOT recommended since Ubuntu’s Network Manager plugin overwrites if you reboot your system. Therefore, we need to edit the /etc/dhclient.conf file and add/change the “prepend” line by adding the DNS server IP
      sudo nano /etc/dhcp3/dhclient.conf
      Then add your Domain DNS servers IPs seperated by comma (”,”)



      Resetting the network connection
      In order for Network Manager to refresh the new settings we need to reset the network connection. Finally ping a hostname registered with the Domains DNS server in order to make sure that is working
      sudo ifconfig eth0 down
      sudo ifconfig eth0 up
      ping powercram.com
      Registering with domain
      We can now join the domain by running the following command and authenticating as Administrator (as specified below).
      sudo domainjoin-cli join powercram.com Administrator
      Reboot and Login
      Finally, after restarting the system login using your Active Directory credentials.

      Wednesday, December 2, 2009

      How to: Change / Setup bash custom prompt (PS1)

      So how do you setup, change and pimp out Linux / UNIX shell prompt?

      Most of us work with a shell prompt. By default most Linux distro displays hostname and current working directory. You can easily customize your prompt to display information important to you. You change look and feel by adding colors. In this small howto I will explain howto setup:
      • Customize a bash shell to get a good looking prompt
      • Configure the appearance of the terminal
      • Apply themes using bashish
      • Howto pimp out your shell prompt
      Prompt is controled via a special shell variable. You need to set PS1, PS2, PS3 and PS4 variables. If set, the value is executed as a command prior to issuing each primary prompt.
      • PS1 - The value of this parameter is expanded (see PROMPTING below) and used as the primary prompt string. The default value is \s-\v\$ .
      • PS2 - The value of this parameter is expanded as with PS1 and used as the secondary prompt string. The default is >
      • PS3 - The value of this parameter is used as the prompt for the select command
      • PS4 - The value of this parameter is expanded as with PS1 and the value is printed before each command bash displays during an execution trace. The first character of PS4 is replicated multiple times, as necessary, to indicate multiple levels of indirection. The default is +

      How do I display current prompt setting?

      Simply use echo command, enter:
      $ echo $PS1
      Output:
      \\u@\h \\W]\\$

      How do I modify or change the prompt?

      Modifying the prompt is easy task. Just assign a new value to PS1 and hit enter key:
      My old prompt --> [admin@105r2 ~]$
      PS1="MyNewPrompt : "
      Output: My new prompt
      MyNewPrompt : 
      So when executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:
      • \a : an ASCII bell character (07)
      • \d : the date in "Weekday Month Date" format (e.g., "Tue May 26")
      • \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
      • \e : an ASCII escape character (033)
      • \h : the hostname up to the first '.'
      • \H : the hostname
      • \j : the number of jobs currently managed by the shell
      • \l : the basename of the shell’s terminal device name
      • \n : newline
      • \r : carriage return
      • \s : the name of the shell, the basename of $0 (the portion following the final slash)
      • \t : the current time in 24-hour HH:MM:SS format
      • \T : the current time in 12-hour HH:MM:SS format
      • \@ : the current time in 12-hour am/pm format
      • \A : the current time in 24-hour HH:MM format
      • \u : the username of the current user
      • \v : the version of bash (e.g., 2.00)
      • \V : the release of bash, version + patch level (e.g., 2.00.0)
      • \w : the current working directory, with $HOME abbreviated with a tilde
      • \W : the basename of the current working directory, with $HOME abbreviated with a tilde
      • \! : the history number of this command
      • \# : the command number of this command
      • \$ : if the effective UID is 0, a #, otherwise a $
      • \nnn : the character corresponding to the octal number nnn
      • \\ : a backslash
      • \[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
      • \] : end a sequence of non-printing characters
      Let us try to set the prompt so that it can display today’d date and hostname:
      PS1="\d \h $ "
      Output:
      Wed Dec 02 ServerName $ 
      Now setup prompt to display date/time, hostname and current directory:
      $ PS1="[\d \t \u@\h:\w ] $ "
      Output:
      [Wed Dec 02 18:54:07 admin@ServerName:~ ] $

      How do I add colors to my prompt?

      You can change the color of your shell prompt to impress your friend or to make your own life quite easy while working at command prompt.

      Putting it all together

      Let us say when you login as root/superuser, you want to get visual confirmation using red color prompt. To distinguish between superuser and normal user you use last character in the prompt, if it changes from $ to #, you have superuser privileges. So let us set your prompt color to RED when you login as root, otherwise display normal prompt.

      Open /etc/bashrc (Redhat and friends) / or /etc/bash.bashrc (Debian/Ubuntu) or /etc/bash.bashrc.local (Suse and others) file and append following code:
      # vi /etc/bashrc
      or
      $ sudo gedit /etc/bashrc
      Append the code as follows
      # If id command returns zero, you’ve root access.
      if [ $(id -u) -eq 0 ];
      then # you are root, set red colour prompt
        PS1="\\[$(tput setaf 1)\\]\\u@\\h:\\w #\\[$(tput sgr0)\\]"
      else # normal
        PS1="[\\u@\\h:\\w] $"
      fi

      Close and save the file.

      You can also create complex themes for your bash shell using bashish. Bashish is a theme enviroment for text terminals. It can change colors, font, transparency and background image on a per-application basis. Additionally Bashish supports prompt changing on common shells such as bash, zsh and tcsh. Install bashish using rpm or apt-get command:
      # rpm -ivh bashish*
      OR
      # dpkg -i bashish*
      Now start bashish for installing user configuration files:
      $ bashish
      Next you must restart your shell by typing the following command:
      $ exec bash
      To configure the Bashish theme engine, run
      $ bashishtheme
      basish in action (screenshots from official site):
      flower.png
      urbandawn - based on an artwork by grevenlx
      Finally, you can always use aterm or other terminal program such as rxvt. It supports nice visual effect , like transparency, tinting and much more by visiting profile menu. Select your terminal > click on Edit menu bar > Profiles > Select Profile > Click on Edit button > Select Effects tab > Select transparent background > Close.

      Shutdown Command for BackTrack 3 or 4

      Since BackTrack is built on Linux you can shutdown BackTrack from the shell using poweroff or restart it with reboot.

      BackTrack links

      Sunday, November 29, 2009

      BackTrack 4 PreRelease Hard Disk Install

      Since BackTrack 4 Pre-Release does not contain an installer you can follow these steps to install BT4 quickly and easily. The assumption is that you are installing BT4 on an empty disk (/dev/sda in this tutorial).

      Boot to BT4 DVD (download BackTrack 4 ISO - make sure to get the BT 4 Beta and not the BT4 Pre Release). Enter commands in bold.

      1. Start by creating 3 partitions on the disk, one each for boot, swap and root. Note, since your disk size is probably different than mine the number of cylinders will likely be different.
      root@bt:~# fdisk /dev/sda

      The number of cylinders for this disk is set to 19457.
      There is nothing wrong with that, but this is larger than 1024,
      and could in certain setups cause problems with:
      1) software that runs at boot time (e.g., old versions of LILO)
      2) booting and partitioning software from other OSs
      (e.g., DOS FDISK, OS/2 FDISK)

      Command (m for help): n
      Command action
      e extended
      p primary partition (1-4)
      p
      Partition number (1-4): 1
      First cylinder (1-19457, default 1): <enter>
      Using default value 1
      Last cylinder, +cylinders or +size{K,M,G} (1-19457, default 19457): +128M

      Command (m for help): n
      Command action
      e extended
      p primary partition (1-4)
      p
      Partition number (1-4): 2
      First cylinder (18-19457, default 18): <enter>
      Using default value 18
      Last cylinder, +cylinders or +size{K,M,G} (18-19457, default 19457): +1024M

      Command (m for help): n
      Command action
      e extended
      p primary partition (1-4)
      p
      Partition number (1-4): 3
      First cylinder (150-19457, default 150): <enter>
      Using default value 150
      Last cylinder, +cylinders or +size{K,M,G} (150-19457, default 19457): +16000M

      Command (m for help): t
      Partition number (1-4): 2
      Hex code (type L to list codes): 82
      Changed system type of partition 2 to 82 (Linux swap / Solaris)

      Command (m for help): a
      Partition number (1-4): 1

      Command (m for help): w
      The partition table has been altered!

      Calling ioctl() to re-read partition table.
      Syncing disks.
      root@bt:~#
      2. Format the file systems, mount them and copy over the directory structure. Chroot into new environment.
      root@bt:~# mke2fs /dev/sda1
      root@bt:~# mkswap /dev/sda2
      root@bt:~# swapon /dev/sda2
      root@bt:~# mkreiserfs /dev/sda3
      root@bt:~# mkdir /mnt/bt
      root@bt:~# mount /dev/sda3 /mnt/bt/
      root@bt:~# mkdir /mnt/bt/boot
      root@bt:~# mount /dev/sda1 /mnt/bt/boot
      root@bt:~# cp --preserve -R /{bin,dev,home,pentest,root,usr,boot,etc,lib,opt,sbin,var} /mnt/bt/
      root@bt:~# mkdir /mnt/bt/{mnt,tmp,proc,sys}
      root@bt:~# chmod 1777 /mnt/bt/tmp/
      root@bt:~# mount -t proc proc /mnt/bt/proc
      root@bt:~# mount -o bind /dev /mnt/bt/dev/
      root@bt:~# chroot /mnt/bt/ /bin/bash
      3. Configure /etc/lilo.conf to reflect your setup.
      lba32
      boot=/dev/sda
      root=/dev/sda3

      # bitmap=/boot/sarge.bmp
      # bmp-colors=1,,0,2,,0
      # bmp-table=120p,173p,1,15,17
      # bmp-timer=254p,432p,1,0,0
      # install=bmp

      # delay=20

      prompt
      timeout=50

      # map=/boot/map

      vga=0x317

      image=/boot/vmlinuz
      label="BT4"
      read-only
      initrd=/boot/splash.initrd
      append=quiet
      4. Fix first line in /etc/fstab, and remove unnecessary mount lines. Add the swap partition to the fstab so it gets loaded at boot time. Your fstab should look similar to this:
      /dev/sda3 / reiserfs defaults 0 0 # AutoUpdate
      /dev/sda2 none swap sw 0 0
      proc /proc proc defaults 0 0 # AutoUpdate
      sysfs /sys sysfs defaults 0 0 # AutoUpdate
      devpts /dev/pts devpts gid=5,mode=620 0 0 # AutoUpdate
      tmpfs /dev/shm tmpfs defaults 0 0 # AutoUpdate
      5. Execute lilo and reboot!
      root@bt:/# lilo -v
      LILO version 22.8, Copyright (C) 1992-1998 Werner Almesberger
      Development beyond version 21 Copyright (C) 1999-2006 John Coffman
      Released 19-Feb-2007, and compiled at 14:08:06 on May 15 2008
      Ubuntu

      Reading boot sector from /dev/sda
      Using MENU secondary loader
      Calling map_insert_data

      Boot image: /boot/vmlinuz
      Mapping RAM disk /boot/splash.initrd
      Added BT4 *

      Writing boot sector.
      Backup copy of boot sector in /boot/boot.0800
      root@bt:/# exit
      exit
      root@bt:~# reboot
      BackTrack links