Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Compiling/Installing Ettercap from Source Ubuntu 9.10

Ok, so my mission has thus been to compile all the tools I use from source. This is to guarantee that I have the most recent version, and for the experience. Now you can use the repositories to install most of these tools, but often times the versions are outdated. It wasn't until recently here that nmap was upgraded from 4.76 to 5.00. But this is just my personal task for all the tools I end up needing to use. So to start, download ettercap from ettercap.sourceforge.net. Download the latest tarball, in my case 0.7.3.

CD to the download location and issue the following command:
tar xzf ettercap-NG-0.7.3.tar.gz
cd ettercap-NG-0.7.3
Now we have to install some dependencies...and this I will use apt-get for. Kind of a work around, but one that I'm fine with at the moment.
sudo apt-get install libpcap0.8-dev libpcap-dev libnet1 libnet1-dev
Make sure you have libssl and the development libraries installed as well (libssl0.9.8 and libssl-dev).
Now you will want to make one change to a source file to avoid make errors.
nano src/ec_log.c
Change the following line from
fd->fd = open(filename, 0_CREAT | 0_TRUNC | 0_RDWR | 0_BINARY);
to
fd->fd = open(filename, 0_CREAT | 0_TRUNC | 0_RDWR | 0_BINARY, 0666);
Now issue the following commands, hopefully without error:
./configure
make
sudo make install
If all goes well, ettercap should be installed and you can access the GUI by issuing:
sudo ettercap -G
Hope this works for everyone, leave comments if you run into problems.Technorati Tags:

Manually Share and Mount a Samba Share in Ubuntu Server 9.04

For those of you who do not have/use a GUI, this is how to manually share and map a samba share:

On the server:

apt-get install samba
Nano the smb.conf in /etc/samba/smb.conf to include
[Share Name]
path = /home/share
available = yes
browseable = yes
public = yes
writable = yes
Modify that to meet your needs then restart the samba service:
/etc/init.d/samba restart

On the client:
apt-get install smbfs
mkdir /mnt/share
mount -t smbfs //serverIP/share /mnt/share
If the share is not public, then you might need to use the switch -o username=user.


Setting Up and Configuring Ubuntu Server 9.04 VMWARE with SSH, VSFTPD (TSL/SSL), OpenVPN, Fail2ban (PART 3)

Ok, now its time for OpenVPN. There is a really good write-up on how to install OpenVPN by niels on http://nielsvz.com. Follow his guide to install it on 9.04 and then you can play with some options below.

To authenticate via PAM, add this line in your server.conf file:
plugin /usr/lib/openvpn/openvpn-auth-pam.so system-auth

To route all traffic through your VPN connection (HTTP, DNS...), uncomment this line in your server.conf file:
push "redirect-gateway def1 bypass-dhcp"

Corresponding with this switch, you will need to enable NAT redirection. This will allow your VPN connected clients to see and access network resources on the subnet your server is on. Enable it with the following:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

To configure OpenVPN to only allow certain users to log in, follow the instructions here.

Here is a copy of my client config to reference:
persist-key
tls-client
remote techaccesstips.servehome.net 1194
proto udp
ca ca.crt
dev tun
persist-tun
cert client1.crt
comp-lzo
nobind
key client.key
pull
auth-user-pass

Here are a list of clients for Windows and Mac:
Tunnelblick - Free OpenVPN client for Mac
Viscosity - Shareware client for Mac
OpenVPN GUI - Free client for Windows

So ends the guide...If you have any questions, comments, or revisions/suggestions please leave a comment and I will get back with you.




Arrow Keys Not Working in Ubuntu VMWare / Backtrack

Found this post from projektd at http://bias9.blogspot.com/2008/10/keys-not-working-in-vmware.html.

Either modify or create the file in your Home directory:

cd ~/.vmware
nano config


Add this line to your config file:

xkeymap.nokeycodeMap = true


Then restart VMware with:

sudo /etc/init.d/vmware restart

Should work after that.

Setting Up and Configuring Ubuntu Server 9.04 VMWARE with SSH, VSFTPD (TSL/SSL), OpenVPN, Fail2ban (PART 2)

Continuing from Part 1...

With installing and configuring VSFTPD...here is what we want to accomplish:

   1. Setup a FTP server that only allows secure (TSL/SSL) connections so passwords and data aren't sent in the clear.
   2. Have virtual users who are linked to a local user account with no shell privledges.
   3. Be able to access it from outside of our private network.

