Exemple #1
0
    def __init__(self, login, password, server):
        self.client = Client(server, debug=[])

        self.client.connect()
        if not self.client.auth(login, password):
            self.client.disconnect()
            raise JabberAuthException()
Exemple #2
0
def connect_jid(server, jid, password):
    print server, jid, password
    client = Client(server, debug=[])
    client.connect()
    if not client.auth(jid, password):
        raise IOError('Cannot connect to %s' % server)
    client.RegisterHandler('message', message_handler)
    return client
Exemple #3
0
 def __init__(self, args):
     self.args = args
     self.xmpp = Client(self.args.jid,
                        self.args.password,
                        pubsub=False,
                        priority=127)
     self.xmpp.run(args.server, threaded=True)
     self.pubsub = self.xmpp['xep_0060']
Exemple #4
0
 def __init__(self):
     jid = JID(settings["jid"])
     conn = Client(jid.getDomain(), debug=[])
     if not conn.connect():
         statusMessage("PSTO: connection error")
     if not conn.auth(jid.getNode(), settings["password"], settings["res"]):
         statusMessage("PSTO: autentification error")
     self.conn = conn
Exemple #5
0
class XmpppyTransport(Transport):
	"""
	Implements the XMPP transport (xmpppy).

	"""
	def __init__(self):
		settings = core.server.server.settings

		self.domain = settings.get('xmpp_domain')
		self.host = settings.get('xmpp_host')
		self.port = settings.get('xmpp_port')
		self.user = settings.get('xmpp_user')
		self.password = settings.get('xmpp_password')
		self.presence = settings.get('xmpp_presence')
		
		self.connected = False

	@classmethod
	def isIdentifiedBy(cls, type):
		return type == 'xmpp'

	def connect(self):
		"""
		Connects to an XMPP server.

		"""
		self.client = Client(self.domain)

		if not self.client.connect(server=(self.host, self.port)):
			raise IOError('Cannot connect to server.')

		if not self.client.auth(self.user, self.password, self.presence):
			raise IOError('Cannot auth with server.')

		self.client.RegisterHandler('message', message_handler)

		self.client.sendInitPresence()

		self.connected = True

		while True:
			self.client.Process(1)

	def disconnect(self):
		"""
		Disconnects from the current XMPP server.

		"""
		if connected:
			self.client.sendPresence(typ='unavailable')
			self.client.disconnect()

		self.client = None
		self.connected = False

	def send(self, destination, action):
		self.client.send(Message('tim@localhost', str(action)))
def send_psto(jid, password, message):
    jid = JID(jid)
    conn = Client(jid.getDomain(), debug=[])

    if not conn.connect():
        logger.error("not connect to jabber")
    if not conn.auth(jid.getNode(), password, "Lastfm2Jabber"):
        logger.error("error auth to jabber")
    try:
        conn.send(Message(to="*****@*****.**",
                          body="* bot, /mu/ // %s" % message))
    except:
        logger.error("error sending message")
Exemple #7
0
    def reconnect(self):
        try:
            time.sleep(7)
            self.client.disconnect()
        except:
            pass

        if self.debug:
            self.client = Client(self.jid.getDomain())
        else:
            self.client = Client(self.jid.getDomain(), debug=[])

        try:
            if not self.connect():
                self.reconnect()
        except:
            self.reconnect()
Exemple #8
0
	def makeBot(self,resource):
		client = Client(bot_jid.getDomain(), debug=[])
		client.connect()
		client.auth(bot_jid.getNode(),bot_passwd,self.resource)
		client.sendInitPresence()
		client.RegisterHandler('message',self.getMessage)
		return client
Exemple #9
0
class JabberJob:
    def __init__(self, login, password, server):
        self.client = Client(server, debug=[])

        self.client.connect()
        if not self.client.auth(login, password):
            self.client.disconnect()
            raise JabberAuthException()

    def send_message(self, to, message):
        self.client.send(protocol.Message(to, message))

    def disconnect(self):
        self.client.disconnect()
