Nmap Development mailing list archives

URL nselib


From: "Eddie Bell" <ejlbell () gmail com>
Date: Mon, 25 Jun 2007 12:07:23 +0100

I've been working on a http based NSE script so have had to do a lot
of URL manipulation which lead me into thinking about a URL nselib.
Luckily I found a existing implementation from LuaSocket which fulfils
most of the criteria.

The main parsing function returns a table (lua's catch all data
structure) and can be accessed like a C structure, a hash-table or
through iterators.

u = url.parse("http://www.site.com/scripts/view.php?code=nmap&id=10#section";)

u['schema'] => http
u.authority => www.site.com
u['path'] => /scripts/view.php
...

Along with parse() there are another 6 supporting functions: escape(),
unescape(), build(), absolute(), parse_path() and build_path(). I have
also added parse_query() and build_query():

x = url.parse_query('code=nmap&id=10')
x['id'] = 11;
x['stuff'] = 'extra'
url.build_query(x) => 'code=nmap&id=11&stuff=extra'

If you wish to know more or can think of other desirable functions
check out nselib/url.lua in the soc07 branch. The comments describe in
detail how to use it.

thanks
- eddie

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: