Exemple #1
0
def buy():
    new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    new.connect(('110.76.141.20', 5228))

    data = '\x01\x00\x00\x00'  # Packet ID (4)
    data += '\x00\x00'  # Status Code (2)
    data += 'BUY\x00\x00\x00\x00\x00\x00\x00\x00'  # Method (11)
    data += '\x00'  # Body Type (1)

    body = BSON.encode({
        u'ntype': 3,
        u'countryISO': u'US',
        u'userId': user_id,
        u'MCCMNC': None,
        u'appVer': u'3.8.7',
        u'os': u'android',
        u'voip': False
    })

    data += body[:4]  # Body Length (4)
    data += body  # Body Contents

    new.sendall(data)
    reply = new.recv(4096)

    bs = reply[22:]
    (document, _) = bson._bson_to_dict(bs, dict, True, bson.OLD_UUID_SUBTYPE)

    print "[*] BUY"

    return document
Exemple #2
0
def checkin():
    new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    new.connect(('110.76.141.20', 5228))

    data = '\x12\x27\x00\x00'  # Packet ID (4)
    data += '\x00\x00'  # Status Code (2)
    data += 'CHECKIN\x00\x00\x00\x00'  # Method (11)
    data += '\x00'  # Body Type (1)

    body = BSON.encode({
        u'useSub': True,
        u'ntype': 3,
        u'userId': user_id,
        u'MCCMNC': None,
        u'appVer': u'3.8.7',
        u'os': u'android'
    })

    data += body[:4]  # Body Length (4)
    data += body  # Body Contents

    new.sendall(data)
    reply = new.recv(20480)

    bs = reply[22:]
    (document, _) = bson._bson_to_dict(bs, dict, True, bson.OLD_UUID_SUBTYPE)

    print "[*] CHECKIN"

    return document
Exemple #3
0
def checkin():
    global user_id

    if user_id == '':
        print "[x] ERROR: user_id is not defined"
        return

    new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    new.connect(('110.76.141.20', 5228))

    data = '\x12\x27\x00\x00' # Packet ID (4)
    data += '\x00\x00' # Status Code (2)
    data += 'CHECKIN\x00\x00\x00\x00' # Method (11)
    data += '\x00' # Body Type (1)

    body = BSON.encode({u'useSub': True, u'ntype': 3, u'userId': user_id, u'MCCMNC': None, u'appVer': u'3.8.7', u'os': u'android'})

    data += body[:4] # Body Length (4)
    data += body # Body Contents

    new.sendall(data)
    reply = new.recv(20480)

    bs = reply[22:]
    (document, _) = bson._bson_to_dict(bs,dict, True, bson.OLD_UUID_SUBTYPE)

    print "[*] CHECKIN"

    return document
Exemple #4
0
def checkin():
    new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    new.connect(("110.76.141.20", 5228))

    data = "\x12\x27\x00\x00"  # Packet ID (4)
    data += "\x00\x00"  # Status Code (2)
    data += "CHECKIN\x00\x00\x00\x00"  # Method (11)
    data += "\x00"  # Body Type (1)

    body = BSON.encode(
        {u"useSub": True, u"ntype": 3, u"userId": user_id, u"MCCMNC": None, u"appVer": u"3.8.7", u"os": u"android"}
    )

    data += body[:4]  # Body Length (4)
    data += body  # Body Contents

    new.sendall(data)
    reply = new.recv(20480)

    bs = reply[22:]
    (document, _) = bson._bson_to_dict(bs, dict, True, bson.OLD_UUID_SUBTYPE)

    print "[*] CHECKIN"

    return document
Exemple #5
0
    def next(self):
        """Advance the cursor.

        This method blocks until the next change document is returned or an
        unrecoverable error is raised.

        Raises :exc:`StopIteration` if this ChangeStream is closed.
        """
        while True:
            try:
                raw_change = self._cursor.next()
            except (ConnectionFailure, CursorNotFound):
                try:
                    self._cursor.close()
                except PyMongoError:
                    pass
                self._cursor = self._create_cursor()
                continue
            try:
                self._resume_token = raw_change['_id']
            except KeyError:
                raise InvalidOperation(
                    "Cannot provide resume functionality when the resume "
                    "token is missing.")
            if self._codec_options.document_class == RawBSONDocument:
                return raw_change
            next_change = _bson_to_dict(raw_change.raw, self._codec_options)
            next_change['_id'] = self._resume_token
            return next_change
Exemple #6
0
    def try_next(self):
        """Advance the cursor without blocking indefinitely.

        This method returns the next change document without waiting
        indefinitely for the next change. For example::

            with db.collection.watch() as stream:
                while stream.alive:
                    change = stream.try_next()
                    if change is not None:
                        print(change)
                    elif stream.alive:
                        # We end up here when there are no recent changes.
                        # Sleep for a while to avoid flooding the server with
                        # getMore requests when no changes are available.
                        time.sleep(10)

        If no change document is cached locally then this method runs a single
        getMore command. If the getMore yields any documents, the next
        document is returned, otherwise, if the getMore returns no documents
        (because there have been no changes) then ``None`` is returned.

        :Returns:
          The next change document or ``None`` when no document is available
          after running a single getMore or when the cursor is closed.

        .. versionadded:: 3.8
        """
        # Attempt to get the next change with at most one getMore and at most
        # one resume attempt.
        try:
            change = self._cursor._try_next(True)
        except ConnectionFailure:
            self._resume()
            change = self._cursor._try_next(False)
        except OperationFailure as exc:
            if (exc.code in _NON_RESUMABLE_GETMORE_ERRORS or
                    exc.has_error_label("NonResumableChangeStreamError")):
                raise
            self._resume()
            change = self._cursor._try_next(False)

        # No changes are available.
        if change is None:
            return None

        try:
            resume_token = change['_id']
        except KeyError:
            self.close()
            raise InvalidOperation(
                "Cannot provide resume functionality when the resume "
                "token is missing.")
        self._resume_token = copy.copy(resume_token)
        self._start_at_operation_time = None
        self._start_after = None

        if self._decode_custom:
            return _bson_to_dict(change.raw, self._orig_codec_options)
        return change
Exemple #7
0
    def next(self, ordered=False):
        """Return the next document of current cursor, and move forward.

        Parameters:
           Name      Type  Info:
           ordered   bool  Set true if need field-ordered records, default false.

        Return values:
           a dict object of record
        Exceptions:
           pysequoiadb.error.SDBEndOfCursor
           pysequoiadb.error.SDBBaseError
        """
        if not isinstance(ordered, bool):
            raise SDBTypeError("ordered must be an instance of bool")

        as_class = dict
        if ordered:
            as_class = OrderedDict

        rc, bson_string = sdb.cr_next(self._cursor)
        raise_if_error(rc, "Failed to get next record")
        record, size = bson._bson_to_dict(bson_string, as_class, False,
                                          bson.OLD_UUID_SUBTYPE, True)
        return record
    def try_next(self):
        """Advance the cursor without blocking indefinitely.

        This method returns the next change document without waiting
        indefinitely for the next change. For example::

            with db.collection.watch() as stream:
                while stream.alive:
                    change = stream.try_next()
                    if change is not None:
                        print(change)
                    elif stream.alive:
                        # We end up here when there are no recent changes.
                        # Sleep for a while to avoid flooding the server with
                        # getMore requests when no changes are available.
                        time.sleep(10)

        If no change document is cached locally then this method runs a single
        getMore command. If the getMore yields any documents, the next
        document is returned, otherwise, if the getMore returns no documents
        (because there have been no changes) then ``None`` is returned.

        :Returns:
          The next change document or ``None`` when no document is available
          after running a single getMore or when the cursor is closed.

        .. versionadded:: 3.8
        """
        # Attempt to get the next change with at most one getMore and at most
        # one resume attempt.
        try:
            change = self._cursor._try_next(True)
        except ConnectionFailure:
            self._resume()
            change = self._cursor._try_next(False)
        except OperationFailure as exc:
            if exc.code in _NON_RESUMABLE_GETMORE_ERRORS:
                raise
            self._resume()
            change = self._cursor._try_next(False)

        # No changes are available.
        if change is None:
            return None

        try:
            resume_token = change['_id']
        except KeyError:
            self.close()
            raise InvalidOperation(
                "Cannot provide resume functionality when the resume "
                "token is missing.")
        self._resume_token = copy.copy(resume_token)
        self._start_at_operation_time = None

        if self._decode_custom:
            return _bson_to_dict(change.raw, self._orig_codec_options)
        return change
Exemple #9
0
    def get_detail(self):
        """Get the detail of the replica group.

        Return values:
           a dict object of query
        Exceptions:
           pysequoiadb.error.SDBBaseError
        """
        rc, bson_string = sdb.gp_get_detail(self._group)
        raise_if_error(rc, "Failed to get detail")
        detail, size = bson._bson_to_dict(bson_string, dict, False,
                                          bson.OLD_UUID_SUBTYPE, True)
        return detail
Exemple #10
0
    def insert_data_key(self, data_key):
        """Insert a data key into the key vault.

        :Parameters:
          - `data_key`: The data key document to insert.

        :Returns:
          The _id of the inserted data key document.
        """
        # insert does not return the inserted _id when given a RawBSONDocument.
        doc = _bson_to_dict(data_key, _DATA_KEY_OPTS)
        if not isinstance(doc.get('_id'), uuid.UUID):
            raise TypeError(
                'data_key _id must be a bson.binary.Binary with subtype 4')
        res = self.key_vault_coll.insert_one(doc)
        return Binary(res.inserted_id.bytes, subtype=UUID_SUBTYPE)
Exemple #11
0
   def get_detail(self):
      """Get the detail of the replica group.

      Return values:
         a dict object of query
      Exceptions:
         pysequoiadb.error.SDBBaseError
      """
      try:
         rc, bson_string = sdb.gp_get_detail(self._group)
         pysequoiadb._raise_if_error("Failed to get detail", rc)
      except SDBBaseError:
         detail=None
         raise

      detail, size = bson._bson_to_dict(bson_string, dict, False,
                                        bson.OLD_UUID_SUBTYPE, True)
      return detail
Exemple #12
0
   def get_detail(self):
      """Get detail info of data center

      Return values:
         a dict object of detail info
      Exceptions:
         pysequoiadb.error.SDBBaseError
      """
      try:
         rc, detail = sdb.dc_get_detail(self._dc)
         if const.SDB_OK == rc:
            record, size = bson._bson_to_dict(detail, dict, False,
                                              bson.OLD_UUID_SUBTYPE, True)
         pysequoiadb._raise_if_error("Failed to get detail info of data center", rc)
      except SDBBaseError:
         raise

      return record
Exemple #13
0
    def get_detail(self):
        """Get detail info of data center

      Return values:
         a dict object of detail info
      Exceptions:
         pysequoiadb.error.SDBBaseError
      """
        try:
            rc, detail = sdb.dc_get_detail(self._dc)
            if const.SDB_OK == rc:
                record, size = bson._bson_to_dict(detail, dict, False,
                                                  bson.OLD_UUID_SUBTYPE, True)
            pysequoiadb._raise_if_error(
                "Failed to get detail info of data center", rc)
        except SDBBaseError:
            raise

        return record
Exemple #14
0
def bson_iter(bson_file):
    """
    Takes a file handle to a .bson file and returns an iterator for each
    doc in the file.  This will not load all docs into memory.

    with open('User.bson', 'rb') as bs:
        active_users = filter(bson_iter(bs), "type", "active")

    """
    while True:
        size_str = bson_file.read(4)
        if not len(size_str):
            break

        obj_size = struct.unpack("<i", size_str)[0]
        obj = bson_file.read(obj_size - 4)
        if obj[-1] != "\x00":
            raise InvalidBSON("bad eoo")
        yield bson._bson_to_dict(size_str + obj, dict, True)[0]
Exemple #15
0
def bson_iter(bson_file):
    """
    Takes a file handle to a .bson file and returns an iterator for each
    doc in the file.  This will not load all docs into memory.

    with open('User.bson', 'rb') as bs:
        active_users = filter(bson_iter(bs), "type", "active")

    """
    while True:
        size_str = bson_file.read(4)
        if not len(size_str):
            break

        obj_size = struct.unpack("<i", size_str)[0]
        obj = bson_file.read(obj_size - 4)
        if obj[-1] != "\x00":
            raise InvalidBSON("bad eoo")
        yield bson._bson_to_dict(size_str + obj, dict, True)[0]
Exemple #16
0
def _decode_batch(batch):
    """
    NOTE: This implementation is the same as the bson.decode_iter implementation, with some minor differences.

    This methods decodes a raw bson data batch, and yields dict items for every valid batch item.
    Batch items that cannot be decoded from their bson format will be skipped.
    """
    position = 0
    end = len(batch) - 1
    while position < end:
        obj_size = bson._UNPACK_INT(batch[position:position + 4])[0]
        elements = batch[position:position + obj_size]
        position += obj_size

        try:
            yield bson._bson_to_dict(elements,
                                     codec_options.DEFAULT_CODEC_OPTIONS)
        except bson.InvalidBSON as err:
            logging.warning("ignored invalid record: {}".format(str(err)))
            continue
Exemple #17
0
    def next(self):
        """Return the next document of current cursor, and move forward.

      Return values:
         a dict object of record
      Exceptions:
         pysequoiadb.error.SDBBaseError
         pysequoiadb.error.SDBEndOfCursor
      """
        try:
            rc, bson_string = sdb.cr_next(self._cursor)
            if const.SDB_OK != rc:
                if const.SDB_DMS_EOC == rc:
                    raise SDBEndOfCursor
                else:
                    raise SDBBaseError("Failed to get next record", rc)
            else:
                record, size = bson._bson_to_dict(bson_string, dict, False,
                                                  bson.OLD_UUID_SUBTYPE, True)
        except SDBBaseError:
            raise

        return record
Exemple #18
0
   def next(self):
      """Return the next document of current cursor, and move forward.

      Return values:
         a dict object of record
      Exceptions:
         pysequoiadb.error.SDBBaseError
         pysequoiadb.error.SDBEndOfCursor
      """
      try:
         rc, bson_string = sdb.cr_next(self._cursor)
         if const.SDB_OK != rc:
            if const.SDB_DMS_EOC == rc:
               raise SDBEndOfCursor
            else:
               raise SDBBaseError("Failed to get next record", rc)
         else:
            record, size = bson._bson_to_dict(bson_string, dict, False,
                                              bson.OLD_UUID_SUBTYPE, True)
      except SDBBaseError:
         raise

      return record
Exemple #19
0
def buy():
    new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    new.connect(('110.76.141.20', 5228))

    data = '\x01\x00\x00\x00' # Packet ID (4)
    data += '\x00\x00' # Status Code (2)
    data += 'BUY\x00\x00\x00\x00\x00\x00\x00\x00' # Method (11)
    data += '\x00' # Body Type (1)

    body = BSON.encode({u'ntype': 3, u'countryISO': u'US', u'userId': user_id, u'MCCMNC': None, u'appVer': u'3.8.7', u'os': u'android', u'voip': False})

    data += body[:4] # Body Length (4)
    data += body # Body Contents

    new.sendall(data)
    reply = new.recv(4096)

    bs = reply[22:]
    (document, _) = bson._bson_to_dict(bs,dict, True, bson.OLD_UUID_SUBTYPE)

    print "[*] BUY"

    return document
Exemple #20
0
def dec_bson(data):
    (document, _) = bson._bson_to_dict(data, dict, True, bson.OLD_UUID_SUBTYPE)
    return document
Exemple #21
0
 def _decode_body(self, bodybytes):
     """
     Returns a body object.
     """
     return _bson_to_dict(bodybytes, SON, False)[0]
 def test__bson_to_dict(self):
     document = {'average': Decimal('56.47')}
     rawbytes = encode(document, codec_options=self.codecopts)
     decoded_document = _bson_to_dict(rawbytes, self.codecopts)
     self.assertEqual(document, decoded_document)
Exemple #23
0
def dec_bson(data):
    (document, _) = bson._bson_to_dict(data, dict, True, bson.OLD_UUID_SUBTYPE)
    return document
Exemple #24
0
        u'countryISO': u'US',
        u'userId': 7155596L,
        u'MCCMNC': None,
        u'appVer': u'3.8.7',
        u'os': u'android',
        u'voip': False
    })

    data += body[:4]  # Body Length (4)
    data += body  # Body Contents

    new.sendall(data)
    reply = new.recv(4096)

    bs = reply[22:]
    (document, _) = bson._bson_to_dict(bs, dict, True, bson.OLD_UUID_SUBTYPE)

    print "[*] BUY"

    return document


def enc_rsa(secret):
    n = 0xaf0dddb4de63c066808f08b441349ac0d34c57c499b89b2640fd357e5f4783bfa7b808af199d48a37c67155d77f063ddc356ebf15157d97f5eb601edc5a104fffcc8895cf9e46a40304ae1c6e44d0bcc2359221d28f757f859feccf07c13377eec2bf6ac2cdd3d13078ab6da289a236342599f07ffc1d3ef377d3181ce24c719
    e = 3

    pub_key = RSA.PublicKey(n, e)
    enc_key = RSA.encrypt(secret, pub_key)

    return enc_key
 def test__bson_to_dict(self):
     document = {'average': Decimal('56.47')}
     rawbytes = BSON.encode(document, codec_options=self.codecopts)
     decoded_document = _bson_to_dict(rawbytes, self.codecopts)
     self.assertEqual(document, decoded_document)
