Пример #1
0
 def __init__(
     self,
     host='localhost',
     bindingip='',
     externalip=None,
     localport=5060,
     port=5060,
     method='REGISTER',
     guessmode=1,
     guessargs=None,
     selecttime=0.005,
     sessionpath=None,
     compact=False,
     socktimeout=3,
     initialcheck=True,
     enableack=False,
     maxlastrecvtime=15,
     domain=None,
     printdebug=False,
 ):
     from libs.svhelper import dictionaryattack, numericbrute, packetcounter
     import logging
     self.log = logging.getLogger('TakeASip')
     self.maxlastrecvtime = maxlastrecvtime
     self.sessionpath = sessionpath
     self.dbsyncs = False
     self.enableack = enableack
     if self.sessionpath is not None:
         self.resultauth = anydbm.open(
             os.path.join(self.sessionpath, 'resultauth'), 'c')
         try:
             self.resultauth.sync()
             self.dbsyncs = True
             self.log.info("Db does sync")
         except AttributeError:
             self.log.info("Db does not sync")
             pass
     else:
         self.resultauth = dict()
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.sock.settimeout(socktimeout)
     self.bindingip = bindingip
     self.localport = localport
     self.originallocalport = localport
     self.rlist = [self.sock]
     self.wlist = list()
     self.xlist = list()
     self.challenges = list()
     self.realm = None
     self.dsthost, self.dstport = host, int(port)
     self.domain = self.dsthost
     if domain:
         self.domain = domain
     self.guessmode = guessmode
     self.guessargs = guessargs
     if self.guessmode == 1:
         self.usernamegen = numericbrute(*self.guessargs)
     elif guessmode == 2:
         self.usernamegen = dictionaryattack(self.guessargs)
     self.selecttime = selecttime
     self.compact = compact
     self.nomore = False
     self.BADUSER = None
     self.method = method.upper()
     if self.method == 'INVITE':
         self.log.warn(
             'using an INVITE scan on an endpoint (i.e. SIP phone) may cause it to ring and wake up people in the middle of the night'
         )
     if self.sessionpath is not None:
         self.packetcount = packetcounter(50)
     self.initialcheck = initialcheck
     self.lastrecvtime = time.time()
     if externalip is None:
         self.log.debug("external ip was not set")
         if (self.bindingip != '0.0.0.0') and (len(self.bindingip) > 0):
             self.log.debug(
                 "but bindingip was set! we'll set it to the binding ip")
             self.externalip = self.bindingip
         else:
             try:
                 self.log.info(
                     "trying to get self ip .. might take a while")
                 self.externalip = socket.gethostbyname(
                     socket.gethostname())
             except socket.error:
                 self.externalip = '127.0.0.1'
     else:
         self.log.debug("external ip was set")
         self.externalip = externalip
     self.printdebug = printdebug
Пример #2
0
 def __init__(self,host='localhost',bindingip='',localport=5060,port=5060,
              externalip=None,
              username=None,crackmode=1,crackargs=None,realm=None,sessionpath=None,
              selecttime=0.005,compact=False,reusenonce=False,extension=None,
              maxlastrecvtime=10,domain=None):
     # Import additional module
     from libs.svhelper import dictionaryattack, numericbrute, packetcounter
     # Return a logger with the specified name or, if no name is specified, return a logger which is the root
     # logger of the hierarchy. If specified, the name is typically a dot-separated hierarchical name like "a",
     # "a.b" or "a.b.c.d". Choice of these names is entirely up to the developer who is using logging.
     self.log = logging.getLogger('ASipOfRedWine')
     # Create a new socket using the given address family, socket type and protocol number.
     # The address family should be AF_INET (the default), AF_INET6 or AF_UNIX.
     # The socket type should be SOCK_STREAM (the default), SOCK_DGRAM or perhaps one of the other SOCK_ constants.
     # The protocol number is usually zero and may be omitted in that case.
     self.sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
     # Set a timeout on blocking socket operations. The value argument can be a nonnegative float expressing seconds, or None.
     self.sock.settimeout(10)
     self.sessionpath = sessionpath
     self.maxlastrecvtime = maxlastrecvtime
     self.lastrecvtime = time.time()
     self.dbsyncs = False
     if self.sessionpath is not  None:
         # Open the database file filename and return a corresponding object.
         self.resultpasswd = anydbm.open(
             os.path.join(self.sessionpath,'resultpasswd'),'c'
             )
         try:
             # When the database has been opened in fast mode, this method forces any unwritten data to be
             # written to the disk.
             self.resultpasswd.sync()
             self.dbsyncs = True
             # Print log string
             self.log.info("Db does sync")
         # Raised when an attribute reference (see Attribute references) or assignment fails.
         except AttributeError:
             self.log.info("Db does not sync")
             pass
     else:
         self.resultpasswd = dict()
     self.nomore = False
     self.passwordcracked = False
     self.rlist = [self.sock]
     self.wlist = list()
     self.xlist = list()
     self.challenges = list()        
     self.crackmode = crackmode
     self.crackargs = crackargs
     self.dsthost,self.dstport =host,int(port)
     self.domain = self.dsthost
     if domain:
         self.domain = domain
     # Create generator
     if crackmode == 1:
         self.passwdgen = numericbrute(*crackargs)
     elif crackmode == 2:
         self.passwdgen = dictionaryattack(crackargs)        
         
     self.username = username
     self.realm = realm
     self.selecttime = selecttime
     self.dstisproxy = None
     self.ignorenewnonce = True
     self.noauth = False
     self.auth = dict()
     self.previouspassword = str()
     self.compact=compact
     self.reusenonce = reusenonce
     self.staticnonce = None
     self.staticcid = None
     if extension is not None:
         self.extension = extension
     else:
         self.extension = username
     self.bindingip = bindingip
     self.localport = localport
     self.originallocalport = localport
     if self.sessionpath is not None:
         self.packetcount = packetcounter(50)
     if externalip is None:
         self.log.debug("external ip was not set")
         if (self.bindingip != '0.0.0.0') and (len(self.bindingip) > 0):
             self.log.debug("but bindingip was set! we'll set it to the binding ip")
             self.externalip = self.bindingip
         else:
             try:
                 self.log.info("trying to get self ip .. might take a while")
                 self.externalip = socket.gethostbyname(socket.gethostname())
             except socket.error:
                 self.externalip = '127.0.0.1'
     else:
         self.log.debug("external ip was set")
         self.externalip = externalip
Пример #3
0
 def __init__(self,host='localhost',bindingip='',externalip=None,localport=5060,port=5060,
              method='REGISTER',guessmode=1,guessargs=None,selecttime=0.005,
              sessionpath=None,compact=False,socktimeout=3,initialcheck=True,
              enableack=False,maxlastrecvtime=15, domain=None, printdebug=False,
              ):
     from libs.svhelper import dictionaryattack, numericbrute, packetcounter
     import logging
     self.log = logging.getLogger('TakeASip')
     self.maxlastrecvtime = maxlastrecvtime
     self.sessionpath = sessionpath
     self.dbsyncs = False
     self.enableack = enableack
     if self.sessionpath is not  None:
         self.resultauth = anydbm.open(os.path.join(self.sessionpath,'resultauth'),'c')
         try:
             self.resultauth.sync()
             self.dbsyncs = True
             self.log.info("Db does sync")
         except AttributeError:
             self.log.info("Db does not sync")
             pass
     else:
         self.resultauth = dict()
     self.sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
     self.sock.settimeout(socktimeout)
     self.bindingip = bindingip        
     self.localport = localport
     self.originallocalport = localport
     self.rlist = [self.sock]
     self.wlist = list()
     self.xlist = list()
     self.challenges = list()        
     self.realm = None
     self.dsthost,self.dstport = host,int(port)
     self.domain = self.dsthost
     if domain:
         self.domain = domain
     self.guessmode = guessmode
     self.guessargs = guessargs
     if self.guessmode == 1:
         self.usernamegen = numericbrute(*self.guessargs)            
     elif guessmode == 2:
         self.usernamegen = dictionaryattack(self.guessargs)
     self.selecttime = selecttime
     self.compact=compact
     self.nomore=False
     self.BADUSER=None
     self.method = method.upper()
     if self.method == 'INVITE':
         self.log.warn('using an INVITE scan on an endpoint (i.e. SIP phone) may cause it to ring and wake up people in the middle of the night')
     if self.sessionpath is not None:
         self.packetcount = packetcounter(50)
     self.initialcheck = initialcheck
     self.lastrecvtime = time.time()
     if externalip is None:
         self.log.debug("external ip was not set")
         if (self.bindingip != '0.0.0.0') and (len(self.bindingip) > 0):
             self.log.debug("but bindingip was set! we'll set it to the binding ip")
             self.externalip = self.bindingip
         else:
             try:
                 self.log.info("trying to get self ip .. might take a while")
                 self.externalip = socket.gethostbyname(socket.gethostname())
             except socket.error:
                 self.externalip = '127.0.0.1'
     else:
         self.log.debug("external ip was set")
         self.externalip = externalip
     self.printdebug = printdebug
