1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

Fixes a bug that prevented the script to find its resource file. Fixes #1608

This commit is contained in:
nnposter
2019-05-24 00:24:51 +00:00
parent 57ff460847
commit 168cbfde8e
2 changed files with 22 additions and 9 deletions

View File

@@ -56,6 +56,7 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
local http = require "http"
local io = require "io"
local nmap = require "nmap"
local string = require "string"
local httpspider = require "httpspider"
local shortport = require "shortport"
@@ -211,6 +212,16 @@ action = function(host, port)
local foundfield = 0
local fail = 0
local pixel = nil
local pixelfn = nmap.fetchfile("nselib/data/pixel.gif")
if pixelfn then
local fh = io.open(pixelfn, "rb")
pixel = fh:read("a")
fh:close()
end
if not pixel then
stdnse.debug1("Warning: Test file nselib/data/pixel.gif not found")
end
local crawler = httpspider.Crawler:new( host, port, '/', { scriptname = SCRIPT_NAME } )
@@ -300,16 +311,15 @@ action = function(host, port)
end
-- Method (3).
local inp = assert(io.open("nselib/data/pixel.gif", "rb"))
local image = inp:read("a")
if pixel then
buildRequests(host, port, submission, filefield["name"], "image/gif", partofrequest, uploadspaths, pixel)
buildRequests(host, port, submission, filefield["name"], "image/gif", partofrequest, uploadspaths, image)
result = makeAndCheckRequests(uploadspaths)
if result then
table.insert(returntable, result)
else
fail = 1
result = makeAndCheckRequests(uploadspaths)
if result then
table.insert(returntable, result)
else
fail = 1
end
end
end
else