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
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
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)
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
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
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)
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