DSL Tips and Tricks :: commands from web



Hello,

I found a nice way to send Linux commands to the system from the web :
The monkey web server must be running
copy/paste the first file in /opt/monkey/htdocs give the name: command.html
copy/paste the second file in /opt/monkey/cgi-in/ give the name: command.lua
from a naviguator go to your.dsl.ip.box/command.html
All commands are not working because of some caracters like / or | or .. but you can have the output of :
ls, pwd, ps aux, mount, cat file, etc..

Of course take care of your security : don't use outside your local network...

FIRST FILE BEGIN ===============
<HTML>
<FORM action="/cgi-bin/command.lua" method="get">
<P>
<LABEL>COMMAND:</LABEL>
<INPUT type="text" name="Command"><BR>
<INPUT type="submit" value="GO">
</P>
</FORM>
</HTML>
FIRST FILE END ================

SECOND FILE BEGIN ===============
#!/bin/lua
dofile("/opt/monkey-0.9.2/cgi-bin/cgi.lua")

print("Content-type: text/plain\n\n")
vars=(CGI.vars(CGI.content()))

io.write("\n=============COMMAND START===================\n")
local f = io.popen(vars.Command)
local l = f:read("*a")
print(l)
f:close()
io.write("=============COMMAND END===================\n")

SECOND FILE END ================

Have fun!
--
Jmp0


original here.