diff --git a/nselib/afp.lua b/nselib/afp.lua index 4b304d33c..60478e99f 100644 --- a/nselib/afp.lua +++ b/nselib/afp.lua @@ -835,7 +835,7 @@ Proto = { end data = response:getPacketData() - pos, parms.server_time, parms.vol_count = bin.unpack("IC", data) + pos, parms.server_time, parms.vol_count = bin.unpack(">IC", data) -- we should now be at the leading zero preceding the first volume name -- next is the length of the volume name, move pos there diff --git a/nselib/ipmi.lua b/nselib/ipmi.lua index 976e13a12..210196957 100644 --- a/nselib/ipmi.lua +++ b/nselib/ipmi.lua @@ -166,6 +166,17 @@ verify_rakp_hmac_sha1 = function(salt, hash, password) return (digest == hash) end +--[[ +Multi-byte fields in RMCP/ASF fields are specified as being transmitted in +'Network Byte Order' - meaning most-significant byte first. +RMCP and ASF-specified fields are therefore transferred most-significant byte +first. +The IPMI convention is to transfer multi-byte numeric fields least-significant +Byte first. Therefore, unless otherwise specified: +Data in the IPMI Session Header and IPMI Message fields are transmitted +least-significant byte first. +--]] + parse_channel_auth_reply = function(reply) local data = {} local pos = 0 @@ -252,14 +263,14 @@ parse_open_session_reply = function(reply) -- bit [3:8] data["session_payload_type"] = bit.band(value, 0x3F) - pos, data["session_id"] = bin.unpack("I", reply, pos) - pos, data["session_sequence"] = bin.unpack("I", reply, pos) + pos, data["session_id"] = bin.unpack("I2", self.DT_3270_DATA, -- type 0, -- request 0, -- response diff --git a/nselib/tns.lua b/nselib/tns.lua index 6631d309a..b8e691bf7 100644 --- a/nselib/tns.lua +++ b/nselib/tns.lua @@ -616,7 +616,7 @@ Packet.SNS = { -- -- @return string containing the packet __tostring = function( self ) - return bin.pack("SH", self.flags, + return bin.pack(">SH", self.flags, [[ deadbeef00920b1006000004000004000300000000000400050b10060000080 001000015cb353abecb00120001deadbeef0003000000040004000100010002 diff --git a/nselib/xdmcp.lua b/nselib/xdmcp.lua index 12fa171aa..551b4bcd5 100644 --- a/nselib/xdmcp.lua +++ b/nselib/xdmcp.lua @@ -79,7 +79,7 @@ Packet = { local data = tostring(self.header) data = data .. bin.pack("C", #self.authnames) for _, name in ipairs(self.authnames) do - data = data .. bin.pack("P", name) + data = data .. bin.pack(">P", name) end return data end, diff --git a/scripts/citrix-enum-apps.nse b/scripts/citrix-enum-apps.nse index 400065cf8..1babf9a59 100644 --- a/scripts/citrix-enum-apps.nse +++ b/scripts/citrix-enum-apps.nse @@ -42,7 +42,7 @@ portrule = shortport.portnumber(1604, "udp") -- @return string row delimited with \n containing all published applications function process_pa_response(response) - local pos, packet_len = bin.unpack("SS", response) + local pos, packet_len = bin.unpack("I", packet.header.raw, DATA_LENGTH_OFFSET ) end @@ -270,7 +270,7 @@ function create_das_packet( magic, data ) .. "\x01\x04\x00\x00\x00\x10\x39\x7a\x00\x05\x00\x00\x00\x00\x00\x00" .. "\x00\x00\x00\x00" .. bin.pack("C", magic) - .. bin.pack("S", data_len) + .. bin.pack("I2", number_of_stations) .. station_list -- put them all together and return return ethernet_hdr .. demultiplex_hdr .. base_hdr .. discover_up_lev_hdr