root/ponzi.py

User picture

Author: therm000

Revision: 30 («Previous)

File Size 3.05 KB

(July 18, 2011 UTC) 7 months ago

comic ponzi scheme on whuffiebank plus failure...

 
Show/hide line numbers
# Ponzi Scheme on WhuffieBank, failure...
# copyleftrightdicotomy -> @therm000
# December, 2009.

import time,urllib2,random

import twython

create_whuffies = 1

bernie_account = '_berniemadoff_'
bernie_pass = 'XXXXXXXXXXXXXX'

bernie_followers = ['twittustest1','twittustest2', 'twittustest3']
bernie_followers_pass = ['XXXXXXXXXXX','XXXXXXXXXX','XXXXXXXXXXXX']

agent_sleep = 240.0 # seconds
twit_sleep = 120.0 # seconds


bernie_agents = map(lambda (f, fp) : twython.setup(username=f, password=fp), zip(bernie_followers,bernie_followers_pass))


def get_balance(user, user_pass):
	ret = None
	try:
		balance = eval(urllib2.urlopen('http://thewhuffiebank.org/api/balance?username=%s&password=%s'%(user,user_pass)).read())
		ret = balance['balance']
	except:
		balance = eval(urllib2.urlopen('http://thewhuffiebank.org/api/balance?username=%s&password=%s'%(user,user_pass)).read())
		ret = balance['balance']
	return ret		

initial_bernie_balance = get_balance(bernie_account, bernie_pass)

direct_rt, indirect_rt, stop = 0, 0, False

print 'BEGIN: Starting money creating process inside re-twitting Ponzi Scheme!'
print 'BEGIN: Initial money of bernie: %d whuffies' % initial_bernie_balance

while True:

	for agent, foll in zip(bernie_agents,bernie_followers):

		twitter = agent

		print 'INFO: analysing agent "%s" friend timeline to create bernie\'s money...' % foll
		res = twitter.getFriendsTimeline(count=1)
		for e in res:
	
			#print e['user']['screen_name']
			#print e['text']

			if bernie_account == e['user']['screen_name']:
		
				print 'INFO: bernie\'s money seed detected in "%s" timeline!' % foll
				print 'INFO: replicating twit...'
				t = "RT @%s: %s time -> %s" % (bernie_account,e['text'][:90],time.ctime	())
				print 'INFO: ' + t
				twitter.updateStatus( t[:140] )
				direct_rt += 1

				random_sleep = random.random() * twit_sleep
				print 'INFO: sleeping %.1f seconds after twit...' % random_sleep
				time.sleep(random_sleep)

	
			elif e['text'].startswith('RT @%s'%bernie_account):
				print 'INFO: bernie\'s re-twit detected in "%s" timeline!' % foll
				print 'INFO: replicating twit...'
				t = "%s time -> %s" % (e['text'][:90],time.ctime())
				print 'INFO:' + t
				twitter.updateStatus( t[:140] )
				indirect_rt += 1

				random_sleep = random.random() * twit_sleep
				print 'INFO: sleeping %.1f seconds after twit...' % random_sleep
				time.sleep(random_sleep)


		bernie_balance = get_balance(bernie_account, bernie_pass)
		print 'INFO:'			
		print 'INFO: new bernie balance is %d' % bernie_balance
		if bernie_balance >= initial_bernie_balance + create_whuffies:
			stop = True
			break
			
	if stop:
		break

	random_sleep = random.random() * agent_sleep
	print 'INFO: sleeping %.1f seconds between all agents...' % random_sleep
	time.sleep(random_sleep)


print 'END: Done! %d whuffies created!' % (bernie_balance - initial_bernie_balance)
print 'END: Stop!'
print 'END: Desired whuffies: %d' % (create_whuffies)
print 'END: %d direct re-twits' % direct_rt
print 'END: %d indirect re-twits' % indirect_rt
print 'END: total %d re-twits' % (direct_rt+indirect_rt)