Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure at vagrant up - ElasticSearch/WinRM #63

Closed
binaryAccess opened this issue Dec 11, 2016 · 7 comments
Closed

Failure at vagrant up - ElasticSearch/WinRM #63

binaryAccess opened this issue Dec 11, 2016 · 7 comments

Comments

@binaryAccess
Copy link

Issue Description

Failure occurred after executing vagrant up

Host System

  • OS: Linux kali 4.7.0-kali1-amd64 Add JMX vuln to Metasploitable3 #1 SMP Debian 4.7.8-1kali1 (2016-10-24) x86_64 GNU/Linux
  • Packer Version: 0.12.0
  • Vagrant Version: 1.9.1
  • VirtualBox Version: 5.1.10

Command Output

==> default: The service 'elasticsearch-service-x64' has been installed.
==> default:
==> default: C:\Windows\system32>sc config "elasticsearch-service-x64" start= auto
==> default:
==> default: [SC] ChangeServiceConfig SUCCESS
==> default: C:\Windows\system32>cmd /c ""C:\Program Files\elasticsearch-1.1.1\bin\service.bat" start"
==> default: The service 'elasticsearch-service-x64' has been started
==> default:
==> default: C:\Windows\system32>powershell -Command "Start-Sleep -s 5"
==> default: C:\Windows\system32>powershell -Command "$req = [System.Net.HttpWebRequest]::Create('http://localhost:9200/metasploitable3/'); $req.method = 'PUT'; $req.GetResponse()"
==> default: Exception calling "GetResponse" with "0" argument(s): "Unable to connect to the
==> default:
==> default: remote server"
==> default: At line:1 char:124
==> default: + $req = [System.Net.HttpWebRequest]::Create('http://localhost:9200/metasploita
==> default: ble3/'); $req.method = 'PUT'; $req.GetResponse <<<< ()
==> default: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
==> default: + FullyQualifiedErrorId : DotNetMethodException
==> default:
==> default: C:\Windows\system32>powershell -Command "$body = [System.Text.Encoding]::ASCII.GetBytes('{"user":"kimchy", "post_date": "2009-11-15T14:12:12", "message": "Elasticsearch" }'); $req = [System.Net.HttpWebRequest]::Create('http://localhost:9200/metasploitable3/message/1'); $req.method = 'PUT'; $req.ContentType = 'application/x-www-form-urlencoded'; $stream = $req.GetRequestStream(); $stream.Write($body, 0, $body.Length); $stream.close(); $req.GetResponse()"
==> default: Exception calling "GetRequestStream" with "0" argument(s): "Unable to connect t
==> default:
==> default: o the remote server"
==> default: At line:1 char:338
==> default: + $body = [System.Text.Encoding]::ASCII.GetBytes('{"user":"kimchy", "post_date"
==> default: : "2009-11-15T14:12:12", "message": "Elasticsearch" }'); $req = [System.Net.Htt
==> default:
==> default: pWebRequest]::Create('http://localhost:9200/metasploitable3/message/1'); $req.m
==> default: ethod = 'PUT'; $req.ContentType = 'application/x-www-form-urlencoded'; $stream
==> default: = $req.GetRequestStream <<<< (); $stream.Write($body, 0, $body.Length); $stream
==> default:
==> default: .close(); $req.GetResponse()
==> default: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
==> default: + FullyQualifiedErrorId : DotNetMethodException
==> default:
==> default: You cannot call a method on a null-valued expression.
==> default: At line:1 char:355
==> default: + $body = [System.Text.Encoding]::ASCII.GetBytes('{"user":"kimchy", "post_date"
==> default: : "2009-11-15T14:12:12", "message": "Elasticsearch" }'); $req = [System.Net.Htt
==> default: pWebRequest]::Create('http://localhost:9200/metasploitable3/message/1'); $req.m
==> default:
==> default: ethod = 'PUT'; $req.ContentType = 'application/x-www-form-urlencoded'; $stream
==> default: = $req.GetRequestStream(); $stream.Write <<<< ($body, 0, $body.Length); $stream
==> default: .close(); $req.GetResponse()
==> default:
==> default: + CategoryInfo : InvalidOperation: (Write:String) [], RuntimeExce
==> default: ption
==> default: + FullyQualifiedErrorId : InvokeMethodOnNull
==> default:
==> default: You cannot call a method on a null-valued expression.
==> default: At line:1 char:394
==> default: + $body = [System.Text.Encoding]::ASCII.GetBytes('{"user":"kimchy", "post_date"
==> default: : "2009-11-15T14:12:12", "message": "Elasticsearch" }'); $req = [System.Net.Htt
==> default: pWebRequest]::Create('http://localhost:9200/metasploitable3/message/1'); $req.m
==> default:
==> default: ethod = 'PUT'; $req.ContentType = 'application/x-www-form-urlencoded'; $stream
==> default: = $req.GetRequestStream(); $stream.Write($body, 0, $body.Length); $stream.close
==> default: <<<< (); $req.GetResponse()
==> default: + CategoryInfo : InvalidOperation: (close:String) [], RuntimeExce
==> default: ption
==> default:
==> default: + FullyQualifiedErrorId : InvokeMethodOnNull
==> default:
==> default: Exception calling "GetResponse" with "0" argument(s): "Unable to connect to the
==> default: remote server"
==> default: At line:1 char:414
==> default: + $body = [System.Text.Encoding]::ASCII.GetBytes('{"user":"kimchy", "post_date"
==> default: : "2009-11-15T14:12:12", "message": "Elasticsearch" }'); $req = [System.Net.Htt
==> default: pWebRequest]::Create('http://localhost:9200/metasploitable3/message/1'); $req.m
==> default: ethod = 'PUT'; $req.ContentType = 'application/x-www-form-urlencoded'; $stream
==> default: = $req.GetRequestStream(); $stream.Write($body, 0, $body.Length); $stream.close
==> default: (); $req.GetResponse <<<< ()
==> default: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
==> default: + FullyQualifiedErrorId : DotNetMethodException
==> default:
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

c:\tmp\vagrant-shell.bat

Stdout from the command:

Stderr from the command:

@jbarnett-r7
Copy link
Contributor

Are you still having problems with the build? We've pushed a few fixes recently that may have resolved it.

@jikuja
Copy link
Contributor

jikuja commented Feb 25, 2017

I'm getting same. Using

  • Current master: ef8fed0
  • OS: Debian testing
  • Packer: v0.10.2
  • Vagrant: 1.9.1
  • Virtualbox: 5.1.14

Full log for vagrant up https://gist.githubusercontent.com/anonymous/8bdcc2621d9f49869b1c002f59d444ce/raw/2408ba6093a20231a759560db58954f87f1bc64f/elastic.log Seems to be identical with this and #73.

@a-garcia
Copy link
Contributor

Hi everyone,

I changed the sleep time from 5 to 30 seconds within the metasploitable3\scripts\installs\install_elasticsearch.bat file. I believe that the original 5 seconds is not enough time for some machines to start elasticsearch and run a successful GetResponse().

The specific line that I changed in metasploitable3\scripts\installs\install_elasticsearch.bat file was from this:
powershell -Command "Start-Sleep -s 5"

to this:
powershell -Command "Start-Sleep -s 30"

This is the first time I have ever commented on anything on GitHub, so hopefully this helps with this specific problem.

This is what I am currently using, just in case anyone is wondering.
Packer: 0.12.2
Vagrant: 1.9.1
Virtualbox: 5.1.14

@jikuja
Copy link
Contributor

jikuja commented Feb 26, 2017

Thanks. That fixed the problem.

@jbarnett-r7
Copy link
Contributor

Nice fix, @a-garcia. Definitely sounds like that timer should be increased to have better support for more systems. Would you mind submitting a PR with the change?

@jikuja
Copy link
Contributor

jikuja commented Feb 27, 2017

How much is enough for waiting time? Should it poll service until it's running and returning 200 for requests?

@a-garcia
Copy link
Contributor

@jbarnett-r7, I have attempted to submit the PR, please let me know if you don't see it. I haven't worked on a project in awhile so my git skills are a little rusty. Just kind of started tinkering with metasploitable :).

@jikuja, that sounds like an efficient way of solving that issue. A blanket time frame may not be the most optimal solution. How about a try catch? An issue I see is if for some reason the service does not start for some reason, does the polling functionality eventually stop? I think either way there might have to be some kind of timing mechanism for the given scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants