mirror of
https://github.com/nmap/nmap.git
synced 2025-12-20 22:49:01 +00:00
Whitespace in ike.lua.
This commit is contained in:
130
nselib/ike.lua
130
nselib/ike.lua
@@ -15,14 +15,14 @@ The current funcionality includes:
|
|||||||
1. Generating a Main or Aggressive Mode IKE request packet with a variable amount of transforms and a vpn group.
|
1. Generating a Main or Aggressive Mode IKE request packet with a variable amount of transforms and a vpn group.
|
||||||
2. Sending a packet
|
2. Sending a packet
|
||||||
3. Receiving the response
|
3. Receiving the response
|
||||||
4. Parsing the response for VIDs
|
4. Parsing the response for VIDs
|
||||||
5. Searching for the VIDs in 'ike-fingerprints.lua'
|
5. Searching for the VIDs in 'ike-fingerprints.lua'
|
||||||
6. returning a parsed info table
|
6. returning a parsed info table
|
||||||
|
|
||||||
This library is meant for extension, which could include:
|
This library is meant for extension, which could include:
|
||||||
1. complete parsing of the response packet (might allow for better fingerprinting)
|
1. complete parsing of the response packet (might allow for better fingerprinting)
|
||||||
2. adding more options to the request packet
|
2. adding more options to the request packet
|
||||||
vendor field (might give better fingerprinting of services, e.g. Checkpoint)
|
vendor field (might give better fingerprinting of services, e.g. Checkpoint)
|
||||||
3. backoff pattern analyses
|
3. backoff pattern analyses
|
||||||
...
|
...
|
||||||
|
|
||||||
@@ -36,28 +36,47 @@ author = "Jesper Kueckelhahn"
|
|||||||
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||||
categories = {"discovery", "safe"}
|
categories = {"discovery", "safe"}
|
||||||
|
|
||||||
local enc_methods = {
|
local enc_methods = {
|
||||||
["des"] = 0x80010001,
|
["des"] = 0x80010001,
|
||||||
["3des"] = 0x80010005,
|
["3des"] = 0x80010005,
|
||||||
["aes/128"]= { 0x80010007, 0x800E0080 },
|
["aes/128"] = { 0x80010007, 0x800E0080 },
|
||||||
["aes/192"]= { 0x80010007, 0x800E00C0 },
|
["aes/192"] = { 0x80010007, 0x800E00C0 },
|
||||||
["aes/256"]= { 0x80010007, 0x800E0100 }
|
["aes/256"] = { 0x80010007, 0x800E0100 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local authentication= {
|
||||||
|
["psk"] = 0x80030001,
|
||||||
|
["rsa"] = 0x80030003,
|
||||||
|
["Hybrid"] = 0x8003FADD,
|
||||||
|
["XAUTH"] = 0x8003FDE9,
|
||||||
|
}
|
||||||
|
|
||||||
local authentication= { ["psk"] = 0x80030001, ["rsa"] = 0x80030003, ["Hybrid"] = 0x8003FADD, ["XAUTH"] = 0x8003FDE9}
|
local hash_algo = {
|
||||||
|
["md5"] = 0x80020001,
|
||||||
|
["sha1"] = 0x80020002,
|
||||||
|
}
|
||||||
|
|
||||||
local hash_algo = { ["md5"] = 0x80020001, ["sha1"] = 0x80020002}
|
local group_desc = {
|
||||||
local group_desc = { ["768"] = 0x80040001, ["1024"] = 0x80040002, ["1536"]= 0x80040005}
|
["768"] = 0x80040001,
|
||||||
local exchange_mode = { ["Main"] = 0x02, ["Aggressive"]= 0x04}
|
["1024"] = 0x80040002,
|
||||||
local protocol_ids = { ["tcp"] = "06", ["udp"]= "11"}
|
["1536"] = 0x80040005,
|
||||||
|
}
|
||||||
|
|
||||||
|
local exchange_mode = {
|
||||||
|
["Main"] = 0x02,
|
||||||
|
["Aggressive"] = 0x04,
|
||||||
|
}
|
||||||
|
|
||||||
|
local protocol_ids = {
|
||||||
|
["tcp"] = "06",
|
||||||
|
["udp"] = "11",
|
||||||
|
}
|
||||||
|
|
||||||
-- Response packet types
|
-- Response packet types
|
||||||
local response_exchange_type = {
|
local response_exchange_type = {
|
||||||
["02"] = "Main",
|
["02"] = "Main",
|
||||||
["04"] = "Aggressive",
|
["04"] = "Aggressive",
|
||||||
["05"] = "Informational"
|
["05"] = "Informational",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Payload names
|
-- Payload names
|
||||||
@@ -69,7 +88,7 @@ local payloads = {
|
|||||||
["05"] = "ID",
|
["05"] = "ID",
|
||||||
["08"] = "Hash",
|
["08"] = "Hash",
|
||||||
["0A"] = "Nonce",
|
["0A"] = "Nonce",
|
||||||
["0D"] = "VID"
|
["0D"] = "VID",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,7 +144,6 @@ end
|
|||||||
--
|
--
|
||||||
local function convert_to_hex(id)
|
local function convert_to_hex(id)
|
||||||
local hex_str = ""
|
local hex_str = ""
|
||||||
|
|
||||||
for c in string.gmatch(id, ".") do
|
for c in string.gmatch(id, ".") do
|
||||||
hex_str = hex_str .. string.format("%X", c:byte())
|
hex_str = hex_str .. string.format("%X", c:byte())
|
||||||
end
|
end
|
||||||
@@ -140,8 +158,8 @@ local function extract_payloads(packet)
|
|||||||
if packet:len() < 61 then return {} end
|
if packet:len() < 61 then return {} end
|
||||||
|
|
||||||
local np = packet:sub(33,34) -- next payload
|
local np = packet:sub(33,34) -- next payload
|
||||||
local index = 61 -- starting point for search
|
local index = 61 -- starting point for search
|
||||||
local ike_headers = {} -- ike headers
|
local ike_headers = {} -- ike headers
|
||||||
local payload = ''
|
local payload = ''
|
||||||
|
|
||||||
-- loop over packet
|
-- loop over packet
|
||||||
@@ -217,7 +235,6 @@ local function lookup(vendor_ids)
|
|||||||
|
|
||||||
-- Only store the first match
|
-- Only store the first match
|
||||||
if info.vendor == nil then
|
if info.vendor == nil then
|
||||||
|
|
||||||
-- the fingerprint contains information about the VID
|
-- the fingerprint contains information about the VID
|
||||||
info.vendor = row
|
info.vendor = row
|
||||||
|
|
||||||
@@ -379,25 +396,24 @@ local function generate_aggressive(port, protocol, id, diffie)
|
|||||||
key_length = 128
|
key_length = 128
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return bin.pack(">SHHSSHSHCHHH",
|
return bin.pack(">SHHSSHSHCHHH",
|
||||||
-- Key Exchange
|
-- Key Exchange
|
||||||
0x0a00 , -- Next payload (Nonce)
|
0x0a00 , -- Next payload (Nonce)
|
||||||
string.format("%04X", key_length+4) , -- Length (132-bit)
|
string.format("%04X", key_length+4) , -- Length (132-bit)
|
||||||
generate_random(key_length) , -- Random key data
|
generate_random(key_length) , -- Random key data
|
||||||
|
|
||||||
-- Nonce
|
-- Nonce
|
||||||
0x0500 , -- Next payload (Identification)
|
0x0500 , -- Next payload (Identification)
|
||||||
0x0018 , -- Length (24)
|
0x0018 , -- Length (24)
|
||||||
generate_random(20) , -- Nonce data
|
generate_random(20) , -- Nonce data
|
||||||
|
|
||||||
-- Identification
|
-- Identification
|
||||||
0x0000 , -- Next Payload (None)
|
0x0000 , -- Next Payload (None)
|
||||||
id_len , -- Payload length (id + 8)
|
id_len , -- Payload length (id + 8)
|
||||||
0x03 , -- ID Type (USER_FQDN)
|
0x03 , -- ID Type (USER_FQDN)
|
||||||
hex_prot , -- Protocol ID (UDP)
|
hex_prot , -- Protocol ID (UDP)
|
||||||
hex_port , -- Port (500)
|
hex_port , -- Port (500)
|
||||||
convert_to_hex(id) -- Id Data (as hex)
|
convert_to_hex(id) -- Id Data (as hex)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -435,12 +451,12 @@ local function generate_transform(auth, encryption, hash, group, number, total)
|
|||||||
next_payload , -- Next payload
|
next_payload , -- Next payload
|
||||||
trans_length , -- Transform length
|
trans_length , -- Transform length
|
||||||
payload_number , -- Transform number
|
payload_number , -- Transform number
|
||||||
0x01 , -- Transform ID (IKE)
|
0x01 , -- Transform ID (IKE)
|
||||||
0x0000 , -- spacers ?
|
0x0000 , -- spacers ?
|
||||||
enc , -- Encryption algorithm
|
enc , -- Encryption algorithm
|
||||||
hash_algo[hash] , -- Hash algorithm
|
hash_algo[hash] , -- Hash algorithm
|
||||||
authentication[auth], -- Authentication method
|
authentication[auth] , -- Authentication method
|
||||||
group_desc[group] -- Group Description
|
group_desc[group] -- Group Description
|
||||||
)
|
)
|
||||||
|
|
||||||
if key_length ~= nil then
|
if key_length ~= nil then
|
||||||
@@ -448,8 +464,8 @@ local function generate_transform(auth, encryption, hash, group, number, total)
|
|||||||
end
|
end
|
||||||
|
|
||||||
trans = trans .. bin.pack(">IL",
|
trans = trans .. bin.pack(">IL",
|
||||||
0x800b0001 , -- Life type (seconds)
|
0x800b0001 , -- Life type (seconds)
|
||||||
0x000c000400007080 -- Life duration (28800)
|
0x000c000400007080 -- Life duration (28800)
|
||||||
)
|
)
|
||||||
|
|
||||||
return trans
|
return trans
|
||||||
@@ -457,7 +473,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- Generate multiple transforms
|
-- Generate multiple transforms
|
||||||
-- Input nust be a table of complete transforms
|
-- Input nust be a table of complete transforms
|
||||||
--
|
--
|
||||||
local function generate_transforms(transform_table)
|
local function generate_transforms(transform_table)
|
||||||
local transforms = ''
|
local transforms = ''
|
||||||
@@ -500,26 +516,26 @@ function request(port, proto, mode, transforms, diffie, id)
|
|||||||
local packet = bin.pack(">HLCCCCIHSHIISHCCCH",
|
local packet = bin.pack(">HLCCCCIHSHIISHCCCH",
|
||||||
generate_random(8) , -- Initiator cookie
|
generate_random(8) , -- Initiator cookie
|
||||||
0x0000000000000000 , -- Responder cookie
|
0x0000000000000000 , -- Responder cookie
|
||||||
0x01 , -- Next payload (SA)
|
0x01 , -- Next payload (SA)
|
||||||
0x10 , -- Version
|
0x10 , -- Version
|
||||||
exchange_mode[mode] , -- Exchange type
|
exchange_mode[mode] , -- Exchange type
|
||||||
0x00 , -- Flags
|
0x00 , -- Flags
|
||||||
0x00000000 , -- Message id
|
0x00000000 , -- Message id
|
||||||
l , -- packet length
|
l , -- packet length
|
||||||
|
|
||||||
|
|
||||||
--# Security Association
|
-- Security Association
|
||||||
payload_after_sa , -- Next payload (Key exchange, if aggressive mode)
|
payload_after_sa , -- Next payload (Key exchange, if aggressive mode)
|
||||||
l_sa , -- Length
|
l_sa , -- Length
|
||||||
0x00000001 , -- IPSEC
|
0x00000001 , -- IPSEC
|
||||||
0x00000001 , -- Situation
|
0x00000001 , -- Situation
|
||||||
|
|
||||||
--## Proposal
|
--## Proposal
|
||||||
0x0000 , -- Next payload (None)
|
0x0000 , -- Next payload (None)
|
||||||
l_pro , -- Payload length
|
l_pro , -- Payload length
|
||||||
0x01 , -- Proposal number
|
0x01 , -- Proposal number
|
||||||
0x01 , -- Protocol ID (ISAKMP)
|
0x01 , -- Protocol ID (ISAKMP)
|
||||||
0x00 , -- SPI Size
|
0x00 , -- SPI Size
|
||||||
number_transforms -- Proposal transforms
|
number_transforms -- Proposal transforms
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user