diff --git a/twitter_email/anonBrowser.py b/twitter_email/anonBrowser.py new file mode 100644 index 0000000..dc65dd5 --- /dev/null +++ b/twitter_email/anonBrowser.py @@ -0,0 +1,36 @@ +import mechanize, cookielib, random + +class anonBrowser(mechanize.Browser): + + def __init__(self, proxies = [], user_agents = []): + mechanize.Browser.__init__(self) + self.set_handle_robots(False) + self.proxies = proxies + self.user_agents = user_agents + ['Mozilla/4.0 ',\ + 'FireFox/6.01','ExactSearch', 'Nokia7110/1.0'] + + self.cookie_jar = cookielib.LWPCookieJar() + self.set_cookiejar(self.cookie_jar) + self.anonymize() + + def clear_cookies(self): + self.cookie_jar = cookielib.LWPCookieJar() + self.set_cookiejar(self.cookie_jar) + + def change_user_agent(self): + index = random.randrange(0, len(self.user_agents) ) + self.addheaders = [('User-agent', \ + ( self.user_agents[index] ))] + + def change_proxy(self): + if self.proxies: + index = random.randrange(0, len(self.proxies)) + self.set_proxies( {'http': self.proxies[index]} ) + + def anonymize(self, sleep = False): + self.clear_cookies() + self.change_user_agent() + self.change_proxy() + + if sleep: + time.sleep(60) diff --git a/twitter_email/sendSpam.py b/twitter_email/sendSpam.py new file mode 100644 index 0000000..ef34072 --- /dev/null +++ b/twitter_email/sendSpam.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +print 'Created by umarbrowser pyc0d3r 3mail: umarbrowser20@gmail.com' +import smtplib +import optparse + +from email.mime.text import MIMEText +from twitterClass import * +from random import choice + +def sendMail(user,pwd,to,subject,text): + + msg = MIMEText(text) + msg['From'] = user + msg['To'] = to + msg['Subject'] = subject + + try: + smtpServer = smtplib.SMTP('smtp.gmail.com', 587) + print "[+] Connecting To Mail Server." + smtpServer.ehlo() + print "[+] Starting Encrypted Session." + smtpServer.starttls() + smtpServer.ehlo() + print "[+] Logging Into Mail Server." + smtpServer.login(user, pwd) + print "[+] Sending Mail." + smtpServer.sendmail(user, to, msg.as_string()) + smtpServer.close() + print "[+] Mail Sent Successfully." + + except: + print "[-] Sending Mail Failed." + + +def main(): + + parser = optparse.OptionParser('usage %prog '+\ + '-u -t '+\ + '-l -p ') + + parser.add_option('-u', dest='handle', type='string',\ + help='specify twitter handle') + + parser.add_option('-t', dest='tgt', type='string',\ + help='specify target email') + + parser.add_option('-l', dest='user', type='string',\ + help='specify gmail login') + + parser.add_option('-p', dest='pwd', type='string',\ + help='specify gmail password') + + + (options, args) = parser.parse_args() + handle = options.handle + tgt = options.tgt + user = options.user + pwd = options.pwd + + if handle == None or tgt == None\ + or user ==None or pwd==None: + print parser.usage + exit(0) + + + print "[+] Fetching tweets from: "+str(handle) + spamTgt = reconPerson(handle) + spamTgt.get_tweets() + print "[+] Fetching interests from: "+str(handle) + interests = spamTgt.find_interests() + print "[+] Fetching location information from: "+\ + str(handle) + location = spamTgt.twitter_locate('mlb-cities.txt') + + + spamMsg = "Dear "+tgt+"," + + if (location!=None): + randLoc=choice(location) + spamMsg += " Its me from "+randLoc+"." + + if (interests['users']!=None): + randUser=choice(interests['users']) + spamMsg += " "+randUser+" said to say hello." + + if (interests['hashtags']!=None): + randHash=choice(interests['hashtags']) + spamMsg += " Did you see all the fuss about "+\ + randHash+"?" + + if (interests['links']!=None): + randLink=choice(interests['links']) + spamMsg += " I really liked your link to: "+\ + randLink+"." + + spamMsg += " Check out my link to http://evil.tgt/malware" + print "[+] Sending Msg: "+spamMsg + + sendMail(user, pwd, tgt, 'Re: Important', spamMsg) + +if __name__ == '__main__': + main() diff --git a/twitter_email/twitterClass.py b/twitter_email/twitterClass.py new file mode 100644 index 0000000..4a3a8dc --- /dev/null +++ b/twitter_email/twitterClass.py @@ -0,0 +1,94 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import urllib +from anonBrowser import * +import json +import re +import urllib2 + + +class reconPerson: + + def __init__(self, handle): + self.handle = handle + self.tweets = self.get_tweets() + + def get_tweets(self): + query = urllib.quote_plus('from:' + self.handle+\ + ' since:2009-01-01 include:retweets' + ) + tweets = [] + browser = anonBrowser() + browser.anonymize() + response = browser.open('http://search.twitter.com/'+\ + 'search.json?q=' + query) + + json_objects = json.load(response) + for result in json_objects['results']: + new_result = {} + new_result['from_user'] = result['from_user_name'] + new_result['geo'] = result['geo'] + new_result['tweet'] = result['text'] + tweets.append(new_result) + return tweets + + def find_interests(self): + interests = {} + interests['links'] = [] + interests['users'] = [] + interests['hashtags'] = [] + + for tweet in self.tweets: + text = tweet['tweet'] + links = re.compile('(http.*?)\Z|(http.*?) ').findall(text) + + for link in links: + if link[0]: + link = link[0] + elif link[1]: + link = link[1] + else: + continue + + try: + response = urllib2.urlopen(link) + full_link = response.url + interests['links'].append(full_link) + except: + pass + interests['users'] +=\ + re.compile('(@\w+)').findall(text) + interests['hashtags'] +=\ + re.compile('(#\w+)').findall(text) + + interests['users'].sort() + interests['hashtags'].sort() + interests['links'].sort() + return interests + + def twitter_locate(self, cityFile): + cities = [] + if cityFile != None: + for line in open(cityFile).readlines(): + city = line.strip('\n').strip('\r').lower() + cities.append(city) + + locations = [] + locCnt = 0 + cityCnt = 0 + tweetsText = '' + + for tweet in self.tweets: + if tweet['geo'] != None: + locations.append(tweet['geo']) + locCnt += 1 + + tweetsText += tweet['tweet'].lower() + + for city in cities: + if city in tweetsText: + locations.append(city) + cityCnt += 1 + + return locations +