|
Nmap Development
mailing list archives
Re: Lua issues
From: Patrik Karlsson <patrik () cqure net>
Date: Mon, 6 Feb 2012 12:42:04 +0100
On Mon, Feb 6, 2012 at 12:14 PM, CheesStick peak <crnxyrnx () gmail com> wrote:
Hello
Im currently working with the nmap script engine and with lua.
Im more into perl but i wanted to give lua a try so I started scripting a
bit.
Now it looks for me that the nse is not working like normal lua. I have an
example according my work with tables:
local table= { 123, 231 , "aaa" , xxx = { "x1", "x2"} , 666 , test="showme"
, 777 }
now when I do:
for i,v in ipairs(table) do print(i,v) end
it gives me:
1 123
2 231
3 aaa
4 666
5 777
(the same does table.concat(table,"\n") btw.)
BUT, according to different lua sites it should be:
1 123
2 231
3 aaa
4 table: 0035xxxx
5 666
test showme
7 777
... ?
So i hope you can help me, because all I want is to know what http header
http.get gives me back:
local req = http.get ( "example.com" , 80, "/index.php")
print req.status -- 200
print (req['header']) --table: 0x97874a0
print (table.getn(req['header'])) --- erm... what??wtf?
sincerely
peak
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/
Hi Peak,
In the examples you provide it's important to distinguish between what
pairs and ipairs does.
If you replace ipairs with pairs, I believe you will get the results you
expected.
The attached script will connect to a server, retrieve '/' and iterate over
and print all headers in the response.
description = [[
Prints any HTTP headers recevied from a server
]]
require 'http'
require 'shortport'
categories = {"safe"}
portrule = shortport.service("http")
action = function(host, port)
local response = http.get(host, port, "/")
for key, value in pairs(response.header) do
print(("%s: %s"):format(key,value))
end
end
Cheers,
Patrik
--
Patrik Karlsson
http://www.cqure.net
http://twitter.com/nevdull77
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/
By Date
By Thread
Current thread:
|