Exemplo n.º 1
0
 def __init__(self,
              scaniter,
              selecttime=0.005,
              compact=False,
              bindingip='0.0.0.0',
              fromname='sipvicious',
              fromaddr='sip:[email protected]',
              extension=None,
              sessionpath=None,
              socktimeout=3,
              externalip=None,
              localport=8080,
              printdebug=False,
              first=None,
              fpworks=False):
     import logging, anydbm
     import os.path
     from svhelper import packetcounter
     from svfphelper import sipfingerprint
     self.sipfingerprint = sipfingerprint
     self.log = logging.getLogger('DrinkOrSip')
     self.bindingip = bindingip
     self.sessionpath = sessionpath
     self.dbsyncs = False
     if self.sessionpath is not None:
         self.resultip = anydbm.open(
             os.path.join(self.sessionpath, 'resultip'), 'c')
         self.resultua = anydbm.open(
             os.path.join(self.sessionpath, 'resultua'), 'c')
         self.resultfp = anydbm.open(
             os.path.join(self.sessionpath, 'resultfp'), 'c')
         try:
             self.resultip.sync()
             self.dbsyncs = True
             self.log.info("Db does sync")
         except AttributeError:
             self.log.info("Db does not sync")
             pass
     else:
         self.resultip = dict()
         self.resultua = dict()
         self.resultfp = dict()
     # we do UDP
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     # socket timeout - this is particularly useful when quitting .. to eat
     # up some final packets
     self.sock.settimeout(socktimeout)
     # enable sending to broadcast addresses
     self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
     # read handles
     self.rlist = [self.sock]
     # write handles
     self.wlist = list()
     # error handles
     self.xlist = list()
     self.scaniter = scaniter
     self.selecttime = selecttime
     self.localport = localport
     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.log.debug("External ip: %s:%s" % (self.externalip, localport))
     self.compact = compact
     self.log.debug("Compact mode: %s" % self.compact)
     self.fromname = fromname
     self.fromaddr = fromaddr
     self.log.debug("From: %s <%s>" % (self.fromname, self.fromaddr))
     self.nomoretoscan = False
     self.originallocalport = self.localport
     self.nextip = None
     self.extension = extension
     self.fpworks = fpworks
     self.printdebug = printdebug
     self.first = first
     if self.sessionpath is not None:
         self.packetcount = packetcounter(50)
     self.sentpackets = 0
Exemplo n.º 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):
        from 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
Exemplo n.º 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,
     disableack=False,
     maxlastrecvtime=15,
     domain=None,
     printdebug=False,
 ):
     from svhelper import dictionaryattack, numericbrute, packetcounter
     import logging
     self.log = logging.getLogger('TakeASip')
     self.maxlastrecvtime = maxlastrecvtime
     self.sessionpath = sessionpath
     self.dbsyncs = False
     self.disableack = disableack
     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.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