Last active
March 8, 2020 09:37
-
-
Save nickfox-taterli/54ec3c659ee1cbfcc077cefb3db16958 to your computer and use it in GitHub Desktop.
vmess ws 检测脚本(配合nmap)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 只扫原生WS,不要太恐慌. | |
local stdnse = require "stdnse" | |
local http = require "http" | |
categories = { "default", "discovery", "safe" } | |
portrule = function(host, port) | |
return true | |
end | |
action = function(host, port) | |
local status, err, response | |
local socket = nmap.new_socket() | |
socket:connect(host.ip, port) | |
status, err = socket:send("GET / HTTP/1.1\r\n" .. | |
"Upgrade: websocket\r\n" .. | |
"User-Agent: Go-http-client/1.1\r\n" .. | |
"Host: " .. stdnse.get_hostname(host) .. "\r\n" .. | |
"Connection: Upgrade\r\n" .. | |
"Sec-WebSocket-Key: TY1n4XlyfRO8xsIl5G3ItA==\r\n" .. | |
"Sec-WebSocket-Version: 13\r\n\r\n") | |
status, response = socket:receive_bytes(0) | |
if response:find("BG6gqUP5dsX94TVCHFvaqKywM6c=") and response:find("HTTP/1.1 101 Switching Protocols") and response:find("Server") == nil then | |
answer = http.get(host.ip, port, "/", { bypass_cache = true }) | |
if answer.status == 400 and tonumber(answer.header["content-length"]) == 12 and answer.header["server"] == nil then | |
return 'vmess detect(url correct!)' | |
end | |
elseif response:find("HTTP/1.1 404 Not Found") then | |
answer = http.get(host.ip, port, "/", { bypass_cache = true }) | |
if answer.status == 404 and tonumber(answer.header["content-length"]) == 0 and answer.header["server"] == nil then | |
return 'vmess detect(url incorrect!)' | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment