forked from jobroche/InSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InSpy.py
executable file
·91 lines (72 loc) · 3.38 KB
/
InSpy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python2
# Copyright (c) 2018 Jonathan Broche (@LeapSecurity)
import argparse, sys, os
from lib.http import *
from lib.workbench import *
from lib.soup import *
from lib.export import *
from lib.logger import *
parser = argparse.ArgumentParser(description='InSpy - A LinkedIn enumeration tool by Jonathan Broche (@LeapSecurity)', version="3.0.1")
parser.add_argument('company', help="Company name to use for tasks.")
parser.add_argument('--domain', help="Company domain to use for searching.")
parser.add_argument('--email', help="Email format to create email addresses with. [Accepted Formats: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]]")
parser.add_argument('--titles', metavar='file', default="wordlists/title-list-small.txt", nargs='?', help="Discover employees by title and/or department. Titles and departments are imported from a new line delimited file. [Default: title-list-small.txt]")
outgroup = parser.add_argument_group(title="Output Options")
outgroup.add_argument('--html', metavar='file', help="Print results in HTML file.")
outgroup.add_argument('--csv', metavar='file', help="Print results in CSV format.")
outgroup.add_argument('--json', metavar='file', help="Print results in JSON.")
outgroup.add_argument('--xml', metavar='file', help="Print results in XML.")
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
start_logger(args.company)
hunterapi = "" #insert hunterio api key here
email = args.email
domain = args.domain
print "\nInSpy {}".format(parser.version)
try:
if domain and not email: #search hunterio for email format
email = get_email_format(args.domain, hunterapi)
if email and not domain: #search clearbit for domain
domain = get_domain(args.company)
if not email and not domain: #no domain or email provided - fully automate it
domain = get_domain(args.company)
if domain:
email = get_email_format(domain, hunterapi)
if email and domain:
email = email.replace("{", "").replace("}","")
print "\nDomain: {}, Email Format: {}\n".format(domain, email)
employees = {}
if os.path.exists(os.path.abspath(args.titles)):
for response in search_linkedin(args.company, os.path.abspath(args.titles)):
for name, title in get_employees(soupify(response)).items():
if args.company.lower() in title.lower():
if not name in employees:
employees[name] = title
print "\n{} Employees identified".format(len(employees.keys()))
else:
print os.path.abspath(args.titles)
print "No such file or directory: '{}'".format(args.titles)
if employees:
#output employees
for name, title in employees.iteritems():
print "{} {}".format(name, title[:50].replace('&', '&'))
#craft emails
emails = create_emails(employees, domain, email)
if emails:
#output emails
print "\nEmails crafted\n".format(len(emails.keys()))
for name, email in emails.items():
print email
#export results
if args.html:
output("html", args.html, args.company, domain, employees, emails)
if args.xml:
output("xml", args.xml, args.company, domain, employees, emails)
if args.json:
output("json", args.json, args.company, domain, employees, emails)
if args.csv:
output("csv", args.csv, args.company, domain, employees, emails)
except (KeyboardInterrupt, SystemExit):
print "\nTerminated script.\n"