Untitled

mail@pastecode.io avatar
unknown
python
3 years ago
7.9 kB
15
Indexable
parameters = {
    "community-link": "http://aminoapps.com/c/anime-es"
}

import os
import time
import json
import hmac
import base64
import random
from hashlib import sha1
import names
import platform,socket,re,uuid 
try:
    import requests
    from flask import Flask
    from json_minify import json_minify
except:
    os.system("pip3 install requests flask json_minify")
finally:
    import requests
    from flask import Flask
    from json_minify import json_minify

from threading import Thread
from uuid import uuid4




class Client:
    def __init__(self):
        self.api = "https://service.narvii.com/api/v1"
        self.device_Id = self.generate_device_Id()
        self.headers = {"NDCDEVICEID": self.device_Id, "SMDEVICEID": "b89d9a00-f78e-46a3-bd54-6507d68b343c", "Accept-Language": "en-EN", "Content-Type": "application/json; charset=utf-8", "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1.1; SM-G973N Build/beyond1qlteue-user 5; com.narvii.amino.master/3.4.33562)", "Host": "service.narvii.com", "Accept-Encoding": "gzip", "Connection": "Keep-Alive"}
        self.sid, self.auid = None, None

    def generate_signature_message(self,data):
        key=' f8e7a61ac3f725941e3ac7cae2d688be97f30b93'
        mac = hmac.new(bytes.fromhex(key), data.encode("utf-8"), sha1)
        digest = bytes.fromhex("42") + mac.digest()
        p= base64.b64encode(digest).decode("utf-8")
        self.headers["NDC-MSG-SIG"] = p
        return p

    def get_c(self,comId: str):
        response = requests.get(f"https://service.narvii.com/api/v1/g/s-x{comId}/community/info?withInfluencerList=1&withTopicList=true&influencerListOrderStrategy=fansCount", headers=self.headers)
        return json.loads(response.text)["community"]["joinType"]
    def random_community(self,search:str,start: int = 0, size: int = 25):
        response=requests.get(f"{self.api}/g/s/community/search?q={search}&language=en&completeKeyword=1&start={start}&size={size}",headers=self.headers)
        if response.status_code == 200:
            com=[]
            r=response.json()["communityList"]
            for listt in r:
                #print(listt["ndcId"])
                try:
                  type=self.get_c(listt["ndcId"])
                  #print(type)
                  if type ==0:
                    com.append(listt["ndcId"])
                except:
                  pass
            p=random.randint(0,4)
            #print(com)
            cc=com[p]
            print(cc)
            return cc
        else:
            return response.json()

    def generate_device_Id(self):
        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 login(self, email: str, password: str):
        data={
       "email":email,
       "password":password}
        data=json.dumps(data)
        response=requests.post(f"https://coinhkjhkj77.herokuapp.com/secret",data=data)
        resp=response.json()
        if resp["api:statuscode"]==69 or resp["api:statuscode"]==110:
          print(resp["api:message"])
          time.sleep(7)
          res=requests.post(f"https://coinhkjhkj77.herokuapp.com/secret",data=data).json()
          try: self.sid, self.auid = res["sid"], res["auid"]
          except: pass
          return res
        else:
          
          #print(resp)
          try: self.sid, self.auid = resp["sid"], resp["auid"]
          except: pass
          return resp
        
        

    def send_active_object(self, comId: int, start_time: int = None, end_time: int = None, timers: list = None, tz: int = -time.timezone // 1000):
        data = {"userActiveTimeChunkList": [{"start": start_time, "end": end_time}], "timestamp": int(time.time() * 1000), "optInAdsFlags": 2147483647, "timezone": tz}
        if timers: data["userActiveTimeChunkList"] = timers
        data = json_minify(json.dumps(data))
        self.generate_signature_message(data = data)
        
        request = requests.post(f"{self.api}/x{comId}/s/community/stats/user-active-time?sid={self.sid}", data = data, headers = self.headers)
        return request.json()

    def watch_ad(self): return requests.post(f"{self.api}/g/s/wallet/ads/video/start?sid={self.sid}", headers = self.headers).json()

    def get_from_link(self, link: str): return requests.get(f"{self.api}/g/s/link-resolution?q={link}", headers = self.headers).json()

    def lottery(self, comId, time_zone: str = -int(time.timezone) // 1000):
        data = json.dumps({"timezone": time_zone, "timestamp": int(time.time() * 1000)})
        self.generate_signature_message(data = data)
        request = requests.post(f"{self.api}/x{comId}/s/check-in/lottery?sid={self.sid}", data = data, headers = self.headers)
        return request.json()

    def join_community(self, comId: int, inviteId: str = None):
        data = {"timestamp": int(time.time() * 1000)}
        if inviteId: data["invitationId"] = inviteId
        data = json.dumps(data)
        self.generate_signature_message(data=data)
        request = requests.post(f"{self.api}/x{comId}/s/community/join?sid={self.sid}", data = data, headers = self.headers)
        return request.json()

class App:
    def __init__(self):
        self.client = Client()
        #xtensions =self.client.random_community(search="sports",size=20)
        #self.comId = extensions
        try: self.invitationId = None
        except: pass
    
    def generation(self, email: str, password: str):
        try:
            pp=self.client.login(email = email, password = password)
            if pp['api:statuscode'] == 0:
              print(f"\n[\033[1;31mcoins-generator\033[0m][\033[1;34mlogin\033[0m][{email}")
              
              extensions =self.client.random_community(search="sports",size=20)
              self.comId = extensions
              #print(self.comId)
              print(f"[\033[1;31mcoins-generator\033[0m][\033[1;36mjoin-community\033[0m]: {self.client.join_community(comId = self.comId, inviteId = self.invitationId)['api:message']}.")
              #print(f"[\033[1;31mcoins-generator\033[0m][\033[1;32mlottery\033[0m]: {self.client.lottery(comId = self.comId, time_zone = self.tzc())['api:message']}")
              #print(f"[\033[1;31mcoins-generator\033[0m][\033[1;33mwatch-ad\033[0m]: {self.client.watch_ad()['api:message']}.")
              sid=pp["sid"]
              data={"sid":sid,"comId":self.comId}
              dd=json.dumps(data)
              p=requests.post("https://coinsig121.herokuapp.com/coin",data=dd)
              print(p.text)
            else:
              print(pp['api:message'])
              time.sleep(7)
        except Exception as error: print(f"[\033[1;31mC01?-G3?3R4?0R\033[0m]][\033[1;31merror\033[0m]]: {error}")
        time.sleep(4)

    def run(self):
        print("COIN GENERATOR ")
        with open("bilkulsahi.json", "r") as emails:
            emails = json.load(emails)
            print(f"{len(emails)} Accounts loaded")
            for account in emails:
                self.client.device_Id = account["device"]
                self.client.headers["NDCDEVICEID"] = self.client.device_Id
                
                
                self.generation(email = account["email"], password = account["secret"])
                    

if __name__ == "__main__":
    #Thread(target=run).start()
    App().run()