How do I coerce a table to string
Alo Yommist <[email protected]>
| Newsgroups | gmane.comp.security.nmap.devel |
|---|---|
| Message-ID | <CAL59SMTsR8J3cmW_iTYSM8noTjMhd=GrHwu9=w27nhi+q3hrWQ@mail.gmail.com> |
How do I coerce cookie from response.cookies to string I know the response.cookies is a table having another table as value but I just kept getting error bad argument #1 to pairs (table expected, got nil) when iterating through the table I need to be able to send cookie as a string I tried manipulating my code I don't seem to get it to work _______________________________________________ Sent through the dev mailing list https://nmap.org/mailman/listinfo/dev Archived at http://seclists.org/nmap-dev/
spmleecher.txt
(text/plain, 2.4 KB)
description = [[
My test script for spm leecher
]]
local http = require "http"
local stdnse = require "stdnse"
local string = require "string"
local shortport = require "shortport"
local table = require "table"
local url = require "url"
portrule = shortport.port_or_service({80,443}, {"http", "https"}, "tcp", "open")
detect_form = function(host, port, path, hostname)
path = path or "/v3/login"
hostname = stdnse.get_hostname(host)
local resp = http.get(host, port, path, {bypass_cache = true, header = {Connection = "keep-alive", Host = hostname, ["Accept-Language"] = "en-US,en;q=0.5", ["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", ["Accept-Encoding"] = "gzip, deflate, br", ["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; rv:54.0) Gecko/20100101 Firefox/54.0", Host = stdnse.get_hostname(host)} })
return resp.cookies
end
action = function(host, port, uri, options)
local response, status, path
uri = "/v3/login/process"
path = "/v3/login"
local form, errmsg
local kies = detect_form(host, port, path, stdnse.get_hostname(host))
strcookies = ""
for k, v in pairs(kies.value) do
kies = kies .. k ..": " .. value .. ""
end
response = http.post(host, port, uri, { header = { ["Connection"] = "keep-alive", ["Accept-Language"] = "en-US,en;q=0.5", ["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", ["Accept-Encoding"] = "gzip, deflate, br", ["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; rv:54.0) Gecko/20100101 Firefox/54.0",["Content-Type"] = "application/x-www-forn-urlencoded", Referer = "https://www.seniorpeoplemeet.com/v3/login",Origin = "https://www.seniorpeoplemeet.com", Host = stdnse.get_hostname(host), ["Cache-Control"] = "max-age=0" }, cookies = kies}, nil,
"SkipCSSVerif=HTMLEditor&FromLocation=%2Fv3%2Flogin&username=bodede+297%40yahoo.com&password=javagoogle")
--[[ if response.location then
local redirect_url = response.location[#response.location]
if response.status and tostring(response.status):match(" 30%d ") then
return {redirect_url = redirect_url},( "Did not followrect to %s" ):format(redirect_url), response.status
en
end ]]
return kies
end