Skip to content

Instantly share code, notes, and snippets.

@d-Rickyy-b
Created February 28, 2020 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d-Rickyy-b/e83dab86b812a3cacc112d1851223de2 to your computer and use it in GitHub Desktop.
Save d-Rickyy-b/e83dab86b812a3cacc112d1851223de2 to your computer and use it in GitHub Desktop.
Sample config for pastepwn
# -*- coding: utf-8 -*-
import logging.handlers
import os
from pastepwn import PastePwn
# Import new actions here - you need to import each action prior to using it
from pastepwn.actions import EmailAction, IrcAction
# Import new analyzers here - you need to import each analyzer prior to using it
from pastepwn.analyzers import MailAnalyzer, WordAnalyzer
from pastepwn.database import MysqlDB
# Setting up the logging
logdir_path = os.path.dirname(os.path.abspath(__file__))
logfile_path = os.path.join(logdir_path, "logs", "pastepwn.log")
if not os.path.exists(os.path.join(logdir_path, "logs")):
os.makedirs(os.path.join(logdir_path, "logs"))
logfile_handler = logging.handlers.WatchedFileHandler(logfile_path, "a", "utf-8")
logger = logging.getLogger(__name__)
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO, handlers=[logfile_handler, logging.StreamHandler()])
# Framework code
database = MysqlDB(ip="localhost", port=3306, username="MYUSername", password="MYPAssword")
pastepwn = PastePwn(database)
# You need to replace 'me@gmail.com' with your sender mail address,
# "myPassword" with the password of that address,
# the receiver (me@example.com) with the receiver of the mail
# and the hostname (smtp.gmail.com) with the SMTP server hostname of your mail provider.
# Define your actions here:
email_action = EmailAction(username="me@gmail.com", password="myPassword", receiver="me@example.com", hostname="smtp.gmail.com")
# You need to replace the data with your IRC server's data!
irc_action = IrcAction(server="servernameORipaddress", channel="channel", port=6667, nick="pastepwn")
# Define your analyzers here:
# You can now use the IrcAction with the same analyzer or with another analyzer - let's try with another analyzer:
# You can uncomment the following line, if you want to have a WordAnalyzer searching for the Word "anything"
# word_analyzer = WordAnalyzer(irc_action, words="anything")
# You can create as many analyzers as you want!
# Or you can use the same MailAnalyzer as before and simply add another action to it.
# You can use as many actions as you want!
actions = [email_action, irc_action]
mail_analyzer = MailAnalyzer(actions)
# Now we add all our analyzers to pastepwn
pastepwn.add_analyzer(mail_analyzer)
pastepwn.add_analyzer(word_analyzer)
# And all the way in the end we start pastepwn
pastepwn.start()
@d-Rickyy-b
Copy link
Author

You can add as many analyzers as you want. One analyzer always scans pastes for a certain word or pattern. And each analyzer can have multiple actions attached to it. So in theory you could have:

telegram_action = .....
mail_action = ...
discord_action = ...
irc_action = ...

mail_analyzer = MailAnalyzer([telegram_action, mail_action, discord_action, irc_action])

But of course you can also use different actions on different analyzers. And you can even use them twice:

telegram_action = .....
mail_action = ...
discord_action = ...
irc_action = ...

# If the mail analyzer matches, we perform all the actions
mail_analyzer = MailAnalyzer([telegram_action, mail_action, discord_action, irc_action])

# but if the word analyzer finds "d-Rickyy-b" then we only send a telegram message and an email
word_analyzer = WordAnalyzer([telegram_action, mail_action], "d-Rickyy-b")

# you can even setup two different actions (e.g. I use two telegram actions, one for PMs and one for a channel
telegram_action2 = ...
word_analyzer2 = WordAnalyzer(telegram_action2, "my-secret-mail-address")
# You maybe want to send that match only to a certain account on Telegram and not via irc or anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment