Skip to content

Commit

Permalink
moving header
Browse files Browse the repository at this point in the history
  • Loading branch information
mikechabot committed Aug 6, 2018
1 parent 7c986bd commit d4a19d0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 34 deletions.
13 changes: 2 additions & 11 deletions commands/cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import logger
from appheader import print_header
from smtpconnection import SMTPConnection

app_description = """ email-spoofer-py v0.0.2 (CLI wizard)
Python 3.x based email spoofer
https://github.com/mikechabot/email-spoofer-py"""


def run(args):
logger.bright('\n{0}'.format('='*50))
logger.header(app_description)
logger.bright('{0}\n'.format('='*50))
print_header()

# Connect to SMTP over TLS
connection = SMTPConnection(args.host, str(args.port))
Expand All @@ -35,9 +30,5 @@ def run(args):
message_body
)

logger.bright('\n{0}\n'.format('='*70))
logger.header(message.as_string())
logger.bright('\n{0}\n'.format('='*70))

connection.send_mail(message)

13 changes: 2 additions & 11 deletions commands/wizard.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import logger
import userinput as ui
from appheader import print_header
from smtpconnection import SMTPConnection

app_description = """ email-spoofer-py v0.0.2 (CLI wizard)
Python 3.x based email spoofer
https://github.com/mikechabot/email-spoofer-py"""


def run():
logger.bright('\n{0}'.format('='*50))
logger.header(app_description)
logger.bright('{0}\n'.format('='*50))
print_header()

# Connect to SMTP over TLS
connection = SMTPConnection(ui.get_host(), ui.get_port())
Expand All @@ -32,9 +27,5 @@ def run():
ui.get_message_body()
)

logger.bright('\n{0}\n'.format('='*70))
logger.header(message.as_string())
logger.bright('\n{0}\n'.format('='*70))

if ui.do_send_mail():
connection.send_mail(message)
4 changes: 1 addition & 3 deletions models/smtpconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def __connect(self):
try:
logger.info('Connecting to SMTP socket (' + self.socket + ')...')
self._server = smtplib.SMTP(self.host, self.port)
logger.success('Connected to SMTP server')
except (gaierror, OSError):
logger.error('Unable to establish connection to SMTP socket.')
exit(1)
Expand All @@ -71,7 +70,6 @@ def __start_tls(self):
try:
logger.info('Starting TLS session...')
self.server.starttls()
logger.success('Started TLS session')
except RuntimeError:
logger.error('SSL/TLS support is not available to your Python interpreter.')
exit(1)
Expand Down Expand Up @@ -122,7 +120,7 @@ def send_mail(self, message):
try:
logger.info('Sending spoofed message...')
self.server.sendmail(self.sender, self.recipients, message.as_string())
logger.success('Sent message')
logger.success('Message sent!')
except smtplib.SMTPException:
logger.error('Unable to send message. Check sender, recipients and message body')
exit(1)
1 change: 1 addition & 0 deletions utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import logger
import userinput
import appheader
12 changes: 12 additions & 0 deletions utils/appheader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from logger import bright, header

description = """ email-spoofer-py v0.0.3 (CLI wizard)
Python 3.x based email spoofer
https://github.com/mikechabot/email-spoofer-py"""

def print_header():
bright('\n{0}'.format('='*50))
header(description)
bright('{0}\n'.format('='*50))


18 changes: 9 additions & 9 deletions utils/userinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from logger import info, success, error


def __prompt(text):
def __prompt(text, color):
try:
print(Fore.WHITE, end='')
print(color, end='')
return input(text).strip()
except KeyboardInterrupt:
error('\nInterrupt received. Exiting...')
Expand All @@ -17,12 +17,12 @@ def __prompt(text):
def __get_required_input(text):
var = None
while not var:
var = __prompt(text)
var = __prompt(text, Fore.WHITE)
return var


def __get_optional_input(text, default_value):
var = __prompt(text)
var = __prompt(text, Fore.WHITE)
if var:
return var
else:
Expand Down Expand Up @@ -61,23 +61,23 @@ def get_password():


def get_sender_address():
return __get_required_input('Sender address (e.g. spoofed@domain.com): ')
return __get_required_input('Sender address: ')


def get_sender_name():
return __get_required_input('Sender name (e.g. John Smith): ')
return __get_required_input('Sender name: ')


def get_subject():
return __get_required_input('Subject line: ')


def get_recipient_addresses():
to_address = __get_required_input('Recipient address (e.g. victim@domain.com): ')
to_address = __get_required_input('Recipient address: ')
to_addresses = [to_address]
if is_multi_address():
while to_address:
to_address = __get_optional_input('Recipient address (blank to continue): ', None)
to_address = __get_optional_input('Recipient address: ', None)
if to_address:
to_addresses.append(to_address)
return to_addresses
Expand Down Expand Up @@ -112,7 +112,7 @@ def get_html():
html = ''
while True:
try:
line = input('>| ')
line = __prompt('>| ', Fore.LIGHTBLACK_EX)
html += line + '\n'
except EOFError:
success('Captured HTML body')
Expand Down

0 comments on commit d4a19d0

Please sign in to comment.