Exemple #10
0
    def connect(self):
        """
		Connects to an XMPP server.

		"""
        self.client = Client(self.domain)

        if not self.client.connect(server=(self.host, self.port)):
            raise IOError('Cannot connect to server.')

        if not self.client.auth(self.user, self.password, self.presence):
            raise IOError('Cannot auth with server.')

        self.client.RegisterHandler('message', message_handler)

        self.client.sendInitPresence()

        self.connected = True

        while True:
            self.client.Process(1)
Exemple #11
0
def test():

	client = Client('localhost')

	def message_handler(conn, mess_node):
		client.send(Message('tim@localhost', 'reponse!'))

	if not client.connect(server=('127.0.0.1', 5222)):
		raise IOError('Can not connect to server.')

	if not client.auth('abitbol', 'abitbol', 'abitbol'):
		raise IOError('Can not auth with server.')

	client.RegisterHandler('message', message_handler)

	client.sendInitPresence()

	client.send(Message('tim@localhost', 'Test message'))

	while 1:
		client.Process(1)
Exemple #12
0
    def create_connection(self, configuration):
        connection = Client(configuration.domain)
        connection_result = connection.connect(server=configuration.server)
        server = configuration.server

        if not connection_result:
            raise Exception('Unable to connect to %s' % (server,))

        if connection_result not in ('ssl', 'tls'):
            raise Exception('No SSL/TLS support when connecting to %s' % (server,))

        user = configuration.user
        password = configuration.password

        auth_result = connection.auth(
            user=user,
            password=password,
            resource=user,
        )

        if not auth_result:
            raise Exception('Unable to authenticate %s@%s with %s' % (user, server, '*' * len(password)))

        return connection
    def on_process_start(self, feed):
        try:
            from xmpp import Client, Message, JID, Presence
        except ImportError:
            raise PluginError("output_xmpp requires xmppy, either `pip install xmpppy` or `apt-get install python-xmpp`")

        config = self.get_config(feed)
        debug = []
        self.jid = JID(config.get('jid'))
        self.client = Client(self.jid, debug=debug)

        if self.client.connect() is None or self.client.auth(self.jid.getNode(), config['password'], uuid4()):
            self.error('Unable to connect to XMPP, disabling plugin')
            config['enabled'] = None
            return
        self.client.SendInitPresence()
        log.debug('Connected to XMPP server on JID %s' % self.jid.getNode())
Exemple #14
0
def _get_connected_client(account):
    client = Client(account['server'], debug=[])
    if not client.connect():
        logging.error(
            "Can not connect to %s server, please check your configuration",
            account['server'])
        raise IOError('Can not connect to server.')
    if not client.auth(account['user'], account['password'],
                       account['resource']):
        logging.error("Can not auth as %s@%s, please check your configuration",
                      account['user'], account['server'])
        raise IOError('Can not auth with server.')

    logging.info("Logged in as %s@%s", account['user'], account['server'])
    client.RegisterHandler('message', _handle_messages)
    client.sendInitPresence()
    client.Process(1)

    return client
Exemple #15
0
 def send(self, recipients, message):
     """Send message to recipients via xmpp."""
     jid = JID(self.user)
     if self.server:
         server = self.server
     else:
         server = jid.getDomain()
     cl = Client(server, port=self.port, debug=[])
     if not cl.connect():
         raise IOError("Couldn't connect to xmpp server %s" % server)
     if not cl.auth(jid.getNode(), self.password, resource=self.resource):
         cl.Connection.disconnect()
         raise IOError("Xmpp auth erro using %s to %s", jid, server)
     for recip in recipients:
         cl.send(Message(recip[2], message))
Exemple #16
0
	def connect(self):
		"""
		Connects to an XMPP server.

		"""
		self.client = Client(self.domain)

		if not self.client.connect(server=(self.host, self.port)):
			raise IOError('Cannot connect to server.')

		if not self.client.auth(self.user, self.password, self.presence):
			raise IOError('Cannot auth with server.')

		self.client.RegisterHandler('message', message_handler)

		self.client.sendInitPresence()

		self.connected = True

		while True:
			self.client.Process(1)
Exemple #17
0
def xmppBrute0x00(ip, usernames, passwords, port, delay):
    client = Client(str(ip))
    client.connect(server=(str(ip), port))
    for username in usernames:
        for password in passwords:
            try:
                if client.auth(username, password):
                    client.sendInitPresence()
                    print(G + ' [+] Username: %s | Password found: %s\n' %
                          (username, password))
                    client.disconnect()
            except Exception as e:
                print(R + " [-] Error caught! Name: " + str(e))
            except KeyboardInterrupt:
                client.disconnect()
                sys.exit(1)
            except:
                print(GR + " [*] Checking : " + C + "Username: %s | " + B +
                      "Password: %s " + R + "| Incorrect!\n" %
                      (username, password))
                sleep(delay)
Exemple #18
0
 def __init__(self, *args, **kwargs):
     self.token = kwargs.pop('token')
     self.Namespace, self.DBG = 'jabber:client', DBG_CLIENT # DAAAAAAAAAAH -> see the CommonClient class, it introspects it descendents to determine that
     Client.__init__(self, *args, **kwargs)
Exemple #19
0
 def __init__(self, server, port=5222, debug=[], stream=None):
     Client.__init__(self, server, port, debug)
     self.stream = stream
Exemple #20
0
class XmpppyTransport(Transport):
    """
	Implements the XMPP transport (xmpppy).

	"""
    def __init__(self):
        settings = core.server.server.settings

        self.domain = settings.get('xmpp_domain')
        self.host = settings.get('xmpp_host')
        self.port = settings.get('xmpp_port')
        self.user = settings.get('xmpp_user')
        self.password = settings.get('xmpp_password')
        self.presence = settings.get('xmpp_presence')

        self.connected = False

    @classmethod
    def isIdentifiedBy(cls, type):
        return type == 'xmpp'

    def connect(self):
        """
		Connects to an XMPP server.

		"""
        self.client = Client(self.domain)

        if not self.client.connect(server=(self.host, self.port)):
            raise IOError('Cannot connect to server.')

        if not self.client.auth(self.user, self.password, self.presence):
            raise IOError('Cannot auth with server.')

        self.client.RegisterHandler('message', message_handler)

        self.client.sendInitPresence()

        self.connected = True

        while True:
            self.client.Process(1)

    def disconnect(self):
        """
		Disconnects from the current XMPP server.

		"""
        if connected:
            self.client.sendPresence(typ='unavailable')
            self.client.disconnect()

        self.client = None
        self.connected = False

    def send(self, destination, action):
        self.client.send(Message('tim@localhost', str(action)))
Exemple #21
0
from keyring import get_password

from xmpp import Client, Presence
from xmpp.protocol import Message

from xmpp.roster import Roster

cl = Client('wisc.edu')
cl.connect()
cl.auth('tjandersen', get_password("xmpp", "tjandersen"), "bot")

roster = Roster()
roster.PlugIn(cl)

roster.getRoster()

print roster.getRawRoster()
cl.disconnect()
Exemple #22
0
    if extension:
        presence = Presence(to='%s/%s+%s' % (room, nick, extension))
    else:
        presence = Presence(to='%s/%s' % (room, nick))
    presence.setTag('x', namespace=NS_MUC).setTagData('password', room_password)
    presence.getTag('x').addChild('history',{'maxchars':'0','maxstanzas':'0'})
    client.send(presence)

def msg_room(message):
    send_msg(room, message, typ='groupchat')

def send_msg(to, message, typ='chat'):
    client.send(Message(to=to, body=message, typ=typ))

# connect to server
client = Client(JID(user).getDomain(), debug=[])
client.connect()
while not client.auth(JID(user).getNode(), user_password, resource=JID(user).getResource()):
    print('Unable to authorize.')
    password = getpass('Password for %s:' % (user))

