|
| 1 | +""" |
| 2 | +This module is a CLI script that calls the class/functions in orca.py and |
| 3 | +coreutils.py. This is the 'main' script that is executed by usres to find |
| 4 | +and remove phishing emails. |
| 5 | +
|
| 6 | +Classes: |
| 7 | +None |
| 8 | +
|
| 9 | +Functions: |
| 10 | +None |
| 11 | +""" |
1 | 12 | from argparse import ArgumentParser
|
2 | 13 | from configparser import ConfigParser
|
3 | 14 | from logging import basicConfig, DEBUG, getLogger
|
|
64 | 75 | # Looking for phishing emails based on supplied arguments.
|
65 | 76 | # Check if URL is supplied.
|
66 | 77 | if orca_args.url is not None:
|
67 |
| - # Performing input validation. |
68 |
| - url_validate = validate.URL(orca_args.url) |
69 |
| - if url_validate is False: |
70 |
| - print('Input validation for URL failed. Exiting') |
71 |
| - exit(1) |
72 | 78 | # Finding and pulling emails with indicated URL.
|
73 | 79 | phish_list = phish_hunt.find_phish(url=orca_args.url)
|
74 | 80 | print('*' * 32 + 'WARNING' + '*' * 32)
|
75 |
| - print('You are going to pull email from %d mailboxes.' % len(phish_list)) |
| 81 | + print('You are going to pull email from %d mailboxes.', len(phish_list)) |
76 | 82 | warning = str(input('Press Y/N to continue> '))
|
77 | 83 | if warning.lower() == 'y':
|
78 |
| - log.info('Acknowledgment accepted for %d mailboxes' % len(phish_list)) |
| 84 | + log.info('Acknowledgment accepted for %d mailboxes', len(phish_list)) |
79 | 85 | else:
|
80 | 86 | print('*' * 32 + 'ABORTING' + '*' * 32)
|
81 | 87 | exit(0)
|
82 | 88 | # Checking for pull or purge and taking appropriate action.
|
83 |
| - log.debug('Performing URL pull for %s' % orca_args.url) |
| 89 | + log.debug('Performing URL pull for %s', orca_args.url) |
84 | 90 | if orca_args.action == 'pull':
|
85 | 91 | phish_hunt.pull_email(phish_list)
|
86 | 92 | # elif orca_args.action == 'purge':
|
87 | 93 | # phish_hunt.purge_email(phish_list)
|
88 | 94 | # Check if file hash is supplied.
|
89 | 95 | elif orca_args.hash is not None:
|
90 |
| - # Performing input validation. |
91 |
| - hash_validate = validate.SHA1(orca_args.hash) |
92 |
| - if hash_validate is False: |
93 |
| - print('SHA1 hash failed input validation. Exiting.') |
94 |
| - exit(1) |
95 | 96 | # Finding and pulling emails with indicated file hash.
|
96 | 97 | phish_list = phish_hunt.find_phish(file_hash=orca_args.hash)
|
97 | 98 | print('*' * 32 + 'WARNING' + '*' * 32)
|
98 |
| - print('You are going to pull email from %d mailboxes.' % len(phish_list)) |
| 99 | + print('You are going to pull email from %d mailboxes.', len(phish_list)) |
99 | 100 | warning = str(input('Press Y/N to continue> '))
|
100 | 101 | if warning.lower() == 'y':
|
101 |
| - log.info('Acknowledgment accepted for %d mailboxes' % len(phish_list)) |
| 102 | + log.info('Acknowledgment accepted for %d mailboxes', len(phish_list)) |
102 | 103 | else:
|
103 | 104 | print('*' * 32 + 'ABORTING' + '*' * 32)
|
104 | 105 | exit(0)
|
105 | 106 | # Checking for pull or purge and taking appropriate action.
|
106 |
| - log.debug('Performing SHA1 hash pull for %s' % orca_args.hash) |
| 107 | + log.debug('Performing SHA1 hash pull for %s', orca_args.hash) |
107 | 108 | if orca_args.action == 'pull':
|
108 | 109 | phish_hunt.pull_email(phish_list)
|
109 | 110 | # elif orca_args.action == 'purge':
|
|
115 | 116 | orca_args.file_extension is not None
|
116 | 117 | ):
|
117 | 118 | # Beginning input validation.
|
118 |
| - validate_sender = validate.Email(orca_args.sender) |
| 119 | + validate_sender = validate.email(orca_args.sender) |
119 | 120 | if validate_sender is False:
|
120 | 121 | print('Sender email address faield input validation. Exiting.')
|
121 | 122 | exit(1)
|
122 |
| - validate_file = validate.FileExt(orca_args.file_extension) |
| 123 | + validate_file = validate.file_ext(orca_args.file_extension) |
123 | 124 | if validate_file is False:
|
124 | 125 | print('File extension input validation failed. Exiting.')
|
125 | 126 | exit(1)
|
|
130 | 131 | file_ext=orca_args.file_extension
|
131 | 132 | )
|
132 | 133 | print('*' * 32 + 'WARNING' + '*' * 32)
|
133 |
| - print('You are going to pull email from %d mailboxes.' % len(phish_list)) |
| 134 | + print('You are going to pull email from %d mailboxes.', len(phish_list)) |
134 | 135 | warning = str(input('Press Y/N to continue> '))
|
135 | 136 | if warning.lower() == 'y':
|
136 |
| - log.info('Acknowledgment accepted for %d mailboxes' % len(phish_list)) |
| 137 | + log.info('Acknowledgment accepted for %d mailboxes', len(phish_list)) |
137 | 138 | else:
|
138 | 139 | print('*' * 32 + 'ABORTING' + '*' * 32)
|
139 | 140 | exit(0)
|
|
152 | 153 | elif (orca_args.sender is not None and
|
153 | 154 | orca_args.subject is not None):
|
154 | 155 | # Performing input validation.
|
155 |
| - sender_validate = validate.Email(orca_args.sender) |
| 156 | + sender_validate = validate.email(orca_args.sender) |
156 | 157 | if sender_validate is False:
|
157 | 158 | print('Sender email address failed validation. Exiting.')
|
158 | 159 | exit(1)
|
|
161 | 162 | subject=orca_args.subject
|
162 | 163 | )
|
163 | 164 | print('*' * 32 + 'WARNING' + '*' * 32)
|
164 |
| - print('You are going to pull email from %d mailboxes.' % len(phish_list)) |
| 165 | + print('You are going to pull email from %d mailboxes.', len(phish_list)) |
165 | 166 | warning = str(input('Press Y/N to continue> '))
|
166 | 167 | if warning.lower() == 'y':
|
167 |
| - log.info('Acknowledgment accepted for %d mailboxes' % len(phish_list)) |
| 168 | + log.info('Acknowledgment accepted for %d mailboxes', len(phish_list)) |
168 | 169 | else:
|
169 | 170 | print('*' * 32 + 'ABORTING' + '*' * 32)
|
170 | 171 | exit(0)
|
|
182 | 183 | elif (orca_args.sender is not None and
|
183 | 184 | orca_args.file_extension is not None):
|
184 | 185 | # Performing input validation.
|
185 |
| - sender_validate = validate.Email(orca_args.sender) |
| 186 | + sender_validate = validate.email(orca_args.sender) |
186 | 187 | if sender_validate is False:
|
187 | 188 | print('Sender email address failed input validation. Exiting.')
|
188 | 189 | exit(1)
|
189 |
| - file_validate = validate.FileExt(orca_args.file_extension) |
| 190 | + file_validate = validate.file_ext(orca_args.file_extension) |
190 | 191 | if file_validate is False:
|
191 | 192 | print('File extension input validation failed. Exiting.')
|
192 | 193 | exit(1)
|
|
196 | 197 | file_ext=orca_args.file_extension
|
197 | 198 | )
|
198 | 199 | print('*' * 32 + 'WARNING' + '*' * 32)
|
199 |
| - print('You are going to pull email from %d mailboxes.' % len(phish_list)) |
| 200 | + print('You are going to pull email from %d mailboxes.', len(phish_list)) |
200 | 201 | warning = str(input('Press Y/N to continue> '))
|
201 | 202 | if warning.lower() == 'y':
|
202 |
| - log.info('Acknowledgment accepted for %d mailboxes' % len(phish_list)) |
| 203 | + log.info('Acknowledgment accepted for %d mailboxes', len(phish_list)) |
203 | 204 | else:
|
204 | 205 | print('*' * 32 + 'ABORTING' + '*' * 32)
|
205 | 206 | exit(0)
|
|
216 | 217 | # Checking only for sender
|
217 | 218 | elif orca_args.sender is not None:
|
218 | 219 | # Performing input validation.
|
219 |
| - validate_sender = validate.Email(orca_args.sender) |
220 |
| - if validate_sender is False: |
221 |
| - print('Sender email address failed input validation. Exiting.') |
222 |
| - exit(1) |
| 220 | + # validate_sender = validate.Email(orca_args.sender) |
| 221 | + # if validate_sender is False: |
| 222 | + # print('Sender email address failed input validation. Exiting.') |
| 223 | + # exit(1) |
223 | 224 | # Finding and pulling emails that match the sender.
|
224 | 225 | phish_list = phish_hunt.find_phish(sender=orca_args.sender)
|
225 | 226 | print('*' * 32 + 'WARNING' + '*' * 32)
|
226 |
| - print('You are going to pull email from %d mailboxes.' % len(phish_list)) |
| 227 | + print('You are going to pull email from %d mailboxes.', len(phish_list)) |
| 228 | + warning = str(input('Press Y/N to continue> ')) |
| 229 | + if warning.lower() == 'y': |
| 230 | + log.info('Acknowledgment accepted for %d mailboxes', len(phish_list)) |
| 231 | + else: |
| 232 | + print('*' * 32 + 'ABORTING' + '*' * 32) |
| 233 | + exit(0) |
| 234 | + # Checking for pull or purge and taking appropriate action. |
| 235 | + log.debug('Pulling email based on sender: %s', orca_args.sender) |
| 236 | + if orca_args.action == 'pull': |
| 237 | + phish_hunt.pull_email(phish_list) |
| 238 | + # elif orca_args.action == 'purge': |
| 239 | + # phish_hunt.purge_email(phish_list) |
| 240 | +# Chcking for subject only |
| 241 | +elif orca_args.subject is not None: |
| 242 | + phish_list = phish_hunt.find_phish(subject=orca_args.subject) |
| 243 | + print('*' * 32 + 'WARNING' + '*' * 32) |
| 244 | + print('You are going to pull email from %d mailboxes.', len(phish_list)) |
227 | 245 | warning = str(input('Press Y/N to continue> '))
|
228 | 246 | if warning.lower() == 'y':
|
229 |
| - log.info('Acknowledgment accepted for %d mailboxes' % len(phish_list)) |
| 247 | + log.info('Acknowledgment accepted for %d mailboxes', len(phish_list)) |
230 | 248 | else:
|
231 | 249 | print('*' * 32 + 'ABORTING' + '*' * 32)
|
232 | 250 | exit(0)
|
233 | 251 | # Checking for pull or purge and taking appropriate action.
|
234 |
| - log.debug('Pulling email based on sender: %s' % orca_args.sender) |
| 252 | + log.debug('Pulling email based on sender: %s', orca_args.sender) |
235 | 253 | if orca_args.action == 'pull':
|
236 | 254 | phish_hunt.pull_email(phish_list)
|
237 | 255 | # elif orca_args.action == 'purge':
|
|
0 commit comments