Skip to content

Commit 2245533

Browse files
committed
Added better logging support
Using Twitter 1.9.2 module (https://pypi.python.org/pypi/twitter) Fixed hash regex to hopefully not find XML
1 parent 3adcb5e commit 2245533

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

dumpmon.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from lib.Pastie import Pastie, PastiePaste
1515
from lib.helper import log
1616
from time import sleep
17-
import twitter
18-
from settings import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
17+
from twitter import Twitter, OAuth
18+
from settings import CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET, log_file
1919
import threading
2020
import logging
2121

@@ -34,12 +34,12 @@ def monitor():
3434
if args.verbose:
3535
level = logging.DEBUG
3636
logging.basicConfig(
37-
format='%(asctime)s [%(levelname)s] %(message)s', level=level)
37+
format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level)
3838
logging.info('Monitoring...')
39-
bot = twitter.Api(consumer_key=CONSUMER_KEY,
40-
consumer_secret=CONSUMER_SECRET,
41-
access_token_key=ACCESS_TOKEN,
42-
access_token_secret=ACCESS_TOKEN_SECRET)
39+
bot = Twitter(
40+
auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET,
41+
CONSUMER_KEY, CONSUMER_SECRET)
42+
)
4343
# Create lock for both output log and tweet action
4444
log_lock = threading.Lock()
4545
tweet_lock = threading.Lock()

lib/Site.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import requests
33
import time
44
from requests import ConnectionError
5+
from twitter import TwitterError
56
import logging
67
import helper
78

@@ -75,7 +76,7 @@ def monitor(self, bot, t_lock):
7576
with t_lock:
7677
helper.record(tweet)
7778
try:
78-
bot.PostUpdate(tweet)
79+
bot.statuses.update(status=tweet)
7980
except TwitterError:
8081
pass
8182
self.update()

lib/helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def download(url, headers=None):
2121
try:
2222
response = r.get(url).text
2323
except requests.ConnectionError:
24-
print('[!] Critical Error - Cannot connect to Pastebin')
24+
logging.warn('[!] Critical Error - Cannot connect to site')
2525
sleep(5)
26-
print('[!] Retrying...')
26+
logging.warn('[!] Retrying...')
2727
response = self.download(url)
2828
return response
2929

lib/regexes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
regexes = {
44
'email': re.compile(r'[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}', re.I),
55
#'ssn' : re.compile(r'\d{3}-?\d{2}-?\d{4}'),
6-
'hash32': re.compile(r'[^A-F\d/]([A-F\d]{32})[^A-F\d]', re.I),
6+
'hash32': re.compile(r'[^<A-F\d/]([A-F\d]{32})[^A-F\d]', re.I),
77
'FFF': re.compile(r'FBI\s*Friday', re.I), # will need to work on this to not match CSS
88
'lulz': re.compile(r'(lulzsec|antisec)', re.I),
99
'cisco_hash': re.compile(r'enable\s+secret', re.I),

0 commit comments

Comments
 (0)