Archive Page 3
Quick nslookup bash script
I recently had to determine if a large set of URLs resolved to the same set of IP addresses. Knowing a little about a few different scripting languages/technologies let me know that this was definitely possible, so I just had to figure out which one I wanted to use for the most efficient results. I decided to just go with Bash shell scripting (since I’ve recently gotten a little used to it).
Say I have a file called urls.txt (newline delimited). This file started with more than just the hostname (e.g., www.example.com/foo/bar.aspx). I had to pare those down so I opened the list in vim and did a little replacement. I could have done the same thing with sed but I’m most familiar with doing this in vim. In vim, open the file and type:
:%s#/.*##g
Ok, ready for some nslookup action in a Cygwin Bash loop. Note that this does not output what I’d like to do, which is the format of “url,ip” and output to a .csv file. It’s also important to note that the loop will take the input line-by-line, so the output file will have all the results in the right order. I could do this in perl very quickly and get the results I’m looking for, but it takes that much more time to write the script. Anyway, here it is:
$ for i in `cat urls.txt`; do nslookup $i 198.6.1.4 2>/dev/null | grep Address | tail -n 1 | cut -d " " -f 3; done > ips.txt
The “$” is the prompt, so don’t write that. For all values (i.e. lines) in urls.txt, do an nslookup of the url and specify the uu.net DNS server to avoid any problems with local resolution (I was having trouble, so had to go outside my corporate DNS server). Redirect all nslookup STDERR messages to /dev/null (there’s a header). Only show me the lines with “Address” and only give me the last of those lines (head & tail working together). Then strip the “Address: ” from the remaining line to give me the IP address by itself. And when you’re done with all that work, redirect to ips.txt instead of STDOUT.
Now I open an Excel or Calc spreadsheet and drop the values from urls.txt right next to ips.txt and I’m cooking with gas.
I recently had a moment of clarity with regards to my historical stance on downloading software that I have not paid for. It wasn’t the sort of clarity that helps me to pass on my point of view to others, but the sort that is more or less self-defining.
A new jailbroken iPhone application has been released into the wild that allows users to install cracked versions of pay apps as if they paid for it. It’s no different than using a cracked version of Photoshop or Premier or any other pirated software, but it’s new because it’s on th iPhone! The new app is called Installous (available at www.hackulo.us) and it is a great idea.
I saw my friend using a very expensive application ($70) that he hadn’t paid for and I though, “I want to do that too!” I downloaded the app and installed a couple games that are normally pay-only. I was messing around a little more today and it dawned on me again, after many years … I don’t want to pirate software.
This was particularly poignant because I was recently speaking with someone about the importance of revisiting semi-religious decisions like this with some regularity. I don’t know that I can take a stand against the moral implications of piracy, because I’m honestly not against the concept of learning how to use an application from the cracked (i.e. pirated) versions. But I can say that I have followed-through with my conscience regarding my desires to “have” and to “be able to resist”. I have learned to do without these toys this long, and I can do without them longer if I don’t want to pay for them.
What are your thoughts on piracy? Do you feel you’re just saving money? Do you care?
(Written from my iPhone)
Window 7 experiences
I’ve been using Window 7 pre-release on my home desktop for a couple weeks now and it’s probably a decent time to jot down some thoughts.
I really dig most elements of the user interface: the organization of the screen, as well as the addition of Mac-ish features like preview from the taskbar, make it pretty easy to find directories (aka folders) when you aren’t necessarily good at navigating that sort of thing. I believe there are a few more elements from Vista-land that Vista users have shown me, but I forget to check it when I get home.
I’m am not sure I like the way Win7 handles the congregation of the My Documents folders. I haven’t looked too far into this, but the requirement that I add folders to My Documents instead of just switch where that folder is located is sort of annoying.
The thing that I truly dislike is how hard it is to act like an administrator. When I’m an admin, I don’t ever want to have to use the “Run as administrator” option. I even disable UAC and still am hamstrung when installing or trying to delete certain files. It’s very frustrating when I’m so used to the XP experience, so I’m going to definitely check out what I’m doing wrong there.
Overall I report positive things. I think the average Windows user will like the changes. Being a true power-user, there are a few things I would like to see or use differently.
The trouble with tribbles…
My computer died… all of a sudden… for no apparent reason.
My main home desktop is was Windows XP SP3.
Hey everyone, I just wanted to let you know that MANDIANT Highlighter v1.1.1 is released and ready to rock and roll!
MANDIANT is proud to announce a new version of Highlighter (version 1.1.1).




