summaryrefslogtreecommitdiff
path: root/example/script/protocol_recognition.lua
blob: 2089d982b392f24ecc2e214e7d7749c77c70b600 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
local str = TSG.data;
local len = string.len(str)
local thread_id = string.byte(str, -1)
local info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:str:%s, str_len:%d", thread_id, str, len - 1)
print(info)
local ret = "unrecognition."
local index, _ = string.find(str, "tcp")
if index then
    ret = "tcp"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "udp")
if index then
    ret = "udp"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "ssh")
if index then
    ret = "ssh"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "vnc")
if index then
    ret = "vnc"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "sock")
if index then
    ret = "sock"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "quic")
if index then
    ret = "quic"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "pop3")
if index then
    ret = "pop3"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "smpt")
if index then
    ret = "smpt"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "imap")
if index then
    ret = "imap"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
index, _ = string.find(str, "http")
if index then
    ret = "http"
    info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
    print(info)
    return string.len(ret), ret
end
info = string.format("[lua][thread_id:%d][protocol_recognition.lua]:return str_len:%d, str:%s", thread_id, string.len(ret), ret)
print(info)
return string.len(ret), ret