–Linux1.6(修复bug)
e={}–储存变量的环境
pt=”lua”–平台
–定义文件储存
files={user={}}
–定义工作目录
work=’files.user’
–定义系统最高权限
root=false
–定义储存网络
net_code={}
–定义一个执行代码的函数
function runcode(code)
if pt==”mini”
then
f,e=LoadLuaScript(code)
elseif pt==”lua”
then
f,e=load(code)
end
return f()
end
–定义网络模块
function curl(http)
if net_code[http] ~= nil
then
print(net_code[http])
else
print(“Not Found “..http)
end
end
function server(http,code)
if net_code[http] == nil
then
net_code[http]=code
else
print(http..” site has been created”)
end
end
–定义根
function su()
if root==false
then
root=true
print(“The highest privilege of the system has been opened”)
else
root=false
print(“The highest privilege of the system is turned off”)
end
end
–定义文件函数
function pwd()
print(string.gsub(work,”%.”,”/”))
end
function mkdir(name)
if root==true
then
c=runcode(work..”[‘”..name..”‘]”..”=”..[=[{}]=])
else
print(“Insufficient permissions”)
end
end
function rm(name)
if root==true
then
c=runcode(work..'[“‘..name..'”]’..”=”..”nil”)
else
print(“Insufficient permissions”)
end
end
function echo(text)
print(text)
end
function ls()
co=runcode(“co=”..work..[[
return co]])
for i,j in pairs(co)
do
print(i)
end
end
function help()
print([[help –帮助
rm $name –删除文件
mkdir $name –创建文件夹
cd $path –改变工作目录
touch $name –创建文件
write_file $name $text –写入文件
ls –查看文件
cat $name –读取文件
echo $text –打印
uname –查看系统
pwd –查看当前运行路径
$name=$value –定义变量
$$name –调用变量
server $url $text –搭建网站可以用curl访问(只能在脚本里)
curl $url –访问网站
su –获取最高权限,第1次是获取,第2次是取消
source $name –执行文件]])
end
function touch(name)
if root==true
then
c=runcode(work..”[‘”..name..”‘]”..”=”..[=[“”]=])
else
print(“Insufficient permissions”)
end
end
function cat(name)
c=runcode(“print(“..work..'[“‘..name..'”]’..”)”)
end
function uname()
print(“Linux”)
end
function cd(path)
if root==true
then
work=path
else
print(“Insufficient permissions”)
end
end
function write_file(name,text)
if root==true
then
c=runcode(work..”[‘”..name..”‘]”..”=”..”[=[“..text..”]=]”)
else
print(“Insufficient permissions”)
end
end
function system(code)
if string.find(code,”%$”)
then
a,b=string.find(code,”%$”)
code=string.sub(code,1,b-1)..runcode(“return “..”e[‘”..string.sub(code,b+1)..”‘]”)
end
if string.find(code,”echo “)
then
a,b=string.find(code,”echo “)
echo(string.sub(code,b+1))
elseif string.find(code,”cat”)
then
a,b=string.find(code,”cat “)
cat(string.sub(code,b+1))
elseif string.find(code,”mkdir”)
then
a,b=string.find(code,”mkdir “)
mkdir(string.sub(code,b+1))
elseif string.find(code,”touch”)
then
a,b=string.find(code,”touch “)
touch(string.sub(code,b+1))
elseif string.find(code,”write_file “)
then
a,b=string.find(code,”write_file “)
k=string.sub(code,b+1)
l,l2=string.find(k,” “)
k2=string.sub(k,1,l-1)
k3=string.sub(k,l2+1)
write_file(k2,k3)
elseif string.find(code,”rm “)
then
a,b=string.find(code,”rm “)
rm(string.sub(code,b+1))
elseif string.find(code,”cd “)
then
a,b=string.find(code,”cd “)
cd(string.sub(code,b+1))
elseif string.find(code,”ls”)
then
ls()
elseif string.find(code,”help”)
then
help()
elseif string.find(code,”uname”)
then
uname()
elseif string.find(code,”pwd”)
then
pwd()
elseif string.find(code,”=”)
then
a,b=string.find(code,”=”)
co=runcode(“e[‘”..string.sub(code,1,b-1)..”‘]=”..string.sub(code,b+1))
elseif string.find(code,”curl “)
then
a,b=string.find(code,”curl “)
curl(string.sub(code,b+1))
elseif string.find(code,”server “)
then
a,b=string.find(code,”server “)
k=string.sub(code,b+1)
l,l2=string.find(k,” “)
k2=string.sub(k,1,l-1)
k3=string.sub(k,l2+1)
server(k2,k3)
elseif string.find(code,”su”)
then
su()
elseif string.find(code,”source “)
then
a,b=string.find(code,”source “)
n=string.sub(code,b+1)
co=runcode(“return “..work..”[‘”..n..”‘]”)
local multiLineString=string.gsub(co,”`”,””)
local lines = {}
for line in multiLineString:gmatch(“[^\r\n]+”) do
table.insert(lines, line)
end
for i, line in ipairs(lines) do
system(line)
end
end
end
暂无评论内容