forked from SpengeSec/peasant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
peasant.py
executable file
·117 lines (90 loc) · 3.12 KB
/
peasant.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python3
import json
import argparse
import warnings
import csv
from sys import stdout, exit
from pathlib import Path
from Peasant.validators import *
from Peasant.parsers import *
from Peasant.generators import *
from Peasant.extractors import *
from Peasant.auth import *
from Peasant.args import parser as arg_parser
from Peasant.suffix_printer import *
from Peasant.banner import banner
from Peasant.generic import *
from Peasant.exceptions import *
from Peasant.harvest import harvest_contacts
import pdb
warnings.filterwarnings('ignore')
print(banner)
# ==================================
# HANDLE ARGUMENTS AND SET VARIABLES
# ==================================
args = arg_parser.parse_args()
if not args.cmd:
arg_parser.print_help()
exit()
headers = {'User-Agent':args.user_agent}
# ===========
# SET PROXIES
# ===========
args.proxies = handleProxies(args.proxies)
# ========================
# HANDLE PREVIOUS CSV FILE
# ========================
if 'output_file' in args.__dict__:
if args.output_file != stdout and Path(args.output_file).exists():
esprint(f'Loading CSV file: {args.output_file}')
main_profiles = loadProfiles(args)
esprint(f'Total profiles loaded: {main_profiles.__len__()}')
else:
if args.output_file != stdout:
esprint(f'Starting new CSV file: {args.output_file}')
main_profiles = []
try:
# =====================
# HANDLE AUTHENTICATION
# =====================
session = Session(headers=headers,
proxies=args.proxies,
verify=args.verify_ssl)
esprint('Authenticating session')
session.login(args)
profile = session.getBasicProfile()
if not session.authenticated:
esprint('Authentication failed! Check credential settings ' \
'and try again.')
exit()
if profile.premiumSubscriber:
esprint('Authenticated as a premium subscriber')
# ===============
# EXECUTE COMMAND
# ===============
# Harvest contacts
if args.cmd == 'harvest':
harvest_contacts(args,session,main_profiles)
# Add contacts from CSV file
elif args.cmd == 'add_contacts':
esprint('Sending connection requests, which will take '\
'some time...')
main_profiles = addContacts(session,main_profiles,args.message)
esprint(f'Writing profiles to file: {args.output_file}')
writeProfiles(args,main_profiles)
# Profile spoofing
elif args.cmd == 'spoof_profile':
esprint('Spoofing basic profile information...')
session.spoofBasicInfo(args.public_identifier)
esprint('Clearing current profile education and spoofing ' \
'target content...')
session.deleteEducation()
session.spoofEducation(args.public_identifier)
esprint('Clearing current profile experience and spoofing ' \
'target content...')
session.deleteExperience()
session.spoofExperience(args.public_identifier)
finally:
esprint('Logging out')
#session.getLogout()
esprint('Done...exiting')