Last active
December 19, 2017 19:11
-
-
Save p3t3r67x0/bfdb5cc0aab0ed5880856ed3abed2bb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -!- coding:utf-8 -!- | |
import os | |
from twython import Twython | |
from twython.exceptions import TwythonError | |
def get_secrets(): | |
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '.secret')) | |
lines = load_document(path) | |
return [l.strip() for l in lines[0:4]] | |
def load_document(filename): | |
try: | |
with open(filename, 'rb') as f: | |
return f.readlines() | |
except IOError as e: | |
print e | |
sys.exit(1) | |
def execute_command(action, twitter, query): | |
result = twitter.search(q=query, result_type='resent', count=20) | |
for i in result['statuses']: | |
try: | |
if action == 'favorite': | |
r = twitter.create_favorite(id= i['id']) | |
elif action == 'retweet': | |
r = twitter.retweet(id= i['id']) | |
print u'[I] Favorited: {} with id: {}'.format(r['text'], r['id']) | |
except TwythonError as e: | |
print u'[E] {}'.format(e) | |
def authenticate(): | |
secret = get_secrets() | |
return Twython(secret[0], secret[1], secret[2], secret[3]) | |
def main(): | |
twitter = authenticate() | |
query_retweet = ['ssl intercept', '#infosec #hash', '#password #cracking'] | |
query_favorite = ['#infosec #pentest', '#cve #infosec'] | |
for query in query_retweet: | |
execute_command('retweet', twitter, query) | |
for query in query_favorite: | |
execute_command('favorite', twitter, query) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
.secret
file should look like this..