-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.php
92 lines (74 loc) · 3.11 KB
/
bot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
require_once 'Faker/src/autoload.php';
$cookie_jar = tempnam('/tmp','cookie');
$cookies = Array();
$c = curl_init();
curl_setopt($c, CURLOPT_HEADERFUNCTION, "curlResponseHeaderCallback");
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
curl_setopt($c, CURLOPT_URL, 'https://www.pokemon.com/us/pokemon-trainer-club/sign-up/');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);
$page = curl_exec($c);
//file_put_contents("bot.html", $page);
//die();
preg_match('/csrftoken=([^;]+)/', $page, $matches);
$fields = array(
"csrfmiddlewaretoken" => $matches[1],
"dob" => "1938-12-21",
"country" => "US",
"country" => "US"
);
$fields_string = "";
foreach($fields as $key=>$value) { $fields_string .= $key.'='.urlencode($value).'&'; }
rtrim($fields_string, '&');
curl_setopt($c, CURLOPT_HEADERFUNCTION, "curlResponseHeaderCallback");
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
curl_setopt($c, CURLOPT_URL, 'https://club.pokemon.com/us/pokemon-trainer-club/sign-up/');
curl_setopt($c, CURLOPT_REFERER, 'https://club.pokemon.com/us/pokemon-trainer-club/sign-up/');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_POST, count($fields));
curl_setopt($c, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);
$page = curl_exec($c);
$faker = Faker\Factory::create();
$usrname = $faker->firstname . rand(1, 99999);
$password = $faker->firstname . rand(1, 99999);
$email = $faker->email;
$fields = array(
"csrfmiddlewaretoken" => $matches[1],
"username" => $usrname,
"password" => $password,
"confirm_password" => $password,
"email" => $email,
"confirm_email" => $email,
"public_profile_opt_in" => "True",
"screen_name" => $usrname,
"terms" => "on"
);
$fields_string = "";
foreach($fields as $key=>$value) { $fields_string .= $key.'='.urlencode($value).'&'; }
rtrim($fields_string, '&');
curl_setopt($c, CURLOPT_URL, 'https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up');
curl_setopt($c, CURLOPT_REFERER, 'https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up');
curl_setopt($c, CURLOPT_POST, count($fields));
curl_setopt($c, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);
$page = curl_exec($c);
curl_close($c);
unlink($cookie_jar) or die("Can't unlink $cookie_jar");
echo "Username: " . $usrname . "\n";
echo "Password: " . $password . "\n";
echo "Email: " . $email . "\n";
function curlResponseHeaderCallback($ch, $headerLine) {
global $cookies;
if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
$cookies[] = $cookie;
return strlen($headerLine); // Needed by curl
}