-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathminecraft.nse
51 lines (38 loc) · 998 Bytes
/
minecraft.nse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- Minecraft Server Probe
description = [[
Checks for Minecraft Servers using the 0x02 "Handshake" protocol
]]
---
-- @output
-- Host script results:
-- |_ minecraft: Minecraft Server!
author = "cbock"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"safe"}
require "stdnse"
require "shortport"
portrule = shortport.port_or_service(25565, "minecraft")
action = function(host, port)
local socket, result, try, catch, status
result=""
status=true
socket = nmap.new_socket()
socket:set_timeout(1000)
catch = function()
socket:close()
end
try=nmap.new_try(catch)
try(socket:connect(host, port))
try(socket:send("\002\000\001\0000"))
status, result = socket:receive_bytes(16);
if (not status) then
socket:close()
return "Not a Minecraft Server"
end
if (result == "TIMEOUT") then
socket:close()
return "Not a Minecraft Server"
end
socket:close()
return "Minecraft Server!", result
end