Interwebs O Trash - IoT Hacking Stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dissector.lua 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. -- protocol dissector for EcoPlugs protocol
  2. -- declare our protocol
  3. eocProt = Proto("EP","EcoPlugs IoT")
  4. -- create a function to dissect it
  5. function eocProt.dissector(buffer,pinfo,tree)
  6. pinfo.cols.protocol = "EP"
  7. local protocolTree = tree:add(eocProt, buffer(), "EcoPlugs Protocol Data")
  8. if buffer:len() == 408 then
  9. -- this is a broadcast packet response
  10. protocolTree:add(buffer(4,6), "Version: " .. buffer(4,6):stringz())
  11. protocolTree:add(buffer(10,32), "ID: " .. buffer(10,32):stringz())
  12. protocolTree:add(buffer(42,32), "Name: " .. buffer(42,32):stringz())
  13. protocolTree:add(buffer(74,32), "Short ID: ".. buffer(74,32):stringz())
  14. protocolTree:add(buffer(106,14), "Time: " .. buffer(106,14))
  15. protocolTree:add(buffer(252,8), "Region: " .. buffer(252,8):stringz())
  16. protocolTree:add(buffer(260,5), "Zip Code: " .. buffer(260,5):stringz())
  17. ipl = protocolTree:add(buffer(272,48), "Cloud IP Addresses")
  18. ipl:add(buffer(272,16), "Cloud IP 1: " .. buffer(272,16):stringz())
  19. ipl:add(buffer(288,16), "Cloud IP 2: " .. buffer(288,16):stringz())
  20. ipl:add(buffer(304,16), "Cloud IP 3: " .. buffer(304,16):stringz())
  21. protocolTree:add(buffer(368,18), "Device MAC Address: " .. buffer(368,18):stringz())
  22. protocolTree:add(buffer(386,18), "Host: " .. buffer(386,18):stringz())
  23. else
  24. -- this is a query/set command
  25. protocolTree:add(buffer(0,6), "Command: " .. buffer(0,6))
  26. protocolTree:add(buffer(6,4), "Model: " .. buffer(6,4))
  27. protocolTree:add(buffer(10,6), "Version: " .. buffer(10,6):stringz())
  28. protocolTree:add(buffer(16,32), "ID: " .. buffer(16,32):stringz())
  29. protocolTree:add(buffer(48,32), "Name: " .. buffer(48,32):stringz())
  30. protocolTree:add(buffer(80,32), "Short ID: ".. buffer(80,32):stringz())
  31. -- set command here
  32. if buffer:len() == 130 then
  33. protocolTree:add(buffer(128,2), "Set Mode: " .. buffer(128,2))
  34. end
  35. end
  36. end
  37. -- load the udp.port table
  38. udp_table = DissectorTable.get("udp.port")
  39. -- register our protocol to handle udp port 25 and if I could, dest ports of 31423
  40. udp_table:add(25, eocProt)