Skip to content

Commit

Permalink
Merge 583d393 into 1d9b82e
Browse files Browse the repository at this point in the history
  • Loading branch information
nishu88 committed Oct 2, 2019
2 parents 1d9b82e + 583d393 commit c7ac0f4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pastepwn/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
from .genericaction import GenericAction
from .databaseaction import DatabaseAction
from .savejsonaction import SaveJSONAction
from .sendemailaction import SendEmailAction

__all__ = ('BasicAction', 'SaveFileAction', 'TelegramAction', 'LogAction', 'GenericAction', 'DatabaseAction', 'SaveJSONAction')
__all__ = ('BasicAction', 'SaveFileAction', 'TelegramAction', 'LogAction', 'GenericAction', 'DatabaseAction', 'SaveJSONAction','SendEmailAction')
33 changes: 33 additions & 0 deletions pastepwn/actions/sendemailaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import smtplib
import re
from .basicaction import BasicAction

class SendEmailAction(BasicAction):
"""Action to send a Email containing the paste through SMTP protocol to a certain email-id"""
name = "SendEmailAction"

def __init__(self, username,password,reciever_email,hostname,port):
super().__init__()

if not re.match(r"^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$", username) or username is None:
raise ValueError("username not correct or None!")
if not re.match(r"^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$", reciever_email) or reciever_email is None:
raise ValueError("reciever_email not correct or None!")
self.username = username
self.password=password
self.reciever_email=reciever_email
self.hostname="smtp."+hostname+".com"
self.port=port


def perform(self, paste, analyzer_name=None):
address = self.username
password =self.password
mailto = self.reciever_email
msg = 'Subject: {}\n\n{}'.format("From Pastepwn", str(paste))
mailServer = smtplib.SMTP(self.hostname , self.port)
mailServer.starttls()
mailServer.login(address ,password)
mailServer.sendmail(address, mailto , msg)
print(" \n Sent!")
mailServer.quit()

0 comments on commit c7ac0f4

Please sign in to comment.