运行 meterpreter 时 ruby​​ 脚本出错

发布于 2024-11-01 07:06:55 字数 937 浏览 2 评论 0原文

我喜欢这个网站,它通过其他人的问题帮助了我很多,现在我加入了,所以如果可以的话我可以互相帮助。

我这里有个问题。 在虚拟机中运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆光下的微笑 2024-11-08 07:06:55
$stdout.string

该行将返回一个 String 对象,其中包含输出的所有行,其中包括 \n 字符。
字符串对象没有任何each 方法。

也许您想获取一个字符串列表,表示输出的行列表。在这种情况下,您应该首先拆分字符串:

temphosts.split("\n").each do |x|
$stdout.string

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:

temphosts.split("\n").each do |x|
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文