Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
deathsec
GitHub Repository: deathsec/instagram-py
Path: blob/master/InstagramPy/InstagramPyCLI.py
197 views
1
# The MIT License.
2
# Copyright (C) 2017 The Future Shell , DeathSec.
3
#
4
# @filename : InstagramPyCLI.py
5
# @description : Simple command line interface to display progress
6
# and efficiently show response too.
7
8
import datetime
9
import sys
10
from InstagramPy import AppInfo
11
from .colors import *
12
13
14
class InstagramPyCLI:
15
username = None
16
started = None
17
verbose = 0
18
19
def __init__(self, appinfo, started, verbose_level, username):
20
try:
21
self.verbose = int(verbose_level)
22
self.started = started
23
self.username = username
24
if not appinfo == None:
25
appinfo = appinfo
26
except:
27
self.verbose = 0
28
self.started = started
29
appinfo = AppInfo.appInfo
30
if username == None or username == '':
31
self.ReportError("username not provided!")
32
else:
33
self.username = username
34
35
self.HEADER = "{} {} , {}.\nCopyright (C) {} {} , {}.\n".format(appinfo['name'],
36
appinfo['version'],
37
appinfo['description'],
38
appinfo['year'],
39
appinfo['company'],
40
appinfo['author'])
41
self.HEADER = Fore.MAGENTA + self.HEADER + Style.RESET_ALL
42
43
def ReportError(self, error):
44
print('{}{}fatal error::{} {}'.format(
45
Style.BRIGHT, Fore.RED, Style.RESET_ALL, error))
46
sys.exit(-1)
47
48
def PrintHeader(self):
49
print(self.HEADER)
50
return True
51
52
def PrintDatetime(self):
53
print('{}[{}+{}{}]{} {}Started{} @ {}'.format(Style.BRIGHT,
54
Fore.YELLOW,
55
Style.RESET_ALL,
56
Style.BRIGHT,
57
Style.RESET_ALL,
58
Fore.MAGENTA,
59
Style.RESET_ALL + Fore.YELLOW,
60
str(self.started) +
61
Style.RESET_ALL
62
))
63
return True
64
65
def PrintChangingIP(self):
66
print('[{}*{}] {}Changing IP Address... {}'.format(Fore.YELLOW,
67
Style.RESET_ALL, Fore.GREEN, Style.RESET_ALL))
68
return True
69
70
def PrintIPAddress(self, ip):
71
print('[{}+{}] {}Current IP{} :: {}{}{}'.format(Fore.RED,
72
Style.RESET_ALL,
73
Fore.YELLOW,
74
Style.RESET_ALL,
75
Style.BRIGHT,
76
str(ip),
77
Style.RESET_ALL
78
))
79
return True
80
81
def PrintPassword(self, password):
82
print('[{}+{}] {}Trying [FOR] @{} {} :: {}{}{}'.format(Fore.GREEN,
83
Style.RESET_ALL,
84
Fore.CYAN,
85
self.username,
86
Style.RESET_ALL,
87
Style.BRIGHT,
88
password,
89
Style.RESET_ALL
90
))
91
return True
92
93
def PrintRequest(self, req):
94
print('\n[{}-{}] --:: {}REQUEST START -> @{} {} ::--'.format(Fore.MAGENTA,
95
Style.RESET_ALL, Back.CYAN + Style.BRIGHT, self.username, Style.RESET_ALL))
96
print('{}{}{} {}{}{}'.format(Fore.GREEN, req.method,
97
Style.RESET_ALL, Style.BRIGHT, req.url, Style.RESET_ALL))
98
print('{}{}{}'.format(Fore.YELLOW, '\n'.join('{}: {}'.format(k, v)
99
for k, v in req.headers.items()), Style.RESET_ALL))
100
print('{}{}{}'.format(Style.BRIGHT, req.body, Style.RESET_ALL))
101
print('[{}+{}] --:: {}REQUEST END{} ::--'.format(Fore.GREEN,
102
Style.RESET_ALL, Back.GREEN + Style.BRIGHT, Style.RESET_ALL))
103
return True
104
105
def PrintResponse(self, resp):
106
print('\n[{}-{}] --:: {}RESPONSE START -> @{} {} ::--'.format(Fore.MAGENTA,
107
Style.RESET_ALL, Back.CYAN + Style.BRIGHT, self.username, Style.RESET_ALL))
108
print('{}{}{}'.format(Style.BRIGHT, str(resp), Style.RESET_ALL))
109
print('[{}+{}] --:: {}RESPONSE END{} ::--'.format(Fore.GREEN,
110
Style.RESET_ALL, Back.GREEN + Style.BRIGHT, Style.RESET_ALL))
111
return True
112
113
def PrintProgress(self, password, ip, request, response):
114
if self.verbose == 0:
115
self.PrintPassword(password)
116
elif self.verbose == 1:
117
self.PrintPassword(password)
118
self.PrintResponse(response)
119
elif self.verbose == 2:
120
self.PrintPassword(password)
121
self.PrintResponse(response)
122
self.PrintIPAddress(ip)
123
else:
124
self.PrintPassword(password)
125
self.PrintRequest(request)
126
self.PrintResponse(response)
127
self.PrintIPAddress(ip)
128
return True
129
130
def ReportAttack(self, password):
131
print('\n[{}+{}] --:: {}Completed -> @{} {} ::--'.format(Fore.YELLOW,
132
Style.RESET_ALL, Back.YELLOW + Style.BRIGHT, self.username, Style.RESET_ALL),
133
end='')
134
if not password == None:
135
print('{}[{}*{}{}]{} {}Password Found!{} :: {}'.format(Style.BRIGHT,
136
Fore.RED,
137
Style.RESET_ALL,
138
Style.BRIGHT,
139
Style.RESET_ALL,
140
Fore.CYAN,
141
Style.RESET_ALL + Style.BRIGHT + Fore.GREEN,
142
password + Style.RESET_ALL
143
))
144
else:
145
print('{}{}Password not found , Try using another wordlist.{}'.format(
146
Style.BRIGHT, Fore.RED, Style.RESET_ALL))
147
148
print('{}[{}+{}{}]{} {}Finnished in {}{}'.format(Style.BRIGHT,
149
Fore.YELLOW,
150
Style.RESET_ALL,
151
Style.BRIGHT,
152
Style.RESET_ALL,
153
Fore.MAGENTA,
154
Style.RESET_ALL + Fore.YELLOW,
155
str(datetime.datetime.now(
156
) - self.started) + Style.RESET_ALL
157
))
158
return True
159
160
def PrintFooter(self):
161
print('\n{}Report bug, suggestions and new features at {}{}https://github.com/deathsec/instagram-py{}'.format(Fore.GREEN,
162
Style.RESET_ALL,
163
Style.BRIGHT,
164
Style.RESET_ALL
165
))
166
return True
167
168