Advertisement
Guest User

fj_viewer

a guest
Oct 30th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.42 KB | None | 0 0
  1. """
  2. TL:DR:
  3. 1.Install Python 2.7
  4. 2. Copy from 'import threading' down, or Ctrl A if youre SUPER lazy
  5. 3. Paste into notepad, not word
  6. 4. Save as fj_viewer.py
  7. 5. Double click the file, hit enter, view count skyrocket.
  8.  
  9. funnyjunk anon here. Heres my view spammer code. Already explained a few unimportant things in my comment section but heres a
  10. how to guide on getting my code working(and it works quite reliably and well if im allowed a moment of pride for my messy code, but could always be better!). I provide explanation for each step for the curious. Theres not many I promise!
  11.  
  12. 1. Get the python interpreter here: https://www.python.org/downloads/release/python-278/
  13. (direct link to windows installer for lazy: https://www.python.org/ftp/python/2.7.8/python-2.7.8.msi
  14.  
  15. what is it? why you need it? This is an interpreter for the python programming language. it reads source code and executes
  16. actions based on the code. Python is an amazing language to learn and use(plus more and more companies are using it, including Google)
  17. and while possible to make python code into an executable to remove the need to install the interpreter, I doubt you want to run some
  18. executable I post(I wouldnt) so getting the interpreter yourself and running the code directly is safer(plus some pythonista would be able to point out if I was trying anything sneaky). And who knows, you may get curious enough to learn how to program in python yourself, and youre already set to go.
  19.  
  20. 2. Make sure while installing that the register extensions and add Python to path is added, should be checked by default but this will
  21. make your life easier(esp if you get into python later on).
  22.  
  23. 3. open up your text editor of choice such as notepad.exe DO NOT USE WORD. microsoft word and similar programs add extra data to the
  24. text which makes it unreadable to the interpreter. using something like notepad.exe or notepad++ will save the text as is and preserve formatting that python needs
  25.  
  26. 4. Copy the entire file starting from 'import threading' down.
  27. you can copy this entire paste if youre THAT lazy, I used some document strings so if python encounters this whole block of text it'll think this is all some huge comment and not any code that needs to be processed.
  28.  
  29. 5. Paste it into your text editor and save it as fj_viewer.py
  30. you can actually name it whatever you want but the important part is the .py at the end. For the save as file type '*.* all files' or '*.txt' is fine. the file icon should appear to be a piece of paper with a blue/yellow logo on it.
  31.  
  32. 6. You can either double click the file to run it with the default values(recommended if youre just trying to join in on the fun)
  33. and it will pause to ask you if youre sure before continuing, just hit enter to start, OR you can run it in something like cmd.exe or PowerShell(installed by default on at least win7) and run it by typing in 'python INSERT_FILE_NAME_HERE' with any of the optional arguments(input specified to change the programs behavior for you non-programmer types).
  34.  
  35. note: in the case of double-clicking it or using cmd.exe the output of the program may look ugly cause of the small boxes. Sorry nothing I can do about that without spending waay too much more time than necessary. I wrote it with the box of PowerShell in mind, since thats my terminal of choice.
  36.  
  37. note on arguments: for the command line enthusiasts and those wanting to use arguments, the usage stuff that gets printed at the start explains it well(notably you can specify WHICH link to 'view'. And I'm already repeating tons of things as is cause Adderall lol So ask questions if need be. The astute reader will note that very little is actually hardcoded for funnyjunk. With some little modification one could easily modify this to increase the view count of other pages on completely different websites. You should also note that this does NOT(unless the advertisements are coded THAT weirdly) increase ad revenue for admin. This script never actually finds and 'views' any of the ad links like your browser automatically would. While it really wouldnt be difficult to extend this to view the ads as well, Im not going to because the ad companies could consider it Click Fraud and Glorious Admin could get in trouble. Im willing to be a dick and flood his bandwidth/viewcount for the lawls, but potentially ruining his advertisement income if those companies notice the fake views is too far for my personal morals(without being asked to try by Admin himself of course, hue hue hue).
  38.  
  39. 7. MASSIVE view counts inbound!!!
  40. """
  41. import threading
  42. import urllib2
  43. import sys
  44. import time
  45.  
  46. def get_cookies():
  47.     request = urllib2.Request("http://www.funnyjunk.com")
  48.     try:
  49.         response = urllib2.urlopen(request)
  50.         cookies = response.info()['Set-Cookie']
  51.         print "Got session cookies: ", cookies
  52.         return cookies
  53.     except urllib2.URLError, e:
  54.         print 'Failed to get cookies: %s', e
  55.        
  56. class ThreadedViews(threading.Thread):
  57.     def __init__(self, session, link, timeout):
  58.         threading.Thread.__init__(self)
  59.         self.session = session
  60.         self.link = link
  61.         self.viewcount = 0
  62.         self.requestObj = None
  63.         self.timeout = timeout
  64.         #use Alive as a 'kill control' for cleaner exiting
  65.         self.Alive = True
  66.         #we set some default headers here, that makes the script look like a browser
  67.         self.headers = { 'host': 'funnyjunk.com',
  68.                          'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0',
  69.                          'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  70.                          'Accept-Language': 'en-US,en;q=0.5',
  71.                          'Accept-Encoding': 'gzip, deflate',
  72.                          'DNT': '1',
  73.                          'Connection': 'keep-alive'}
  74.                              
  75.     def send_req(self):
  76.         try:
  77.             response = urllib2.urlopen(self.requestObj, None, timeout=self.timeout)
  78.             #dont give a fuck about the response, return true for success
  79.             return True
  80.         except Exception as e:
  81.             print 'View failed from %s because %s: ' % (threading.current_thread().getName(),e)
  82.             return False
  83.            
  84.     def load_session(self):
  85.         #probably couldve done this is __init__, but I want to lower my time needed
  86.         #debugging this by doing it more explicitly
  87.         self.headers['Cookie'] = self.session
  88.         self.requestObj = urllib2.Request(self.link, None, self.headers)
  89.  
  90.        
  91.     def run(self):
  92.         self.load_session()
  93.         while self.Alive:
  94.             result = self.send_req()
  95.             if result:
  96.                 self.viewcount += 1
  97.         #print "Thread closing: ", threading.current_thread().getName()
  98.  
  99. def usage():
  100.     print """\nRun with nothing to run default options or specify the following in a cmd prompt\n
  101.     --help      to see this message again(weirdo)\n
  102.     -t NUMBER   specify NUMBER of threads to run, higher = more views
  103.                 but more likely to overload your network/server and cause issues\n
  104.     --link LINK     specify a differnt fj link to 'view' cause why the fuck not?
  105.     --timeout NUMBER    How long to wait for each view request in seconds, too low and youll get a lot of
  106.                         failed views, too high and a thread will stall for a long time if a
  107.                         network error occurs.
  108. ex:
  109.     cmdprompt> python fj_viewer.py -t 30 --timeout 10 --link http://funnyjunk.com/This+is+how+i+did+it/funny-pictures/5338724/\n
  110.             """
  111.            
  112. def mass_view(link, threadcount,timeout):
  113.     session = get_cookies()
  114.     threads = []
  115.     for i in range(threadcount):
  116.         new_thread = ThreadedViews(session,link,timeout)
  117.         threads.append(new_thread)
  118.         new_thread.start()
  119.     print "Started all threads, spam ctrl-C to close"
  120.     while True:
  121.         #loop to catch interrupts and periodically print current view counts
  122.         try:
  123.             poll_viewcount(threads)
  124.             time.sleep(5)
  125.            
  126.         except KeyboardInterrupt:
  127.             for i in threads:
  128.                 i.Alive = False
  129.                 i.join
  130.             sys.exit()
  131.            
  132. def poll_viewcount(threads):
  133.     total_views = 0
  134.     for i in threads:
  135.         total_views += i.viewcount
  136.     print "Total views: %i" % total_views
  137.  
  138. if __name__ == '__main__':
  139.     link = 'http://funnyjunk.com/This+is+how+i+did+it/funny-pictures/5338724/'
  140.     threads = 30
  141.     timeout = 10
  142.     if len(sys.argv) < 2:
  143.         usage()
  144.         print "Running with default options, bail now if you dont like it or enter to continue!\n"
  145.         print "link: %s, threadcount:%s" % (link,threads)
  146.         cont = raw_input("Enter to continue(or anything really)>> ")
  147.     else:
  148.         if '--help' in sys.argv:
  149.             usage()
  150.             sys.exit()
  151.         elif '-t' in sys.argv:
  152.             threads = int(sys.argv[sys.argv.index('-t')+1])
  153.         elif '--link' in sys.argv:
  154.             link = sys.argv[sys.argv.index('--link')+1]
  155.         elif '--timeout' in sys.argv:
  156.             timeout = int(sys.argv[sys.argv.index('--timeout')+1])
  157.     mass_view(link,threads,timeout)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement