Friday, July 11, 2008

Ettercap

Ettercap is a penetration tester, it has many functions that are fun to play around with. To install it via ports browse over to the dir and install it.

# cd /usr/ports/net-mgmt/ettercap
# make install clean

I built it with the default settings



An example how to run a dns_spoof can be found here

Tuesday, June 24, 2008

Cisco 7940 on Asterisk FreeBSD

After a week of trial an error and reading oh so many guides I have finally managed to get these phones to work. First thing is first to enable the built in tftp server that comes along with FreeBSD.
#nano /etc/inetd.conf
scroll down to where it says tftp and uncomment those two lines by deleting the # at the begining of them. Now save the file. Incase your computer dosn't load inetd on startup do the following.
#nano /etc/rc.conf
and add the following line
inetd_enable="YES"
and save the file, and reboot your computer. Next create the default tftp directory
#mkdir /tftpboot
Next move to the new dir
#cd /tftpboot
I really recommend using this cisco sip firmware, you can get it by using wget
#wget http://www.xs4all.nl/~graver1/cisco/SIP-7960/P0S3-08-8-00.zip
Once its done downloading you need to unzip it.
#unzip P0S3-08-8-00.zip
The zip file contains 5 files
OS79XX.TXT
P003-08-8-00.bin
P003-08-8-00.sbn
P0S3-08-8-00.loads
P0S3-08-8-00.sb2
Next you have to create a SIPDefault.cnf file
#nano SIPDefault.cnf
This is what mine contains.
# Image Versionimage_version: "P0S3-08-8-00"
# Proxy Serverproxy1_address: "TrixboxIpaddress"proxy2_address: ""proxy3_address: ""proxy4_address: ""proxy5_address: ""proxy6_address: ""
# Proxy Server Port (default - 5060)proxy1_port:"5060"proxy2_port:""proxy3_port:""proxy4_port:""proxy5_port:""proxy6_port:""
# Emergency Proxy infoproxy_emergency: "TrixboxIP"proxy_emergency_port: "5060"
# Backup Proxy infoproxy_backup: ""proxy_backup_port: "5060"
# Outbound Proxy infooutbound_proxy: "TrixboxIpaddress"outbound_proxy_port: "5060"
# NAT/Firewall Traversalnat_enable: ""nat_address: ""voip_control_port: "5061"start_media_port: "16384"end_media_port: "32766"nat_received_processing: "0"
# Proxy Registration (0-disable (default), 1-enable)proxy_register: "1"
# Phone Registration Expiration [1-3932100 sec] (Default - 3600)timer_register_expires: "3600"
# Codec for media stream (g711ulaw (default), g711alaw, g729)preferred_codec: "none"
# TOS bits in media stream [0-5] (Default - 5)tos_media: "5"
# Enable VAD (0-disable (default), 1-enable)enable_vad: "1"
# Allow for the bridge on a 3way call to join remaining parties upon hangupcnf_join_enable: "1" ; 0-Disabled, 1-Enabled (default)
# Allow Transfer to be completed while target phone is still ringingsemi_attended_transfer: "0" ; 0-Disabled, 1-Enabled (default)
# Telnet Level (enable or disable the ability to telnet into this phonetelnet_level: "2" ; 0-Disabled (default), 1-Enabled, 2-Privileged
# Inband DTMF Settings (0-disable, 1-enable (default))dtmf_inband: "1"
# Out of band DTMF Settings (none-disable, avt-avt enable (default), avt_always - always avt )dtmf_outofband: "1"
# DTMF dB Level Settings (1-6dB down, 2-3db down, 3-nominal (default), 4-3db up, 5-6dB up)dtmf_db_level: "3"
# SIP Timerstimer_t1: "500" ; Default 500 msectimer_t2: "4000" ; Default 4 secsip_retx: "10" ; Default 11sip_invite_retx: "6" ; Default 7timer_invite_expires: "180" ; Default 180 sec
# Setting for Message speeddial to UOne boxmessages_uri: "*97"
#********* Release 2 new config parameters **********
# TFTP Phone Specific Configuration File Directorytftp_cfg_dir: "./"
# Time Serversntp_mode: "unicast"sntp_server: "time.nist.gov"time_zone: "EST"dst_offset: "1"dst_start_month: "April"dst_start_day: ""dst_start_day_of_week: "Sun"dst_start_week_of_month: "1"dst_start_time: "02"dst_stop_month: "Oct"dst_stop_day: ""dst_stop_day_of_week: "Sunday"dst_stop_week_of_month: "8"dst_stop_time: "2"dst_auto_adjust: "1"
# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control)dnd_control: "1" ; Default 0 (Do Not Disturb feature is off)
# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control)callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous)
# Anonymous Call Blocking (0-disbaled, 1-enabled, 2-disabled no user control, 3-enabled no user control)anonymous_call_block: "0" ; Default 0 (Disable blocking of anonymous calls)
# Call Waiting (0-disabled, 1-enabled, 2-disabled with no user control, 3-enabled with no user control)call_waiting: "1" ; Default 1 (Call Waiting enabled)
# DTMF AVT Payload (Dynamic payload range for AVT tones - 96-127)dtmf_avt_payload: "101" ; Default 100
# XML file that specifies the dialplan desireddial_template: "dialplan"
# Network Media Type (auto, full100, full10, half100, half10)network_media_type: "auto"
#Autocompletion During Dial (0-off, 1-on [default])autocomplete: "1"
#Time Format (0-12hr, 1-24hr [default])time_format_24hr: "0"
# URL for external Phone Servicesservices_url: "http://TrixboxIpaddress/cisco/services/index_cisco.php"
# URL for external Directory locationdirectory_url: "http://TrixboxIpaddress/cisco/services/PhoneDirectory.php"
# URL for branding logologo_url: http://TrixboxIpaddress/cisco/bmp/trixbox.bmp


