Advertisement
NiHaoMike

jericho_key.py

Dec 20th, 2018
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.27 KB | None | 0 0
  1. """
  2. Welcome to Jericho!
  3.  
  4. In the game Detroit: Become Human, deviant androids are androids that have decided to break free from their programming and live a life of their own. Jericho is a safe haven for deviant androids to live.
  5.  
  6. Similarly, in the television world, many content creators have decided to break free from or have never been part of corporate media. Many of them rely on donations from viewers in order to be able to do so. Unfortunately, only a small percentage of viewers actually donate to content creators. This script is codenamed Jericho since it is intended to be shared with viewers who want to support content creators. They can then make a profit mining Swagbucks and share that profit with their favorite content creators.
  7.  
  8. Before you start: The mining pools impose IP limits so multiple setups on the same IP address will not work. They also only allow mining from some countries including the US. The script will require some modifications to work with your device. Expect about $17/month of profit as of December 2018. That's not much until many viewers do it and the donations add up! The profit will continue to slowly go down as difficulty increases. The more miners online, the faster the difficulty will rise. *Therefore, please only share this script with people you trust to give back to community!*
  9.  
  10. As for who to support, I strongly recommend supporting Fran Blanche and/or Naomi Wu because they're currently in most need of support. I suggest giving at least 80% of the profit since the setup is very energy efficient and less than 5% is sufficient to cover electricity expenses. It would probably work best using yourself as an exchange service - e.g. use a credit card to give to the creators and exchange the mined Swagbucks for gift cards you can use to offset the cost.
  11. Fran Blanche:
  12. https://www.youtube.com/user/ContourCorsets/videos
  13. https://www.patreon.com/frantone
  14. Naomi Wu:
  15. https://www.youtube.com/channel/UCh_ugKacslKhsGGdXP0cRRA/videos
  16. https://www.subscribestar.com/naomi-wu
  17. https://www.sther.co/naomiwu
  18. https://en.tipeee.com/naomiwu
  19.  
  20. Please note that they are not officially involved with this script so do not contact them regarding it - this script was shared out of my interest to support independent television!
  21.  
  22. Requirements:
  23. * Raspberry Pi or other low power Linux computer
  24. * dedicated phone or tablet running at least Android 5, rooted
  25. * old pair of headphones, 3.5mm plug/cable, or hardware modification to mute device
  26. * Python 2.7 (this script is old and is not guaranteed to work on Python 3)
  27. * adb
  28. * AdAway
  29. * Swagbucks mining apps - Swagbucks Watch, EntertainNow, Indymusic.tv, Lifestylz.tv, MovieCli.ps, Sportly.tv, Swagbucks
  30.  
  31. Set up a Swagbucks account if you don't already have one. Don't bother with buying Swagbucks or taking the surveys - it's far more profitable to mine!
  32. Install the mining apps and AdAway. (Do not run AdAway yet.) I suggest using Apkpure (https://apkpure.com/) either on the device or downloading the APKs on your PC and then using adb to install them onto the device. Afterwards, disable the browsers and Play store on the device, disable the lockscreen, mute the device, and enable adb if it isn't already. Also enable displaying touch coordinates to make it easy to edit the adb tap commands.
  33. Open one mining app, log it in, and add favorites (except for the Swagbucks app) - see the following as a guideline for the shortest videos which maximise profits:
  34. https://www.reddit.com/r/SwagBucks/comments/91jzyd/what_are_the_current_shortest_videos_for_each/
  35. Manually run the app to test it. Take note of the menu coordinates since those will be needed later. It's OK if it gets stuck on an ad - that will be solved in the next step. Exit the app and move on to the next one. Repeat until every app has been set up.
  36. Close all apps and open Adaway. Select just the topmost entry in the list (https://adaway.org/hosts.txt), go into the user lists, and add the following to the blacklist:
  37. * ads.tremorhub.com
  38. * ads30.adcolony.com
  39. * config.tremorhub.com
  40. * device-api.urbanairship.com
  41. * e.crashlytics.com
  42. * events3.adcolony.com
  43. * i.yimg.com
  44. * mediate-android-b74.hyprmx.com
  45. * remote-data.urbanairship.com
  46. * rm4.adtilt.com
  47. * syn.entertainmentcrave.com
  48. * wd.adcolony.com
  49.  
  50. Now apply the changes and close AdAway.
  51.  
  52. Place shortcuts of each app on the home screen. Note their coordinates in order to edit the tap commands used to automatically start them. Have the Swagbucks app run last since it is slower than the others.
  53. Set the Raspberry Pi to Pacific time zone if it isn't already. Install adb on the Raspberry Pi if it isn't already and run adb devices with the device connected to verify it can be seen. The device may ask whether or not to allow adb access, in which case select the option to remember and press yes.
  54. Now just run this script and with luck, it will automatically start mining every day. Some debugging is likely to be necessary for it to run flawlessly.
  55.  
  56. Copyright (C) 2016-2019 Mike Lu
  57.  
  58. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  59.  
  60. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  61.  
  62. You should have received a copy of the GNU General Public License along with this program.  If not, see <https://www.gnu.org/licenses/>.
  63. """
  64. import subprocess
  65. from time import sleep
  66. from time import time
  67. from time import localtime
  68. ip="0123456789ABCDEF"  # IP address or serial number of device
  69.  
  70. def connect(ip):
  71.     if "." in ip:
  72.         subprocess.check_output(["adb","connect",ip])
  73.     else:
  74.         subprocess.check_output(["adb","-s",ip,"shell","echo ok"])
  75.  
  76. def startminer(ip,menu="input tap 36 380"):
  77.     if menu is not None:
  78.         subprocess.check_output(["adb","-s",ip,"shell","input tap 33 88"])
  79.         sleep(3)
  80.         subprocess.check_output(["adb","-s",ip,"shell",menu])
  81.         sleep(3)
  82.         subprocess.check_output(["adb","-s",ip,"shell","input tap 36 250"])
  83.     else:
  84.         subprocess.check_output(["adb","-s",ip,"shell","input tap 200 400"])
  85.     sleep(15)
  86.  
  87. def closeall(ip):  # stop all apps
  88.     subprocess.check_output(["adb","-s",ip,"shell","input keyevent 3"])
  89.     subprocess.check_output(["adb","-s",ip,"shell","am force-stop com.sportly.views"])
  90.     subprocess.check_output(["adb","-s",ip,"shell","am force-stop com.movieclips.views"])
  91.     subprocess.check_output(["adb","-s",ip,"shell","am force-stop com.lifestylztv.views"])
  92.     subprocess.check_output(["adb","-s",ip,"shell","am force-stop com.entertainnowmobile.views"])
  93.     subprocess.check_output(["adb","-s",ip,"shell","am force-stop com.indymusictv.views"])
  94.     subprocess.check_output(["adb","-s",ip,"shell","am force-stop com.prodege.swagbucksmobile"])
  95.     subprocess.check_output(["adb","-s",ip,"shell","am force-stop com.swagbuckstvmobile.views"])
  96.     subprocess.check_output(["adb","-s",ip,"shell","input keyevent 3"])
  97.     sleep(1)
  98.  
  99. def checkminer(ip,timeout_i=45,restart="input tap 800 380",menu="input tap 36 380",lp=False):
  100.     proc=None
  101.     errorcount=0
  102.     timeout=timeout_i
  103.     res=""
  104.     while True:
  105.         try:
  106.             connect(ip)
  107.             sleep(1)
  108.             subprocess.check_output(["adb","-s",ip,"logcat","-c"])
  109.             proc=subprocess.Popen(["adb","-s",ip,"logcat"],stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
  110.             lastupdate=time()
  111.             if "- waiting for device -" in proc.stdout.readline():
  112.                 errorcount=0
  113.                 raise IOError
  114.             while (time()-lastupdate)<5:
  115.                 proc.stdout.readline()
  116.             lastupdate=time()
  117.             stuckcount=0
  118.             while True:
  119.                 line=proc.stdout.readline()
  120.                 if ": AH vidur 0" in line or "returning error: 0x80001001" in line or "GraphicBufferAllocator: Failed to allocate" in line:
  121.                     subprocess.check_output(["adb","-s",ip,"reboot"])
  122.                     errorcount=0
  123.                     sleep(120)
  124.                     connect(ip)
  125.                     startminer(ip,menu)
  126.                     raise IOError
  127.                 elif "AH " in line or "OkHttp" in line:
  128.                     print(line.strip())
  129.                     lastupdate=time()
  130.                     timeout=timeout_i
  131.                     if "sb_today" in line:
  132.                         res=line.strip()
  133.                     if "was_in_bonus" in line:
  134.                         stuckcount=0
  135.                         errorcount=0
  136.                     if "win/at limit" in line or '"to_win":0,"current_count":0,"bonus":false' in line:
  137.                         print("limit reached")
  138.                         proc.terminate()
  139.                         return res
  140.                 elif "Player" in line and "NuPlayer" not in line or "OMX" in line or "Ads" in line:
  141.                     #print(line)
  142.                     stuckcount=0
  143.                     timeout=timeout_i
  144.                     if (time()-lastupdate)>15:
  145.                         print("Last update "+str(time()-lastupdate)+" seconds ago")
  146.                     lastupdate=time()
  147.                 elif (time()-lastupdate)>timeout:
  148.                     print("Appears to be stuck, trying to unstick")
  149.                     stuckcount=stuckcount+1
  150.                     timeout=timeout_i/2
  151.                     subprocess.check_output(["adb","-s",ip,"shell","input tap 1400 21"])
  152.                     subprocess.check_output(["adb","-s",ip,"shell","input tap 800 21"])
  153.                     if stuckcount==2:
  154.                         if errorcount>12:
  155.                             return "Error"
  156.                         subprocess.check_output(["adb","-s",ip,"shell","input keyevent 4"])
  157.                         sleep(5)
  158.                         startminer(ip,menu)
  159.                         errorcount=errorcount+1
  160.                     elif stuckcount==3:
  161.                         if errorcount>12:
  162.                             return "Error"
  163.                         closeall(ip)
  164.                         subprocess.check_output(["adb","-s",ip,"shell",restart])
  165.                         sleep(25)
  166.                         startminer(ip,menu)
  167.                         errorcount=errorcount+1
  168.                     elif stuckcount>3:
  169.                         if errorcount>12:
  170.                             return "Error"
  171.                         raise IOError
  172.                     lastupdate=time()
  173.                 elif lp:
  174.                     ctime=localtime()
  175.                     if (ctime.tm_hour==23) and ctime.tm_min>=59:  # exit low priority app to allow more profitable app to run
  176.                         proc.terminate()
  177.                         return ""
  178.         except IOError:
  179.             try:
  180.                 errorcount=errorcount+1
  181.                 if "." in ip:
  182.                     subprocess.check_output(["adb","disconnect",ip])
  183.                 else:
  184.                     subprocess.check_output(["adb","-s",ip,"shell","echo ok"])
  185.             except:
  186.                 pass
  187.         except:
  188.             pass
  189.         proc.terminate()
  190.         sleep(10)
  191.  
  192.  
  193. print("Welcome to Jericho!")
  194. results=["","","","","","",""]
  195. while True:
  196.     try:
  197.         connect(ip)
  198.         sleep(1)
  199.         closeall(ip)
  200.         subprocess.check_output(["adb","-s",ip,"shell","input tap 800 380"])  # start app
  201.         sleep(25)
  202.         startminer(ip)
  203.         starttime=time()
  204.         results[0]=checkminer(ip,45,"input tap 800 380")  # also give coordinates here for automatically restarting app
  205.         subprocess.check_output(["adb","connect",ip])
  206.         sleep(1)
  207.         closeall(ip)
  208.         subprocess.check_output(["adb","-s",ip,"shell","input tap 800 150"])  # start app
  209.         sleep(25)
  210.         startminer(ip)
  211.         results[1]=checkminer(ip,45,"input tap 800 150")
  212.         subprocess.check_output(["adb","connect",ip])
  213.         sleep(1)
  214.         closeall(ip)
  215.         subprocess.check_output(["adb","-s",ip,"shell","input tap 660 150"])  # start app
  216.         sleep(25)
  217.         startminer(ip)
  218.         results[2]=checkminer(ip,45,"input tap 660 150")
  219.         subprocess.check_output(["adb","connect",ip])
  220.         sleep(1)
  221.         closeall(ip)
  222.         subprocess.check_output(["adb","-s",ip,"shell","input tap 520 150"])  # start app
  223.         sleep(25)
  224.         startminer(ip)
  225.         results[3]=checkminer(ip,45,"input tap 520 150")
  226.         subprocess.check_output(["adb","connect",ip])
  227.         sleep(1)
  228.         closeall(ip)
  229.         subprocess.check_output(["adb","-s",ip,"shell","input tap 370 150"])  # start app
  230.         sleep(25)
  231.         startminer(ip)
  232.         results[4]=checkminer(ip,45,"input tap 370 150")
  233.         subprocess.check_output(["adb","connect",ip])
  234.         sleep(1)
  235.         closeall(ip)
  236.         subprocess.check_output(["adb","-s",ip,"shell","input tap 240 150"])  # start app
  237.         sleep(25)
  238.         startminer(ip)
  239.         results[5]=checkminer(ip,45,"input tap 240 150")
  240.         subprocess.check_output(["adb","connect",ip])
  241.         sleep(1)
  242.         closeall(ip)
  243.         if (time()-starttime)>60000:  # if previous apps have run for a long time, give them a rerun before moving on
  244.             continue
  245.         subprocess.check_output(["adb","-s",ip,"shell","input tap 800 600"])  # start Swagbucks
  246.         sleep(25)
  247.         startminer(ip,menu=None)
  248.         results[6]=checkminer(ip,120,"input tap 800 600",menu=None,lp=True)
  249.         connect(ip)
  250.         sleep(1)
  251.         closeall(ip)
  252.         for result in results:  # print summary
  253.             print(result)
  254.         while True:  # wait for next day
  255.             ctime=localtime()
  256.             if (ctime.tm_hour==23) and ctime.tm_min==59:
  257.                 break
  258.             if (ctime.tm_hour==0) and ctime.tm_min<=5:
  259.                 break
  260.             sleep(10)
  261.         for i in range(3):
  262.             subprocess.check_output(["adb","-s",ip,"shell","input keyevent 3"])  # wake up device
  263.     except:
  264.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement