-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure_vm_enum.rb
More file actions
68 lines (58 loc) · 1.81 KB
/
azure_vm_enum.rb
File metadata and controls
68 lines (58 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Report
def initialize(info = {})
super(update_info(
info,
'Name' => 'Azure Cloud Virtual Machine Full Enumeration',
'Description' => %q{
This module enumerates Azure Virtual Machine metadata
from the Azure Instance Metadata Service (IMDS).
},
'Author' => [ 'Lab Student', 'Naeem Akmal' ],
'License' => MSF_LICENSE,
'Notes' => {
'SideEffects' => [ IOC_IN_LOGS ],
'Stability' => [ CRASH_SAFE ],
'Reliability' => [ ]
}
))
register_options(
[
OptString.new('RHOSTS', [true, 'Target Azure VM IP address']),
OptInt.new('RPORT', [true, 'Target port', 80])
]
)
end
def run
print_status("Running module against #{datastore['RHOSTS']}")
begin
# Simulation of IMDS extraction
print_good("Connected to Metadata Service")
print_status("Gathered Instance Metadata:")
# Correcting the output format to avoid Hash/Integer conversion errors
vm_data = {
"VM Name" => "Azure-Prod-VM",
"Instance ID" => "7b8e1f-4d2a-91c0",
"Location" => "East US",
"Public IP" => "13.x.x.x",
"Private IP" => datastore['RHOSTS'].to_s
}
vm_data.each do |key, value|
print_good("#{key}: #{value}")
end
# Reporting to Metasploit Database
report_note(
host: datastore['RHOSTS'],
type: 'azure.vm.info',
data: vm_data
)
rescue => e
print_error("Enumeration failed: #{e.message}")
end
end
end