active room scanner

cyberwaste
by cyberwaste · 9 posts
4 years ago in Python
Posted 4 years ago · Author
Hello fellow people,

some time back I wrote myself a little active person/room scanner and I thought I'd share it with you. Because it was just for myself, I never really cleaned up the code. However I might improve it in the future e.g. threads and proxy support wouldn't be bad to speed it up. Requires "requests" lib. Get it over pip.

Usage:

Code

-c <cid>
-b <room to start with, should be 1>
-e <room to end with>
-v <verbose mode, display all scans>
-p <just show rooms with people inside and list them>
-d <delay in seconds, float values as 0.5 possible>

example 1:
python rscan.py -c 00000000 -b 1 -e 500 -p -d 0.5

example 2:
python rscan.py -c 00000000 -b 200 -e 499 -v



I don't mind when you share / copy / modify the code, but keep giving creds. Thanks.

Code

#!/usr/bin/python
"""

        .______  .________._______ .______  .______ 
        : __   \ |    ___/:_.  ___\:      \ :      \
        |  \____||___    \|  : |/\ |   .   ||       |
        |   :  \ |       /|    /  \|   :   ||   |   |
        |   |___\|__:___/ |. _____/|___|   ||___|   |
        |___|       :      :/          |___|    |___|
                    :

      roomscanner is a tool for scanning rooms owned by a person.
      It aims on finding all of one avatar, even private rooms.

      Version: 0.1

      Written by cyberwaste

"""

import sys
import argparse
import os
import requests
import time
import json

def clear():
   os.system("cls" if os.name == "nt" else "clear")


def infoheader(mode):
    clear()
    print("="*50)
    print("=>")
    print("=> RSCAN - 0.1")
    print("=> written by cyberwaste")
    print("=>")
    print("="*50)
    if ( mode == 0 ):
        print("-"*50)
        print("->>  Target: %s" %(options.cid))
        print("->>    From: %d to %d" %(options.begin,options.end))
        print("-"*50)
    elif ( mode == 1):
        parser.print_help()


def extract_values(obj, key):
    """Pull all values of specified key from nested JSON."""
    arr = []

    def extract(obj, arr, key):
        """Recursively search for values of key in JSON tree."""
        if isinstance(obj, dict):
            for k, v in obj.items():
                if isinstance(v, (dict, list)):
                    extract(v, arr, key)
                elif k == key:
                    arr.append(v)
        elif isinstance(obj, list):
            for item in obj:
                extract(item, arr, key)
        return arr

    results = extract(obj, arr, key)
    return results

# needs a big cleanup :o
def checkroom(cid,number):
    room = 'http://client-dynamic.imvu.com/api/rooms/room_info.php?room_id=%s-%d' % (cid,number)
    response = requests.get(room)
    rcontent = response.content
    if rcontent.find(b'Room does not exist') != -1:
        if verb:
            print('[-] %s-%d') % (cid,number)
    elif rcontent.find(b'You have made too many requests recently') != -1:
        print('\n\r\n\r')
        print(' --- too many requests, lets have a break and get a coffee for a bit. waiting 3 minutes ---\n\r')
        time.sleep(180) #3 minutes
    else:
        dict = json.loads(response.content)
        roomname = (dict['name'].encode("utf-8"))
        ownercid = (dict['customers_id'])
        count = len(dict['participants'])
        if ( verb == True ):
            print('CID: %s-%d' % (cid,number))
            print("Name: %s" % (roomname))
            print ("Users: %d" % count)
            cids = extract_values(dict, 'customers_id')
            cids.remove(ownercid)
            names = extract_values(dict, 'avatar_name')
            for x in range(count):
                print ("--- %s - %s" %(names[x],cids[x]))
            print("-"*50)
        elif ( verb == False ):
            if ( peep == True ):
                if( count != 0 ):
                    print('CID: %s-%d' % (cid,number))
                    print("Name: %s" % (roomname))
                    print ("Users: %d" % count)
                    cids = extract_values(dict, 'customers_id')
                    cids.remove(ownercid)
                    names = extract_values(dict, 'avatar_name')
                    for x in range(count):
                        print ("--- %s - %s" %(names[x],cids[x]))
                    print("-"*50)
            elif ( peep == False ):
                print('CID: %s-%d' % (cid,number))
                print("Name: %s" % (roomname))
                if count != 0 :
                    print ("Users: %d" % count)
                    cids = extract_values(dict, 'customers_id')
                    cids.remove(ownercid)
                    names = extract_values(dict, 'avatar_name')
                    for x in range(count):
                        print ("--- %s - %s" %(names[x],cids[x]))
                print("-"*50)

# will be added in next version
def usernametocid(user):
   whatever
   return cid

if __name__=="__main__":
    parser = argparse.ArgumentParser("usage: %prog [options] arg1 arg2")
    parser.add_argument("-c", "--cid", dest="cid",default=00000000,help="specify the cid of a user")
    parser.add_argument("-b", "--begin", dest="begin",type=int,default=1,help="specify the room number to start with")
    parser.add_argument("-e", "--end", dest="end",type=int,default=100,help="specify the room number to end with")
    parser.add_argument("-v", "--verbose",dest="verbose_switch",default=False, action="store_true",help="shows all attempts")
    parser.add_argument("-p", "--people",dest="people_switch",default=False, action="store_true",help="shows only rooms with people inside")
    parser.add_argument("-d", "--delay", dest="delay",type=float,default=0.0,help="specify the delay between each room to scan")
    options = parser.parse_args()
    if len(sys.argv) < 2:
        infoheader(1)
        quit()
    else:
        cid = options.cid
        verb = options.verbose_switch
        peep = options.people_switch
        delay = options.delay
        infoheader(0)
        for x in range(options.begin,options.end):
            checkroom(cid,x)
            time.sleep(delay)
        print(" -- done --")

Posted 4 years ago
@cyberwaste


just have to make a .py and run it?
Posted 4 years ago · Author
godviras wrote:
@cyberwastejust have to make a .py and run it?

@godviras


Having python3 installed and the library "requests".
A documentary how to install "requests" can be found on https://pypi.org/project/requests/ or https://stackoverflow.com/questions/30362600/how-to-install-requests-module-in-python-3-4-instead-of-2-7
Posted 4 years ago
@cyberwaste


good. thanks i will check out :)

-- Mon Jun 01, 2020 1:02 pm --

@cyberwaste


I installed Requests library. Paste the above code in a text editor and saved as .py. but when i run that programm, the program window closes.
Posted 4 years ago · Author
@godviras


you need to execute it from command line and pass the parameters to it, as shown in the examples.

Code
example 1:
python rscan.py -c 00000000 -b 1 -e 500 -p -d 0.5

example 2:
python rscan.py -c 00000000 -b 200 -e 499 -v
Posted 3 years ago
Since a couple of months this doesn't work anymore, getting

{"error":"Room does not exist","room_id":"1,1"}

for whatever room i try to read out.


Its actually this line that doesn't work anymore:

room = 'http://client-dynamic.imvu.com/api/rooms/room_info.php?room_id=%s-%d' % (cid,number)

so the webservice for reading out the room info must have changed, someone some suggestion?
Posted 3 years ago
can u give me step by step plz? im a nop
Posted 3 years ago
Step by step of what?
In the Python code there is a reference to a webservice (room = 'http://client-dynamic.imvu.com/api/rooms/room_info.php?room_id=%s-%d' % (cid,number), see the code in the original topic).

The webservice URL must have changed so my question is does somebody know the changed URL for this web api?
Posted 2 years ago · Author
IMVU added an auth to the API. So this script is actually broken.
PS: told you i wrote it, gamer.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT