forked from ByamB4/byamb4insta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
235 lines (214 loc) · 9.45 KB
/
main.py
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
from requests import get, post
from os import path
from json import load
import random
from time import sleep
import typing
# =============== CONFIGURE THIS ===============
TARGET = 'byamb4'
DEBUG = False
PASSWORD = 'p4$$w0rD!'
# ==============================================
BASE_URL = 'https://api.mrinsta.com/api'
class MrInsta:
def __init__(self) -> None:
print(f'[+] Target: {TARGET}')
accounts = load(
open(f"{path.join(path.dirname(__file__), 'accounts.json')}", 'r'))
random.shuffle(accounts)
for account in accounts:
_, access_token, insta_session = self.login(account)
if not _:
print(f"\t[-] Login failed: {account['email']}")
continue
print(f'[+] Logged in: {account["email"]}')
connected_accounts = self.get_connected_accounts(
access_token, insta_session)
usernames = [_['instagram_data']['username']
for _ in connected_accounts['connected_account']]
usernames.append(
connected_accounts['primary_account']['instagram_data']['username'])
for username in usernames:
print(f'\t[*] Username: {username}')
resp = post(f'{BASE_URL}/changeIGAccount', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}, json={
'username': username
})
insta_session, access_token = resp.cookies['mrinsta_session'], resp.json()[
'data']['token']
is_free_followers_plan_active, is_free_post_like_active = self.active_subscription_setup(
access_token, insta_session)
_, message = self.activate_follow_user(
access_token, insta_session)
if not is_free_followers_plan_active and not 'activated' in message:
self.follow_user(message['user']['id'],
access_token, insta_session)
else:
print(f'\t\t[-] Follow plan not active')
if not is_free_post_like_active:
self.like_post(access_token, insta_session)
else:
print(f'\t\t[-] Like plan not active')
total_coin = self.get_earned_coin_details(
access_token, insta_session)
if total_coin > 0:
print(f'\t\t[+] Added: {total_coin // 10} followers')
self.redeem_earned_coin(
total_coin, access_token, insta_session)
self.log_out(access_token, insta_session)
def get_earned_coin_details(self, access_token: str, insta_session: str) -> int:
try:
resp = get(
f'{BASE_URL}/getEarnedCoinDetails', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()
return int(resp['data']['total_earn_coin'])
except Exception as e:
print(f'\t\t[-] Error@get_earned_coin_details: {e}')
print(f'\t\t[-] {resp}')
if DEBUG:
input()
return 0
def redeem_earned_coin(self, total_coin: int, access_token: str, insta_session: str) -> None:
# coin, qnty should be more clear, fix needed
coin, qnty = total_coin, total_coin // 10
if total_coin > 1000:
coin, qnty = 1000, 100
resp = post(f'{BASE_URL}/redeemEarnedCoinDetails', json={
'service': 'followers',
'comments': '',
'link': f'https://www.instagram.com/{TARGET}/',
'qnty': qnty,
'coin': coin,
}, headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()
def get_connected_accounts(self, access_token: str, insta_session: str):
resp = get(f'{BASE_URL}/listConnectedAccount', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()
return resp['data']
def validate_post_like(self, access_token: str, insta_session: str) -> str:
return post(f'{BASE_URL}/validatePostLike', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()['message']
def confirm_like_post(self, target_id: str, access_token: str, insta_session: str) -> str:
try:
return post(f'{BASE_URL}/confirmLikePosts', json={'post_id': target_id}, headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()['message']
except Exception as e:
print(f'[-] Error@confirm_like_post: {e}')
input()
def refresh_user_like(self, access_token: str, insta_session: str) -> str:
return post(f'{BASE_URL}/refreshUserLike', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()['data']['id']
def like_posts_info(self, access_token: str, insta_session: str) -> str:
return get(f'{BASE_URL}/likePostsInfo', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()['data']['confirmed_posts']
def active_subscription_setup(self, access_token: str, insta_session: str) -> typing.Tuple[bool, bool]:
resp = get(
f'{BASE_URL}/activeSubscriptionSetupForAll',
headers={
"Authorization": f"Bearer {access_token}"
},
cookies={
'mrinsta_session': insta_session
}
).json()['data']
return resp['is_free_followers_plan_active'], resp['is_free_post_like_active']
def login(self, account: dict) -> typing.Tuple[bool, str, str]:
# it's related to mrinsta server
for _ in range(50):
sleep(2)
resp = post(f'{BASE_URL}/login', json={
'username': account['email'],
'password': PASSWORD,
})
try:
return True, resp.json()['data']['access_token'], resp.cookies['mrinsta_session']
except Exception as e:
pass
return False, "", ""
def log_out(self, access_token: str, insta_session: str) -> None: post(f'{BASE_URL}/logout', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
})
def activate_follow_user(self, access_token: str, insta_session: str) -> typing.Tuple[bool, typing.Union[str, typing.Any]]:
resp = post(f'{BASE_URL}/activateFollowUser', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()
message, data = resp['message'], resp['data']
return (False, message) if "activated" in message else (True, data)
def like_post(self, access_token: str, insta_session: str) -> None:
for _ in range(10):
self.confirm_like_post(
self.refresh_user_like(access_token, insta_session), access_token, insta_session)
confirmed_posts = self.like_posts_info(access_token, insta_session)
print(f'\t\t[*] Confirmed posts: {confirmed_posts}')
if confirmed_posts > 10:
break
self.validate_post_like(access_token, insta_session)
def follow_user(self, user_id: int, access_token: str, insta_session: str) -> None:
for _ in range(10):
try:
confirmed_followers = get(
f'{BASE_URL}/getTotalAndPendingFollow', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
}).json()['data']['confirmed_followers']
if confirmed_followers + 1 > 10:
break
print(
f'\t\t[*] Confirmed followers: {confirmed_followers + 1}')
post(f'{BASE_URL}/confirmFollow', json={
'user_id': user_id,
'premium_user': 1,
}, headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
})
resp = post(
f'{BASE_URL}/refreshUserFollow', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
})
user_id = resp.json()['data']['user']['id']
except Exception as e:
print(f'\t[-] Error@follow_user@{_}: {e}')
print(resp.json())
if DEBUG:
input()
post(f'{BASE_URL}/validateFollowUser', headers={
"Authorization": f"Bearer {access_token}"
}, cookies={
"mrinsta_session": insta_session
})
if __name__ == '__main__':
MrInsta()
# delete->MrInsta()