Пример #1
0
    def post(self, request, *args, **kwargs):
        def abort_with_error(title, error, domain):
            """Abort processing and show error in frontend"""
            return render(
                request, "home.html", {
                    'notification': {
                        "message": error,
                        "title": title,
                        "domain": domain
                    },
                    'global_stats': self.get_global_stats()
                })

        def offer_identity_creation(domain):
            """Offer the user the option to create a new identity for the provided domain"""
            return render(
                request, "home.html", {
                    'offer_identity_creation': domain,
                    'global_stats': self.get_global_stats()
                })

        # Get the requested domain from the POST request
        try:
            domain = request.POST['domain']
            # Format domain. Will also ensure that the domain is valid, and return None on invalid domains
            domain = validate_domain(domain)
        except KeyError:
            # Someone is messing with us. Log this.
            logger.warning('HomeView.post: Malformed POST request received',
                           extra={'request': request})
            # Send them back to the homepage with a slap on the wrist
            return abort_with_error(
                _("Internal error"),
                _("You sent a request the server did not understand. Please try again, or contact us if the problem persists."
                  ), domain)
        except AssertionError:
            # Someone may be messing with us. Save it, just in case.
            logger.info("HomeView.post: Invalid URL passed",
                        extra={
                            'request': request,
                            'domain': domain
                        })
            # Send them back to the homepage with a slap on the wrist
            return abort_with_error(
                _("Invalid Address"),
                _("This does not look like a website - please try again"),
                domain)

        # See if we already have it in the database
        try:
            service = Service.objects.get(url=domain)
        except ObjectDoesNotExist:
            return offer_identity_creation(domain)

        # Return results by forwarding to service URL with identifer
        return redirect('Service', service=service.id)
Пример #2
0
    def post(self, request, *args, **kwargs):
        try:
            url = request.POST["url"]
            url = validate_domain(url)

            # Get or create the service matching this domain
            service, created = Service.get_or_create(url=url, name=url)
            service.save()

            # Select a domain to use for the identity
            # Create a list of possible domains
            domains = [cred["DOMAIN"] for cred in settings.MAILCREDENTIALS]
            # Shuffle it
            shuffle(domains)
            # Iterate through it
            for identityDomain in domains:
                # If the domain has not yet been used, stop the loop, otherwise try the next
                if (Identity.objects.filter(service_id=service.pk).filter(
                        mail__contains=identityDomain).count() == 0):
                    break
            # At this point, we have either selected a domain that has not yet been used for the
            # provided service, or the service already has at least one identity for each domain,
            # in which case we have picked one domain at random (by shuffling the list first).

            # Create an identity and save it
            ident = Identity.create(service, identityDomain)
            ident.save()

            if created:
                create_service_cache(service, force=True)

            # Return the created identity
            r = JsonResponse({
                "site": url,
                "email": ident.mail,
                "first": ident.first_name,
                "last": ident.surname,
                "gender": "Male" if ident.gender else "Female",
            })
        except KeyError:
            logger.warning(
                "BookmarkletApiView.post: Malformed request received, missing url.",
                extra={"request": request},
            )
            r = JsonResponse({"error": "No URL passed"})
        except AssertionError:
            # Invalid URL passed
            logger.warning(
                "BookmarkletApiView.post: Malformed request received, malformed URL.",
                extra={"request": request},
            )
            r = JsonResponse({"error": "Invalid URL passed."})
        r["Access-Control-Allow-Origin"] = "*"
        return r
Пример #3
0
    def post(self, request, *args, **kwargs):
        try:
            domain = request.POST['domain']
            # Format domain. Will also ensure that the domain is valid, and return None on invalid domains
            domain = validate_domain(domain)
        except KeyError:
            # Someone is messing with us. Log this.
            logger.warning(
                'IdentityView.post: Malformed POST request received',
                extra={'request': request})
            # Send them back to the homepage with a slap on the wrist
            # TODO: Add code to display a warning on homepage
            return redirect('Home')
        # Check if people are messing with us
        except AssertionError:
            # Someone may be messing with us. Save it, just in case.
            logger.info("IdentityView.post: Invalid URL passed",
                        extra={
                            'request': request,
                            'domain': domain
                        })
            # Send them back to the homepage with a slap on the wrist
            # TODO: Add code to display a warning on homepage
            return redirect('Home')

        # Get or create service
        service, created = Service.get_or_create(url=domain, name=domain)
        service.save()

        # Select a domain to use for the identity
        # Create a list of possible domains
        domains = [cred["DOMAIN"] for cred in settings.MAILCREDENTIALS]
        # Shuffle it
        shuffle(domains)
        # Iterate through it
        for identityDomain in domains:
            # If the domain has not yet been used, stop the loop, otherwise try the next
            if Identity.objects.filter(service_id=service.pk).filter(
                    mail__contains=identityDomain).count() == 0:
                break
        # At this point, we have either selected a domain that has not yet been used for the
        # provided service, or the service already has at least one identity for each domain,
        # in which case we have picked one domain at random (by shuffling the list first).

        # Create an identity and save it
        ident = Identity.create(service, identityDomain)
        ident.save()

        if created:
            create_service_cache(service, force=True)

        # Display the result to the user
        return render(request, 'identity/identity.html', {'ident': ident})
Пример #4
0
    def post(self, request, *args, **kwargs):
        try:
            # Get service from database
            body_unicode = request.body.decode("utf-8")
            body = json.loads(body_unicode)
            domain = body["domain"]
        except KeyError:
            # No service kwarg is set, warn
            logger.warn(
                "ServiceMetaView.post: Malformed POST request received",
                extra={"request": request},
            )
            # TODO: Add code to display a warning on homepage
            return JsonResponse(convertForJsonResponse({"success": False}))
        try:
            # Format domain. Will also ensure that the domain is valid, and return None on invalid domains
            domain = validate_domain(domain)
        except KeyError:
            # Someone is messing with us. Log this.
            logger.warning(
                "IdentityView.post: Malformed POST request received",
                extra={"request": request},
            )
            # Send them back to the homepage with a slap on the wrist
            # TODO: Add code to display a warning on homepage
            return JsonResponse(convertForJsonResponse({"success": False}))
        # Check if people are messing with us
        except AssertionError:
            # Someone may be messing with us. Save it, just in case.
            logger.info(
                "IdentityView.post: Invalid URL passed",
                extra={"request": request, "domain": domain},
            )
            # Send them back to the homepage with a slap on the wrist
            # TODO: Add code to display a warning on homepage
            return JsonResponse(convertForJsonResponse({"success": False}))

        # Get or create service
        service, created = Service.get_or_create(url=domain, name=domain)
        service.save()

        # Select a domain to use for the identity
        # Create a list of possible domains
        domains = [cred["DOMAIN"] for cred in settings.MAILCREDENTIALS]
        # Shuffle it
        shuffle(domains)
        # Iterate through it
        for identityDomain in domains:
            # If the domain has not yet been used, stop the loop, otherwise try the next
            if (
                Identity.objects.filter(service_id=service.pk)
                .filter(mail__contains=identityDomain)
                .count()
                == 0
            ):
                break
        # At this point, we have either selected a domain that has not yet been used for the
        # provided service, or the service already has at least one identity for each domain,
        # in which case we have picked one domain at random (by shuffling the list first).

        # Create an identity and save it
        ident = Identity.create(service, identityDomain)
        ident.save()

        if created:
            create_service_cache(service, force=True)

        # Display the result to the user
        return JsonResponse(convertForJsonResponse(ident))
Пример #5
0
 def parseUrlToId(url):
     domain = validate_domain(url)
     print("domain" + domain)
     service = Thirdparty.objects.get(name=domain)
     return service.id
Пример #6
0
 def parseUrlToId(url):
     domain = validate_domain(url)
     service = Service.objects.get(url=domain)
     return service.id
Пример #7
0
    "https://yaantra.com", "https://yandy.com", "https://yarn.com",
    "https://yellowoctopus.com.au", "https://yeskicks.cn",
    "https://yesstyle.com", "https://yeswevibe.com", "https://ylcamera.com.my",
    "https://ylighting.com", "https://yogisurprise.com",
    "https://yourwdwstore.net", "https://yumo.ca", "https://zaful.com",
    "https://zando.co.za", "https://zasttra.com", "https://zerolemon.com",
    "https://zodeys.com", "https://zookr.in", "https://zoolaa.com",
    "https://zotezo.com", "https://zox.la", "https://zzounds.com"
]
# targets = ["atperrys.com", "wineinsiders.com", "centralvapors.com", "countycomm.com", "beautypie.com", "mirraw.com", "forzieri.com", "nordstromrack.com", "inlineskates.com", "tartecosmetics.com", "imaginaryfoundation.com", "aafnation.com", "lastcall.com", "cbdfx.com", "iheartcats.com", "luckytacklebox.com", "netzpolitik.org", "magicmadhouse.co.uk", "savagex.de", "tkmaxx.com", "rustico.com", "proflowers.com", "net32.com", "simplyswim.com", "1-day.co.nz", "squattypotty.com", "kiiroo.com", "washingtonexaminer.com", "flattummyco.com", "overstock.ca", "surfstitch.com", "repubblica.it", "faz.de", "mattressfirm.com", "rcmoment.com", "6pm.com", "fragrancenet.com", "roolee.com", "workingperson.com", "shopurbansociety.com", "conrad.de", "rugs.com", "tilebar.com", "4wdsupacentre.com.au", "czechbeadsexclusive.com", "wolfandbadger.com", "sated.com", "dresslily.com", "brightechshop.com", "tennis-point.com", "smiggle.co.uk", "onceuponatee.net", "thursdayboots.com", "lemonde.fr", "gearbest.com", "aerotelegraph.com", "amnesty.de", "radioshack.com", "uniqlo.com", "shopimpressions.com", "ringtoperfection.com", "thejewelhut.co.uk", "brooktaverner.co.uk", "sueddeutsche.de", "opticsplanet.com", "therealreal.com", "shopplanetblue.com", "hotsauce.com", "stanley-pmi.com", "sportsmansguide.com", "planetcyclery.com", "liligal.com", "toolur.com", "golfavenue.com", "nierle.com", "mackage.com", "lovecrafts.com", "blackboxmycar.com", "floryday.com", "papayaclothing.com", "rains.com", "wowcher.co.uk", "okayamadenim.com", "vickypick.com", "bild.de", "intotheam.com", "laptopoutlet.co.uk", "extinctionrebellion.de", "linenchest.com", "urbandecay.co.uk", "forever21.com", "hygoshop.com", "universitycoop.com", "secretsales.com", "petcube.com", "stylewe.com", "lexpro.de", "paperwishes.com", "shoeaholics.com", "harveynorman.ie", "fluevog.com", "dekanta.com", "decalgirl.com", "wethepeopleholsters.com", "wetseal.com", "touratech-usa.com", "chicsoul.com", "sunglasses-shop.co.uk", "topcoat.store", "mightydeals.com", "skatedeluxe.com", "oracle.com", "modes.com", "fathersonsclothing.com", "alaindupetit.eu", "cokodive.com", "yarn.com", "chicwish.com", "dunelondon.com", "freeshipdeal.com", "jskis.com", "theconversation.com", "impressionsvanity.com", "vzbv.de", "flatpyramid.com", "citysightsny.com", "iheartraves.com", "catch.com.au", "emmacloth.com", "mandp.co.uk", "chainedandable.com", "urban-planet.com", "treds.co.uk", "yesstyle.com", "vapoureyes.com.au", "fashionnova.com", "puffy.com", "bettystoybox.com", "zando.co.za", "voylla.com", "gazetadopovo.com.br", "beckettsimonon.com", "greenfingers.com", "sammydress.com", "ttdeye.com", "staud.clothing", "theinsolestore.com", "wickedcushions.com", "museumreplicas.com", "suzyshier.com", "foxnews.com", "spartoo.co.uk", "brandhousedirect.com.au", "brandsego.com", "doreenbeads.com", "diyelectricskateboard.com", "styletread.com.au", "thechivery.com", "mammut.com", "turntablelab.com", "ylighting.com", "ikigaisoul.com", "perigold.com", "o2online.de", "beautytap.com", "motorcyclecloseouts.com", "officesupply.com", "1800flowers.com", "koala.com", "nbcnews.com", "platzl.de", "theater-bielefeld.de", "motoloot.com", "totemokawaiishop.com", "minicasettetomp3.com", "swfa.com", "lighting-direct.co.uk", "justfab.com", "stio.com", "zoolaa.com", "onnit.com", "tentworld.com.au", "shophq.com", "jaanuu.com", "maccosmetics.co.uk", "temptationgifts.com", "unmannedtechshop.co.uk"]
# targets = ["nytimes.com"]

for target in targets:
    target = target.replace('https://', '')
    target = target.replace('http://', '')
    dom = validate_domain(target)
    try:
        service = Service.objects.get(url=dom)
    except ObjectDoesNotExist:
        print("Not found: %s (coerced to %s)" % (target, dom))
        continue

    # We have a match
    for mail in service.mails():
        assert mail.identity.count() == 1

        addr = mail.identity.all()[0].mail.replace(
            '@', '_')  # Make the email compatible with Unix filenames
        date = mail.date_time.strftime('%FT%T').replace(
            ':', '_')  # Make the date and time compatible