Example #1
0
 def prepare(self):
     domain_query = DomainLogs.select().where(
         DomainLogs.domain == self.request.host).first()
     if not domain_query:
         user = User.select().where(
             User.domain == self.request.host.split(".")[-3]).first()
         if not user:
             return
         domain_query = DomainLogs()
         domain_query.user_id = user.id
         domain_query.domain = self.request.host
         domain_query.save()
         log = DNSLogs()
         log.ip = self.request.headers.get('X-Forwarded-For')
         log.user_id = user.id
         log.domain_id = domain_query.id
         log.save()
     if not self.request.uri == "/favicon.ico":
         log = UrlLogs()
         packet = "%s %s %s\n" % (self.request.method, self.request.uri,
                                  self.request.version)
         for header in self.request.headers:
             packet += "%s: %s\n" % (header,
                                     self.request.headers.get(header))
         packet += "\n%s" % self.request.body
         log.url = self.request.uri
         log.ip = self.request.headers.get("X-Forwarded-For")
         log.domain_id = domain_query.id
         log.user_id = domain_query.user_id
         log.packet = packet
         log.save()
Example #2
0
 def prepare(self):
     domain_query = DomainLogs.select().where(DomainLogs.domain == self.request.host).first()
     if not domain_query:
         user = User.select().where(User.domain == self.request.host.split(".")[-3]).first()
         if not user:
             return
         domain_query = DomainLogs()
         domain_query.user_id = user.id
         domain_query.domain = self.request.host
         domain_query.save()
         log = DNSLogs()
         log.ip = self.request.headers.get('X-Forwarded-For')
         log.user_id = user.id
         log.domain_id = domain_query.id
         log.save()
     if not self.request.uri == "/favicon.ico":
         log = UrlLogs()
         packet = "%s %s %s\n" % (self.request.method, self.request.uri, self.request.version)
         for header in self.request.headers:
             packet += "%s: %s\n" % (header, self.request.headers.get(header))
         packet += "\n%s" % self.request.body
         log.url = self.request.uri
         log.ip = self.request.headers.get("X-Forwarded-For")
         log.domain_id = domain_query.id
         log.user_id = domain_query.user_id
         log.packet = packet
         log.save()
Example #3
0
def start_qvq(domain, ip):
    domain = "%s." % domain
    qvqdns = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    qvqdns.bind(('', 53))
    try:
        print("QvQDNS is listening on 0.0.0.0:53\n")
        while 1:
            data, addr = qvqdns.recvfrom(1024)
            try:
                p = DNSQuery(data)
            except:
                p = None
                pass
            if p and p.dominio.endswith(domain):
                qvqdns.sendto(p.respuesta(ip), addr)
                print("%s------%s" % (p.dominio[:-1], addr[0]))
                user = User.select().where(User.domain == p.dominio.split(
                    domain)[0].split(".")[-1]).first()
                if user:
                    domain_query = DomainLogs.select().where(
                        DomainLogs.domain == p.dominio[:-1]).first()
                    if not domain_query:
                        domain_query = DomainLogs()
                        domain_query.user_id = user.id
                        domain_query.domain = p.dominio[:-1]
                        domain_query.save()
                    log = DNSLogs()
                    log.ip = addr[0]
                    log.user_id = user.id
                    log.domain_id = domain_query.id
                    log.save()
            else:
                print("%s------%s" % (p.dominio[:-1], addr[0]))
                try:
                    result = domain_to_ip(p.dominio[:-1])
                    qvqdns.sendto(p.respuesta(result[0]), addr)
                except:
                    pass
            del p
    except KeyboardInterrupt:
        qvqdns.close()
        print("QvQDNS is closed!")
Example #4
0
def start_qvq(domain, ip):
    domain = "%s." % domain
    qvqdns = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    qvqdns.bind(('', 53))
    try:
        print ("QvQDNS is listening on 0.0.0.0:53\n")
        while 1:
            data, addr = qvqdns.recvfrom(1024)
            try:
                p = DNSQuery(data)
            except:
                p = None
                pass
            if p and p.dominio.endswith(domain):
                qvqdns.sendto(p.respuesta(ip), addr)
                print("%s------%s" % (p.dominio[:-1], addr[0]))
                user = User.select().where(User.domain == p.dominio.split(domain)[0].split(".")[-1]).first()
                if user:
                    domain_query = DomainLogs.select().where(DomainLogs.domain == p.dominio[:-1]).first()
                    if not domain_query:
                        domain_query = DomainLogs()
                        domain_query.user_id = user.id
                        domain_query.domain = p.dominio[:-1]
                        domain_query.save()
                    log = DNSLogs()
                    log.ip = addr[0]
                    log.user_id = user.id
                    log.domain_id = domain_query.id
                    log.save()
            else:
                print("%s------%s" % (p.dominio[:-1], addr[0]))
                try:
                    result = domain_to_ip(p.dominio[:-1])
                    qvqdns.sendto(p.respuesta(result[0]), addr)
                except:
                    pass
            del p
    except KeyboardInterrupt:
        qvqdns.close()
        print ("QvQDNS is closed!")