Compare commits

..

11 Commits

Author SHA1 Message Date
bddaa541bf use shortport.http 2024-10-23 19:12:50 +02:00
180ecf99b5 http get 2024-10-23 19:03:52 +02:00
6bbe7e270a return to bin.pack 2024-10-22 15:55:40 +02:00
2191a53956 update 2024-10-20 02:37:36 +02:00
10395a01e6 smbdomain 2024-10-20 02:27:52 +02:00
5995afaf18 smbdomain 2024-10-20 02:27:10 +02:00
1c12e66a04 align & portrule 2024-10-20 02:19:57 +02:00
523712a4c2 rename info to output 2024-10-18 01:01:59 +02:00
7c849a0088 dont follow smb-authentication.ini 2024-10-17 20:52:12 +02:00
365aba434c rename args-file 2024-10-17 20:50:34 +02:00
50039189aa ignore password 2024-10-17 18:15:45 +02:00
5 changed files with 30 additions and 29 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
smb-authentication.ini

View File

@ -23,7 +23,7 @@ categories = {"discovery", "intrusive"}
author = "Adrien Malingrey" author = "Adrien Malingrey"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html" license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
portrule = shortport.service({"http", "https", "ssl"}) portrule = shortport.http
local http = require "http" local http = require "http"
local stdnse = require "stdnse" local stdnse = require "stdnse"
@ -32,50 +32,49 @@ action = function(host, port)
local scheme = "" local scheme = ""
local hostaddress = (host.name ~= '' and host.name) or host.ip local hostaddress = (host.name ~= '' and host.name) or host.ip
local path = "/" local path = "/"
local uri
local favicon_relative_uri = "/favicon.ico" local favicon_relative_uri = "/favicon.ico"
local favicon local favicon
stdnse.debug1("port", port.service)
if (port.service == "ssl") then if (port.service == "ssl") then
scheme = "https" scheme = "https"
else else
scheme = port.service scheme = port.service
end end
stdnse.debug1("scheme", scheme)
if(stdnse.get_script_args('http-get.path')) then if(stdnse.get_script_args('http-get.path')) then
path = stdnse.get_script_args('http-info.path') path = stdnse.get_script_args('http-info.path')
end end
uri = scheme.."://"..hostaddress..":"..port.number..path stdnse.debug1("Try to download %s", path)
stdnse.debug1("Try to download %s", uri) local answer = http.get(hostaddress, port, path)
local answer = http.get_url(uri, {})
local info = {status=answer.status, ["status-line"]=answer["status-line"]} local output = {status=answer.status, ["status-line"]=answer["status-line"]}
if (answer and answer.status == 200) then if (answer and answer.status == 200) then
stdnse.debug1("[SUCCESS] Load page %s", uri) stdnse.debug1("[SUCCESS] Load page %s", path)
-- Taken from http-title.nse by Diman Todorov -- Taken from http-title.nse by Diman Todorov
local title = string.match(answer.body, "<[Tt][Ii][Tt][Ll][Ee][^>]*>([^<]*)</[Tt][Ii][Tt][Ll][Ee]>") local title = string.match(answer.body, "<[Tt][Ii][Tt][Ll][Ee][^>]*>([^<]*)</[Tt][Ii][Tt][Ll][Ee]>")
if (title) then if (title) then
info.title = title output.title = title
end end
stdnse.debug1("[INFO] Try favicon %s", favicon_relative_uri) stdnse.debug1("[INFO] Try favicon %s", favicon_relative_uri)
favicon_relative_uri = parseIcon(answer.body) or "favicon.ico" favicon_relative_uri = parseIcon(answer.body) or favicon_relative_uri
else else
stdnse.debug1("[ERROR] Can't load page %s", uri) stdnse.debug1("[ERROR] Can't load page %s", path)
end end
favicon_absolute_uri = scheme.."://"..hostaddress..":"..port.number..favicon_relative_uri favicon = http.get(hostaddress, port, favicon_relative_uri)
favicon = http.get_url(favicon_absolute_uri, {})
if (favicon and favicon.status == 200) then if (favicon and favicon.status == 200) then
stdnse.debug1("[SUCCESS] Load favicon %s", favicon_absolute_uri) stdnse.debug1("[SUCCESS] Load favicon %s", favicon_relative_uri)
info.favicon = favicon_absolute_uri output.favicon = favicon_relative_uri
else else
stdnse.debug1("[ERROR] Can't load favicon %s", favicon_absolute_uri) stdnse.debug1("[ERROR] Can't load favicon %s", favicon_relative_uri)
end end
return info return output
end end
--- function taken from http_favicon.nse by Vlatko Kosturjak --- function taken from http_favicon.nse by Vlatko Kosturjak

3
smb-authentication.ini Normal file
View File

@ -0,0 +1,3 @@
smbdomain =
smbuser =
smbpassword =

View File

@ -1,2 +0,0 @@
smbuser =
smbpassword =

View File

@ -1,8 +1,3 @@
local stdnse = require "stdnse"
local smb = require "smb"
local smb2 = require "smb2"
local msrpc = require "msrpc"
local bin = require "bin"
local shortport = require "shortport" local shortport = require "shortport"
description = [[ description = [[
@ -12,7 +7,7 @@ Return free and total size in octets of each SMB shares
--- ---
-- @args See the documentation for the smbauth library. -- @args See the documentation for the smbauth library.
-- --
-- @usage nmap -p137-139,445 --script smb-shares-size.nse --script-args-file smb-shares-size.ini <host> -- @usage nmap -p137-139,445 --script smb-shares-size.nse --script-args-file smb-authentication.ini <host>
-- --
-- @output -- @output
-- Host script results: -- Host script results:
@ -29,6 +24,11 @@ license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
portrule = shortport.service({"microsoft-ds", "netbios-ssn", "smb"}) portrule = shortport.service({"microsoft-ds", "netbios-ssn", "smb"})
local stdnse = require "stdnse"
local smb = require "smb"
local smb2 = require "smb2"
local msrpc = require "msrpc"
local bin = require "bin"
action = function(host) action = function(host)
local status, shares, extra local status, shares, extra