Skip to content

Instantly share code, notes, and snippets.

@voteblake
Created February 18, 2021 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voteblake/04f5e8ab0c2305cb51376a4f3dd682fe to your computer and use it in GitHub Desktop.
Save voteblake/04f5e8ab0c2305cb51376a4f3dd682fe to your computer and use it in GitHub Desktop.
➜ Redpoint git:(master) ✗ git diff
diff --git a/codesys-v2-discover.nse b/codesys-v2-discover.nse
index f50e502..e3c73ef 100644
--- a/codesys-v2-discover.nse
+++ b/codesys-v2-discover.nse
@@ -56,9 +56,9 @@ end
-- @param port port that was scanned via nmap
action = function( host, port )
-- little endian query
- lile_query = bin.pack("H", "bbbb0100000001")
+ lile_query = string.pack("s16", "bbbb0100000001")
-- big endian query
- bige_query = bin.pack("H", "bbbb0100000101")
+ bige_query = string.pack("s16", "bbbb0100000101")
-- set up table for output
local output = stdnse.output_table()
-- create socket
@@ -106,16 +106,16 @@ action = function( host, port )
end
end
-- unpack first byte to see if it is 0xbb
- local pos, codesys_check = bin.unpack("C", response, 1)
+ local pos, codesys_check = string.unpack("I1", response, 1)
-- is first byte 0xbb?
if (codesys_check ~= 0xbb) then
sock:close()
return nil
end
- local pos, os_name = bin.unpack("z", response, 65)
- local pos , os_type = bin.unpack("z", response, 97)
- local pos, product_type = bin.unpack("z", response, 129)
+ local pos, os_name = string.unpack("z", response, 65)
+ local pos , os_type = string.unpack("z", response, 97)
+ local pos, product_type = string.unpack("z", response, 129)
-- close socket
sock:close()
-- set nmap port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment