Last active
August 29, 2015 13:57
-
-
Save tomoconnor/9911745 to your computer and use it in GitHub Desktop.
Unicoin Miner script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # REPLACE YOUR FKEY value. You need to load a stack site, view the source, Ctrl-F and find your fkey, then put it into the command line as argv[1]. | |
| # so run it as python miner.py <your fkey> | |
| # It also relies on Google Chrome's cookie lib to find the auth cookies. | |
| import requests | |
| import sqlite3 | |
| import os | |
| from urlparse import urlparse | |
| import sys | |
| fkey = sys.argv[1] | |
| import time | |
| def chrome_cookies(url): | |
| # Set the path to Chrome cookies in OSX | |
| cookie_file = os.path.expanduser('~/.config/google-chrome/Default/Cookies') | |
| # Part of the domain name that will help the sqlite3 query pick it from the Chrome cookies | |
| domain = urlparse(url).netloc | |
| conn = sqlite3.connect(cookie_file) | |
| sql = '''select name, value from cookies where host_key like "%{}%"'''.format(domain) | |
| cookies = {} | |
| cookies_list = [] | |
| for row in conn.execute(sql): | |
| cookies_list.append(row) | |
| cookies.update(cookies_list) | |
| return cookies | |
| while True: | |
| ts = int(time.time())*1000 | |
| rock_url = "http://serverfault.com/unicoin/rock?_=%s" % ts | |
| mine_url = "http://serverfault.com/unicoin/mine?rock=%s" | |
| _headers = { 'Origin':'http://serverfault.com', | |
| "Accept-Encoding": 'gzip,deflate,sdch', | |
| 'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6', | |
| 'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36', | |
| 'Content-Type': 'application/x-www-form-urlencoded', | |
| 'Accept': '*/*', | |
| 'Referer':' http://serverfault.com/', | |
| 'X-Requested-With':' XMLHttpRequest', | |
| 'Connection': 'keep-alive' | |
| } | |
| payload={'fkey':fkey} | |
| rock = requests.get(rock_url, data=payload, headers=_headers, cookies=chrome_cookies(rock_url)) | |
| print rock.status_code | |
| if rock.status_code == 404: | |
| break | |
| if rock.status_code == 200: | |
| print rock.content | |
| print rock.json() | |
| rock_id = rock.json()['rock'] | |
| mine = requests.post(mine_url % rock_id, data=payload, headers=_headers, cookies=chrome_cookies(rock_url)) | |
| print mine_url % rock_id | |
| print mine.status_code | |
| if mine.status_code == 404: | |
| break | |
| if mine.status_code != 404: | |
| print mine.content | |
| print mine.json() | |
| time.sleep(10) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment