Skip to content

Commit e9e4e9b

Browse files
committed
Updated elasticsearch.rb
1 parent f9ce6cc commit e9e4e9b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

chef/cookbooks/metasploitable/recipes/elasticsearch.rb

100644100755
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#
55
# Copyright:: 2017, The Authors, All Rights Reserved.
66

7-
include_recipe 'metasploitable::7zip'
8-
include_recipe 'metasploitable::jdk8'
9-
107
powershell_script 'Download ElasticSearch' do
118
code '(New-Object System.Net.WebClient).DownloadFile(\'http://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/1.1.1/elasticsearch-1.1.1.zip\', \'C:\Windows\Temp\elasticsearch-1.1.1.zip\')'
129
end
@@ -18,6 +15,7 @@
1815

1916
execute 'Install ElasticSearch' do
2017
command '"C:\Program Files\elasticsearch-1.1.1\bin\service.bat" install'
18+
environment ({"JAVA_HOME" => "C:\\Program Files\\Java\\jdk1.8.0_144"})
2119
action :run
2220
end
2321

@@ -39,11 +37,18 @@
3937
action :start
4038
end
4139

40+
powershell_script 'Sleep 5 secs' do
41+
code 'Start-Sleep -s 5'
42+
end
43+
4244
powershell_script 'Test response' do
43-
code '$req = [System.Net.HttpWebRequest]::Create(\'http://localhost:9200/metasploitable3/\'); $req.method = \'PUT\'; $req.GetResponse()'
45+
code "$req = [System.Net.HttpWebRequest]::Create('http://localhost:9200/metasploitable3/'); $req.method = 'PUT'; $req.GetResponse()"
4446
end
4547

46-
powershell_script 'Test' do
47-
code '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()"'
48+
powershell_script 'Sleep 5 secs' do
49+
code 'Start-Sleep -s 5'
4850
end
4951

52+
powershell_script 'Test' do
53+
code "$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()"
54+
end

0 commit comments

Comments
 (0)