wesson wesson 26 juin 2016 19:16

@Anthrax
On appelle ça le déni ...


Allez, je suis gentil  :

# !/usr/bin/env python

import tempmail

import mechanize, time, re
import random, string

def genname() :
  length = random.randint(3, 12)
  s = ’’
  while len(s) < length :
    s += random.choice(string.lowercase)
  return s

def doit() :
  print ’Generating TempMail...’
  tm = tempmail.TempMail()
  email = tm.get_email_address()


  name = genname() + ’ ’ + genname()
  postcode = ’SW1A 0AA’

  print ’Signing as %s / %s (%s)’ % (name, email, postcode)

  br = mechanize.Browser()
  br.set_handle_robots(False)
  br.open(url)
  br.form = list(br.forms())[0]

  c = br.form.find_control(type="checkbox") 
  c.value = [’1’]
  br.form[’signature[name]’] = name
  br.form[’signature[email]’] = email
  br.form[’signature[location_code]’] = [’GB’]
  br.form[’signature[postcode]’] = postcode

  response = br.submit()
  html = response.read()
  #with open(’temp.html’, ’w’) as f : f.write(html)
  
  badness = [
    « Postcode not recognised »,
    « disposable email address »
  ]
  
  for x in badness :
    if x in html :
      print x
      print ’Fuck.’
      exit()
      
  br.form = list(br.forms())[0]
  print ’Confirming...’
  response = br.submit()
  html = response.read()

  while True :
    print ’Checking mail...’
    mb = tm.get_mailbox(email)
    if not ’error’ in mb :
      html = mb[0][’mail_html’]
      url = re.search(’<p><a href="(.* ?)">’, html).group(1)
      break
    time.sleep(1)

  print ’Validating %s’ % url
  response = mechanize.urlopen(url)
  html = response.read()
  #with open(’temp2.html’, ’w’) as f : f.write(html)
  sigs = re.search(’<h1 class="visuallyhidden">(.* ?) signatures</h1>’, html).group(1)
  print ’%s total signatures’ % sigs

while True :
  doit()

Bien évidemment, vous pouvez toujours prétendre qu’il s’agit là de la recette du gigot de 7 heures.

Ajouter une réaction

Pour réagir, identifiez-vous avec votre login / mot de passe