-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLeafTurnOnCC.php
164 lines (134 loc) · 5.89 KB
/
LeafTurnOnCC.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
class LeafTurnOnCC
{
private $userId = '';
private $password = '';
private $initialAppStrings = 'geORNtsZe5I4lRGjG9GZiA';
private $lg = 'da-DK';
private $regionCode = 'NE';
private $dcmid = '';
private $VIN;
private $baseRPM = ''; //Indsættes fra kald til initialAppStrings
private $customSessionID = '';
private $tz = 'Europe/Copenhagen';
function __construct($userId, $password)
{
$this->userId = $userId;
$this->password = $password;
}
public function getInitalAppStrings()
{
$params = array();
$params['custom_sessionid'] = $this->customSessionID;
$params['initial_app_strings'] = $this->initialAppStrings;
$params['RegionCode'] = $this->regionCode;
$params['lg'] = $this->lg;
$params['DCMID'] = $this->dcmid;
$params['VIN'] = $this->VIN;
$params['tz'] = $this->tz;
$url = 'https://gdcportalgw.its-mo.com/gworchest_160803EC/gdc/' . 'InitialApp.php';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
if ($result === FALSE) {
die("Error during request to $url: " . curl_error($ch) . "\n");
}
curl_close($ch);
$json = json_decode($result);
var_export($json);
echo 'Indsæt følgende værdi: ' . $json->baseprm . PHP_EOL;
echo 'I toppen af filen som baseRPM' . PHP_EOL;
}
public function fire()
{
$i = 0;
do {
$postBody = 'UserId=' . urlencode($this->userId) . '&cartype=&custom_sessionid=&initial_app_strings=' . $this->initialAppStrings . '&tz=&lg=' . $this->lg . '&DCMID=&VIN=&RegionCode=' . $this->regionCode . '&Password=' . urlencode($this->encryptPassword($this->password,$this->baseRPM));
var_dump($postBody);
$headerArray = array('Content-Type: application/x-www-form-urlencoded',
'Charset: UTF-8',
'User-Agent: Dalvik/2.1.0 (Linux; U; Android 5.1; Custom Phone - 5.1.0 - API 22 - 768x1280 Build/LMY47D)',
'Connection: Keep-Alive',
'Accept-Encoding: gzip');
$curlOptions = array(
CURLOPT_HTTPHEADER => $headerArray,
CURLOPT_POSTFIELDS => $postBody,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
);
$url = "https://gdcportalgw.its-mo.com/gworchest_160803EC/gdc/UserLoginRequest.php";
$handle = curl_init($url);
curl_setopt_array($handle, $curlOptions);
$content = curl_exec($handle);
$response = json_decode($content);
var_export($response);
} while ($i<9 && $response->status != 200);
if($response->status != 200)
{
die();
}
$custom_sessionid = $response->VehicleInfoList->vehicleInfo[0]->custom_sessionid;
$this->dcmid = $response->vehicle->profile->dcmId;
$this->VIN = $response->vehicle->profile->vin;
$i = 0;
do {
//New request
$postBody = 'UserId=' . urlencode($this->userId) . '&cartype=&custom_sessionid=' . urlencode($custom_sessionid) . '&tz=Europe%2FCopenhagen&lg=da-DK&DCMID=' . $this->dcmid . '&VIN=' . $this->VIN . '&RegionCode=' . $this->regionCode;
var_dump($postBody);
$curlOptions = array(
CURLOPT_HTTPHEADER => $headerArray,
CURLOPT_POSTFIELDS => $postBody,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
);
$url = "https://gdcportalgw.its-mo.com/gworchest_160803EC/gdc/ACRemoteRequest.php";
$handle = curl_init($url);
curl_setopt_array($handle, $curlOptions);
$content = curl_exec($handle);
$response = json_decode($content);
//Dette er muligvis resultatet af 'morgentravlhed':
//array(
// 'status' => '-2000',
// 'ErrorCode' => '-2000',
// 'ErrorMessage' => 'GDC Internal Error')
var_export($response);
} while ($i<9 && $response->status != 200);
curl_close($handle);
}
public function encryptPassword($password, $key)
{
if (!extension_loaded('mcrypt')) {
throw new Exception("mcrypt PHP extension is not loaded.");
}
$size = @call_user_func('mcrypt_get_block_size', MCRYPT_BLOWFISH);
if (empty($size)) {
$size = @call_user_func('mcrypt_get_block_size', MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
}
$password = static::pkcs5_pad($password, $size);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted_password = mcrypt_encrypt(MCRYPT_BLOWFISH, $key, $password, MCRYPT_MODE_ECB, $iv);
return base64_encode($encrypted_password);
}
private static function pkcs5_pad ($text, $blocksize) {
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
private function encryptPassword2($password, $key) {
if ($this->config->encryptionOption == static::ENCRYPTION_OPTION_WEBSERVICE) {
return trim(file_get_contents("https://dataproxy.pommepause.com/nissan-connect-encrypt.php?key=" . urlencode($key) . "&password=" . urlencode($password)));
}
if (!function_exists('openssl_encrypt')) {
throw new Exception("OpenSSL support in PHP is not available. Either use ENCRYPTION_OPTION_WEBSERVICE as the encryption option, to use a remote web-service to encrypt passwords, or compile PHP using --with-openssl.");
}
$method = 'bf-ecb';
$encrypted_password = openssl_encrypt($password, $method, $key, TRUE);
var_dump(base64_encode($encrypted_password));
return base64_encode($encrypted_password);
}
}
$obj = new LeafTurnOnCC($argv[1], $argv[2]);
//$obj->fire();
$obj->getInitalAppStrings();