1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00
Commit Graph

112 Commits

Author SHA1 Message Date
patrik
b844caa6cd Changed the way cookie table fields are created in http.lua. This change
ensures that attribute names are always treated as lower case. [Patrik]
2011-03-15 21:42:49 +00:00
david
61543b681e Fix to http.validate_options from Sebastian Prengel: The cookies table
was being iterated over incorrectly.

Also from Sebastian: add "expires" to the list of handled keys in
validate_options.
2011-02-24 20:16:06 +00:00
batrick
47e6012b15 remove old commented code 2010-12-08 14:19:08 +00:00
patrik
e26eef6533 fixed typo intead -> instead [Patrik] 2010-11-05 10:10:36 +00:00
ron
fef25e6a42 Made some big style changes to clean up HTTP library. Primarily focused on improving the interface, NSEDoc, and pipline support 2010-11-02 02:07:01 +00:00
ron
13bb98b8b8 Bring in changes from my experimental brange, nmap-http 2010-10-27 03:08:08 +00:00
ron
2608bae6ca Rollback the changes to the HTTP library I accidentally commited in the last revision 2010-10-18 21:23:24 +00:00
ron
b8e712ceeb Added a couple shares to the list of common ones (requested on IRC by kraigus) 2010-10-18 21:16:48 +00:00
david
53bd35c9cd Increase the debug level required to print out the http.lua cache size. 2010-09-27 18:51:04 +00:00
david
92362b2d24 Move special request body handling out of http.post and into http.generic_request. 2010-09-27 01:21:45 +00:00
david
600848c268 Fix NSEDoc (@param not @arg). 2010-09-14 02:02:50 +00:00
david
f1ea488753 Add better error checking to http.read_auth_challenge; bail out if
read_token or read_token_or_quoted_string fails.
2010-08-18 18:22:03 +00:00
david
d275f88183 Fix two bugs in http.read_auth_challenge reported by Tom Sellers. The
first was that pos was declared as a local variable and shadowed the pos
parameter. The second was that when multiple WWW-Authenticate headers
were present, the wrong pos would be returned after reading the first
one. The arrow shows the pos it was returning:

Digest realm="My Site", domain="/", Basic realm="My Site"
                                          ^

It now returns this correct pos, ready to read the next challenge:

Digest realm="My Site", domain="/", Basic realm="My Site"
                                    ^

This was a problem I had already solved for Ncat but I copied the logic
imperfectly to http.lua.
2010-08-18 18:16:22 +00:00
david
de90361073 Fix a bug in header parsing in http.lua. After reading a block of
non-whitespace characters, the position counter was advanced one past
where it was supposed to be. This didn't have any bad effect when the
server used CRLF to separate header fields, because it ate the CR and
still recognized LF as ending the field. But it concatenated multiple
header fields when the server only used LF to separate them.
2010-08-18 17:55:27 +00:00
david
abbe5324bd Pass host and port tables instead of host.ip and port.number in http.lua
and comm.lua.
2010-08-16 17:41:57 +00:00
batrick
47bbbfdcea Fixed some local declarations. 2010-08-13 18:40:00 +00:00
batrick
7c7c30fc24 [NSE] (Global fix.) This fixes a spelling error. 2010-08-10 16:32:48 +00:00
david
1e54009fb9 Change the "namevals" key in the return value of
http.read_auth_challenge to "params" to match RFC 2617.
2010-07-25 17:33:35 +00:00
david
bb1119e199 Make the indentation of new auth-related http function match that of the
rest of the file.
2010-07-25 17:30:32 +00:00
david
bd0f13c9a0 Move the http.get_default_timeout function out of the section for
parsing header values. get_default_timeout seems to be completely
unused, so I've moved it right to the end until someone can check on
that.
2010-07-25 17:29:36 +00:00
david
d053e1a6cc Add RFC section references to the new http auth-related functions. 2010-07-25 17:26:46 +00:00
david
42a1bd99ab Merge from /nmap-exp/david/nmap-http-brute. This adds Basic
authentication support for http requests.
2010-07-25 17:12:52 +00:00
david
acd64e2921 Fix HTTP caching; every lookup was a cache miss. The problem was r16435,
where I added a check to make sure that a GET request would hit a cache
entry for a HEAD request and vice versa. Because of a misnamed
identifier, the test was always false.
2010-07-21 20:36:03 +00:00
david
7d0c08a097 Brief copyediting of NSEDoc for modules. 2010-07-12 19:42:43 +00:00
jah
e651aced8c Strip newlines from the the portion of the http status line starting after a
space.
2010-07-02 11:35:18 +00:00
batrick
148fa94265 whitespace/formatting consistency 2010-04-24 03:29:29 +00:00
batrick
98d4bee8e5 global bug fixes 2010-04-08 20:36:43 +00:00
jah
aec0b2c88c Add nsedoc @return tag for get_url. 2010-04-04 13:00:02 +00:00
ron
dd471d09d5 Fixed a bug in http.lua where http.post() wouldn't work if the arguments were passed in as a string instead of a table (the documentation says it should work in both places) 2010-04-01 04:41:48 +00:00
david
5fa554266b Fix NSEDoc. 2010-03-31 20:28:14 +00:00
david
3510744a54 Canonicalize the formatting of some functions in http.lua. 2010-02-19 05:13:02 +00:00
david
4178846c05 Honor the options table in http.request (specifically options.timeout).
I think this was supposed to work but it was broken.
2010-02-19 05:06:57 +00:00
david
bb2e8c439b Factor out common code for HTTP request building. Replace the two-step
buildGet/buildRequest with a one-step build_request. Provide a new
function generic_request that can do a request for any given method
(get, head, and post are now defined in terms of this function).
2010-02-19 04:54:28 +00:00
david
7f892c1563 Don't pass the cookies table as a parameter, but as a member of the
options table, in http functions. It was unreasonable that this
yet-unused feature was given a more prominent place than even the header
and request body, both of which are in the options table.

