Skip to content

Commit

Permalink
Can dump all ip info and added netblock analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTruncer committed Oct 8, 2015
1 parent 996260f commit 75ff262
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/orchestra.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def run_ipinfo_command(self, ip_addr):
ip_found = False
try:
for path, ip_objd in self.ip_objects.iteritems():
if ip_objd[0].ip_address == ip_addr:
if ip_objd[0].ip_address == ip_addr or ip_addr.lower() == 'all':
attrs = vars(ip_objd[0])
print ip_objd[0].ip_address
print "*" * 25
Expand Down
51 changes: 51 additions & 0 deletions modules/analytics/whois_cidr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'''
This module finds all systems that have the same public keys (https or ssh)
'''

# No available information within Shodan about 190.90.112.8

from common import helpers


class Analytics:

def __init__(self, cli_options):
self.cli_name = "TopNetBlocks"
self.description = "Returns the top \"X\" number of most seen whois CIDR netblocks"
if cli_options is None:
self.top_number = ''
else:
self.top_number = int(cli_options.analyze_number)

def analyze(self, all_ip_objects):

if self.top_number == '':
print "You selected the \"TopNetblocks\" module, how many CIDR blocks do you want returned?"
print "Ex: 10"
self.top_number = int(raw_input(' \n\n[>] Total: ').strip())

top_cidrs = {}

for single_ip in all_ip_objects.values():
if 'asn_cidr' in single_ip[0].ip_whois.keys():
if single_ip[0].ip_whois['asn_cidr'] in top_cidrs:
top_cidrs[single_ip[0].ip_whois['asn_cidr']] += 1
else:
top_cidrs[single_ip[0].ip_whois['asn_cidr']] = 1

# Iterate over all ports
sorted_top_cidrs = self.dict_sorter(top_cidrs)
list_counter = 1
print "*" * 70
print helpers.color(" " * 20 + "Top CIDR NetBlocks : Number of Instances" + " " * 20)
print "*" * 70
while ((list_counter <= self.top_number) and ((list_counter -1) != len(sorted_top_cidrs))):
sorted_ports_tuple = sorted_top_cidrs[-list_counter]
print "Port: " + helpers.color(str(sorted_ports_tuple[0])) + " - " + str(sorted_ports_tuple[1]) + " instances"
list_counter += 1
print

return

def dict_sorter(self, data_dictionary):
return sorted(data_dictionary.items(), key=lambda x: x[1])

0 comments on commit 75ff262

Please sign in to comment.