# register handlers
client.RegisterHandler('message', message_callback)
client.RegisterHandler('presence', presence_callback)

# send presence
client.sendInitPresence()
join_room()

# process incoming messages
while True:
Exemple #23
0
 def __init__(self, *args, **kwargs):
     self.token = kwargs.pop('token')
     self.Namespace, self.DBG = 'jabber:client', DBG_CLIENT # DAAAAAAAAAAH -> see the CommonClient class, it introspects it descendents to determine that
     Client.__init__(self, *args, **kwargs)
class OutputXMPP:

    rooms = []

    def validator(self):
        from flexget import validator
        config = validator.factory('dict')
        config.accept('text', key='jid', required=True)
        config.accept('text', key='password', required=True)
        config.accept('text', key='to', required=True)
        config.accept('text', key='nickname')
        config.accept('text', key='connection_host')
        config.accept('integer', key='connection_port')
        config.accept('text', key='message_format')
        config.accept('text', key='message_type')
        return config

    def get_config(self, feed):
        config = feed.config['xmpp']
        config.setdefault('message_format', '{{title}} has started downloading')
        config.setdefault('message_type', 'headline')
        config.setdefault('nickname', 'FlexGet')
        return config

    def on_process_start(self, feed):
        try:
            from xmpp import Client, Message, JID, Presence
        except ImportError:
            raise PluginError("output_xmpp requires xmppy, either `pip install xmpppy` or `apt-get install python-xmpp`")

        config = self.get_config(feed)
        debug = []
        self.jid = JID(config.get('jid'))
        self.client = Client(self.jid, debug=debug)

        if self.client.connect() is None or self.client.auth(self.jid.getNode(), config['password'], uuid4()):
            self.error('Unable to connect to XMPP, disabling plugin')
            config['enabled'] = None
            return
        self.client.SendInitPresence()
        log.debug('Connected to XMPP server on JID %s' % self.jid.getNode())

    def on_process_end(self, feed):
        if hasattr(self, 'client') and self.client.isConnected():
            self.client.disconnect()
        self.client = None

    def on_feed_output(self, feed):
        from xmpp import Client, Message, JID, Presence

        config = self.get_config(feed)
        if config['enabled'] is None or feed.manager.options.learn:
            log.debug('XMPP plugin disabled or in learning mode, skipping.')
            return

        for entry in feed.accepted:
            body = entry.render(config.get('message_format'))
            if feed.manager.options.test:
                log.info("XMPP message: %s", body)
                continue
            msg = Message(body=body)
            for dest in [x.strip() for x in config['to'].split(',')]:
                if dest[0] == '@':
                    dest = dest[1:]
                    if not dest in self.rooms:
                        self.client.send(Presence("%s/%s" % (dest, config['nickname'])))                   
                    msg.setAttr('to', dest)
                    msg.setType('groupchat')
                else:
                    msg.setAttr('to', dest)
                    msg.setType(config['message_type'])
                self.client.send(msg)
#!/usr/bin/env python
import os
from xmpp import Client,Iq,Node
import sys
username = "******"       
password = "******"
domain = "gmail.com"

 

import warnings
warnings.filterwarnings("ignore") 
from xmpp import *
 
cl=Client(server='gmail.com',debug=[])
if not cl.connect(server=('talk.google.com',5222)):
    raise IOError('Can not connect to server.')
if not cl.auth(username, password, domain):
    raise IOError('Can not auth with server.')
cl.send(Iq('set','google:shared-status', payload=[
        Node('show',payload=[sys.argv[1]]),
        Node('status',payload=[sys.argv[2] if len(sys.argv)>2 else ""])
]))
cl.disconnect()
Exemple #26
0
 def __init__(self, args):
     self.args = args
     self.xmpp = Client(self.args.jid, self.args.password, pubsub=False, priority=127)
     self.xmpp.run(args.server, threaded=True)
     self.pubsub = self.xmpp['xep_0060']