0

The end goal is to create a program that runs when my hard drive is plugged into a computer. This program will attempt to verify that the user is me through username and password. Upon correct input, the program will allow access to the files on the hard drive. Incorrect input will 'safely eject' the hard drive so it cannot be accessed until it is plugged in again (obviously that would mean it runs the program again).

I already have a program folder with two programs I've written in it:

1) A program that asks for username and password (which are preset within it). This program allows three attempts at both username and password. On a third strike of either variable, the program displays "Unauthorized Access Prohibited!", imports my contact information from the second program, and then emails me that my hard drive has been accessed.

2) A program that displays my contact information. This program is imported into the other when a third strike happens.

Does anyone know how I could meet my end goal?
Thanks ahead of time.

2
Contributors
3
Replies
13
Views
7 Months
Discussion Span
Last Post by rproffitt
0

Well, to begin with, I didn't realize autorun was disabled. Regardless, the question was if anyone knew a way. I've heard of people having programs run in the background of their PC to detect the program within the hard drive, but that seems both inefficient and useless, as it would bog down the PC and the point of my attempt is to be able to plug the hard drive into any computer, not just one.

But, as for the code, here is the main program:

# set username and password here
name = 'whatever you want'
password = 'also whatever you want'

# define whodis(): asks for username; 3 strikes, you're out
# correct username runs itsme()
# 3 incorrect usernames imports mine.py and exits
def whodis():
    who = input('Please enter username: ')
    if who == name:
        itsme()
    else:
        print('Incorrect username.')
        who = input('Please enter username: ')
        if who == name:
            itsme()
        else:
            print('Incorrect username.')
            who = input('Please enter username: ')
            if who == name:
                itsme()
            else:
                print('UNAUTHORIZED ACCESS PROHIBITED!')
                import mine

# python functions for sending email alert
                import smtplib
                server = smtplib.SMTP('smtp.gmail.com',587)
                server.starttls()
                server.login('email address, password')
                msg = 'Your hard drive has been accessed.'
                server.sendmail('source email','destination email',msg)
                server.quit()
                exit

# define itsme(): asks for password; 3 strikes, you're out
# 3 incorrect passwords imports mine.py and exits
def itsme():
    key = input('Please enter password: ')
    if key == password:
        print('Welcome')
    else:
        print('Incorrect password.')
        key = input('Please enter password: ')
        if key == password:
            print('Welcome')
        else:
            print('Incorrect password.')
            key = input('Please enter password: ')
            if key == password:
                print('Welcome')
            else:
                print('UNAUTHORIZED ACCESS PROHIBITED!')
                import mine
                import smtplib
                server = smtplib.SMTP('smtp.gmail.com',587)
                server.starttls()
                server.login('email address, password'
                msg = 'Your hard drive has been accessed.'
                server.sendmail('source email','destination email',msg)
                server.quit()
                exit

# runs whodis()
whodis()

The 'import mine' line imports my contact information, which in this case would simply be my name and email. I also don't want these files to be able to be accessed by anyone but myself, as my email and password are needed in line for it to work. The email alert lines I found elsewhere, and after allowing the program to log in to my email, it works.

Essentially, I have the code doing what I want it to do. I just need to be able to get this program to run whenever someone tries to access my hard drive (including myself) and I need the program files to be hidden from prying eyes.

0

Just a suggestion, next time add a tag with the OS you are targetting. It looks like you haven't solved the autorun problem yet. We know the OS has it disabled so you go back to the design phase to create another solution.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.