Exemplo n.º 1
0
 def run(self, conf, args, plugins):
     be = BinaryEdge(conf['BinaryEdge']['key'])
     try:
         if hasattr(args, 'which'):
             if args.which == 'ip':
                 if args.score:
                     res = be.host_score(unbracket(args.IP))
                 elif args.image:
                     res = be.image_ip(unbracket(args.IP))
                 elif args.torrent:
                     if args.historical:
                         res = be.torrent_historical_ip(unbracket(args.IP))
                     else:
                         res = be.torrent_ip(unbracket(args.IP))
                 elif args.historical:
                     res = be.host_historical(unbracket(args.IP))
                 elif args.dns:
                     res = be.domain_ip(args.IP, page=args.page)
                 else:
                     res = be.host(unbracket(args.IP))
                 print(json.dumps(res, sort_keys=True, indent=4))
             elif args.which == 'search':
                 if args.image:
                     res = be.image_search(args.SEARCH, page=args.page)
                 else:
                     res = be.host_search(args.SEARCH, page=args.page)
                 print(json.dumps(res, sort_keys=True, indent=4))
             elif args.which == 'dataleaks':
                 if args.domain:
                     res = be.dataleaks_organization(args.EMAIL)
                 else:
                     res = be.dataleaks_email(args.EMAIL)
                 print(json.dumps(res, sort_keys=True, indent=4))
             elif args.which == 'domain':
                 if args.subdomains:
                     res = be.domain_subdomains(args.DOMAIN, page=args.page)
                 else:
                     res = be.domain_dns(args.DOMAIN, page=args.page)
                 print(json.dumps(res, sort_keys=True, indent=4))
             else:
                 self.parser.print_help()
         else:
             self.parser.print_help()
     except ValueError as e:
         print('Invalid Value: %s' % e.message)
     except BinaryEdgeNotFound:
         print('Search term not found')
     except BinaryEdgeException as e:
         print('Error: %s' % e.message)
Exemplo n.º 2
0
def binary_edge_scan(id):
    key = keys['keys']['binaryedge']
    device1 = Device.objects.get(id=id)
    be = BinaryEdge(key)
    results = be.host_score(device1.ip)
    normalized_ip_score = results['normalized_ip_score']

    cve = {}

    if 'cve' in results['results_detailed']:
        for cc in results['results_detailed']['cve']['result']:
            if isinstance(cc['cve'], list):
                for i in cc['cve']:
                    cve[i['cpe']] = i['cve_list']
            if isinstance(cc['cve'], dict):
                if 'cpe' in cc['cve']:
                    cve[cc['cve']['cpe'][0]] = cc['cve']['cve_list']

    device2 = BinaryEdgeScore(device=device1, grades=results['ip_score_detailed'], cve=cve, score=normalized_ip_score)
    device2.save()