Beispiel #1
0
    def trigger_add_user(self, client, message, **kwargs):
        # Get the results of the capture
        capture = kwargs.get('capture_groups', None)
        captured_name = capture[0]
        captured_username = capture[1]

        if captured_name and captured_username:
            logger.info("values are '%s' and '%s'" % (captured_name, captured_username))

            a_user = User(0)
            a_user.name = captured_name
            a_user.usernames = {client.integration_name: [captured_username]}

            try:
                self.havocbot.db.add_user(a_user)
            except UserDataAlreadyExistsException:
                text = "That user already exists"
                client.send_message(text, message.reply(), event=message.event)
            else:
                text = "User added"
                client.send_message(text, message.reply(), event=message.event)
            # finally:
            #     client.send_message(text, message.reply(), event=message.event)
        else:
            text = 'Invalid parameters. Check the help option for usage'
            client.send_message(text, message.reply(), event=message.event)
Beispiel #2
0
    def build_user(self, result_data):
        user = User(result_data['user_id'])

        user.aliases = result_data['aliases'] if 'aliases' in result_data else None
        user.is_stashed = True
        user.last_modified = (
            result_data['last_modified']
            if 'last_modified' in result_data
            else None
        )
        user.name = result_data['name'] if 'name' in result_data else None
        user.plugin_data = (
            result_data['plugin_data']
            if 'plugin_data' in result_data and isinstance(result_data['plugin_data'], dict)
            else None
        )
        user.points = (
            result_data['points']
            if 'points' in result_data and isinstance(result_data['points'], (int, long))
            else 0
        )
        user.timestamp = result_data['timestamp'] if 'timestamp' in result_data else None
        user.usernames = (
            result_data['usernames']
            if 'usernames' in result_data and isinstance(result_data['usernames'], dict)
            else None
        )
        user.permissions = result_data['permissions'] if 'permissions' in result_data else None

        return user
Beispiel #3
0
def create_user_object(handle, name, aliases):
    client = 'skype'

    user = User(handle)
    user.aliases = aliases
    user.client = client
    user.name = name

    logger.debug("create_user_object - user is '%s'" % user)
    return user
Beispiel #4
0
def create_user_object(handle, name, aliases):
    client = 'skype'

    user = User(handle)
    user.aliases = aliases
    user.client = client
    user.name = name

    logger.debug("create_user_object - user is '%s'" % (user))
    return user
Beispiel #5
0
    def get_user_from_message(self, message_sender, channel=None, event=None, **kwargs):
        user = User(0)

        logger.debug("Channel is '%s', message_sender is '%s', event is '%s'" % (channel, message_sender, event))

        # Get client object information
        client_user = self._get_client_object_from_message_object(message_sender, channel=channel, event=event)
        user.client_user = client_user

        user.name = client_user.name
        user.current_username = client_user.username

        return user
Beispiel #6
0
    def get_user_from_message(self, message_sender, channel=None, event=None, **kwargs):
        user = User(0)

        logger.debug("Channel is '%s', message_sender is '%s', event is '%s'" % (channel, message_sender, event))

        api_json = self.client.api_call('users.info', user=message_sender)
        if 'user' in api_json and api_json['user'] is not None:
            client_user = create_user_object_from_json(api_json['user'])
            user.client_user = client_user

            user.name = client_user.name
            user.current_username = client_user.username

        return user
Beispiel #7
0
    def build_user(self, result_data):
        user = User(result_data.eid)

        user.name = result_data['name'] if 'name' in result_data else None
        user.usernames = result_data['usernames'] if 'usernames' in result_data else {}
        user.points = result_data['points'] if 'points' in result_data else None
        user.permissions = result_data['permissions'] if 'permissions' in result_data else []
        user.aliases = result_data['aliases'] if 'aliases' in result_data else []
        user.image = result_data['image'] if 'image' in result_data else None
        user.is_stashed = True

        return user
Beispiel #8
0
def create_user_object(jabber_id, name, vcard):
    if isinstance(jabber_id, sleekxmpp.jid.JID
                  ) and jabber_id.bare is not None and jabber_id.bare:
        jabber_id_bare = jabber_id.bare
    else:
        jabber_id_bare = jabber_id

    vcard_nickname = None
    vcard_email = None

    if vcard is not None:
        # get_payload() returns the xml for the Iq() as a Element object
        payload = vcard.get_payload()
        vcard_xml = payload[0]
        # vcard_full_name = vcard_xml.findtext('.//{vcard-temp}FN')
        vcard_nickname = vcard_xml.findtext('.//{vcard-temp}NICKNAME')
        vcard_email = vcard_xml.findtext('.//{vcard-temp}USERID')

    client_user = XMPPUser(
        jabber_id_bare, vcard_nickname
        if vcard_nickname is not None and vcard_nickname else name,
        vcard_email if vcard_email is not None and vcard_email else None)

    # Create a User object
    user_object = User(0)
    user_object.name = name
    user_object.points = 0
    json_data = client_user.to_json()
    user_object.usernames = {json_data['client']: [json_data['username']]}
    user_object.current_username = json_data['username']

    logger.debug("client_user is '%s'" % client_user)
    return client_user