Exemple #26
0
    def try_next(self):
        """Advance the cursor without blocking indefinitely.

        This method returns the next change document without waiting
        indefinitely for the next change. For example::

            with db.collection.watch() as stream:
                while stream.alive:
                    change = stream.try_next()
                    # Note that the ChangeStream's resume token may be updated
                    # even when no changes are returned.
                    print("Current resume token: %r" % (stream.resume_token,))
                    if change is not None:
                        print("Change document: %r" % (change,))
                        continue
                    # We end up here when there are no recent changes.
                    # Sleep for a while before trying again to avoid flooding
                    # the server with getMore requests when no changes are
                    # available.
                    time.sleep(10)

        If no change document is cached locally then this method runs a single
        getMore command. If the getMore yields any documents, the next
        document is returned, otherwise, if the getMore returns no documents
        (because there have been no changes) then ``None`` is returned.

        :Returns:
          The next change document or ``None`` when no document is available
          after running a single getMore or when the cursor is closed.

        .. versionadded:: 3.8
        """
        # Attempt to get the next change with at most one getMore and at most
        # one resume attempt.
        try:
            change = self._cursor._try_next(True)
        except ConnectionFailure:
            self._resume()
            change = self._cursor._try_next(False)
        except OperationFailure as exc:
            if (exc.code in _NON_RESUMABLE_GETMORE_ERRORS
                    or exc.has_error_label("NonResumableChangeStreamError")):
                raise
            self._resume()
            change = self._cursor._try_next(False)

        # If no changes are available.
        if change is None:
            # We have either iterated over all documents in the cursor,
            # OR the most-recently returned batch is empty. In either case,
            # update the cached resume token with the postBatchResumeToken if
            # one was returned. We also clear the startAtOperationTime.
            if self._cursor._post_batch_resume_token is not None:
                self._resume_token = self._cursor._post_batch_resume_token
                self._start_at_operation_time = None
            return change

        # Else, changes are available.
        try:
            resume_token = change['_id']
        except KeyError:
            self.close()
            raise InvalidOperation(
                "Cannot provide resume functionality when the resume "
                "token is missing.")

        # If this is the last change document from the current batch, cache the
        # postBatchResumeToken.
        if (not self._cursor._has_next()
                and self._cursor._post_batch_resume_token):
            resume_token = self._cursor._post_batch_resume_token

        # Hereafter, don't use startAfter; instead use resumeAfter.
        self._uses_start_after = False
        self._uses_resume_after = True

        # Cache the resume token and clear startAtOperationTime.
        self._resume_token = resume_token
        self._start_at_operation_time = None

        if self._decode_custom:
            return _bson_to_dict(change.raw, self._orig_codec_options)
        return change
Exemple #27
0
    data = '\x01\x00\x00\x00' # Packet ID (4)
    data += '\x00\x00' # Status Code (2)
    data += 'BUY\x00\x00\x00\x00\x00\x00\x00\x00' # Method (11)
    data += '\x00' # Body Type (1)

    #body = BSON.encode({u'ntype': 3, u'countryISO': u'KR', u'userId': 7155596L, u'MCCMNC': u'', u'appVer': u'1.5.0', u'os': u'wp', u'voip': False})
    body = BSON.encode({u'ntype': 3, u'countryISO': u'US', u'userId': 7155596L, u'MCCMNC': None, u'appVer': u'3.8.7', u'os': u'android', u'voip': False})

    data += body[:4] # Body Length (4)
    data += body # Body Contents

    new.sendall(data)
    reply = new.recv(4096)

    bs = reply[22:]
    (document, _) = bson._bson_to_dict(bs,dict, True, bson.OLD_UUID_SUBTYPE)

    print "[*] BUY"

    return document

def enc_rsa(secret):
    n = 0xaf0dddb4de63c066808f08b441349ac0d34c57c499b89b2640fd357e5f4783bfa7b808af199d48a37c67155d77f063ddc356ebf15157d97f5eb601edc5a104fffcc8895cf9e46a40304ae1c6e44d0bcc2359221d28f757f859feccf07c13377eec2bf6ac2cdd3d13078ab6da289a236342599f07ffc1d3ef377d3181ce24c719
    e = 3

    pub_key = RSA.PublicKey(n, e)
    enc_key = RSA.encrypt(secret, pub_key)

    return enc_key

def hand():