Archive for July, 2010

Writing Traceroute in Python

Ksplice.com has put together a tutorial on how to write the traceroute/tracert application in Python in just 8 easy steps.  This is a good introduction on how the traceroute application works and socket programming in Python.

Here is the finished product but please read thier post to see all of the steps.

#!/usr/bin/python
 
    import socket
 
    def main(dest_name):
        dest_addr = socket.gethostbyname(dest_name)
        port = 33434
        max_hops = 30
        icmp = socket.getprotobyname('icmp')
        udp = socket.getprotobyname('udp')
        ttl = 1
        while True:
            recv_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)
            send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, udp)
            send_socket.setsockopt(socket.SOL_IP, socket.IP_TTL, ttl)
            recv_socket.bind(("", port))
            send_socket.sendto("", (dest_name, port))
            curr_addr = None
            curr_name = None
            try:
                _, curr_addr = recv_socket.recvfrom(512)
                curr_addr = curr_addr[0]
                try:
                    curr_name = socket.gethostbyaddr(curr_addr)[0]
                except socket.error:
                    curr_name = curr_addr
            except socket.error:
                pass
            finally:
                send_socket.close()
                recv_socket.close()
 
            if curr_addr is not None:
                curr_host = "%s (%s)" % (curr_name, curr_addr)
            else:
                curr_host = "*"
            print "%d\t%s" % (ttl, curr_host)
 
            ttl += 1
            if curr_addr == dest_addr or ttl > max_hops:
                break
 
    if __name__ == "__main__":
        main('google.com')

How To: Speed Up OpenOffice in Linux and Windows

Have you made the switch from Microsoft Office to Openoffice but are really annoyed with how long it takes to open even the smallest of documents?  Well here is a quick hack that you can do to decrease the time that it takes for OpenOffice to launch.

Step 1:
Launch any Open Office application.  In this example I will be using Writer

Step 2:
Click On Tools.
Then click Options

Step 3:
Under OpenOffice.org; click on Java
Then Uncheck Use Java runtime environment
And then Click OK


Evolution is Finally Useful

I have been using Evolution on and off for many years because of its ability to connect to Microsoft Exchange severs.  But I typically will use it for a few weeks only to get pissed off because of random crashes or lockups and go back to using Outlook in a Virtual Machine.  Even though Ubuntu 10.04 was released with Gnome 2.30 it held back the Evolution release to 2.28.  Stupid move IMHO but lucky I have told you all how to update to the latest release.

Well have been using the 2.30 release for several days on my work laptop connected to Exchange 2007 and as the title of this post says, It Finally Useful!  I have not had any lock ups or slow downs.  I did have an issue with it downloading all of my message headers from my inbox but I have over 5500 emails in there so I don’t blame Evolution.  I have since decided to have it download the full emails so that I can use it offline and that seems to have helped.  Also after a rocky start with the Exchange MAPI connector in Evolution 2.28, in 2.30 it works like a charm.  I can send and recieve email, add events to my calendar and query email address in Active Direcory with no issue.

Kudos Evolution Developers!

Update: (2007-7-26)
Looks like I spoke a little too soon.  It seems that Evolution will not send emails periodically.  I haven’t been able to pin point what the cause is but as soon as I do I will be filing a but report.

pfSense Firewall

Over the past few months my company has been testing out a different firewall products to protect us from all you h4x0rs out there. Our old Watchguard Firebox is no longer supported so we needed to look elsewhere.  We started by looking at a couple of commercial products and despite having a $5000 budget for a new firewall we decided to give pfSense a try.   pfSense is a open-source customized FreeBSD installation that is designed from the ground up to be a solid, secure firewall.

Last night I found myself at work late so I decided that after two months of testing it was time to move the pfSense installation onto a production server.  I re-purposed an older 1U Pentium 4 4GB of RAM server that was a decomissioned FreeNAS box. Now I releze that this is overkill but it was the only rack mountable server that I had available.

The server has two internal gigabit NICs and 2 dual port NICs for a total of six network interfaces and we are using all but one.  Currently we have LAN, WAN, VPN, Training Network, and finally the Guest Wireless  all hanging off this box.  We are running the Captive portal on the Guest Wireless and currently I am testing the OpenVPN that is built into pfSense to replace our old MS PPTP VPN.

pfSense has a package repository that is contains community created packages.  We have installed the Arping, Cron, and Snort.  After running the Snort package for a few weeks on the test server (but in production) I determined that China is a pain in the ass due to constant hacking attacks to our FTP server so I found the package Country Block which allow for you to drop packets coming from specific countries.  Lucky we are not an international company so I was able to block China, Korea, Russia, and a few others.  (Sorry if you are from those countries but a few bad apples ruin it for everyone.)

All and all this is an excellent firewall product that I would recommend for any SMB.  They have an excellent community to help you if you have any issues and if your company is worried about relying on strangers they also have commercial support.  I have barely descriped a tenth of the features that this awesome product contains so head over to their website for more indepth information. www.pfSense.com

Ha Ha Google