Nmap Development mailing list archives
[NSE] redirect support in http.lua
From: Patrik Karlsson <patrik () cqure net>
Date: Thu, 9 Feb 2012 17:08:29 +0100
Hi all, I'm attaching a patch that I would like to apply to the http library. It adds support for HTTP redirects to the http.get and http.head functions. The default behavior will be to follow 5 levels of redirects before bailing out. The no_follow_redirect can be passed as an option to disable redirect support. The new functionality checks whether it should follow redirects or not based on code from http-title that I've modified slightly. Basically this is how it works: 1. http.get or http.head requests a page 2. if the server returns a 301, 302 or 307 the handle_redirect function will validate the location with redirect_ok 3. if the redirect_ok passes all the tests, it will allow http.get or http.head to proceed fetching the new location 4. http.get or http.head continues to do 1-3 until it no longer receives a redirect, exceeds the max redirect count or fails to validate the location url 5. http.get or http.head returns the redirected response (transparently to the script) and sets a new response table field "location", a table, with an entry for each redirect that lead to the final page. Unless someone finds problems with this design or otherwise disagrees, I'll commit this change within the next few days. Cheers, Patrik -- Patrik Karlsson http://www.cqure.net http://twitter.com/nevdull77
Attachment:
http-redirect.patch
Description:
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- [NSE] redirect support in http.lua Patrik Karlsson (Feb 09)
- Re: [NSE] redirect support in http.lua Michael Kohl (Feb 09)
- Re: [NSE] redirect support in http.lua Lauri Kokkonen (Feb 09)
- Re: [NSE] redirect support in http.lua David Fifield (Feb 09)
- Re: [NSE] redirect support in http.lua Patrik Karlsson (Feb 11)
- Re: [NSE] redirect support in http.lua David Fifield (Feb 11)
- Re: [NSE] redirect support in http.lua Patrik Karlsson (Feb 11)
- Re: [NSE] redirect support in http.lua Patrik Karlsson (Feb 11)