|
17 | 17 | from passivetotal.libs.cookies import CookiesRequest, CookiesResponse |
18 | 18 | from passivetotal.libs.services import ServicesRequest, ServicesResponse |
19 | 19 | from passivetotal.libs.projects import ProjectsRequest, ProjectsResponse |
| 20 | +from passivetotal.libs.illuminate import IlluminateRequest, IlluminateReputationResponse |
20 | 21 | from passivetotal.response import Response |
21 | 22 |
|
22 | 23 | __author__ = 'Brandon Dixon (PassiveTotal)' |
@@ -280,6 +281,21 @@ def call_projects(args): |
280 | 281 | data = ProjectsResponse.process(response) |
281 | 282 | return data |
282 | 283 |
|
| 284 | +def call_illuminate(args): |
| 285 | + client = IlluminateRequest.from_config() |
| 286 | + if args.illuminate_cmd == 'reputation': |
| 287 | + results = [] |
| 288 | + for host in args.hosts: |
| 289 | + try: |
| 290 | + response = client.get_reputation(query=host) |
| 291 | + except Exception as e: |
| 292 | + response = {} |
| 293 | + response.update({'host': host}) |
| 294 | + if args.brief: |
| 295 | + del(response['rules']) |
| 296 | + results.append(response) |
| 297 | + data = IlluminateReputationResponse.process(results) |
| 298 | + return data |
283 | 299 |
|
284 | 300 | def write_output(results, arguments): |
285 | 301 | """Format data based on the type. |
@@ -506,7 +522,15 @@ def main(): |
506 | 522 | projects.add_argument('--format', choices=['json'], default='json', |
507 | 523 | help="Format of the output from the query") |
508 | 524 |
|
509 | | - |
| 525 | + illuminate = subs.add_parser('illuminate', help="Query RiskIQ Illuminate API") |
| 526 | + illuminate.add_argument('--reputation', dest='illuminate_cmd', action='store_const', const='reputation', |
| 527 | + help="Get hostname or IP reputation from RiskIQ Illuminate.") |
| 528 | + illuminate.add_argument('--format', choices=['json','csv','text'], default='json', |
| 529 | + help="Format of the output from the query") |
| 530 | + illuminate.add_argument('--brief', action='store_true', |
| 531 | + help="Create a brief output; for reputation, prints score and classification only") |
| 532 | + illuminate.add_argument('hosts', metavar='query', nargs='+', |
| 533 | + help="One or more hostnames or IPs") |
510 | 534 | args, unknown = parser.parse_known_args() |
511 | 535 | data = None |
512 | 536 |
|
@@ -535,6 +559,8 @@ def main(): |
535 | 559 | data = call_services(args) |
536 | 560 | elif args.cmd == 'projects': |
537 | 561 | data = call_projects(args) |
| 562 | + elif args.cmd == 'illuminate': |
| 563 | + data = call_illuminate(args) |
538 | 564 | else: |
539 | 565 | parser.print_usage() |
540 | 566 | sys.exit(1) |
|
0 commit comments