You are also going to need another file called SIPMAC.cnf all letters in the mac address have to be CAPITAL. Here is mine
#nano SIP000C85F059F8.cnf
# Cisco SIP Configuration
phone_label: "Your Name Here"line1_name: "435"line1_shortname: "435"line1_displayname: "435"line1_password: "Pass Removed"line2_name: "335"line2_shortname: "335"line2_displayname: "335"line2_password: "Pass Removed"line3_name: "UNPROVISIONED"line3_shortname: "UNPROVISIONED"line3_displayname: "UNPROVISIONED"line3_password: "UNPROVISIONED"line4_name: "UNPROVISIONED"line4_shortname: "UNPROVISIONED"line4_displayname: "UNPROVISIONED"line4_password: "UNPROVISIONED"line5_name: "UNPROVISIONED"line5_shortname: "UNPROVISIONED"line5_displayname: "UNPROVISIONED"line5_password: "UNPROVISIONED"line6_name: "UNPROVISIONED"line6_shortname: "UNPROVISIONED"line6_displayname: "UNPROVISIONED"line6_password: "UNPROVISIONED"line1_authname: "435"line2_authname: "335"line3_authname: "UNPROVISIONED"line4_authname: "UNPROVISIONED"line5_authname: "UNPROVISIONED"line6_authname: "UNPROVISIONED"


Now it is time to boot the phone I would really recommend reseting it to factory defaults to do this when it powers on the headset light comes on hold down # then when the speaker light goes off put in this key combination 123456789*0# the phone will ask you if you want to reset it press 2 to continue. The phone will boot up three times at most. I had an old version of the firmware for you can see what is going on it will boot mine said
Cisco System Inc 2000-2005
Then its said
Verifying load
Upgrading app
Reboot
Cisco System Inc 2000-2007
Verifying load
Upgrading app
Reboot
Cisco System Inc 2000-2006
Sip
Now your configuration will be loaded.

Tuesday, June 17, 2008

Asterisk