Lets start by creating a user with no shell privledges:
nano /etc/shells
(Add the following entry at the bottom: /usr/sbin/nologin)
mkdir /home/luigi
groupadd ftpaccess
useradd -d /home/luigi -G ftpaccess -s /usr/sbin/nologin luigi
chown luigi /home/luigi
chgrp ftpaccess /home/luigi
Then we will install VSFTPD:
apt-get install vsftpd libdb4.7 db4.7-util
cd /etc
mkdir vsftpd
mv vsftpd.conf vsftpd.bak
nano vsftpd.conf
(Make your vsftpd.conf look like the following) *UPDATE: the config file cannot have spaces between the entries and the values (i.e. 'listen = yes' is bad, it should be 'listen=yes').
listen=YES
listen_port=21
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=NO
xferlog_file=/var/log/vsftpd.log
ftpd_banner=ITSA ME...MARIO
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=ftp
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=YES
ssl_sslv3=YES
pasv_min_port=13000
pasv_max_port=12300
hide_ids=YES
guest_enable=YES
guest_username=luigi
user_config_dir=/etc/vsftpd

nano users.txt (with alternating lines of username and passwords; exclude the markings when making the file)
bill #username
verysecure #password
sue
filetransfer
bob
protocol
db4.7_load -T -t hash -f users.txt /etc/vsftpd_users.db
nano /etc/pam.d/ftpservice
auth required /lib/sercurity/pam_userdb.so db=/etc/vsftpd_users
account required /lib/security/pam_userdb.so db=/etc/vsftpd_users
Now we must specify a user config file for each virtual user.
nano /etc/vsftp_userconfig

Now add the following:
write_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
anon_upload_enable=YES
local_root=/home/luigi
chroot_local_user=YES
dirlist_enable=YES
download_enable=YES
guest_username=luigi

Save and exit. Now lets make a link to this file for each user:
ln -s /etc/vsftp_userconfig /etc/vsftpd/bill
ln -s /etc/vsftp_userconfig /etc/vsftpd/sue
ln -s /etc/vsftp_userconfig /etc/vsftpd/bob

Now open up your router and set it to forward the port range specified in pasv_min_port and pasv_max_port...in this case port forward 12300-12400. Then use IPTABLES to set an outbound exception with the following commands:
iptables -A OUTPUT -p tcp --dport 12300:12400 -j ACCEPT
iptables -L (to verify the exception was added)
Then finally restart the vsftpd service:
/etc/init.d/vsftpd restart

Now for fail2ban...the configs are pretty self-explanitory, but read up on it if you have questions:
apt-get install fail2ban
cd /etc/fail2ban
mv jail.conf jail.bak
nano jail.conf
[DEFAULT]
ignoreip = 127.0.0.1
bantime  = 600
maxretry = 3
backend = polling
destemail = root@localhost
action = iptables[name=%(__name__)s, port=%(port)s]

[ssh]

enabled = true
port    = 12345
filter  = sshd
logpath  = /var/log/auth.log
maxretry = 3

[vsftp]

enabled = tue
port = 21
filter = vsftpd
logpath = /var/log/vsftpd.log
maxretry = 3
/etc/init.d/fail2ban restart
Try to SSH into your machine from another virtual or another computer and enter the wrong credentials...check /var/log/fail2ban.log to see if it worked. You can also look at the IPTABLES again.

Please give me feedback on if this worked for you or any problems you encounter by dropping a comment.

Part 3 with OpenVPN coming soon...

Setting Up and Configuring Ubuntu Server 9.04 VMWare with SSH, VSFTPD (TSL/SSL), OpenVPN, Fail2ban (PART 1)

Finally, after much tinkering and reading many guides...

My goal was to make a server with these components installed so I could practice breaking into it. Like any logical "practice" server, I made it a VM. Here's a guide on how to set up one of your own...

Things assumed and required:
  1. You have VMWare Server Installed
  2. You have Ubuntu Server 9.04 installed in a VM with no services preinstalled (i.e. LAMP)
  3. You have mounted the VMWare tools installer
  4. I am using the username mario for my default username and have set the server IP to 192.168.3.100
  5. You have a free domain name setup and registered with DynDNS.org.
Let's get started:

