Advertisement
makispaiktis

Lua 1 - Print a message in case of open port

Nov 9th, 2024 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | Cybersecurity | 0 0
  1. -- 1. HEAD  (META INFORMATION)
  2. local nmap = require "nmap"
  3. local shortport = require "shortport"
  4. description =[[
  5.   My first ever script in Lua!
  6. ]]
  7. author = "boufik"
  8. license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
  9. categories = {"safe"}
  10.  
  11.  
  12.  
  13. -- 2. RULE
  14. portrule = function(host, port)
  15.     local port_to_check = {number = 4000, protocol = "tcp" }
  16.     local port_state = nmap.get_port_state(host, port_to_check)
  17.     return port_state ~= nil and port_state.state == "open"
  18. end
  19.  
  20.  
  21.  
  22. -- 3. ACTION
  23. action = function(host, port)
  24.     return "This message will be printed in case port 4000 is open"
  25. end
  26.  
  27. -- Bash Run: nmap --script my-script-name localhost
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement