@@ -66,11 +66,11 @@ def run
66
66
67
67
# Results table holds raw string data
68
68
results_table = Rex ::Ui ::Text ::Table . new (
69
- 'Header' => "Domain Computers" ,
70
- 'Indent' => 1 ,
71
- 'SortIndex' => -1 ,
72
- 'Columns' => fields
73
- )
69
+ 'Header' => "Domain Computers" ,
70
+ 'Indent' => 1 ,
71
+ 'SortIndex' => -1 ,
72
+ 'Columns' => fields
73
+ )
74
74
75
75
# Hostnames holds DNS Names to Resolve
76
76
hostnames = [ ]
@@ -81,40 +81,37 @@ def run
81
81
82
82
report = { }
83
83
0 . upto ( fields . length -1 ) do |i |
84
- if result [ i ] . nil?
85
- field = ""
86
- else
87
- field = result [ i ]
88
-
89
- # Only perform these actions if the database is connected and we want
90
- # to store in the DB.
91
- if db and datastore [ 'STORE_DB' ]
92
- case fields [ i ]
93
- when 'dNSHostName'
94
- dns = field
95
- report [ :name ] = dns
96
- hostnames << dns
97
- when 'operatingSystem'
98
- report [ :os_name ] = os
99
- when 'distinguishedName'
100
- if field =~ /Domain Controllers/i
101
- # TODO: Find another way to mark a host as being a domain controller
102
- # The 'purpose' field should be server, client, device, printer, etc
103
- # report[:purpose] = "DC"
104
- end
105
- when 'operatingSystemServicePack'
106
- # XXX: Does this take into account the leading 'SP' string?
107
-
108
- if field . to_i > 0
109
- report [ :os_sp ] = 'SP' + field
110
- end
111
- if field =~ /(Service Pack|SP)\s ?(\d +)/
112
- report [ :os_sp ] = 'SP' + $2
113
- end
114
-
115
- when 'description'
116
- report [ :info ] = field
84
+ field = result [ i ] || ""
85
+
86
+ # Only perform these actions if the database is connected and we want
87
+ # to store in the DB.
88
+ if db && datastore [ 'STORE_DB' ]
89
+ case fields [ i ]
90
+ when 'dNSHostName'
91
+ dns = field
92
+ report [ :name ] = dns
93
+ hostnames << dns
94
+ when 'operatingSystem'
95
+ report [ :os_name ] = field
96
+ when 'distinguishedName'
97
+ if field =~ /Domain Controllers/i
98
+ # TODO: Find another way to mark a host as being a domain controller
99
+ # The 'purpose' field should be server, client, device, printer, etc
100
+ #report[:purpose] = "DC"
101
+ report [ :purpose ] = "server"
117
102
end
103
+ when 'operatingSystemServicePack'
104
+ # XXX: Does this take into account the leading 'SP' string?
105
+
106
+ if field . to_i > 0
107
+ report [ :os_sp ] = 'SP' + field
108
+ end
109
+ if field =~ /(Service Pack|SP)\s ?(\d +)/
110
+ report [ :os_sp ] = 'SP' + $2
111
+ end
112
+
113
+ when 'description'
114
+ report [ :info ] = field
118
115
end
119
116
end
120
117
@@ -125,7 +122,7 @@ def run
125
122
results_table << row
126
123
end
127
124
128
- if db and datastore [ 'STORE_DB' ]
125
+ if db && datastore [ 'STORE_DB' ]
129
126
print_status ( "Resolving IP addresses..." )
130
127
ip_results = client . net . resolve . resolve_hosts ( hostnames , AF_INET )
131
128
0 commit comments