forked from double-z/lab
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
two-spacing and refactoring to move esx -> esxi
- Loading branch information
Showing
26 changed files
with
1,845 additions
and
1,747 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
- vmid: backtrack | ||
driver: workstation | ||
location: /opt/vm/backtrack5/Backtrack5x64.vmx | ||
modifiers: | ||
- Test | ||
credentials: | ||
- user: root | ||
pass: toor | ||
os: linux | ||
flavor: ubuntu | ||
arch: 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- vmid: metasploitable | ||
driver: workstation | ||
location: /opt/vm/lab/user/Metasploitable/Metasploitable.vmx | ||
tools: false | ||
credentials: | ||
- user: msfadmin | ||
pass: msfadmin | ||
- vmid: windows2000_target | ||
driver: workstation | ||
location: /opt/vm/lab/vuln/msf_Win2000SP4/Windows 2000 AS.vmx | ||
tools: true | ||
credentials: | ||
- vmid: windowsxp_target | ||
driver: remote_workstation | ||
host: vmhost | ||
user: root | ||
location: /opt/vm/lab/vuln/msf_WinXPSP1/Windows XP Professional.vmx | ||
tools: true | ||
credentials: | ||
- user: administrator | ||
pass: administrator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This controller was built against: | ||
# VMware ESX Host Agent 4.1.0 build-348481 | ||
|
||
module Lab | ||
module Controllers | ||
module RemoteEsxiController | ||
|
||
# Note that 3.5 was different (vmware-vim-cmd) | ||
VIM_CMD = 'vim-cmd'.freeze | ||
|
||
def self.dir_list(basepath=nil) | ||
# Does this method really even make sense for esx? | ||
return "Unsupported :(" | ||
end | ||
|
||
def self.running_list(user, host) | ||
user.gsub!(/(\W)*/, '') | ||
host.gsub!(/(\W)*/, '') | ||
|
||
# first get all registered vms | ||
registered_vms = self.get_vms(user, host) || [] | ||
running_vms = [] | ||
|
||
# now let's see which ones are running | ||
# TODO: this is ghetto, would be better not to connect repeatedly | ||
registered_vms.each do |vm| | ||
remote_cmd = "ssh #{user}@#{host} \"#{VIM_CMD} vmsvc/power.getstate #{vm[:id]}\"" | ||
raw = `#{remote_cmd}` | ||
running_vms << vm if raw =~ /Powered on/ | ||
end | ||
|
||
return running_vms | ||
end | ||
|
||
private | ||
|
||
def self.get_vms(user, host) | ||
user.gsub!(/(\W)*/, '') | ||
host.gsub!(/(\W)*/, '') | ||
|
||
vms = [] # array of VM hashes | ||
remote_cmd = "ssh #{user}@#{host} \"#{VIM_CMD} vmsvc/getallvms | grep ^[0-9] | sed 's/[[:blank:]]\\{3,\\}/ /g'\"" | ||
raw = `#{remote_cmd}`.split("\n") | ||
|
||
raw.each do |line| | ||
# So effing ghetto | ||
id_and_name = line.split('[datastore').first | ||
id = id_and_name.split(' ').first | ||
|
||
## TODO - there's surely a better way to do this. | ||
name_array = id_and_name.split(' ') | ||
name_array.shift | ||
name = name_array.join(' ') | ||
vms << {:id => id, :name => name} | ||
end | ||
|
||
return vms | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.