@@ -93,6 +93,8 @@ def get_inventory_data(ws, **kwargs):
93
93
ip = row [0 ].value ,
94
94
name = row [1 ].value ,
95
95
color = (copy (row [0 ].fill ), copy (row [0 ].font )),
96
+ mac_address = "" ,
97
+ vendor = ""
96
98
)
97
99
return inventory
98
100
@@ -262,14 +264,17 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
262
264
* DHCP Broadcasting
263
265
* Multicast
264
266
* Within Segments identified
265
- * Within Inventory, not within an Identified Segment
267
+ * Resolution by DNS, then Inventory, and then Unknown
268
+ * Appends name if External IP
266
269
* Private Network
270
+ * Resolution by DNS, Inventory, then Unknown
267
271
* External (Public IP space) or Internet
272
+ * Resolution by DNS, Unknown
268
273
269
274
This will capture the name description and the color coding identified within the worksheet.
270
275
"""
271
276
segment_ips = [segment .network for segment in segments ]
272
- desc_to_change = ("Unknown IP Address " , IPV6_CELL_COLOR )
277
+ desc_to_change = ("Not Triggered IP " , IPV6_CELL_COLOR )
273
278
if ip_to_check == str ("0.0.0.0" ):
274
279
desc_to_change = (
275
280
"Unassigned IPv4" ,
@@ -288,39 +293,42 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
288
293
IPV6_CELL_COLOR ,
289
294
)
290
295
elif ip_to_check in segment_ips :
291
- for segment in segments [:- 1 ]:
292
- if ip_to_check not in segment .network :
293
- continue
294
- elif ip_to_check in dns_data :
295
- desc_to_change = (dns_data [ip_to_check ] , segment .color )
296
- elif ip_to_check in inventory :
297
- desc_to_change = (inventory [ip_to_check ].name , segment .color )
298
- else :
296
+ for x in range (0 , len (segments [:- 1 ])):
297
+ if segments [x ].network == ip_to_check :
298
+ if ip_to_check in dns_data :
299
+ resolution = dns_data [ip_to_check ].name
300
+ elif ip_to_check in inventory :
301
+ resolution = inventory [ip_to_check ].name
302
+ else :
303
+ resolution = f"Unknown device in { segments [x ].name } network"
304
+ unk_int_IPs .add (ip_to_check )
305
+ if not netaddr .IPAddress (ip_to_check ).is_private ():
306
+ resolution = resolution + " {Non-Priv IP}"
299
307
desc_to_change = (
300
- f"Unknown device in { segment .name } network" ,
301
- segment .color ,
302
- )
303
- unk_int_IPs .add (ip_to_check )
304
- elif ip_to_check in inventory :
305
- desc_to_change = (inventory [ip_to_check ].name , inventory [ip_to_check ].color )
308
+ resolution ,
309
+ segments [x ].color ,
310
+ )
306
311
elif netaddr .IPAddress (ip_to_check ).is_private ():
307
312
if ip_to_check in dns_data :
308
313
desc_to_change = (dns_data [ip_to_check ], INTERNAL_NETWORK_CELL_COLOR )
314
+ elif ip_to_check in inventory :
315
+ desc_to_change = (inventory [ip_to_check ].name , INTERNAL_NETWORK_CELL_COLOR )
309
316
else :
310
317
desc_to_change = ("Unknown Internal address" , INTERNAL_NETWORK_CELL_COLOR )
311
318
unk_int_IPs .add (ip_to_check )
312
319
else :
313
320
ext_IPs .add (ip_to_check )
314
- resolution = "Unresolved external address"
315
321
if ip_to_check in dns_data :
316
322
resolution = dns_data [ip_to_check ]
323
+ elif ip_to_check in inventory :
324
+ resolution = inventory [ip_to_check ].name + " {Non-Priv IP}"
317
325
else :
318
326
try :
319
327
resolution = socket .gethostbyaddr (ip_to_check )[0 ]
320
328
except socket .herror :
321
329
ALREADY_UNRESOLVED .append (ip_to_check )
322
330
finally :
323
- dns_data [ ip_to_check ] = resolution
331
+ resolution = "Unresolved external address"
324
332
desc_to_change = (resolution , EXTERNAL_NETWORK_CELL_COLOR )
325
333
return desc_to_change
326
334
0 commit comments