open(fn, "r") return True except IOError: print "Error: File does not appear to exist" return False # Align options: to, URI, domain, registrar_ip, username, host, port if options.spoof_auto and not(options.to and options.registrar_ip): options.to = 'sip:[email protected]:5060' if not options.to and not options.registrar_ip: print 'must supply --to option with the target SIP address' sys.exit(-1) else: if not options.to: if not options.uri: options.registrar_ip = options.registrar_ip if options.registrar_ip else options.domain options.to = rfc2396_IPv6.Address(str('<sip:'+str(options.username)+'@'+str(options.registrar_ip if rfc2396_IPv6.isIPv4(options.registrar_ip) else ('['+options.registrar_ip+']'))+'>')) options.uri = options.to.uri.dup() options.to.uri.port = options.uri.port = options.port else: options.uri = rfc2396_IPv6.URI(options.uri) if options.uri else rfc2396_IPv6.URI(str('sip:'+options.username+'@'+(options.registrar_ip if rfc2396_IPv6.isIPv4(options.registrar_ip) else ('['+options.registrar_ip+']')))) options.to = rfc2396_IPv6.Address(str(options.uri)) options.registrar_ip = options.registrar_ip if options.registrar_ip else options.to.uri.host options.to.uri.port = options.uri.port = options.port else: options.to = rfc2396_IPv6.Address(options.to) options.uri = rfc2396_IPv6.URI(options.uri) if options.uri else options.to.uri.dup() options.registrar_ip = options.registrar_ip if options.registrar_ip else options.to.uri.host options.port = options.to.uri.port if options.to.uri.port else options.port options.to.uri.port = options.uri.port = options.port if not options.fromAddr: options.username = options.username if options.username else (options.reg_username if options.reg_username else options.to.uri.user)
def __init__(self, app): '''The Base User is initiated with the app objects, the socket setup and some general options.''' self.app = app self.state = self.reg_state = None self.register = None self.reg_result = self.reg_reason = None # socket setup if rfc2396_IPv6.isIPv6(app.options.to.uri.host): # Unstable print bcolors.FAIL+"ALERT! You are using IPv6 unstable/not tested feature."+bcolors.ENDC if app.options.int_ip == '0.0.0.0': app.options.int_ip= '::1' sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM if app.options.transport == self.UDP else socket.SOCK_STREAM) else: sock = socket.socket(type=socket.SOCK_DGRAM if app.options.transport == self.UDP else socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((app.options.int_ip, (app.options.port+1) if app.options.transport == self.TLS else app.options.port)) self.sock = sock # socket options self.max_size = app.options.max_size self.interval = app.options.interval # REGISTER options self.register_interval = app.options.register_interval self.reg_refresh = app.options.reg_refresh # SIP options self.username = app.options.username self.reg_username = app.options.reg_username self.password = app.options.password self.registrarAddr = rfc2396_IPv6.Address(str('<sip:'+self.reg_username+'@'+(app.options.registrar_ip if rfc2396_IPv6.isIPv4(app.options.registrar_ip) else ('['+app.options.registrar_ip+']'))+'>')) # Generators self._listenerGen = self._registerGen = None # create a SIP stack instance self.transport = rfc3261_IPv6.TransportInfo(self.sock, secure=(app.options.transport == self.TLS)) self._stack = rfc3261_IPv6.Stack(self, self.transport, fix_nat=None) # create a SIP stack instance self.localParty = app.options.fromAddr.dup() self.remoteParty = app.options.to.dup() self.remoteTarget = app.options.to.dup() # create a SIP user agent instance self._ua = None
options.to.uri.port = options.uri.port = options.port else: options.to = rfc2396_IPv6.Address(options.to) options.uri = rfc2396_IPv6.URI( options.uri) if options.uri else options.to.uri.dup() options.registrar_ip = options.registrar_ip if options.registrar_ip else options.to.uri.host options.port = options.to.uri.port if options.to.uri.port else options.port options.to.uri.port = options.uri.port = options.port if not options.fromAddr: options.username = options.username if options.username else ( options.reg_username if options.reg_username else options.to.uri.user) options.reg_username = options.reg_username if options.reg_username else options.username options.fromAddr = rfc2396_IPv6.Address( str('<sip:' + str(options.username) + '@' + str(options.registrar_ip if rfc2396_IPv6.isIPv4( options.registrar_ip) else ('[' + options.registrar_ip + ']')) + '>')) options.fromAddr.uri.port = options.port else: options.fromAddr = rfc2396_IPv6.Address(options.fromAddr) options.username = options.username if options.username else options.fromAddr.displayable options.reg_username = options.reg_username if options.reg_username else options.fromAddr.displayable options.fromAddr.uri.port = options.port # Validate Flooding options if options.flood_msg_file and not FileCheck(options.flood_msg_file): sys.exit(-1) # Validate Fuzzing options if not options.crash_detect: options.audit_file_name = None # Validate Spoofing options if options.spoof_srcURI: options.spoof_srcURI = rfc2396_IPv6.URI(options.spoof_srcURI)