mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Rectify shadowing of the packet module
This commit is contained in:
@@ -17,10 +17,10 @@
|
|||||||
-- pcap:pcap_open(iface.device, 512, true, "ether proto 0x888e")
|
-- pcap:pcap_open(iface.device, 512, true, "ether proto 0x888e")
|
||||||
-- ...
|
-- ...
|
||||||
-- local _, _, l2_data, l3_data, _ = pcap:pcap_receive()
|
-- local _, _, l2_data, l3_data, _ = pcap:pcap_receive()
|
||||||
-- local packet = eap.parse(l2_data .. l3_data3)
|
-- local pkt = eap.parse(l2_data .. l3_data3)
|
||||||
-- if packet then
|
-- if pkt then
|
||||||
-- if packet.eap.type == eap.eap_t.IDENTITY and packet.eap.code == eap.code_t.REQUEST then
|
-- if pkt.eap.type == eap.eap_t.IDENTITY and pkt.eap.code == eap.code_t.REQUEST then
|
||||||
-- eap.send_identity_response(iface, packet.eap.id, "anonymous")
|
-- eap.send_identity_response(iface, pkt.eap.id, "anonymous")
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
-- </code>
|
-- </code>
|
||||||
@@ -186,18 +186,18 @@ local make_eap = function (arg)
|
|||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
parse = function (packet)
|
parse = function (pkt)
|
||||||
local tb = {}
|
local tb = {}
|
||||||
|
|
||||||
stdnse.debug2("packet size: 0x%x", #packet )
|
stdnse.debug2("packet size: 0x%x", #pkt )
|
||||||
|
|
||||||
-- parsing ethernet header
|
-- parsing ethernet header
|
||||||
tb.mac_src, tb.mac_dst, tb.ether_type = string.unpack(">c6c6I2", packet)
|
tb.mac_src, tb.mac_dst, tb.ether_type = string.unpack(">c6c6I2", pkt)
|
||||||
tb.mac_src_str = stdnse.tohex(tb.mac_src)
|
tb.mac_src_str = stdnse.tohex(tb.mac_src)
|
||||||
tb.mac_dst_str = stdnse.tohex(tb.mac_dst)
|
tb.mac_dst_str = stdnse.tohex(tb.mac_dst)
|
||||||
|
|
||||||
-- parsing eapol header
|
-- parsing eapol header
|
||||||
tb.version, tb.type, tb.length = string.unpack(">BBI2", packet, ETHER_HEADER_SIZE + 1)
|
tb.version, tb.type, tb.length = string.unpack(">BBI2", pkt, ETHER_HEADER_SIZE + 1)
|
||||||
|
|
||||||
stdnse.debug1("mac_src: %s, mac_dest: %s, ether_type: 0x%X",
|
stdnse.debug1("mac_src: %s, mac_dest: %s, ether_type: 0x%X",
|
||||||
tb.mac_src_str, tb.mac_dst_str, tb.ether_type)
|
tb.mac_src_str, tb.mac_dst_str, tb.ether_type)
|
||||||
@@ -213,7 +213,7 @@ parse = function (packet)
|
|||||||
if tb.length > 0 then
|
if tb.length > 0 then
|
||||||
-- parsing body
|
-- parsing body
|
||||||
|
|
||||||
tb.eap.code, tb.eap.id, tb.eap.length, tb.eap.type = string.unpack(">BBI2B", packet,
|
tb.eap.code, tb.eap.id, tb.eap.length, tb.eap.type = string.unpack(">BBI2B", pkt,
|
||||||
ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + 1)
|
ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + 1)
|
||||||
stdnse.debug2("code: %s, id: 0x%X, length: 0x%X, type: %s",
|
stdnse.debug2("code: %s, id: 0x%X, length: 0x%X, type: %s",
|
||||||
code_str[tb.eap.code] or "unknown",
|
code_str[tb.eap.code] or "unknown",
|
||||||
@@ -227,13 +227,13 @@ parse = function (packet)
|
|||||||
|
|
||||||
-- parsing payload
|
-- parsing payload
|
||||||
if tb.length > 5 and tb.eap.type == eap_t.IDENTITY then
|
if tb.length > 5 and tb.eap.type == eap_t.IDENTITY then
|
||||||
tb.eap.body.identity = string.unpack("z", packet,
|
tb.eap.body.identity = string.unpack("z", pkt,
|
||||||
ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + EAP_HEADER_SIZE + 1)
|
ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + EAP_HEADER_SIZE + 1)
|
||||||
stdnse.debug1("identity: %s", tb.eap.body.identity )
|
stdnse.debug1("identity: %s", tb.eap.body.identity )
|
||||||
end
|
end
|
||||||
|
|
||||||
if tb.length > 5 and tb.eap.type == eap_t.MD5 then
|
if tb.length > 5 and tb.eap.type == eap_t.MD5 then
|
||||||
tb.eap.body.challenge = string.unpack("s1", packet, ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + EAP_HEADER_SIZE + 1)
|
tb.eap.body.challenge = string.unpack("s1", pkt, ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + EAP_HEADER_SIZE + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return tb
|
return tb
|
||||||
|
|||||||
Reference in New Issue
Block a user