Asterisk is an open source PBX software, it works wonders If you want to use at home or at a small business. I'm trying to convince my place of employment to switch over to Asterisk since they are looking for a new phone setup. I will be using Cisco 7940 phones using the sip protocol. To install Asterisk you need to have source tree installed. The install is straight foward. You change to the asterisk port directory.
#cd /usr/ports/net/asterisk12
#make install clean
I used all the default compile settings.
I launched asterisk to make sure everything was working just fine. I used this following command which will also log you into the asterisk terminal.
#asterisk -vvvvvvvvvvvvvvc
That is 14 v's
Once asterisk was running I installed asterisk-gui.
#cd /usr/ports/www/asterisk-gui
#make install clean
In the compile settings I checked sip and load default config files everything else is default.
No after is done compiling there are some tweaks you have to make to enable it on the conf files.
#cd /usr/local/etc/asterisk
First we are going to edit the manager.conf file
#nano manager.conf
It should read as follows
'displayssystemname = yes
enabled = yes
webenabled = yes
port = 5038
httptimeout = 60
bindaddr = 0.0.0.0'
Save
Next we edit the http.conf file
#nano http.conf
The top portion should be as follows
'enabled=yes
enablestatic=yes
bindaddr=0.0.0.0
bindport=8088'
Save an exit
I have the following at the end of manager.conf for a user names cmclaine it is completley optional but it makes my life easier so I would assume it would do the same for you.
'[cmclaine]
secret=password
permit=10.10.10.197/255.255.255.0
read = system,call,log,verbose,command,agent,config
write = system,call,log,verbose,command,agent,config'
The permit line allows another IP address to connect to the asterisk-gui because by default on localhost can connect to asterisk-gui. You are done configuring asterisk-gui.
I've noticed if you do a reload in asterisk it wont always reload everything so go ahead and reboot your box then you can run asterisk.
#asterisk -vvvvvvvvvvvvvc

Mouse

Several of you emailed me about your mouse not working in X windows there is relatively an easy fix for this. I'm going to assume you are logged in as root on ttyv since your mouse isn't working in X org.
Run the command to detect your mouse, X config has come a long way
#X -configure
Now you should get some output telling you to try it.
#X -config /root/xorg.conf.new
About 90% of the time it will of worked now you just make it the default config file for Xorg.
#cp /root/xorg.conf.new /etc/X11/xorg.conf
Now your mouse will work when you startup Xorg.

Monday, May 12, 2008

Gimp

Gimp is a great open source replacement for photoshop. It has allot of features but not as many as photoshop. You can fix red eye do layer transparency, it is a great product for being free and it is very light weight also. Another simple program to install you browse to the port folder.
#cd /usr/ports/graphics/gimp
#make install clean
You can't tell me you, you aren't liking how simple FreeBSD is.

Libraries

Well I've read about people having this problem in forums. They can't get stuff like firefox mplayer gio-fam-backend to compile through ports. This is pretty easy to fix, it's because FreeBSD 7.0 installs an old version of glib. It's relatively simple to correct just browse over to the glib20 folder
#cd /usr/ports/devel/glib20
#make deinstall
Now the old version is uninstalled and now all you have to do is install the new version.
#make install clean
Now you can compile till your little heart is content, now wasn't that easy?

Installing FreeBSD

Realistically this should have been my first post, but I started with a preconfigured box. The first time I installed FreeBSD a couple years ago it took me two days to learn how to configure everything the way I wanted. Since the FreeBSD has becoming allot easier to me anyways. My roommate tried installing FBSD and failed miserably and I had it up and running in 10min. For this example I will be using FreeBSD 7.0 release version. When you boot of the disc it will ask you what country you are in. If you don't know the answer to this then you probably shouldn't be installing FreeBSD. Once you choose you country you will be prompted with the main menu.