The first thing to do is to login, via VMWare console, and change some fundamental settings. What we are going to do is change the root password, update the server with any patches available, and install some needed dependencies:
sudo su
passwd root
apt-get update
apt-get upgrade
uname -r
apt-get install g++ gcc gawk make unzip zip linux-headers-'uname -r' build-essential

Now to install VMWare tools...its not necessary, but might be helpful in some instances:
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cp /mnt/cdrom/VMWare*.tar.gz /home/mario
tar xzf VMWare*.tar.gz
cd vmware*
vmware-install.pl
(Use all the defaults and when finished)
reboot
Once the system has rebooted, log back in and set a static IP on the interface eth0 and remove apparmor:
su
nano /etc/network/interfaces
(Modify your config to look like this)
inet eth0 iface static
      address 192.68.3.100
      netmask 255.255.255.0
      network 192.168.3.0
      broadcast 192.168.3.255
      gateway 192.168.3.1
/etc/init.d/networking restart
echo techaccesstips.servehome.net > /etc/hostname

/etc/init.d/hostname.sh start
nano /etc/hosts (Make the top portion look like the following)
127.0.0.1            localhost.localdomain                  localhost
192.168.3.100     techaccesstips.servehome.net     servername
/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
apt-get purge apparmor apparmor-utils
Now install the SSH server and configure it:
apt-get install ssh openssh-server
nano /etc/ssh/sshd_config
(Change "PermitRootLogin" to "no" and change the port number if you wish)
/etc/init.d/ssh restart
Ok, now SSH into your server to test it out with the following command:
ssh -l mario -p 12345 192.168.3.100
(Leave the -p switch out if you didn't change the port number)

Continue with Part 2...





Install BT3 with Compiz and Conky to Hard Drive

Ok...yes...there are a lot of guides out there for this...but this is what worked for me.

This guide assumes your HDD is clean (no partitions) and is /dev/hda...use fdisk -l if you're not sure.

Partition your hard drive with the following format:
hda1=/boot (ext2)
hda2=swap
hda3=/ (ext2)

I used one of the partitioners found on Hirens BootCD to partition my drives...but you can use whatever you want just as long as it's in that format.

Next make a USB BT3 drive and boot from it selecting BT3 with compiz.

Now follow these steps:

mkdir /mnt/backtrack
mount /dev/hda3 /mnt/backtrack/
mkdir /mnt/backtrack/boot/
mount /dev/hda1 /mnt/backtrack/boot/
cp --preserve -R /{bin,dev,home,pentest,root,usr,etc,lib,opt,sbin,var} /mnt/backtrack/
mkdir /mnt/backtrack/{mnt,proc,sys,tmp}
mount --bind /dev/ /mnt/backtrack/dev/
mount -t proc proc /mnt/backtrack/proc/
cp /boot/vmlinuz /mnt/backtrack/boot/
chroot /mnt/backtrack /bin/bash
nano /etc/lilo.conf (make changes to the boot section to /dev/hda root section to point to /dev/hda3)
lilo
exit
reboot


Now remove your USB drive and hope you boot.
If successful, you should boot and compiz should be working...
Now for conky...
Download the latest release from the website then:
tar xzf conky*
cd conky*
./configure --with-rss
make
make install
I'm using a configuration found here.
Download it and extract it. I took the weather section out of mine and added an rss feed...to do that just:
nano conkyrc
Then delete the weather section at the bottom and add:
${color white}RSS ${hr 1}${color}
${rss http://www.feedurl.com/feed.xml 0 item_titles 10}
Save as whatever you want...I saved mine as conky.conf
Now to get conky to have a transparent background and still have compiz running...you need to follow these steps:
Download giblib and feh.
tar xzf giblib*
cd giblib*
./configure
make
make install
cd ..
tar xzf feh*
cd feh*
./configure
make
make install
/sbin/ldconfig -v | greb gib
feh --bg-scale 'dcop kdesktop KBackgroundIface currentWallpaper 1'
Now run conky with your conf location with
conky -c /root/conky.conf
Now conky's looking good with compiz. Let me know if this doesn't work for you or theres an easier way to do things...

References:
Based the BT3 install on one found on Remote-Exploit Forums (http://forums.remote-exploit.org/showthread.php?t=14751)
Conky Transparency (http://briancarper.net/blog/transparent-conky-in-kde-part-2)
ldconfig Fix (http://www.netadmintools.com/art410.html)


Cracking Cached Passwords with Cachedump and John the Ripper (JTR)

So if you are looking to audit password strength in a Windows Domain environment, there are two tools that will be of help to you. FGDump is a compilation of PWDump and Cachedump. It also has a some useful switches, but documentation for those can be found here. PWdump will pull hashes for local accounts such as Administrator. Cachedump however will pull the cached hashes from network users who have logged into the machine.

Here is how to grab the hashes.

Download FGDump from here and place the executable on a flashdrive (if you have a U3 device, I will soon be posting how to run fgdump without any user interaction).
Plug the flashdrive into the target computer and open up a command prompt.
Navigate to your flashdrive and execute fgdump.exe.
Wait for it to finish and once it is successful, open up the 127.0.0.1.cachedump file in notepad to see the hashes.
Copy the hashes to a file and save in this format: filename.txt.
Next download John:

wget http://openwall.com/john/f/john-1.7.2.tar.gz
tar xzf john-1.7.2.tar.gz


Now we are going to have to patch it to let it recognize the cachedump format:

wget http://openwall.com/john/contrib/john-1.7.2-mscash-alainesp-4.1.diff.gz
cd john-1.7.2
zcat ../john-1.7.2-mscash-alainesp-4.1.diff.gz | patch -p1 -Z


If you do not have the zcat command, then patch it with gzip:

gzip -dc ../john-VERSION-WHAT-REVISION.diff.gz | patch -p1
cd src
make
make clean SYSTEM
(which ever system type you have as displayed with make)

Once successful:

cd run
./john --test


Now lets crack the cached file

./john -format:mscash hashes.txt


or

./john -w:passwordlist.txt -format:mscash hashes.txt

Give me some feedback if this helped you.

Convert OGV to AVI (gtk-recordMyDesktop)

For a while I have been looking for a good way to make some video tutorials in Linux and be able to upload them in good quality to a video hosting site. I finally found a good piece of software that would let me choose where I wanted to record, gtk-recordMyDesktop. This can be obtained by typing sudo apt-get install gtk-recordmydesktop or through the Add/Remove Programs feature. The output of the recorded file is in a .ogv format. I want to convert it to a .avi format so I can upload it. Here is the command to do so:

mencoder -idx input.ogv -ovc lavc -oac mp3lame -o output


There is another way to do this through ffmpeg with this command:

ffmpeg -i input.ogv output.avi

Either one works, but to keep things easy, I made a script to assist with the conversion:

#!/bin/bash
echo "Convert from .OGV to .AVI"
NAME=$(whoami)
read -p "Is the file on your Desktop? (y/n):" DESKTOP
if [ "$DESKTOP" = "y" ]; then
{
    read -p "Please specify the name of the .OGV file: /home/$NAME/Desktop/" OGV
    read -p "Please specify the desired output filename: /home/$NAME/Desktop/" AVI
    mencoder -idx /home/$NAME/Desktop/$OGV -ovc lavc -oac mp3lame -o /home/$NAME/Desktop/$AVI
    echo "Conversion completed."
}
else
{
    read -p "Please specify the location of the .OGV file: " OGV
    read -p "Please specify the desired output filename: " AVI2
    mencoder -idx $OGV -ovc lavc -oac mp3lame -o $AVI2
    echo "Conversion completed."
}
fi
read -p "Would you like to play the converted movie? (y/n):" PLAY

if [ "$PLAY" = "y" ]; then
{   
    if [ "$DESKTOP" = "y" ]; then
            totem /home/$NAME/Desktop/$AVI
            echo "Process Completed Successfully!"
            clear
            exit
    else
            totem $AVI2
            clear
            echo "Process Completed Successfully!"
            exit       
    fi
}
else
    clear
    echo "Process Completed Successfully!"
    sleep 2
fi
exit

Just make sure to issue chmod 755 ogvtoavi before running it.

So now you can expect some videos in the upcoming days...

Installing BT3 on SD Card for Asus EEE PC

After recently buying a EEE PC online, the first thing I wanted to do was load backtrack on it. I didn't want to load it on the hard drive as the Ubuntu netbook remix looked pretty cool and I thought I would have that as a backup. I went out and bought a 4Gb SDHC card and loaded BT3 on it with changes. It acts as a USB device, but its not as pesky as a USB dongle. I read around and found you can't natively boot to backtrack. So I had to modify my bootable flash drive to include a module special to the EEE PC. This will fix the resolution and allow you to start the x server. Here's what I did to get it working.

1. Inserted the SD card and made a bootable USB BT drive (follow my tutorial if you don't have one already). However, i added the 901_net_gfx (my EEE is the 901) module to the /BT3/optional folder, and it can be downloaded here. Once that was added, you much modify the syslinux.cfg (/boot/syslinux/syslinux.cfg) file to include this under the APPEND section: load=901_net_gfx. That's it, now boot your USB drive and select the option you added the 901_net_gfx tag to.
2. Once booted, issue a fdisk -l and find your SD card.
3. You can either use fdisk to format it or use gparted. For gparted, open up a terminal and type in gparted. Modify your SD card to have one 1024Mb partition formated in FAT32 and the rest of the card to be formatted in ext2.
4. Commit the changes and then copy the boot and BT3 folders from your flash drives FAT32 partition to your SD card's partition: cp -R /mnt/sda1/{boot,BT3} /mnt/sdb1/ (this can be done through the gui using Konqueror)
5. Now make the changes directory in the ext2 partition: mkdir /mnt/sdb2/changes
6. Once that is complete, reboot the machine and remove your USB drive. Then press ESC during the poweron to get a boot menu and select your SD card.

Hope this helps. Let me know if you run in to any problems.

Make Bootable BT3 USB Drive With Changes and Storage Folder

Ok, so lately I have really been wanting to keep my portable drive that I take from computer to computer and also have a bootable BT3 drive with changes. Here are the steps I took to make it happen.

You are going to need:
1. A USB drive of at least 2Gb
2. A copy of the USB BT3 iso, found here.
3. A machine (virtual or real) running Windows.
4. A BT Live CD or BT VM.

Ok here we go...
1. Boot into windows and have your flash drive recognized.
2. I used Acronis Disk Director to partition the drive and made a minimum of 1.5Gb FAT32 partition labeled "BT3", however you can label it whatever you want. If you do not have Acronis Disk Director, then see the steps below...if you do, then move to step 3.
**EDIT** If you do not have a copy of Acronis Disk Director...then boot from the Live CD and use fdisk to partition. Use the following commands:
fdisk -l (find your USB drive)
fdisk /dev/sda
d (delete the partitions until the drive is blank)
1
n (create a new paritition)
p
1
(enter)
+1.3G (the size you want for your install)
n
p
2
(enter)
(enter) (the size you want for your changes...this assumes the rest of the drive)
w
mkfs.vfat -F 32 /dev/sda1
mkfs.ext2 /dev/sda2
umount /dev/sda1
umount /dev/sda2

Now move to step 4
3. Then I partitioned the rest of the drive in ext2 format and labeled it changes.
4. Restart the computer for the changes to be applied (you may not have to do this depending on your partitioner) and boot back into Windows.
5. Extract all files found in the bt3final_usb.iso with WinRAR.
6. Take the extracted files and copy them to your USB drive (the only partition recognized in Windows)
7. Open up a command prompt and enter the following commands:
e: (or the drive letter of your USB drive)
cd boot
bootinst.bat
8. Once it completes, hit enter and restart into your BT Live CD or simply switch to your BT vm.
9. Navigate to your flash drive: cd /mnt/sda1 (replacing sda1 with your flash drive).
10. Enter the following commands:
mkdir X (you can name this what you want, this is for your personal data)
cd /boot/syslinux
chmod +Xx lilo
chmod +Xx syslinux
nano syslinux.cfg
And find the label pchanges and by APPEND, change the changes=/changes/changes.dat to changes=/dev/sda2
mkdir /mnt/sdb2/changes
11. Now restart and boot to your flash drive and select the Persistent Changes option.

Let me know if you found a different way or if this doesn't work for you. I'm hoping to get a video up of this soon.

Eee Tutorials coming soon!

Installing VMWare Server 2 in Ubuntu

Ok, so here is a quick reference to installing VMWare Server 2 in Ubuntu. I used 8.04 at the time, but upgraded to 8.10 and the same methods still apply. If you already have VMWare Server installed, follow the instructions at the end first, then proceed with the install.
  1. Download the VMWare Server TAR file to the desktop. Make sure you copy the serial from the website as well.
  2. Once the download has finished, open up konsole, and enter the following commands.
  • uname -r (Copy the output of this command and paste it where it says *paste* in the next line)
  • sudo apt-get install linux-headers-*paste* build-essential xinetd
  • cd Desktop
  • tar xvzf VMware-server-*.tar.gz
  • cd vmware-server-distrib
  • sudo vmware-install.pl
Keep all the defaults, pressing enter at the prompts. It will continue to install then ask you if you would like to run vmware-config.pl. Press Enter, then once again, leave all the defaults.

*NOTE: It did ask me if I wanted to use a C Compiler, I selected yes (default) and then it found that GCC was a newer version than that which my kernel was compiled with. Here it asks if I want to continue and it is defaulted to 'no'. Just type in 'yes' and be on your way. It might ask this a few times.

Keep chugging along, but pay attention to what you are pressing enter to at this point. You may want to change some directories or options. Once it comes to the part where you enter your serial, make sure you enter the letters in CAPS.

That's pretty much it. Navigate to https://localhost:8333 and log in with the specified user. You may need to add a security exception in Firefox.

*UPDATE* When I upgraded from 8.04 to 8.10, I could not access the web gui. I restarted the vmware service via "/etc/init.d/vmware restart" and it told me I needed to run vmware-config.pl again. I ran vmware-config.pl and went through all prompts and it's back up and running just fine.

TO UNINSTALL and REINSTALL, this is what I did:
Either run sudo vmware-uninstall.pl
or
Log in as root...
  • su
  • rm -R /etc/vmware
  • rm -R /usr/lib/vmware
  • exit
Then continue with the install.

Hope this helps. Let me know if you find something different. A more detailed guide can be found here.

Installing VMWare tools in Backtrack 3 (BT3) *UPDATED*

Finally! I just finished an install of VMware tools on my BT3 VM. This includes seamless mouse and keyboard integration without having to manually capture and release input. I am still unable to drag and drop files from my OS and VM (I still plan on finding a solution). But here is what I did to get it working. If you encounter any errors, just post the errors as a comment and I’ll look into it.

1. Download the BT3 VM from remote-exploit and unzip.
2. Power on the VM and verify everything is working correctly. If it asks you if you moved it or copied it, select "copied it".
3. Open up terminal and make a directory under /mnt called cdrom

  • mkdir /mnt/cdrom
4. Now go to the tool bar VM > Install VMware Tools.
5. Click Install and a window should appear saying that media has been detected. Select Open in New Window. If it doesn't auto open, then you will have to issue these commands:
  • mount /dev/cdrom /mnt/cdrom
  • cp /mnt/cdrom/VM* /root/Desktop/
  • Skip to step 7.
6. Drag and drop the VMwareTools-1.0.6-91891.i386.tar.gz file to your desktop or desired folder.
7. CD into the proper folder (in my case its Desktop).
8. Then untar the file.
  • tar xvzf VMwareTools-1.0.6-91891.i386.tar.gz
9. CD into the newly created vmware-tools-distrib folder.
10. Execute vmware-install.pl
11. Leave all the defaults, pressing enter at every prompt.
12. When completed, configure vmtools by executing vmware-config-tools.pl. Leave all the defaults. Then add the following start up script to the ~/.kde/Autostart directory (it will be hidden).
  • echo "/usr/bin/vmware-toolbox --minimize"> ~/.kde/Autostart/vmware-toolbox.sh
13. Press enter then make it executable
  • chmod +x ~/.kde/Autostart/vmware-toolbox.sh
14. Now restart your VM and the next time you boot you should be able to drag your mouse seamlessly within the BT VM and your native OS.

*NOTE: This process will not allow you to drag and drop files between the two OS's. I am currently working on a solution for that.

An accompanying video showing the steps is coming soon!

If you run into any errors, just post them as a comment and I will investigate the problem. Hope this helps.

Technorati Tags: , , , ,

Find System Specs in Terminal

I was presented with the job of "specing" out our ESX servers and documenting my findings. I figured the easiest way to do that would be to SSH into the box and get the specs that way. I stumbled up a site that gave a lot of useful commands. Here are the commands I used:

Graphics Card
lspci | grep VGA - dislpays graphic card model

Ethernet
lspci | grep Ethernet - displays the ethernet card model / controllers
ifconfig [interface] - displays IP address, MAC, and various other information

Kernel and System Info

cat /etc/issue - current distrobution and kernel version
uname -a - kernel information

Processor
cat /proc/cpuinfo - displays processors, speed, flags, and various other information
top (then press C) - realtime processes information by CPU usage

Memory
cat /proc/meminfo - displays RAM, swap, and amount being used
free -m - displays RAM and swap information in an easier to read format
top (then press M) - displays realtime processes by RAM usage

Hard Drive
df -h - displays total space, mount points, free space, percentages, and various other information
fdisk -l - displays all attached drives and their ID's along with block information

Various
uptime - displays the system uptime
w - displays current logged in users and activity

Linux Alternatives to Popular Windows Applications / Package Finders

Recently I have been trying to edit a video in Linux and haven't quite found a good editor comparable to some editors I use in Windows. I found a few sites that were very useful to me and may be helpful to you.

The Linux Alternative Project
http://www.linuxalt.com/
Compares Windows software with Linux equivalents.

Linux App Finder
http://linuxappfinder.com
Search a large database of Linux Applications.

Open Source as Alternative
http://www.osalt.com/
Open source software alternatives to well-known commercial software.

OpenSuse Software Search
http://packages.opensuse-community.org/
Search for openSuse software that can be downloaded and installed with a click of a button.

Ubuntu Package Finder
http://packages.ubuntu.com
Search for Ubuntu packages based on distribution.

Take Ownership of Locked Files in Ubuntu

I recently installed a program through dpkg and then removed it with the dpkg -r command. However, I encountered some issues with folder permissions. The program I installed also created a security group which my username was not a part of. To take ownership of the files and remove them, I issued these commands:
  • Navigate to the directory above the locked directories.
  • chown -hR username /foldername
This changed the ownership of the folder and subfolders to my username, thus allowing me to remove the files.
*Note: If you are not logged in as root, then you will use the sudo prefix.

SSH into Linux Web Server and find what version of Apache it is running...

So I was sitting at my desk and was approached with a favor. They needed to know what type of web service was running on a specific server. All that was given to me was the name of the server. Ok, so first we need the IP of the server:
Ping servernames
That should give an output similar to this
  • PING servername (10.100.1.15) 56(84) bytes of data.

Now secure shell into the server by typing
ssh -l username ipaddress
Enter your password then once you have successfully connected, type uname -a to see the system details. This includes Kernel version, time stamp, computer name/hostname, and some other goodies.
Now to find the type of web service running, type:
httpd -v
This will give you the version of Apache that is running.

To find out what flavor of Linux the server is running, search /etc for a file that should have the distro-release. If that is all too tedious, then type rpm -qa. This will display all the packages installed, and you should see either some redhat, fedora, debian, or whatever version. That is usually a good indicator of which flavor is installed.

New commands that I have used frequently the past month...

On my never ending Linux/Unix/Windows knowledge quest, I have learned a few basic commands that have just been really helpful and that I have used very often in the past month while troubleshooting random problems.

Linux
smbmount - mount smb shares
Been in a few tight squeezes with some data I needed off a machine, but my only available storage option is a NAS.
  • smbmount //ip/share /mnt/mountpoint -o username=domain\\user,password=pass
For me this would look like:
  • smbmount //192.168.1.10/Backup /mnt/nas -o username=user,password=password
df - shows disk info (usage, mount point, free space)
The
-a switch displays all filesystems, the -T switch displays the FS type, and the -h switch displys the results in "human readable" formats (such as MB and GB)
  • df -a -h -T
du - shows size of files and folders
The -c switch gives a total of the size of all files in the directory, the -h switch lists size in a human readable format, and the -s switch outputs only the size of the directory, not the files within (it is pointless to use the -c switch with the -s switch unless you really enjoy doing so. Also without the -s switch, the output will be of every file and folder in a directory, which could be very verbose)
  • du -c -h /mnt/Backup
  • du -h -s /mnt/Backup
Unix/Mac
Here is how to make a release renew script to make quicken things up a bit:
In a terminal window, type:
  • nano /usr/bin/rr
Which will open a blank page called rr. Now add:
  • #!/bin/bash
  • echo "Now releasing your IP"
  • sudo ipconfig set int BOOTP
  • sleep 5
  • echo "Renewing your IP"
  • sudo ipconfig set int DHCP
  • echo "Done!"
Where int is the specified interface. CTRL+O to write the file then CTRL-X to exit.
Now to make the file executable enter:
  • sudo chmod 775 /usr/bin/rr
That is it...now just enter rr to release and renew your ip.

Windows
I have also been using Windows to mount network shares through command prompt.
  • net use
  • net use a-z: \\ip\share /USER:domain\user
  • net use /DELETE a-z:
  • net use /DELETE *
The first command will display all mapped network shares.
The second command will map a share and use the logon credentials of domain\user, and might prompt you for your password (a-z is the drive letter for the share to be mapped to, you must use a drive letter not currently used).
The third command will delete a specified mapped drive (again, you must specify a drive letter for a-z).
The fourth command will delete all mapped drives.


These are all simple commands, but very useful for me day to day.


Installing BT3 in VMware *UPDATED*

There are a couple of ways to run BT3 in VMware, but when it comes to down to speed and function ability, you should really just install it. *NOTE: Now you can just download a preconfigured VM with an early version of VMWare tools installed. Just download it and when first booting up the VM, select the option "I copied it". Here is a link for the download. The installation process is rather easy. Just make a new virtual machine, select all your settings, and then just format your virtual HDD to ext2 and install.

Here are the steps:
  • Create a new virtual machine.
    • File > New > Virtual Machine
    • Click Next > Typical > Linux (select "Other Linux 2.6 x kernel")
    • Name it what you want and select the storage location of the VM
    • Choose "Use bridged networking" if you want the VM to look like an actual device on your LAN
    • Then select the size of your virtual HDD, and uncheck "allocate disk space now"
    • Click finish
  • Add a USB device to your VM
    • This is real simple to do, and very useful to have done. Select your VM and select "Edit this virtual machine".
    • Under the Hardware tab select "Add".
    • Then select USB controller.
  • Boot into the VM with the BT3 CD in the cd drive.
  • Select Boot into KDE (default selection)
  • Then once BT has booted, open Konsole
  • Prepare the disk for formatting
    • Type fdisk -l
    • See your HD, it should be /dev/sda
    • Assuming it is /dev/sda, enter fdisk /dev/sda
    • Enter n to create a new partition
    • Then p to make it the primary partition
    • Then 1 to assign it as the first partition
    • Then press enter to accept the default first cylinder
    • Then enter again to accept the default last cylinder
    • Finally enter w to write the changes
  • Now format the disk in ext2 format
    • mke2fs /dev/sda1
  • Once the disk is properly formatted, make a mount directory for the hard drive.
    • mkdir /mnt/sda1
    • mount /dev/sda1 /mnt/sda1
    • mount
  • Now you should see that device sda1 is mounted at /mnt/sda1 and is formatted in ext2
  • Install Backtrack
    • K > Backtrack > Backtrack Installer
    • Keep all defaults except change "Installation method" to "Real" and uncheck "Restore Original MBR After LILO".
    • Click install
  • After the installation is finished, reboot the VM without the CD inserted.
After the installation of Backtrack, it might be a good idea to install VMware tools. I am currently writing and figuring out the steps to do so. It will hopefully be up in a few days.


Changing IP configurations and enabling SSH in ESX

A few simple commands to help troubleshoot ESX connections.
NOTE: The commands listed must be executed as root. This guide assumes you are logged in as root and are locally connected to the ESX console.
To change the IP for vswif0 change directory to /usr/sbin/

  • cd /usr/sbin

Then delete the old vswif0 interface:

  • esxcfg-vswif -d vswif0

Now create a new vswif0 interface with the correct IP settings:

  • esxcfg-vswif -a vswif0 -p Service\ Console -i x.x.x.x -n x.x.x.x -b x.x.x.x
  • -a (Adds an interface)
  • -p (Sets the portgroup name of the int)
  • -i (IP of the vswif int, ex. 192.168.1.100)
  • -n (Netmask, ex. 255.255.255.0)
  • -b (Broadcast, ex. 192.168.1.255)

Now to verify the changes have been made type:

  • esxcfg-vswif -l

That will list all vswif interfaces and show the configurations.
To change your default gateway (extends beyond just the vswif interface):

  • nano /etc/sysconfig/network

Here you can change the hostname of the server and the default gateway. To change the gateway, just type in the IP of your gateway where it reads GATEWAY=:

  • GATEWAY=x.x.x.x

Now CTRL-O to write the file then press enter. Then to exit press CTRL-X.
Now that the IP configurations are correct, make sure you can ping the server.

To SSH into your ESX server, you only need to modify one config file. SSH is enabled by default, telnet is not (for security reasons).

  • nano /etc/ssh/sshd_config

Find the line that reads PermitRootLogin and change the no to yes.
Now restart the service and try remoting in.

  • service sshd restart

I use Putty to SSH into ESX, which can be downloaded here.