Пример #4
0
    def __init__(self,
                 host='localhost',
                 bindingip='',
                 localport=5060,
                 port=5060,
                 externalip=None,
                 username=None,
                 crackmode=1,
                 crackargs=None,
                 realm=None,
                 sessionpath=None,
                 selecttime=0.005,
                 compact=False,
                 reusenonce=False,
                 extension=None,
                 maxlastrecvtime=10,
                 domain=None):
        from libs.svhelper import dictionaryattack, numericbrute, packetcounter
        import logging
        self.log = logging.getLogger('ASipOfRedWine')
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.settimeout(10)
        self.sessionpath = sessionpath
        self.maxlastrecvtime = maxlastrecvtime
        self.lastrecvtime = time.time()
        self.dbsyncs = False
        if self.sessionpath is not None:
            self.resultpasswd = anydbm.open(
                os.path.join(self.sessionpath, 'resultpasswd'), 'c')
            try:
                self.resultpasswd.sync()
                self.dbsyncs = True
                self.log.info("Db does sync")
            except AttributeError:
                self.log.info("Db does not sync")
                pass
        else:
            self.resultpasswd = dict()
        self.nomore = False
        self.passwordcracked = False
        self.rlist = [self.sock]
        self.wlist = list()
        self.xlist = list()
        self.challenges = list()
        self.crackmode = crackmode
        self.crackargs = crackargs
        self.dsthost, self.dstport = host, int(port)
        self.domain = self.dsthost
        if domain:
            self.domain = domain
        if crackmode == 1:
            self.passwdgen = numericbrute(*crackargs)
        elif crackmode == 2:
            self.passwdgen = dictionaryattack(crackargs)

        self.username = username
        self.realm = realm
        self.selecttime = selecttime
        self.dstisproxy = None
        self.ignorenewnonce = True
        self.noauth = False
        self.auth = dict()
        self.previouspassword = str()
        self.compact = compact
        self.reusenonce = reusenonce
        self.staticnonce = None
        self.staticcid = None
        if extension is not None:
            self.extension = extension
        else:
            self.extension = username
        self.bindingip = bindingip
        self.localport = localport
        self.originallocalport = localport
        if self.sessionpath is not None:
            self.packetcount = packetcounter(50)
        if externalip is None:
            self.log.debug("external ip was not set")
            if (self.bindingip != '0.0.0.0') and (len(self.bindingip) > 0):
                self.log.debug(
                    "but bindingip was set! we'll set it to the binding ip")
                self.externalip = self.bindingip
            else:
                try:
                    self.log.info(
                        "trying to get self ip .. might take a while")
                    self.externalip = socket.gethostbyname(
                        socket.gethostname())
                except socket.error:
                    self.externalip = '127.0.0.1'
        else:
            self.log.debug("external ip was set")
            self.externalip = externalip
Пример #5
0
 def __init__(self,host='localhost',bindingip='',localport=5060,port=5060,
              externalip=None,
              username=None,crackmode=1,crackargs=None,realm=None,sessionpath=None,
              selecttime=0.005,compact=False,reusenonce=False,extension=None,
              maxlastrecvtime=10,domain=None):
     from libs.svhelper import dictionaryattack, numericbrute, packetcounter
     import logging
     self.log = logging.getLogger('ASipOfRedWine')
     self.sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
     self.sock.settimeout(10)
     self.sessionpath = sessionpath
     self.maxlastrecvtime = maxlastrecvtime
     self.lastrecvtime = time.time()
     self.dbsyncs = False
     if self.sessionpath is not  None:
         self.resultpasswd = anydbm.open(
             os.path.join(self.sessionpath,'resultpasswd'),'c'
             )
         try:
             self.resultpasswd.sync()
             self.dbsyncs = True
             self.log.info("Db does sync")
         except AttributeError:
             self.log.info("Db does not sync")
             pass
     else:
         self.resultpasswd = dict()
     self.nomore = False
     self.passwordcracked = False
     self.rlist = [self.sock]
     self.wlist = list()
     self.xlist = list()
     self.challenges = list()        
     self.crackmode = crackmode
     self.crackargs = crackargs
     self.dsthost,self.dstport =host,int(port)
     self.domain = self.dsthost
     if domain:
         self.domain = domain
     if crackmode == 1:            
         self.passwdgen = numericbrute(*crackargs)
     elif crackmode == 2:
         self.passwdgen = dictionaryattack(crackargs)        
         
     self.username = username
     self.realm = realm
     self.selecttime = selecttime
     self.dstisproxy = None
     self.ignorenewnonce = True
     self.noauth = False
     self.auth = dict()
     self.previouspassword = str()
     self.compact=compact
     self.reusenonce = reusenonce
     self.staticnonce = None
     self.staticcid = None
     if extension is not None:
         self.extension = extension
     else:
         self.extension = username
     self.bindingip = bindingip
     self.localport = localport
     self.originallocalport = localport
     if self.sessionpath is not None:
         self.packetcount = packetcounter(50)
     if externalip is None:
         self.log.debug("external ip was not set")
         if (self.bindingip != '0.0.0.0') and (len(self.bindingip) > 0):
             self.log.debug("but bindingip was set! we'll set it to the binding ip")
             self.externalip = self.bindingip
         else:
             try:
                 self.log.info("trying to get self ip .. might take a while")
                 self.externalip = socket.gethostbyname(socket.gethostname())
             except socket.error:
                 self.externalip = '127.0.0.1'
     else:
         self.log.debug("external ip was set")
         self.externalip = externalip
Пример #6
0
 def __init__(self,host='localhost',bindingip='',externalip=None,localport=5060,port=5060,
              method='REGISTER',guessmode=1,guessargs=None,selecttime=0.005,
              sessionpath=None,compact=False,socktimeout=3,initialcheck=True,
              enableack=False,maxlastrecvtime=15, domain=None, printdebug=False,
              ):
     # Import additional module
     from libs.svhelper import dictionaryattack, numericbrute, packetcounter
     # Return a logger with the specified name or, if no name is specified, return a logger which is the root
     # logger of the hierarchy. If specified, the name is typically a dot-separated hierarchical name like "a",
     # "a.b" or "a.b.c.d". Choice of these names is entirely up to the developer who is using logging.
     self.log = logging.getLogger('TakeASip')
     self.maxlastrecvtime = maxlastrecvtime
     self.sessionpath = sessionpath
     self.dbsyncs = False
     self.enableack = enableack
     if self.sessionpath is not  None:
         # Open the database file filename and return a corresponding object.
         self.resultauth = anydbm.open(os.path.join(self.sessionpath,'resultauth'),'c')
         try:
             # When the database has been opened in fast mode, this method forces any unwritten data to be
             # written to the disk
             self.resultauth.sync()
             self.dbsyncs = True
             # Print log string
             self.log.info("Db does sync")
         except AttributeError:
             self.log.info("Db does not sync")
             pass
     else:
         self.resultauth = dict()
     # Create a new socket using the given address family, socket type and protocol number.
     # The address family should be AF_INET (the default), AF_INET6 or AF_UNIX.
     # The socket type should be SOCK_STREAM (the default), SOCK_DGRAM or perhaps one of the other SOCK_ constants.
     # The protocol number is usually zero and may be omitted in that case.
     self.sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
     # Set a timeout on blocking socket operations.
     self.sock.settimeout(socktimeout)
     self.bindingip = bindingip        
     self.localport = localport
     self.originallocalport = localport
     self.rlist = [self.sock]
     self.wlist = list()
     self.xlist = list()
     self.challenges = list()        
     self.realm = None
     self.dsthost,self.dstport = host,int(port)
     self.domain = self.dsthost
     if domain:
         self.domain = domain
     self.guessmode = guessmode
     self.guessargs = guessargs
     if self.guessmode == 1:
         self.usernamegen = numericbrute(*self.guessargs)            
     elif guessmode == 2:
         self.usernamegen = dictionaryattack(self.guessargs)
     self.selecttime = selecttime
     self.compact=compact
     self.nomore=False
     self.BADUSER=None
     self.method = method.upper()
     if self.method == 'INVITE':
         self.log.warn('using an INVITE scan on an endpoint (i.e. SIP phone) may cause it to ring and wake up people in the middle of the night')
     if self.sessionpath is not None:
         self.packetcount = packetcounter(50)
     self.initialcheck = initialcheck
     self.lastrecvtime = time.time()
     if externalip is None:
         self.log.debug("external ip was not set")
         if (self.bindingip != '0.0.0.0') and (len(self.bindingip) > 0):
             self.log.debug("but bindingip was set! we'll set it to the binding ip")
             self.externalip = self.bindingip
         else:
             try:
                 self.log.info("trying to get self ip .. might take a while")
                 self.externalip = socket.gethostbyname(socket.gethostname())
             except socket.error:
                 self.externalip = '127.0.0.1'
     else:
         self.log.debug("external ip was set")
         self.externalip = externalip
     self.printdebug = printdebug