Show HN: Embed runnable code snippets on your website
amasad.me
amasad.me
You may want to disable shell execution.
# spawn a poor man's shell from repl
require 'Open3'
Open3.popen3("/bin/sh -i") do |stdin,stdout,stderr,wthr|
loop do
ready = select([$stdin, stdout, stderr], nil, nil, 10)
if ready
ready[0].each do |f|
buf = ""
begin
while d = f.read_nonblock(1024)
buf += d
end
rescue Errno::EAGAIN
end
case f
when $stdin
stdin.write(buf)
when stdout,stderr
$stdout.write(buf)
end
end
end
end
end
This lets you explore the environment a bit more. I haven't figured out anything do to with it yet. :)edit: I did find a kernel arbitrary code execution exploit PoC for the kernel version you're running but I decided against trying it out because I didn't want to crash your docker host.
You can do it by hitting my link above, running the saved code, which defines a 'sh' function, then running the 'sh' function from the repl. That will give you a shell, which you can then 'su' in. It doesn't give you a prompt back because that first shell is non-interactive, but if you run 'sh -i' from there you'll get your # prompt.
I told you it wasn't all that clever. :)
edit: great site, by the way. i love the concept and my hat is off to you for letting people run wild. The front-end execution is nice, too.
BTW, I ran into a limit on the size of a script I could save, and I recommend keeping that, as it prevented me from easily uploading a gcc executable by statically declaring GCC="\x7FELF\x02\x01\x01\x00\x00\x00\x00..." and then writing it to a file. It can still be done, but it's a pain in the ass.