python and resolving ips from a csv file.

Problem: I have a CSV file where I have source and destination IPs. I want to resolve only destination IPs.

Format of my CSV file: (let`s call it test.csv) (it`s tab separated…)

99.88.77.66 11.22.33.44 118340.86 187

The solution is pretty simple with python:

#!/usr/bin/env python
import csv
import socket

reader = csv.reader(open(“./test.csv”, “rb”), delimiter=” “)
for row in reader:
host, aliases, ips = socket.gethostbyaddr(row[1])
print row[0] + ” ” + host + ” ” + row[2] + ” ” + row[3]

First we import the necessary libs. (socket and csv)

Then we open the file to read with as a csv object. (Careful because our delimiter is not comma, but TAB)

for each row we get the second row (row[1]), convert it to host, alias and ip by gethostbyaddr method.

The last line is to create the new tab separated format. (Just pipe it to a file and you have your new CSV file. [tab separated... but oh well..])

Done!

RIP Arthur C Clarke

Rest in Peace Sir Arthur C. Clarke.

Today Sir Arthur C Clarke passed away at the age of 90 at Sri Lanka…

24 inch iMac

I pulled the trigger on this 24 inch iMac. So far so good. I was expecting harsh battles with Leopard… But it looks like things are going very good so far. After some 8 hours of usage, I`m still happy with OS X.

I have some projects in the future. But first i need to get used to “über user friendly” interface…

 

Happy pi day!

Happy pi day everyone. And happy birthday Einstein!

Simple merging two files with paste command

Today I learned something new!

I had two files one with a list of domain names, the other with corresponding IPs. I needed to merge these two files to display domain names next to their corresponding IPs.

It looks like it`s the simplest task with the command paste

All I had to do is: paste /tmp/domain_names /tmp/IPs

Thanks Igor for the tip ; ) 

Security vs Privacy.

Here is a great explanation of Security vs Privacy. (I had to copy this image to my blog since I didn`t want it to disappear in the future)

Security and Privacy...

ssh delays on trixbox

I had some ssh problems on my trixbox installations. Each time I try to connect to the trixbox using ssh I had some delay. The classical solution for this is to disable the reverse DNS lookups by changing the line in /etc/ssh/sshd_config to:

UseDNS no

But in this case, this didn`t solve my problem. I ran my connection wth verbosity.

ssh -vvv some.host.com

I had a delay in this step:

debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure.  Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure.  Minor code may provide more information

AFAIK, this is related to openssh kerberos authentication. This is something that I really really don`t need. So I disabled in /etc/ssh/sshd_config the lines:

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
#GSSAPICleanupCredentials yes

After the restart, there was no delay. ; ) Even with the “UseDNS yes”. 

This is my birthday Pearls Before Swine.

Stop drawing me as Andy th dog! : D This was on my birthday damn it! : D

Pastis draw me again!

It`s me: Andy the dog… :

Me... Andy the dog... 

Please give one laptop.

One Laptop Per Child (OLPC) is a project that I`ve been eyeballing for some time now. The concept is very powerful. Provide a laptop to help the developing countries` children. Give them a tool to discover.

First I was skeptical about this. I would say, first lets feed them and then give them a laptop. But then my thoughts changed a bit. When you think about the greatest programmers, computer geniuses of this century, all of them had something in common. They had a computer.

Now let`s think about how many children in this world have access to computer, and how many don`t. To give us an idea, in the least developed countries the number of people who has internet access is 11 per 1000 person. roughly 1%. (WB/UN data) Out of that many who never had a computer, maybe one will use this computer and after X years, (s)he`ll develop an algorithm to make extensive data mining for health projects run twice faster. Maybe another one will develop an idea that will help his/her society… This laptop could be their first step. Technology is an enabler, even if we this is a shot in dark, we need to start somewhere.

This what you can do in the next 7 days. The laptop costs ~$200. You can buy one for your child and pay roughly $400.00 and a second laptop heads to a child in a developing country. It`s called Give one Get one. Give one Get one campaign ends on November 26th. For US citizens and tax payers this campaign is tax deductible.

You can get more information about this laptop built for learning and designed specifically  the children in mind by visiting their FAQ section, Vision and Mission sections. 

You the security enthusiast, if you want to know how you can secure a ten year old kid`s computer without using usernames, passwords, classic file permission structures, etc… please take a look at their Bitfrost Architecture. Very very good reading ; )