Posts for: #OSINT

Tweet Time Histogram

I’ve figured out an easy way to get at interesting data. First I fire up the tweet nabber written in ruby, then run this cheap piece of crap and extract only time data from tweets pulled.

After getting the time data, I open the *.csv in Minitab and create a histogram with it. I then have the frequency with which a person tweets over 3k tweets by time, so I can approximate when they’re most active throughout the day based on my relative time zone.

[]

Twitter OSINT Strategies

My current tweet dumper iteration dumps everything collected into a flat file. That’s fine for intermittent use, but won’t do much good when we eventually get into the “big leagues” and start grabbing at streams of data that will include above and beyond 3200 tweets. Flat files will quickly swell to sizes that are no longer manageable.

Wat do.

Well, there are hundreds of “database backend” options. Literally hundreds. We’re inevitably going to be storing tweets from various sources with multiple goals in mind. A veritable forest of *.csv files doesn’t neatly organize our data. SQLite3 will provide the backend. It’s local, zero configuration required, and we can concentrate all our information into a single file with multiple tables.

[]

Ruby Twitter Scraper

Requires the twitter gem. Install it as per usual. Code as follows:

#!/bin/env ruby
# encoding: utf-8

require 'twitter'
require 'csv'

client = Twitter::REST::Client.new do |config|
	config.consumer_key = "insert"
	config.consumer_secret = "insert"
	config.access_token = "insert"
	config.access_token_secret = "insert"
end

def collect_with_max_id(collection=[], max_id=nil, &block)
  response = yield(max_id)
  collection += response
  response.empty? ? collection.flatten : collect_with_max_id(collection, response.last.id - 1, &block)
end

def client.get_all_tweets(user)
  collect_with_max_id do |max_id|
    options = {:count => 200, :include_rts => true}
    options[:max_id] = max_id unless max_id.nil?
    user_timeline(user, options)
  end
end

junk = client.get_all_tweets(ARGV[0])

CSV.open("#{ARGV[0]}.csv", "w") do |csv|
	junk.each do |tweet|
		csv << [tweet.id, tweet.created_at, tweet.user.screen_name, tweet.text, tweet.source, tweet.geo]
	end
end

Excellent. I’m going to revise it as necessary, but it’s a most effective scraper. Though I’d love to add some sort of progress bar to it, haven’t succeeded in that yet. I’ll keep you posted and update it as the iterations of this thing change. It was smashed together from the twitter gem’s bare scraper and CSV output added. I’m quite pleased. Going to also consider adding time and date statistics compilation. I might just write an entirely separate script for that. Not sure yet.

[]

Putting It All Together

Grab the mention counter. Grab the tweet scraper. Point it at four or five “known” associated targets and grab 3k tweets at regular expected intervals. Better yet, use tweepy to regularly grab tweets as they’re sent. Amass a good amount. Once you’ve amassed a good amount of tweets, fire up the mention counter. Make your cutoff large. Make it count.

Fire up Gephi and open your CSV in it. It should automatically generate an interesting map. Use the heat map feature to get even more interesting results. Be amazed that you can OSINT. Most of all, have fun.

[]