-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
241 lines (208 loc) · 9.8 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
236
237
238
239
240
241
# -*- coding: utf-8 -*-
# For MacOS systems only. Cannot run on a Windows machine.
from colorama import init, Fore
from datetime import datetime
from sys import exit
from os import system
import subprocess
import json
from requests import get
init(True)
title = '''
██ ██ ██
██ ██ ██
██ ██ ██
██ ██ ██
██ ██ ██
████████████████████
██ ██████
██ ██ ██ coffee shop multi-tool ☕️
██ ██ ██ by luca denhez
██ ██████
██ ██
████████████████████████
██ ██
████████████████████
'''
print(Fore.RED + title + '\n')
class Coffee:
def __init__(self):
self.q = ''
@classmethod
def time(self):
return '[' + datetime.now().strftime('%H:%M:%S') + ']'
@classmethod
def start(self):
print(' Enter the command \'help\' for a commands list.\n')
@classmethod
def ask(self):
print(self.time() + ' > ', end = '')
self.q = input(Fore.BLUE)
print(Fore.RESET)
self.invoke()
@classmethod
def invoke(self):
if self.q == 'help':
self.help()
elif self.q == 'exit':
exit()
elif self.q == 'wifi':
self.wifi()
elif self.q == 'cip':
self.currentIP()
elif 'cip' not in self.q and 'ip' in self.q:
try:
ip = self.q.split(' ')[1]
self.ip(ip)
except IndexError:
print(Fore.YELLOW + ' Unknown schema, IP follows command with a space\n')
self.ask()
except Exception as ex:
print(Fore.RED + ' An error occured\n')
print(ex)
self.ask()
elif 'ping' in self.q:
try:
ip = self.q.split(' ')[1]
self.ping(ip)
except IndexError:
print(Fore.YELLOW + ' Unknown schema, IP follows command with a space\n')
self.ask()
except Exception as ex:
print(Fore.RED + ' An error occured\n')
print(ex)
self.ask()
elif self.q == 'coffee':
print('☕️\n')
elif 'savewifi' in self.q:
try:
mode = self.q.split(' ')[1]
self.saveWifi(mode)
except IndexError:
print(Fore.YELLOW + ' Unknown schema, file type follows command with a space\n')
self.ask()
except Exception as ex:
print(Fore.RED + ' An error occured\n')
print(ex)
self.ask()
else:
print(Fore.RED + ' Unknown command entered\n')
self.ask()
@classmethod
def help(self):
print(' wifi - Get lots of info about current connected WiFi\n')
print(' savewifi [json] [text] - Save WiFi information to json or text file\n')
print(' ip [ip address] - Gets info about IP address provided\n')
print(' cip - Gets info about your IP address\n')
print(' ping [ip address] - Pings IP address provided\n')
print(' coffee - ☕️\n')
print(' exit - Exit multi-tool')
print('')
@classmethod
def wifi(self):
process = subprocess.Popen(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport','-I'], stdout=subprocess.PIPE)
info, err = process.communicate()
process.wait()
info = info.decode(encoding='UTF-8')
print('WiFi Information:\n')
print(' WiFi Name: ' + info.split('\n')[12].split(':')[1].strip())
print(' Security Type: ' + info.split('\n')[10].split(':')[1].strip())
print(' Router MAC Address: ' + info.split('\n')[11].split('BSSID:')[1].strip())
print(' Connection Strength: ' + info.split('\n')[0].split(':')[1].strip() + ' RSSI (0 to -100, the greater the stronger)')
print('')
@classmethod
def currentIP(self):
response = get('http://ip-api.com/json/?fields=status,country,region,city,zip,timezone,isp,lat,lon,query,proxy').json()
if response['status'] == 'success':
for key in response:
if key == None:
key = 'Not Available'
print('IP Information:\n')
print(' Current IP: ' + response['query'])
print(' Country: ' + response['country'])
print(' Region: ' + response['city'] + ', ' + response['region'])
print(' Zip Code: ' + response['zip'])
print(' Timezone: ' + response['timezone'])
print(' Internet Provider (ISP): ' + response['isp'])
print(' Lat & Lon: ' + str(response['lat']) + ', ' + str(response['lon']))
print('\n Using Proxy? ' + str(response['proxy']))
print('')
else:
print('\nIP Information: Unavailable')
print('')
@classmethod
def ip(self, ip):
response = get('http://ip-api.com/json/' + ip + '?fields=status,country,region,city,zip,timezone,isp,lat,lon,proxy').json()
if response['status'] == 'success':
for key in response:
if key == None:
key = 'Not Available'
print('Information for IP: ' + ip + ':\n')
print(' Country: ' + response['country'])
print(' Region: ' + response['city'] + ', ' + response['region'])
print(' Zip Code: ' + response['zip'])
print(' Timezone: ' + response['timezone'])
print(' Internet Provider (ISP): ' + response['isp'])
print(' Lat & Lon: ' + str(response['lat']) + ', ' + str(response['lon']))
print('\n Using Proxy? ' + str(response['proxy']))
print('')
else:
print('\nInformation for IP: ' + ip + ' unavailable')
print('')
@classmethod
def ping(self, ip):
system('ping -c 5 ' + ip)
print('')
@classmethod
def saveWifi(self, mode):
process = subprocess.Popen(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport','-I'], stdout=subprocess.PIPE)
info, err = process.communicate()
process.wait()
info = info.decode(encoding='UTF-8')
response = get('http://ip-api.com/json/?fields=status,country,region,city,zip,timezone,isp,lat,lon,query,proxy').json()
if mode == 'json':
data = {}
if response['status'] == 'success':
for key in response:
if key == None:
key = 'unavailable'
data['ssid'] = info.split('\n')[12].split(':')[1].strip()
data['security'] = info.split('\n')[10].split(':')[1].strip()
data['router-mac'] = info.split('\n')[11].split('BSSID:')[1].strip()
data['strength-rssi'] = info.split('\n')[0].split(':')[1].strip()
data['connected-ip'] = response['query']
data['country'] = response['country']
data['city'] = response['city']
data['region'] = response['region']
data['zip-code'] = response['zip']
data['time-zone'] = response['timezone']
data['isp'] = response['isp']
data['latitude'] = response['lat']
data['longitude'] = response['lon']
data['proxy'] = response['proxy']
else:
data['connected-ip'] = 'unavailable'
with open('wifi.json', 'w') as f:
json.dump(data, f, indent = 4)
print(Fore.GREEN + ' Done writing to ' + mode + ' file\n')
elif mode == 'text':
with open('wifi.txt', 'w') as f:
f.write('SSID: ' + info.split('\n')[12].split(':')[1].strip() + '\n')
f.write('Security: ' + info.split('\n')[10].split(':')[1].strip() + '\n')
f.write('MAC Address of Router: ' + info.split('\n')[11].split('BSSID:')[1].strip() + '\n')
f.write('Connection Strength (RSSI): ' + info.split('\n')[0].split(':')[1].strip() + '\n')
f.write('Connected IP: ' + response['query'] + '\n')
f.write('Country: ' + response['country'] + '\n')
f.write('City: ' + response['city'] + '\n')
f.write('Region: ' + response['region'] + '\n')
f.write('Zip Code: ' + response['zip'] + '\n')
f.write('Time Zone: ' + response['timezone'] + '\n')
f.write('Internet Service Provider (ISP): ' + response['isp'] + '\n')
f.write('Latitude & Longitude: ' + str(response['lat']) + ', ' + str(response['lon']) + '\n')
f.write('Using Proxy? ' + str(response['proxy']))
print(Fore.GREEN + ' Done writing to ' + mode + ' file\n')
else:
print(' Unknown schema, file type follows command with a space\n')
Coffee.start()
while True:
Coffee.ask()