Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > 47064720b4f7b041ec2d78a3dc0d9632 > files > 2

nmap-7.40-1.1.mga6.src.rpm

diff --git a/scripts/http-fetch.nse b/scripts/http-fetch.nse
index 631e1c77b..8ae686657 100644
--- a/scripts/http-fetch.nse
+++ b/scripts/http-fetch.nse
@@ -10,7 +10,7 @@ local table = require "table"
 
 description = [[The script is used to fetch files from servers.
 
-The script supports three different use cases :
+The script supports three different use cases:
 * The paths argument isn't provided, the script spiders the host
   and downloads files in their respective folders relative to
   the one provided using "destination".
@@ -47,18 +47,15 @@ The script supports three different use cases :
 -- @output
 -- | http-fetch:
 -- |   Successfully Downloaded:
--- |     http://nmap.org:80/ as /tmp/mirror/index.html
--- |     http://nmap.org/shared/css/insecdb.css as /tmp/mirror/shared/css/insecdb.css
--- |     http://nmap.org/movies/ as /tmp/mirror/movies/index.html
--- |     http://nmap.org/book/man.html as /tmp/mirror/book/man.html
---
+-- |     http://scanme.nmap.org:80/ as /tmp/mirror/45.33.32.156/80/index.html
+-- |_    http://scanme.nmap.org/shared/css/insecdb.css as /tmp/mirror/45.33.32.156/80/shared/css/insecdb.css
 --
+-- @xmloutput
 -- <table key="Successfully Downloaded">
---   <elem>http://nmap.org:80/ as /tmp/mirror/index.html</elem>
---   <elem>http://nmap.org/shared/css/insecdb.css as /tmp/mirror/shared/css/insecdb.css</elem>
---   <elem>http://nmap.org/movies/ as /tmp/mirror/movies/index.html</elem>
---   <elem>http://nmap.org/book/man.html as /tmp/mirror/book/man.html</elem>
+--   <elem>http://scanme.nmap.org:80/ as /tmp/mirror/45.33.32.156/80/index.html</elem>
+--   <elem>http://scanme.nmap.org/shared/css/insecdb.css as /tmp/mirror/45.33.32.156/80/shared/css/insecdb.css</elem>
 -- </table>
+-- <elem key="result">Successfully Downloaded Everything At: /tmp/mirror/45.33.32.156/80/</elem>
 
 author = "Gyanendra Mishra"
 
@@ -183,7 +180,7 @@ local function fetch(host, port, url, destination, path, output)
   local response = http.get(host, port, build_path(path, url), nil)
   if response and response.status and response.status == 200 then
     local file = path:sub(path:find("/[^/]*$") + 1)
-    local save_as = (host.targetname or host.ip) .. ":" ..  tostring(port.number) .. "-" .. file
+    local save_as = (host.targetname or host.ip) .. SEPARATOR ..  tostring(port.number) .. "-" .. file
     local status, err_message = save_file(response.body, save_as, destination)
     if status then
       output['Successfully Downloaded'] = output['Successfully Downloaded'] or {}
@@ -211,10 +208,12 @@ action = function(host, port)
     return output, output.ERROR
   end
 
+  local sub_directory = tostring(host.ip) .. SEPARATOR ..  tostring(port.number) .. SEPARATOR
+
   if destination:sub(-1) == '\\' or destination:sub(-1) == '/' then
-    destination = destination
+    destination = destination .. sub_directory
   else
-    destination = destination .. SEPARATOR
+    destination = destination .. SEPARATOR .. sub_directory
   end
 
   if paths then