Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
3.6 kB
10
Indexable
Never
import os
import sys
import requests
import time
import heroku3
from time import time as timestamp
from time import timezone
import uvicorn
import platform,socket,re,uuid
import names
import base64
import random
from hashlib import sha1
import hmac
from base64 import b85decode, b64decode
from fastapi import FastAPI, Request
import json
from fastapi.responses import JSONResponse
from time import sleep
import hmac
from json_minify import json_minify
import requests_random_user_agent
key="967e107a-b0cf-45fe-8dbe-886a0fb0d6a2"
name="coinsig121"
def res():
    heroku_conn = heroku3.from_key(key)
    botapp= heroku_conn.apps()[name]
    botapp.restart()
def r():
    s = requests.Session()
    return s.headers['User-Agent']
def sigg(data):
        key='f8e7a61ac3f725941e3ac7cae2d688be97f30b93'
        mac = hmac.new(bytes.fromhex(key), data.encode("utf-8"), sha1)
        digest = bytes.fromhex("42") + mac.digest()
        return base64.b64encode(digest).decode("utf-8")
def dev():
    hw=(names.get_full_name()+str(random.randint(0,10000000))+platform.version()+platform.machine()+names.get_first_name()+socket.gethostbyname(socket.gethostname())+':'.join(re.findall('..', '%012x' % uuid.getnode()))+platform.processor())
    identifier=sha1(hw.encode('utf-8')).digest()
    key='02b258c63559d8804321c5d5065af320358d366f'
    mac = hmac.new(bytes.fromhex(key), b"\x42" + identifier, sha1)
    return (f"42{identifier.hex()}{mac.hexdigest()}").upper()


def header(sid):
          headers = {
            "NDCDEVICEID": dev(),
            "Accept-Language": "en-US",
            "Content-Type": "application/json; charset=utf-8",
            "User-Agent":r(),
            "Host": "service.narvii.com",
            "Accept-Encoding": "gzip",
            "Connection": "Keep-Alive"}
          headers["NDCAUTH"] = f"sid={sid}"
          return headers



def sendActive(comId: str,sid:str, rang: int = 1, tz: int = -timezone // 1000, timers: list = None, timestamp: int = int(timestamp() * 1000)):
    
        """
        Send A Active Time To Community
        **Returns**
            - **Success**: Post Request objects (
            - **WssClient**: A Client With Amino Socket Functions (Class)
            - **Success**: Post Request objects
        """
        chunkes = []

        for i in range(rang):
            start = int(time.time())
            end = start + 300
            chunkes.append({"start": start, "end": end})

        data = {
            "userActiveTimeChunkList": chunkes,
            "timestamp": timestamp,
            "optInAdsFlags": 2147483647,
            "timezone": tz
        }

        if timers:
            data["userActiveTimeChunkList"] = timers

        data = json_minify(json.dumps(data))
        headers=header(sid)
        headers["NDC-MSG-SIG"] =sigg(data)
        headers["Content-Length"] = str(len(data))
        response = requests.post(f"https://service.narvii.com/api/v1/x{comId}/s/community/stats/user-active-time", headers=headers, data=data)
        return response.json()

app = FastAPI()

@app.get('/')
async def get_webpage():
    return "coin server"
    
@app.get('/reset')
async def ress():
    res
    return "restarted"



@app.post("/coin")
async def submit_report(request: Request):
    body = await request.json()
    #os.system("sudo service tor restart")
    sid=body["sid"]
    comId=body["comId"]
    #sleep(2)
    rang=40
    #session=get_tor_ip()
    for _ in range(25):
        rr=sendActive(comId,sid,rang)
        print(rr)
    res()
    return rr