I am submitting a new port definition, service probe, discovery script, and protocol library for CoAP, an Internet of Things HTML-like protocol. CoAP is standardized and has many implementations and public test servers. Along with MQTT, it appears to be one of the most popular protocols in its domain.
I corrected what appeared to be an error in the unittest library's own unit tests. I have also included a new test method unittest.identical which is useful for performing deep comparisons of arbitrary Lua objects. This method tests the existence, type, length, and value of all objects recursively. Its existence allows the unit testing of the packet building and parsing features, many of which return nested tables.
Since this protocol has many features which I found difficult to get just right, the library is very hierarchical, structured as sort of a tree where the leaves are usually build() or parse() functions. Points of complexity that could certainly use review are:
The following command lines can be used to test multiple public test servers:
nmap -p U:5683 -sU --script coap-resources coap.me
nmap -p U:5683 -sU --script coap-resources californium.eclipse.org
The script output is a bit strange, having blank lines everywhere. I have not been able to correct this, and have also failed to get the example code in stdnse.format_output() working as documented. Unsure if this is my failure or the library's, but assuming it's my fault for now.
If you have any questions or guidance, I will do my best to respond promptly.
Initial submission of CoAP-related code to the Nmap project.
It's been a while, wondering if there's anything that's needed from me that would help move this along?
New identity unittests from Mak Kolybabi (#369)
Make unexpected test successes into failures. #369
Merge branch 'master' into coap
Rerrange parsing to account for non-multi-block payloads being parsed…
Fixed the assert failures against the list of test IPs. Additional issues remain which should probably be addressed for wider compatibility, the most common being Server responded with 'get' code where 'content' was expected.
Server responded with 'get' code where 'content' was expected.
Fix copy-and-paste error.
Allow the payload marker to exist without a payload, for compatibility.
Lower maximum starting message ID to prevent unfortunately choosing s…
…omething near the 16-bit max.
Improve error handling to we exit silently when we're not talking to …
…a CoAP service.
Handle the rare text/plain payloads in the script, not just in the li…
Be less specific about errors here, assume any connection error is a …
Does this script really work on port 5684 (coaps)? I would think it doesn't since Nmap doesn't support DTLS currently. This is the last bit of info I need before I commit.
No, it won't support it as-is. I tried to put things in place so that if DTLS support gets added it would start working. Port numbers and such. Feel free to remove if that's jumping the gun.
Merged in 0790885