This change doesn't affect any other scripts or libraries because none
of them use cookies. In the cases, like http.get, where cookies was an
optional final parameter, I just removed it. Where it was not the final
parameter, as in http.post and http.pGet, I left the parameter in place
but documented that it is ignored for backwards compatibility.
2010-02-19 03:25:57 +00:00
batrick
2038337907 Fixed a global variable being set. I believe the intent was to set
response.body and not result.body.
2010-02-08 02:35:17 +00:00
fyodor
d85c8d3603 Typo fix: reponses -> responses 2010-01-27 02:05:01 +00:00
david
349f0edad0 Let http.next_response receive a body in response to a HEAD request, if
there is one. Even though section 4.4 of RFC 2616 says that sending a
body in response to a HEAD request is a MUST NOT, pyllyukko sent me a
sample from a server that does--"LuCI - Lua Configuration Interface".
2010-01-21 19:42:52 +00:00
david
929042a690 Fix the first round of HTTP pipeline requests. The pipeline makes an
initial request to get a value stored in the Keep-Alive header, which is
the size of the pipeline. It then iterates, doignt hat many requests at
once until the list of requests is exhausted. The prbolem was that in
the first round, it didn't count its initial Keep-Alive probe. So if the
server said it was good for 40 requests, we would send 41 before closing
the connection. Even worse was when the initial probe returned a
"Connection: close"; the pipeline would try another request before
closing the connection for the first time.
2010-01-21 17:43:23 +00:00
david
c7b4af21db o [NSE] Fixed a bug in http.lua that could lead to an assertion
failure. It happened when there was an error getting the a response
  at the beginning of a batch in http.pipeline. The symptoms of the
  bug were:
    NSE: Received only 0 of 1 expected reponses.
    Decreasing max pipelined requests to 0.
    NSOCK (0.1870s) Write request for 0 bytes...
    nmap: nsock_core.c:516: handle_write_result: Assertion `bytesleft > 0' failed.
  The error was reported by Brandon Enright and pyllyukko.
2010-01-21 16:28:39 +00:00
david
d390452e36 Fix a string format error in the HTTP dechunking code. 2010-01-21 00:35:12 +00:00
david
8a895ff0d9 Fix an error with http.request: If there was a parsing error or a
network error, it was returning nil instead of a table as documented.
2010-01-21 00:23:56 +00:00
david
19c2d93903 Merge from /nmap-exp/david/nselib-http. This is an overhaul of HTTP
parsing mostly. Response parsing is centralized, and fewer operations
are done on raw HTTP data.

The biggest user-visible change is that http.request goes back to
returning a parsed result table, not raw HTTP data. I believe this is
how the function worked in the past; it's what the NSEDoc for the
function says. The only thing that used http.request was citrixxml.lua,
and this commit alters it to match the new expectations.

The other change is that the http.pipeline function no longer accepts
the "raw" option. The only script that used that was sql-injection.nse,
and this commit modifies that script as well.
2010-01-13 02:53:13 +00:00
david
f5cae99a2a Check that nmap.registry.args exists before trying to access
nmap.registry.args["http.useragent"]. The args table doesn't exist
during --script-updatedb. The bug was found by Tom Sellers and fixed by
Jah.
2010-01-12 17:53:01 +00:00
david
12203a8ae1 Don't allow a cached response from a GET request to be returned for a
HEAD request. This makes it look like the response to the HEAD request
has a body. As a result, http-enum can wrongly surmise that HEAD
requests don't work when it hits a cache entry while testing HEAD.

# nmap --script=http-date,http-enum -PN -p 80 -d2
NSE: NSE Script Threads (2) running:
NSE: Final http cache size (373 bytes) of max size of 1000000
NSE: HTTP: Host returns proper 404 result.
NSE: Final http cache size (1905 bytes) of max size of 1000000
NSE: Finished 'http-date' (thread: 0x8535a40).
NSE: HTTP: Warning: Host returned data when performing HEAD.
NSE: Checking if a GET request is going to work out

After this change:

NSE: NSE Script Threads (2) running:
NSE: Final http cache size (373 bytes) of max size of 1000000
NSE: HTTP: Host returns proper 404 result.
NSE: Final http cache size (1905 bytes) of max size of 1000000
NSE: Finished 'http-date' (thread: 0x8e75b00).
NSE: Final http cache size (1905 bytes) of max size of 1000000
NSE: HTTP: Host supports HEAD.
2010-01-10 19:47:33 +00:00
david
d38ef0da41 Change the header name from "Cookies" to "Cookie" in http.lua. "Cookies"
is incorrect; see RFC 2109 section 4.3.4.
2010-01-09 22:54:37 +00:00
david
d6f8e9edda Merge r16415:16416 from /nmap-exp/david/nselib-http. I meant to do those
commits here in the first place.
2010-01-08 01:13:24 +00:00
david
ee0fee26c0 Skip over a single 100 Continue response, if present, before parsing the
real response in http.lua. This patch is by Patrik Karlsson.
2009-12-13 22:52:08 +00:00
david
315e6ef9b0 Remove a debugging statement from http.lua. 2009-12-13 01:51:05 +00:00
david
5eca175a11 Don't encode a POST body and set the content-type
application/x-www-form-urlencoded if the body is a string. Only do it
when the body is a table, meaning we want to do a form submission.
2009-12-13 01:50:26 +00:00
david
5cc9d5249a In http.lua, add the port number to the value of the Host header field
when the number is not 80. See RFC 2616, section 14.23. This was
suggested by Tom Sellers.
2009-11-09 20:26:55 +00:00