diff options
| author | pengxuanzheng <[email protected]> | 2020-08-24 17:10:55 +0800 |
|---|---|---|
| committer | pengxuanzheng <[email protected]> | 2020-08-24 17:10:55 +0800 |
| commit | 503f4af4d8514913eb2ad0405b557abfd4326976 (patch) | |
| tree | 5dd4f67e39f543c1cb1e2048eae0c0f720691c58 /example/script | |
Initial commit
Diffstat (limited to 'example/script')
| -rw-r--r-- | example/script/count_1.lua | 16 | ||||
| -rw-r--r-- | example/script/find_1.lua | 13 | ||||
| -rw-r--r-- | example/script/find_1.luajit | bin | 0 -> 267 bytes | |||
| -rw-r--r-- | example/script/find_1_b.lua | bin | 0 -> 371 bytes | |||
| -rw-r--r-- | example/script/find_hello.lua | 8 | ||||
| -rw-r--r-- | example/script/find_hello.luajit | bin | 0 -> 324 bytes | |||
| -rw-r--r-- | example/script/match_12345.lua | 24 | ||||
| -rw-r--r-- | example/script/print_hello.lua | 5 | ||||
| -rw-r--r-- | example/script/print_hello.luajit | bin | 0 -> 124 bytes | |||
| -rw-r--r-- | example/script/protocol_recognition.lua | 79 |
10 files changed, 145 insertions, 0 deletions
diff --git a/example/script/count_1.lua b/example/script/count_1.lua new file mode 100644 index 0000000..21e5091 --- /dev/null +++ b/example/script/count_1.lua @@ -0,0 +1,16 @@ +local str = tsg.data +local len = string.len(str) +local thread_id = string.byte(str, len) +local str = string.format("[lua][thread_id:%d][count_1.lua]:str:%s, len:%d", thread_id, str, len - 1) +print(str) +local cnt = 0 +local i = 0 +for i = 0, len - 1 do + --print(i, string.byte(str, i), cnt) + if string.byte(str, i) == 1 then + cnt = cnt + 1 + end +end +str = string.format("[lua][thread_id:%d][count_1.lua]:return %d, %s", thread_id, 8, cnt) +print(str) +return 8, cnt diff --git a/example/script/find_1.lua b/example/script/find_1.lua new file mode 100644 index 0000000..2c6e865 --- /dev/null +++ b/example/script/find_1.lua @@ -0,0 +1,13 @@ +local data = tsg.data +local data_len = string.len(data) +local str = string.format("[lua]:data:%s len:%d", data, data_len) +print(str) +for i = 1, data_len do + if string.byte(data, i) == 1 then + str = string.format("[lua]:return %d, %d", 8, i) + print(str); + return 8, i + end +end +return 1, true + diff --git a/example/script/find_1.luajit b/example/script/find_1.luajit Binary files differnew file mode 100644 index 0000000..b558ed1 --- /dev/null +++ b/example/script/find_1.luajit diff --git a/example/script/find_1_b.lua b/example/script/find_1_b.lua Binary files differnew file mode 100644 index 0000000..d04801f --- /dev/null +++ b/example/script/find_1_b.lua diff --git a/example/script/find_hello.lua b/example/script/find_hello.lua new file mode 100644 index 0000000..89037c0 --- /dev/null +++ b/example/script/find_hello.lua @@ -0,0 +1,8 @@ +local ss = tsg.data +print("[lua]:the parameter of lua function is '"..ss.."'") +print("[lua]:start find 'hello'...") +local index_s, index_e = string.find(ss, 'hello') +local str = 'find!' +print("[lua]:result, start at", index_s, ", end at",index_e) +print("[lua]: return ", string.len(str), str) +return string.len(str), str diff --git a/example/script/find_hello.luajit b/example/script/find_hello.luajit Binary files differnew file mode 100644 index 0000000..ba644ec --- /dev/null +++ b/example/script/find_hello.luajit diff --git a/example/script/match_12345.lua b/example/script/match_12345.lua new file mode 100644 index 0000000..c795bd3 --- /dev/null +++ b/example/script/match_12345.lua @@ -0,0 +1,24 @@ +local str = tsg.data +local len = string.len(str) +local thread_id = string.byte(str, len) +local str = string.format("[lua][thread_id:%d][match_12345.lua]:str:%s, len:%d", thread_id, str, len - 1) +print(str) +local i = 0 +for i = 1, string.len(str) do + if string.byte(str, i) == 1 then + if string.byte(str, i + 1) == 2 then + if string.byte(str, i + 2) == 3 then + if string.byte(str, i + 3) == 4 then + if string.byte(str, i + 4) == 5 then + local str = string.format("[lua][thread_id:%d][match_12345.lua]:return %d, %s", thread_id, 1, "true") + print(str) + return 1, true + end + end + end + end + end +end +local str = string.format("[lua][thread_id:%d][match_12345.lua]:return %d, %s", thread_id, 1, "false") +print(str) +return 1, false diff --git a/example/script/print_hello.lua b/example/script/print_hello.lua new file mode 100644 index 0000000..ee823e7 --- /dev/null +++ b/example/script/print_hello.lua @@ -0,0 +1,5 @@ +local str = tsg.data +print("-----------") +print("str") +print("-----------") +return string.len(str), str diff --git a/example/script/print_hello.luajit b/example/script/print_hello.luajit Binary files differnew file mode 100644 index 0000000..c9eb05b --- /dev/null +++ b/example/script/print_hello.luajit diff --git a/example/script/protocol_recognition.lua b/example/script/protocol_recognition.lua new file mode 100644 index 0000000..0987232 --- /dev/null +++ b/example/script/protocol_recognition.lua @@ -0,0 +1,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 |
