运行 meterpreter 时 ruby 脚本出错
我喜欢这个网站,它通过其他人的问题帮助了我很多,现在我加入了,所以如果可以的话我可以互相帮助。
我这里有个问题。 在虚拟机中运行 meterpreter(来自 Metasploit 套件)时,我尝试了一个脚本来中继受感染计算机中的所有端口,并在本地计算机中创建虚拟接口。但我收到错误
未定义的方法:每个
。
在查看代码时:
def discovery()
ip_port = []
# Alive hosts discovery
temphosts = []
hosts = []
## oldstdout = $stdout ## Trick for capturing stdout
$stdout = StringIO.new
client.run_cmd('run landiscovery')
temphosts = $stdout.string
$stdout = oldstdout
print_status "Alive Hosts:"
temphosts.each do |x|
if x.match(/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)
y = x.chomp
hosts << y
print " - #{y}\n"
end
end
end
我认为它与我用 ##
包围的行有某种关系。它必须是 nil,所以 temphosts 也是 nil,我收到每个错误。
有人能给我指出一个好的方向吗?
非常感谢。
PS:如果有人感兴趣的话,脚本在这里: http://tools.pentester.es/multirelay
再次感谢!
I love this website, it has helped me a lot through other people's questions, now I have joined so I can help each others if I can.
I have an issue here.
While running meterpreter (from metasploit suite) in a VM, I have tried a script that relays all the ports in the compromised machine and creates a virtual interface in your local machine. But I'm getting the error
Undefined method: each
.
While going to the code:
def discovery()
ip_port = []
# Alive hosts discovery
temphosts = []
hosts = []
## oldstdout = $stdout ## Trick for capturing stdout
$stdout = StringIO.new
client.run_cmd('run landiscovery')
temphosts = $stdout.string
$stdout = oldstdout
print_status "Alive Hosts:"
temphosts.each do |x|
if x.match(/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)
y = x.chomp
hosts << y
print " - #{y}\n"
end
end
end
I think it is somehow related to the line I have surrounded with ##
. It has to be nil
so temphosts
is nil
too and I get the each error.
Can someone point me in a good direction?
Thanks greatly appreciated.
PS: The scripts if someone is interested are in here: http://tools.pentester.es/multirelay
Thanks again!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该行将返回一个 String 对象,其中包含输出的所有行,其中包括 \n 字符。
字符串对象没有任何each 方法。
也许您想获取一个字符串列表,表示输出的行列表。在这种情况下,您应该首先拆分字符串:
This line will return a single String object, containing all the lines of your output, with \n characters included.
String objects do not have any each method.
Maybe you wanted to get a list of Strings, representing the list of lines of your output. In this case, you should first split your String: