Created
September 22, 2014 04:18
-
-
Save c1b3rh4ck/7da193a41e929471db14 to your computer and use it in GitHub Desktop.
This newsbot is a simple script written in python.using the Twython library to interact with twitter api. The purpose of this script is received all the information(e.g hints,tricks and tips and if there are flags available :P ), Capture the flag or jeopardy contest besides that, OSINT techniques is a form of intelligence collection management t…
This file contains hidden or 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 -*- | |
#Ctf InfoBot [email protected] | |
#it was created thinking in the talk : | |
#Ctf and Jeopardy Contests,BarcampSE 2013 | |
#https://twython.readthedocs.org/en/latest/ | |
""" | |
ToDO : | |
Add Irc option something like a bot and define ruleset. | |
Add Bash command line option. | |
Implement Parsers. | |
""" | |
from twython import Twython,TwythonError,TwythonStreamer | |
from src import core | |
import os, sys, re, urllib,time | |
version='0.1' | |
global APP_KEY,APP_SECRET,twitter,stream | |
APP_KEY = '' | |
APP_SECRET = '' | |
OAUTH_TOKEN = '' | |
OAUTH_TOKEN_SECERT ='' | |
def text_dialog(): | |
print("""\n %sCtfInfoBot | |
version %s | |
Created by c1b3rh4ck%s | |
""" %(core.bold,version,core.reset)) | |
class MiStream(TwythonStreamer): | |
def on_success(self, data): | |
if 'text' in data: | |
print data['text'].encode('utf-8') | |
def on_error(self, status_code, data): | |
print status_code, data | |
stream= MiStream(APP_KEY,APP_SECRET,OAUTH_KEY,OAUTH_TOKEN_SECRET) | |
core.banner() | |
text_dialog() | |
time.sleep(2) | |
print("%s[+]Authenticating..\n%s")%(core.green,core.reset) | |
twitter = Twython(APP_KEY, APP_SECRET) #Authentication with the api | |
auth = twitter.get_authentication_tokens(callback_url='http://twitter.com/c1b3rh4ck') #url callback | |
print("%s[+]Insert the first pattern to search%s") %(core.green,core.reset) | |
q1=raw_input() | |
print("%s[+]Insert a second pattern to search%s")%(core.green,core.reset) | |
q2=raw_input() | |
print("%s[+]Searching for %s %s Patterns...")%(core.red,q1,q2,core.reset) | |
try: | |
search_results =twitter.search(q=q1, count=50) | |
searchs=twitter.search(q=q2,count=25,result_type='popular') | |
searchfromothers=twitter.search(q='reto',count=20,result_type='popular') | |
except TwythonError as e: | |
print("Errores meanwhile was searching ")+ e | |
pattern = re.compile(r"((https?):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)",re.MULTILINE|re.UNICODE) | |
#weetss = map(lambda x: x.text, filter(lambda x: x.text is not None, searchs)) | |
print(pattern) #es un objeto para volcar ! | |
#print "\n".join(set([ urllib.urlopen(pattern.search(t).group(1)).url for t in tweets if pattern.search(t) is not None ])) | |
print("Everything...") | |
for tweet in search_results['statuses']: | |
print 'Tweet from %s @%s %s Date: %s ' % (core.red,tweet['user']['screen_name'].encode('utf-8'),core.reset,tweet['created_at']) | |
print tweet['text'].encode('utf-8'), '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment