Skip to content

Commit

Permalink
Merge branch 'master' into irc-action
Browse files Browse the repository at this point in the history
  • Loading branch information
d-Rickyy-b committed Oct 30, 2019
2 parents c9fe1b7 + df37d7f commit a4873e5
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ To use the pastepwn framework you need to follow these simple steps:

There are 2 ways to use this tool behind a proxy:

* Define the following environment variables: `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`.
* When initializing the PastePwn object, use the `proxies` argument. `proxies` is a dict as defined in [requests' documentation](http://docs.python-requests.org/en/master/user/advanced/#proxies).
- Define the following environment variables: `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`.
- When initializing the PastePwn object, use the `proxies` argument. `proxies` is a dict as defined in [requests' documentation](http://docs.python-requests.org/en/master/user/advanced/#proxies).

### ToDos
There are quite some features which will be implemented in the (near) future.
Expand Down
4 changes: 4 additions & 0 deletions pastepwn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
# Do not mess with the order of the imports
# Otherwise there will be circular imports -> bad

from .core.pastepwn import PastePwn
from .core.paste import Paste
from .core.pastedispatcher import PasteDispatcher
Expand Down
14 changes: 7 additions & 7 deletions pastepwn/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-

from .basicaction import BasicAction
from .savefileaction import SaveFileAction
from .telegramaction import TelegramAction
from .logaction import LogAction
from .genericaction import GenericAction
from .databaseaction import DatabaseAction
from .savejsonaction import SaveJSONAction
from .twitteraction import TwitterAction
from .discordaction import DiscordAction
from .emailaction import EmailAction
from .ircaction import IrcAction
from .genericaction import GenericAction
from .logaction import LogAction
from .mispaction import MISPAction
from .emailaction import EmailAction
from .savefileaction import SaveFileAction
from .savejsonaction import SaveJSONAction
from .telegramaction import TelegramAction
from .twitteraction import TwitterAction

__all__ = (
"BasicAction",
Expand Down
2 changes: 1 addition & 1 deletion pastepwn/actions/discordaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _identify(self, ws_url):
hello = json.loads(hello_str)
if hello.get('op') != 10:
self.logger.warning('[ws] Expected Hello payload but received %s', hello_str)

# Send heartbeat and receive ACK
yield from socket.send(json.dumps({"op": 1, "d": {}}))
ack_str = yield from socket.recv()
Expand Down
13 changes: 6 additions & 7 deletions pastepwn/actions/twitteraction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import logging
from string import Template

import twitter

Expand All @@ -14,12 +13,12 @@ class TwitterAction(BasicAction):
name = "TwitterAction"

def __init__(
self,
consumer_key=None,
consumer_secret=None,
access_token_key=None,
access_token_secret=None,
template=None,
self,
consumer_key=None,
consumer_secret=None,
access_token_key=None,
access_token_secret=None,
template=None,
):
super().__init__()

Expand Down
3 changes: 2 additions & 1 deletion pastepwn/analyzers/basicanalyzer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from pastepwn.util import listify
import logging

from pastepwn.util import listify


class BasicAnalyzer(object):
"""Basic analyzer class"""
Expand Down
1 change: 1 addition & 0 deletions pastepwn/analyzers/phonenumberanalyzer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from .regexanalyzer import RegexAnalyzer


class PhoneNumberAnalyzer(RegexAnalyzer):
"""Analyzer to match Phone Numbers"""

Expand Down
1 change: 0 additions & 1 deletion pastepwn/analyzers/slacktokenanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ def __init__(self, actions):
"""
regex = r'(xox[pboa]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})'
super().__init__(actions, regex)

2 changes: 1 addition & 1 deletion pastepwn/analyzers/slackwebhookanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, action):
Analyzer to match (likely) Slack Webhook URLs
:param action: Single action or list of actions to be executed when a paste matches
"""

regex = r'https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}'

super().__init__(action, regex)
6 changes: 3 additions & 3 deletions pastepwn/analyzers/tests/adobekeyanalyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def test_match_negative(self):
# Invalid length
self.paste.body = "1118-1470-8779-0264-4009-32445"
self.assertFalse(self.analyzer.match(self.paste))
# Invalid length

# Invalid length
self.paste.body = "1118-1470-8779-0264-4009-324"
self.assertFalse(self.analyzer.match(self.paste))

Expand All @@ -58,4 +58,4 @@ def test_match_negative(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_match_negative(self):

self.obj = None
self.assertFalse(self.analyzer.match(self.obj))

def test_match_negative(self):
# random string
self.obj.body = "Test"
Expand Down
6 changes: 3 additions & 3 deletions pastepwn/analyzers/tests/microsoftkeyanalyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def test_match_negative(self):
# Invalid length
self.paste.body = "PNT6B-DKH2Q-GW4J2-DDT6T-PDHT76"
self.assertFalse(self.analyzer.match(self.paste))
# Invalid length

# Invalid length
self.paste.body = "PNT6B-DKH2Q-GW4J2-DDT6T-PDHT"
self.assertFalse(self.analyzer.match(self.paste))

Expand All @@ -58,4 +58,4 @@ def test_match_negative(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
2 changes: 1 addition & 1 deletion pastepwn/analyzers/tests/originkeyanalyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ def test_match_negative(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
1 change: 0 additions & 1 deletion pastepwn/analyzers/tests/privatekeyanalyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def test_match_positive(self):
self.assertTrue(self.analyzer.match(self.paste))
self.paste.body = "-----BEGIN OPENSSH PRIVATE KEY-----"
self.assertTrue(self.analyzer.match(self.paste))


def test_match_negative(self):
"""Test if negatives are not recognized"""
Expand Down
6 changes: 3 additions & 3 deletions pastepwn/analyzers/tests/slackwebhookanalyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_match_positive(self):

# part of a sentence
self.paste.body = "here is the webhook url: The slack webhook key is " \
"https://hooks.slack.com/services/T00000000/B00000000"\
"https://hooks.slack.com/services/T00000000/B00000000" \
"/XXXXXXXXXXXXXXXXXXXXXXXX! how about that!"
self.assertTrue(self.analyzer.match(self.paste))

Expand All @@ -53,11 +53,11 @@ def test_match_negative(self):
# Invalid Length
self.paste.body = "https://hooks.slack.com/services/T00000000/B0000000/XXXXXXXXXXXXXXXXXXXXXXXX"
self.assertFalse(self.analyzer.match(self.paste))

# Invalid Format (/services/Z... vs /services/T...)
self.paste.body = "https://hooks.slack.com/services/Z00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
self.assertFalse(self.analyzer.match(self.paste))


if __name__ == '__main__':
unittest.main()
unittest.main()
2 changes: 2 additions & 0 deletions pastepwn/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Do not mess with the order of the imports
# Otherwise there will be circular imports -> bad

from .actionhandler import ActionHandler
from .scrapinghandler import ScrapingHandler
Expand Down
5 changes: 2 additions & 3 deletions pastepwn/core/pastepwn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

from pastepwn.actions import DatabaseAction
from pastepwn.analyzers import AlwaysTrueAnalyzer
from pastepwn.core import ScrapingHandler, ActionHandler
from pastepwn.core.pastedispatcher import PasteDispatcher
from pastepwn.util.request import Request
from pastepwn.core import ScrapingHandler, ActionHandler, PasteDispatcher
from pastepwn.util import Request


class PastePwn(object):
Expand Down
2 changes: 1 addition & 1 deletion pastepwn/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .abstractdb import AbstractDB
from .mongodb import MongoDB
from .sqlitedb import SQLiteDB
from .mysqldb import MysqlDB
from .sqlitedb import SQLiteDB

__all__ = ('AbstractDB', 'MongoDB', 'SQLiteDB', 'MysqlDB')
2 changes: 1 addition & 1 deletion pastepwn/scraping/pastebin/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

from .ipnotregisterederror import IPNotRegisteredError
from .pastenotreadyexception import PasteNotReadyException
from .pastedeletedexception import PasteDeletedException
from .pasteemptyexception import PasteEmptyException
from .pastenotreadyexception import PasteNotReadyException

__all__ = ('IPNotRegisteredError', 'PasteNotReadyException', 'PasteDeletedException', 'PasteEmptyException')
6 changes: 3 additions & 3 deletions pastepwn/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-

from .request import Request
from .dictwrapper import DictWrapper
from .threadingutils import start_thread, join_threads
from .templatingengine import TemplatingEngine
from .listify import listify
from .request import Request
from .templatingengine import TemplatingEngine
from .threadingutils import start_thread, join_threads

__all__ = ('Request',
'DictWrapper',
Expand Down
1 change: 1 addition & 0 deletions pastepwn/util/dictwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ class DictWrapper(dict):
A wrapper around dicts which returns the key as string when missing.
Used for the templating engine
"""

def __missing__(self, key):
return '{' + key + '}'
2 changes: 1 addition & 1 deletion pastepwn/util/threadingutils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from threading import Thread, current_thread
import logging
from threading import Thread, current_thread


def start_thread(target, name, exception_event, *args, **kwargs):
Expand Down

0 comments on commit a4873e5

Please sign in to comment.