How to use the pastepwn.util.TemplatingEngine function in pastepwn

To help you get started, we’ve selected a few pastepwn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d-Rickyy-b / pastepwn / pastepwn / actions / telegramaction.py View on Github external
def perform(self, paste, analyzer_name=None, matches=None):
        """Send a message via a Telegram bot to a specified user, without checking for errors"""
        r = Request()
        text = TemplatingEngine.fill_template(paste, analyzer_name, template_string=self.template, matches=matches)

        api_url = "https://api.telegram.org/bot{0}/sendMessage?chat_id={1}&text={2}".format(self.token, self.receiver, text)
        r.get(api_url)
github d-Rickyy-b / pastepwn / pastepwn / actions / ircaction.py View on Github external
def perform(self, paste, analyzer_name=None, matches=None):
        """Perform the action on the passed paste"""
        text = TemplatingEngine.fill_template(paste, analyzer_name, template_string=self.template, matches=matches)

        self.ircsock.connect((self.server, self.port))
        self.ircsock.send(bytes("USER " + self.nick + " " + self.nick + " " + self.nick + "n", "UTF-8"))
        self.ircsock.send(bytes("NICK " + self.nick + "n", "UTF-8"))
        self.ircsock.send(bytes("JOIN " + self.channel + "n", "UTF-8"))
        self.ircsock.send(bytes("PRIVMSG " + self.channel + " " + text + "n", "UTF-8"))
        self.ircsock.send(bytes("QUIT n", "UTF-8"))
github d-Rickyy-b / pastepwn / pastepwn / actions / emailaction.py View on Github external
def perform(self, paste, analyzer_name=None):
        """
        Sends an email to the specified receiver with the paste's content
        :param paste: The paste passed by the ActionHandler
        :param analyzer_name: The name of the analyzer which matched the paste
        :return: None
        """
        text = TemplatingEngine.fill_template(paste, analyzer_name, template_string=self.template)

        email = MIMEMultipart()
        email['From'] = self.username
        email['To'] = self.receiver
        email['Subject'] = 'Paste matched by pastepwn via analyzer "{}"'.format(analyzer_name)
        email.attach(MIMEText(text, 'plain'))

        # TODO there should be a way to use starttls - check https://realpython.com/python-send-email/
        with smtplib.SMTP_SSL(self.hostname, self.port) as smtp:
            smtp.login(self.username, self.password)
            text = email.as_string()
            smtp.sendmail(self.username, self.receiver, text)
github d-Rickyy-b / pastepwn / pastepwn / actions / savefileaction.py View on Github external
:param paste: The paste passed by the ActionHandler
        :param analyzer_name: The name of the analyzer which matched the paste
        :param matches: List of matches returned by the analyzer
        :return: None
        """
        if not os.path.exists(self.path):
            os.makedirs(self.path)

        if self.file_ending.startswith("."):
            file_name = "{0}{1}".format(paste.key, self.file_ending)
        elif self.file_ending == "":
            file_name = str(paste.key)
        else:
            file_name = "{0}.{1}".format(paste.key, self.file_ending)

        content = TemplatingEngine.fill_template(paste, analyzer_name, template_string=self.template, matches=matches)
        with open(os.path.join(self.path, file_name), "w", encoding="utf-8") as file:
            file.write(content)
github d-Rickyy-b / pastepwn / pastepwn / actions / twitteraction.py View on Github external
def perform(self, paste, analyzer_name=None):
        """Tweet a message"""
        text = TemplatingEngine.fill_template(paste, analyzer_name, template_string=self.template)
        self.twitter_api.PostUpdate(text)
github d-Rickyy-b / pastepwn / pastepwn / actions / syslogaction.py View on Github external
def perform(self, paste, analyzer_name=None, matches=None):
        """
        Logs a paste to the syslog
        :param paste: The paste passed by the ActionHandler
        :param analyzer_name: The name of the analyzer which matched the paste
        :param matches: List of matches returned by the analyzer
        :return: None
        """
        text = TemplatingEngine.fill_template(paste, analyzer_name, template_string=self.template, matches=matches)
        self.logger.debug(text)