Pages

Showing posts with label parameters. Show all posts
Showing posts with label parameters. Show all posts

Sunday, August 29, 2010

wget: downloader extraordinaire

I always found browsers too bothersome or intrusive when downloading files. The task of downloading files via browsers always require too much clicking and configuring. I'd rather spend time on the task at hand rather than configuring the crap out of some unintuitive graphical user interface.

I always have a shell handy when I'm browsing, so I always download files using wget.

I use an alias to predefine the arguments in $HOME/.bashrc I usually need to download like this:


alias wget="$(which wget) -m -U 'Mozilla/5.0 (compatible; Konqueror/3.2; Linux)' \
-e robots=off --wait 1 -c -nd -nH"


I put a which in there because I'm too lazy to type /usr/bin/wget; the purpose of putting it there is to escape any other current aliases or scripts which might get called using the same invocation name, namely wget.

The arguments there are crafted to make wget ignore robots.txt, to make wget pretend to be a browser. This is generally frowned upon. People call this bad netiquette. As I said, I'd rather get the job done...

If you decide to download recursively, you'll need the following commands:

  • Download recursively with -r --level n, where n is the maximum recursion depth;
  • To reject all files except, you'll need -R<.ext>, where .ext is some type of file extension, for instance .mp3
  • To allow only a certain file extension, you'll need -A<.ext>.

Have fun!

Tuesday, June 22, 2010

Portscanner: nmap

Recently, I wanted to list all the mac addresses of all our voip telephones (not to be confused with softphones) and reserve a block of addresses from our ip-address space and map each macaddy to an ip addy.

I already knew of nmap and I wondered how one could get all the mac addresses.

So I scanned with nmap.

I dug around on the net and bumped into this mindmap. Since I was scanning locally and not sniffing around someone else's stuff, I could get aggressive (-T5).


sudo nmap -T5 ... ip_addr_range


I wanted output I could grep, so I picked a typical output format (-oG).


sudo nmap ... -oG grepme.txt ...


I found out from the nmap man page, that nmap can do fingerprinting with the -O switch.


sudo nmap -O ip_addr_range -T5 -oG grepme.txt ...


Then I found out that the -oG option did not output the mac address. I was bummed out.

Some monkeying around I found out one could sed using multiple patterns, but that would take effort.

Update 23-07-2010: Some googling led to this command (from this blog)

First try:

nmap -T5 -sP -n ip_addr_range | tee log.txt | sed -n '1!H;${;g;s/Host \([0-9.]\+\) is up.*MAC Address: \([0-9A-F:]\+\)/\1 \2/g;p;}'

Way too greedy.

2nd try:
... still working on it...