admin

HOW TO : Use grep to search for credit card numbers

I was looking for a quick way to search for credit card numbers in a file and ran across this excellent post by Adrian Rollett. I tweaked his suggestion a bit to show some additional data.

Original suggestion

[code] grep ‘\(^\|[^0-9]\)\{1\}\([345]\{1\}[0-9]\{3\}\|6011\)\{1\}[-]\?[0-9]\{4\}[-]\?\[0-9]\{2\}[-]\?[0-9]\{2\}-\?[0-9]\{1,4\}\($\|[^0-9]\)\{1\}’ FILE_TO_SEARCH [/code]

My modification

[code]Β grep ‘\([345]\{1\}[0-9]\{3\}\|6011\)\{1\}[ -]\?[0-9]\{4\}[ -]\?[0-9]\{2\}[-]\?[0-9]\{2\}[ -]\?[0-9]\{1,4\}’ –color -H -n FILE_TO_SEARCH [/code]

The modified command will show the name of the file the number was found and at which line. You can tweak it further using additional options for grep. A good reference guide can be found here.

HOW TO : Export and import certificates using keytool

Keytool is a java utility to manage SSL key databases (stores). Here are a couple of options for using this tool

  • List the certificates in the keystore

[code]keytool -list -keystore NAME_OF_KEYSTORE_FILE [/code]

  • Export a particular certificate from the keystore

[code]keytool -export -alias ALIAS_NAME_OF_CERT -keystore NAME_OF_KEYSTORE_FILE [/code]

  • Import a certificate into the keystore

[code]keytool -import -alias ALIAS_NAME_YOU_WANT -keystore NAME_OF_KEYSTORE_FILE -file NAME_OF_CERT_FILE_TO_IMPORT [/code]

HOW TO : Use netcat (nc) on Windows 7

netcat is a swiss army tool for network/security professionals. You can use it to listen on certain ports or connect to certain ports. For example, say, you configured your firewall to allow TCP 80 traffic to your web server. But your web server is not built yet and you want to validate the rule. You can run netcat on your workstation to listen on port 80, assign the IP address of the web server to your workstation and test the rule.

If I am not mistaken, nc comes as a default tool in most of the Linux distros. You can download the windows port of the tool atΒ http://www.securityfocus.com/tools/139

The command to have netcat listen on a specific port is “nc -l PORT_NUMBER”. If you run this on a Windows 7 machine, you will get this dreaded message “local listen fuxored: INVAL”. The fix is to run it with a -L option. So the command would like this

[code]nc -L -p 80[/code]

The -L means “listen harder, re-listen on socket close” :).. Have to dig deeper and see what it really means though. I will leave that for another blog post.

And if you want to validate that netcat is indeed listening on that port, you can connect to that port from another workstation by using nmap.

Huh…???

I was checking out the live feed from Facebook regd the video service they rolled out yesterday and noticed this comment on the live feed form.. all I can say is WTF πŸ™‚

HOW TO : for loop in bash

Quick post for my own reference down the road. the “for” loop comes in very handy, when you want to perform the same task on multiple items in a bash shell.

For example, I wanted to query the DNS results of a couple of sub domains (blog.gogoair.com, pr.gogoair.com, tracker.gogoair.com), I can do it the normal way (that 99% of us do πŸ™‚ )

[code] dig blog.gogoair.com

dig pr.gogoair.com

dig tracker.gogoair.com [/code]

Or, I can use the for loop function and do this

[code] for i in {blog,pr,tracker}.gogoair.com; do echo "$i" ; dig +short "$i"; done [/code]

Got to love technology :).. Makes you lazy!!..err I meant to say productive.

Thx to Cliff for the inspiration.

Celebrating Ugadhi

Jhanvi and I visited India in April and were lucky to celebrate Ugadhi with our family back home. Ugadhi is the an important festival in South India and is essentially the celebration of the begenning of a new year (yep.. new year in April πŸ™‚ ). One of the specialities of Ugadhi in Andhra Pradesh is something called “Ugadhi Pachadi”. It is a mixture of 6 ingredients (Neem Flower, Jaggery, Red Pepper, Green Mango, Salt and Tamarind) which designate the different “tastes” of life (bitter, sweet, hot, salty, tangy etc).

I haven’t been able to celebrate Ugadhi with my family for more than 10 years. So it was a special occasion. And mom went all the way to make it even more memorable. Here are some pictures.

Hanging Mango Leaves

Garelu

Ugadhi Pachadi : Ingredients

Ugadhi Pachadi : Final

Thanking the divine ones

RESOLUTIONS : 2011 : April Update

Another late update. I really want to post these updated in the first week of the month, but something or the other always stops me from doing it. Maybe one of my resolution should be to post updates on resolutions on a timely basis :).

  • Lose the Gut
    • This is the first month, where my weight at the end of the month was higher than the weight at the beginning. And I blame all of it on the yummy food I had in India.
    • This was also the first month during which I didn’t measure my weight on a daily basis for more than 80% of the time.
    • Here is how the graph looks like
    • I feel like I have hit a plateau in my effort to lose weight. And I think I know why. I stopped exercising (whatever little I used to do πŸ™‚ ). One small resolutions and so many issues :).
  • Increase traffic to kudithipudi.org
    • Another goal I didn’t do anything about in April. In fact, this is probably the one goal where I have consistently lagged behind. I haven’t been writing as much as I want to. Plenty of ideas, but at the same time plenty of excuses πŸ™‚ to not write. But does it really matter? I just need to get it done.
  • CISSP Certification
    • I started preparing for the certification. I think I should just schedule the exam, so that I have a deadline to meet.
  • Vacation
    • With the recent vacation in India, I think this resolution has been met.Β  One down, three more to go πŸ™‚