I start off by choosing standard, once you choose it you will be prompted by an fdisk message. Press enter to continue. Now at the fdisk partition editor (I'm going to assume you have a blank drive.) Press A to use Entire disk for the editor looks something like this.Press Q to exit the fdisk manager. For the Boot manager I select "Install the FreeBSD Boot Manager" and press ok. Now you will need to create BSD partitions inside of the fdisk partition. Press OK. Press A to auto partition it and it will look something like thisPress Q to exit the partioner and move on to Distributions.
I choose X-User to make life simple it the easiest time now to install Xorg. So once you choose what you want scroll up and hit exit. You will now be prompted for Instillation media, I always use FTP I find it quicker. Once you choose your instillation media click yes on the User Confirmation Request to start the install.When its done installing you will be prompted with a Congratulations Box, click OK.
Now you will get a couple boxes asking questions, I say no to all of them except SSH login, time zone and linux binary.
“Do you want this machine to function as a network gateway?”
“Do you want to configure inetd and the network services that it provides?”
“Would you like to enable ssh login?”
“Do you want to have anonymous FTP access to this machine?”
“Do you want to configure this machine as an NFS server?”
“Do you want to configure this machine as an NFS client?”
“Would you like to customize your system console settings?”
“Would u like to set this machines time zone now?”
“Would you like enable linux binary compatability?”
“Does this system, have a PS/2, serial, or bus mouse?”
Now you will be prompted if you want to install any ports select yes.
Feel free to install any ports you want, I only install KDE for I have a good gui to go on. So you would scroll down to kde and press enter. I just install bare kde-3 I scroll down and select kde-3.5.8 and it will automatically check all the dependencies that are required as well. So you just check OK and you will go back to the previous menu and select Install.When FreeBSD is done installing it will ask you if you want to seyup a user account select yes and name it what you want. Be sure to put the user account in the wheel group this is what will allow your user account to perform su requests which are veryhelpful especially if you are installing somehting through ssh, by default root account can not log on to an ssh session.

After your user account is settup press OK and you will be prompted to make a root password, after that is done you will get a prompt asking if you want to Visit the general configuration menu for a chance to set any last options. I click no then Exit and reboot. Now you have a FreeBSD box that runs KDE and ssh. Good luck!






Thursday, May 8, 2008

Mounting

Well It seems I've over looked the simple things I don't think twice about such as mounting usb device and hard drives. A good thing about FreeBSD 7 is it has built in support for FAT and NTFS right out of the box you don't need to compile your own kernel. Lets start with something simple an USB flash drive. If you use them for school or work they are probably going to be formated with FAT file system. So when you plug it into your computer and do a dmesg you will get some out put like this.
da0 at umass-sim0 bus 0 target 0 lun 0da0: Removable Direct Access SCSI-0 deviceda0: 40.000MB/s transfersda0: 3935MB (8058880 512 byte sectors: 255H 63S/T 501C)
You can mount it anywhere you wan't I choose to do it neatley and make a usb directory in mnt folder
#mkdir /mnt/usb
Now to mount it
#mount -t msdos /dev/da0s1 /mnt/usb
Now the device is mounted in /mnt/use and you can browse to that folder and see the contents.

It's pretty similar for ntfs drive. Here is the output for my ntfs drive.
da1 at umass-sim1 bus 1 target 0 lun 0da1: Fixed Direct Access SCSI-4 deviceda1: 40.000MB/s transfersda1: 476940MB (976773168 512 byte sectors: 255H 63S/T 60801C)
Make the directory where you want to mount it.
#mkdir /mnt/500
Now we mount it
#mount -t ntfs /dev/da1s1 /mnt/500
Relativley simple

Mounting an IDE or SATA is a little harder but still easy. Ok so lets say you installed a hard drive Im going to use NTFS for example here. dmesg is going to show it but good luck finding it on the list, since it's detected at boot. So the easier way is to view the dev directory.
#cd /dev
#ls
(Im going to trunkate the output to sata drives)
ad14
ad14s1
ad14s1a
ad14s1b
ad14s1c
ad14s1d
ad14s1e
ad14s1f
ad15
ad15s1
From this list we see the ad14 drive had 7 partitions, we can assume this is a unix partition (unless you are partition happy on all your drives) A diffrent partition is made for /, /sys, /home etc...
ad15 has one partition so its safe to assume this is the NTFS drive (unless you make funky partitions which in that case I would assume you would know which drive is yours lol)
Once again make the dir where you want to mount it.
#mkdir /mnt/drive
And mount it
#mount -t ntfs /dev/ad15s1 /mnt/drive
Now you are free to browse you drives.
If you want to know how to mount cd and iso please look at the source tree post they are both covered in there.

Wednesday, May 7, 2008

Apache

I will be showing you how to setup an apache web server. It is alot easier to setup an Apache server on a Fedora box then it is on FreeBSD. They both work fine once they are setup but I have to say I noticed FreeBSD is faster when using the same bandwidth. Apache on FreeBSD is very picky about the FQDN (fully qualified domain name) Which can be a pain in the ass. So first we change to the apache port directory
#cd /usr/ports/www/apache22
#make install clean
I enable MYSQL support encase later on I ever want to throw on a forum it will make life a lot easier.
When it's done compiling you can try to start to see the FQDN error
#httpd
httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.2.107 for ServerName
[Wed May 07 09:34:15 2008] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
To get apache to work we have to edit the httpd.conf file
#nano /usr/local/etc/apache22/httpd.conf
Then you 'Where Is' Servername you change the example host.domain.com:80 to your domain or If you don't own a host name you will put in the computer IP address not the internet IP address to make it read like
ServerName 192.168.2.107:80
80 represents what port you want it to listen on http is normally 80 but you can make it whatever you want as long as it dosn't conflict with another program. For all of you who aren't programers take out the # at the begining of the line. # tells the script to skip over that line. So now you save the config file and run it.
#httpd
If you browse to your IP address you should get a webpage that says
"It works!"
Now you have an Apache server. The home directory for your html files is /usr/local/www/apache22/data Now you can start building your website, Goodluck!

Monday, May 5, 2008

VNC

Today Ill be showing you how to install VNC, its pretty simple VNC allows you to connect to your computer through a Java applet which is pretty handy, you don't need any third party client software. i use tightvnc so to install tightvnc we do the following.
#cd /usr/ports/net/tightvnc
#make install clean
When its done compiling you start tightvnc
#vncserver
You'll get out put like this
You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
So enter the password and if you would like a view only password.

Friday, May 2, 2008

Kernel Source Tree

In the process of Installing ports you might come across an error missing kernel source tree. I'm going to show you how to install the source tree via CD and ISO.
To install source via cd you are going to be in the / directory
1st mounts the cd-rom
#mount /cdrom
Next make this sys directory which some programs look for
#mkdir -p /usr/src/sys
link it with the actual sys directory some programs will look in /sys and other in /usr/src/sys
#ln -s /usr/src/sys /sys
Next copy ssys files from cd-rom
#cat /cdrom/src/ssys.[a-d]* | tar -xzvf -
Copy sbase files from cd
#cat /cdrom/src/sbase.[a-d]* | tar -xzvf -
Now you have all your kernel source on your hard drive.
If your like me and don't have a cdrom you can do it from and iso image as well
Make sure you are in the / directory
make the location where you are going to mount the iso
#mkdir /iso
mount the iso mine is in /root direcotry
#mdconfig -a -t vnode -f /root/7.0-RELEASE-i386-disc1.iso -u 0
#mount -t cd9660 /dev/md0 /iso
Next make this sys directory which some programs look for
#mkdir -p /usr/src/sys
link it with the actual sys directory some programs will look in /sys and other in /usr/src/sys
#ln -s /usr/src/sys /sys
Next copy ssys files from iso
#cat /iso/src/ssys.[a-d]* | tar -xzvf -
Copy sbase files from iso
#cat /iso/src/sbase.[a-d]* | tar -xzvf -
Now you have all your kernel source on your hard drive.

Audio

One of the main problems I hear about from New FreeBSD users is the lack of audio. This isn't linux it's unix so of course it can't be ease lol :) but there is a relativley easy way to get audio to work.
We will let the kernel try to detect.
#kldload snd_driver
You will see the device pop up as the kernel goes through all supported audio, Next you have to find out what audio driver you will need.
#cat /dev/sndstat
You will get output like this
FreeBSD Audio Driver (newpcm: 64bit 2007061600/amd64)
Installed devices:
pcm0: at memory 0xb0000000 irq 22 kld snd_hda {20071129_0050} (1p:1v/1r:1v channels duples default)
So now we unload all the sound drivers
#kldunload snd_driver
We just load the one we need now
#kldload snd_hda
Now we have sound but I'm pretty sure you'll want the sound loaded at startup so we will have to edit the loader.conf (I use nano by default vi is installed)
#nano /boot/loader.conf
now we have to add two lines
sound_load="YES"
snd_hda_load="YES"
Save and exit and when you start your computer you will have audio

CVSUP

When I install FreeBSD I only install my bare minimums such as X-User and KDE. I install my system off of FTP which is quicker in my mind. Downloading only what you need compared to downloading 3 cd's, which can suck if you have a slow connection. Once my system is up I do several things to get it where I like it. The 1st is CVSUP which is a great application to build your port list.
To install cvsup we will do it from a package
#pkg_add -r cvsup
Next we will build our supfile from the example, the supfile tells our system where on the internet to get the ports and which ones to get, and to download them
#csup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

Ports are great you can install pretty much and application you want using ports, all you do to install one if browse to the port folder.
#cd /usr/ports/security/example
Then you install the port
#make install clean

Favorite Apps

Theres some applications I can't live with out and I'll show you how to install them.
1st Firefox for web browser
#pkg_add -r firefox
2nd mplayer which supports mpeg, divx, mp3 and all the good formats
#pkg_add -r mplayer
3rd I get bored so I need good old nmap.
#cd /usr/ports/security/nmap
#make install clean

I do the 1st two from packages because they are constantly updated with new builds and I do nmap from ports because Its not updated as often. If you install firefox through ports you can enable smb support which is a good feature, but I use konquer for smb.