Beispiel #9
0
    def trigger_add_user(self, client, message, **kwargs):
        capture = kwargs.get('capture_groups', None)
        captured_name = capture[0]
        captured_username = capture[1]
        text = None

        if captured_name and captured_username:
            a_user = User(0)
            a_user.name = captured_name
            a_user.usernames = {client.integration_name: [captured_username]}

            try:
                self.havocbot.db.add_user(a_user)
            except UserDataAlreadyExistsException:
                text = 'That user already exists'
            else:
                text = 'User added'
            finally:
                client.send_message(text, message.reply(), event=message.event)
        else:
            text = 'Invalid parameters. Check the help option for usage'
            client.send_message(text, message.reply(), event=message.event)
Beispiel #10
0
    def build_user(self, result_data):
        user = User(result_data.eid)

        user.name = result_data["name"] if "name" in result_data else None
        user.usernames = result_data["usernames"] if "usernames" in result_data else {}
        user.points = result_data["points"] if "points" in result_data else None
        user.permissions = result_data["permissions"] if "permissions" in result_data else []
        user.aliases = result_data["aliases"] if "aliases" in result_data else []
        user.is_stashed = True

        return user
Beispiel #11
0
def create_user_object(jabber_id, name, vcard):
    jabber_id_bare = jabber_id.bare if isinstance(jabber_id, sleekxmpp.jid.JID) and jabber_id.bare is not None and jabber_id.bare else jabber_id

    if vcard is not None:
        # get_payload() returns the xml for the Iq() as a Element object
        payload = vcard.get_payload()
        vcard_xml = payload[0]
        # vcard_full_name = vcard_xml.findtext('.//{vcard-temp}FN')
        vcard_nickname = vcard_xml.findtext('.//{vcard-temp}NICKNAME')
        vcard_email = vcard_xml.findtext('.//{vcard-temp}USERID')

    client_user = HipChatUser(jabber_id_bare, vcard_nickname if vcard_nickname is not None and vcard_nickname else name, vcard_email if vcard_email is not None and vcard_email else None)

    # Create a User object
    user_object = User(0)
    user_object.name = name
    user_object.points = 0
    json_data = client_user.to_json()
    user_object.usernames = {json_data['client']: [json_data['username']]}
    user_object.current_username = json_data['username']

    logger.debug("create_user_object - client_user is '%s'" % (client_user))
    return client_user
Beispiel #12
0
    def get_user_from_message(self, message_sender, channel=None, event=None, **kwargs):
        user = User(0)

        logger.info("Channel is '%s', message_sender is '%s', event is '%s'" % (channel, message_sender, event))

        # Get client object information
        client_user = self.get_client_object_from_message_object(message_sender, channel=channel, event=event)
        user.client_user = client_user

        user.name = client_user.name
        user.username = client_user.username

        # if event is not None and event:
        #     if event in ['chat', 'normal']:
        #         # Get users from private message
        #         user = self._get_user_from_private_chat(message_sender)

        #     elif event in ['groupchat']:
        #         # Get users from groupchat
        #         # user = self._get_user_from_groupchat(message_sender, channel)
        #         user = self._get_user_from_jid(message_sender)

        return user
Beispiel #13
0
    def build_user(self, result_data):
        user = User(result_data['user_id'])

        user.aliases = result_data['aliases'] if 'aliases' in result_data else None
        user.is_stashed = True
        user.last_modified = (
            result_data['last_modified']
            if 'last_modified' in result_data
            else None
        )
        user.name = result_data['name'] if 'name' in result_data else None
        user.plugin_data = (
            result_data['plugin_data']
            if 'plugin_data' in result_data and isinstance(result_data['plugin_data'], dict)
            else None
        )
        user.points = (
            result_data['points']
            if 'points' in result_data and isinstance(result_data['points'], (int, long))
            else 0
        )
        user.timestamp = result_data['timestamp'] if 'timestamp' in result_data else None
        user.usernames = (
            result_data['usernames']
            if 'usernames' in result_data and isinstance(result_data['usernames'], dict)
            else None
        )
        user.permissions = result_data['permissions'] if 'permissions' in result_data else None

        return user