Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View planglois925's full-sized avatar

Philippe Langlois planglois925

View GitHub Profile
[] pulling down advisory
[] Locating CVE's
[]Finding CPE
[]Finding CPE
[]Finding CPE
[]Finding CPE
[]Finding CPE
[]Finding CPE
[]Finding CPE
[]Finding CPE
@planglois925
planglois925 / twitter_monitoring.py
Last active September 1, 2017 14:38
Part one of the tutorial on monitoring twitter
import tweepy
from tweepy.streaming import StreamListener
def main():
print "[] Twitter monitoring starting"
# these are the values associated with the both the application and consumer
#update these to the values that you gained from the previous section
ckey = ""
Status(quote_count=0, contributors=None, truncated=False, text=u'hello worlds \n\nhttps://t.co/ljTv72TLxm', is_quote_status=False, in_reply_to_status_id=[redacted], reply_count=0, id=906254180414783489, favorite_count=0, _api=<tweepy.api.API object at 0x10309c350>, source=u'Twitter Web Client', _json={u'quote_count': 0, u'contributors': None, u'truncated': False, u'text': u'hello worlds \n\nhttps://t.co/ljTv72TLxm', u'is_quote_status': False, u'in_reply_to_status_id': [redacted], u'reply_count': 0, u'id': 906254180414783489, u'favorite_count': 0, u'source': u'<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>', u'retweeted': False, u'coordinates': None, u'timestamp_ms': u'1504902808656', u'entities': {u'user_mentions': [], u'symbols': [], u'hashtags': [], u'urls': [{u'url': u'https://t.co/ljTv72TLxm', u'indices': [15, 38], u'expanded_url': u'http://example.com', u'display_url': u'example.com'}]}, u'in_reply_to_screen_name': u'[redacted]', u'id_str': u'[redacted]', u'retweet_count': 0, u'in_rep
import tweepy
from tweepy.streaming import StreamListener
import os
from urlparse import urlparse
#TODO: alert if the API doesn't connect
def main():
print "[] Twitter monitoring starting"
class Listener(StreamListener):
def __init__(self, api=None):
# This method used to define what needs to be done
# before the class can be actually used
# In our case, we're making sure the api is set up
# and loading the values we need for our tests
self.api = api or tweepy.API()
self.domains = load_domains()
def twitter_hit(status):
# This is a super simple indicator that we found something,
# and the logic will be built up in the next one
print '[x] Hit found \n'
def load_domains():
# start an empty array
domains = []
# A little status information for us
print "[] Loading domains"
# We want our code to platform neutral, so use os.path.join
# to get to our data directory and extract out domains
file_location = os.path.join('data','domains.txt')
def load_twitter_accounts():
twitter_accounts = []
print "[] Loading twitter accounts (the good ones)"
file_location = os.path.join('data','twitter.txt')
if os.path.isfile(file_location):
with open(file_location) as f:
for account in f.readlines():
def domain_test(self,status):
# begin by making an empty array that will store our TRUE/FALSE responses
results = []
# first lets check to see if we got URLs in our Entities object of the status
if status.entities['urls']:
# In a status we'll want to check all the urls that might be there
# so we create a very quick for loop
def user_mention(self, status):
# Once again we create an empty array
results = []
# Here we want to check the user mentions component of the status
# So the first step is to identify if it's empty or not
if status.entities['user_mentions']:
# Multiple users can be mentioned in a tweet,