script to protect the start of an application

Need help with C, C++, perl, python, etc?

script to protect the start of an application

Postby cc » 2006-09-29 01:00

hi

howto write a script to protect the start of an application using password for example thunderbird ?

kind regards
cc
cc
 
Posts: 820
Joined: 2005-06-08 19:14

Postby ajdlinux » 2006-09-29 08:32

Here's a script which could work:

Code: Select all
#!/usr/bin/python

# Password protector
import os, sys, sha, getpass

# Read in hash
hash_file = open("/home/myUser/.password_protect", "r")
hash = hash_file.read()

# Get new hash
pwhash = ''
counter = 0
while pwhash != hash:
    pwhash = sha.sha(getpass.getpass("Password: ")).hexdigest()
    counter += 1
    if counter > 3:
        sys.exit()

os.system("/usr/bin/real_thunderbird")



You would still need to create .password_protect with a similar script, e.g.:

Code: Select all
#!/usr/bin/python

# Password protector
import os, sys, sha, getpass

# Open file
hash_file = open("/home/myUser/.password_protect", "w")

# Get new hash
pwhash = sha.sha(getpass.getpass("New Password: ")).hexdigest()

hash_file.write(pwhash)
hash_file.close()
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au
ajdlinux
 
Posts: 2480
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

Postby cc » 2006-09-30 01:47

thanks, I tried but it won't work.
Last edited by cc on 2006-09-30 13:22, edited 1 time in total.
cc
 
Posts: 820
Joined: 2005-06-08 19:14

Postby ajdlinux » 2006-09-30 02:19

Those scripts work on my system, you need to run the second one to create the password file first.

Note that as long as you aren't using encryption to keep the program you want to protect encrypted, anyone could just read those scripts and find out where the real program is and run that.
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au
ajdlinux
 
Posts: 2480
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

Postby cc » 2006-09-30 12:46

thanks a lot !


it works well, but only from from the command line.

I have 2 scripts:
Code: Select all
mail.py
.password_protect


I've create a new desktop launcher using this command:
Code: Select all
/home/user/mail.py

do a doubble click on the desktop icon, but it won't start.
what's wrong ?
cc
 
Posts: 820
Joined: 2005-06-08 19:14

Postby ajdlinux » 2006-09-30 20:46

The script will be looking for a console input which it won't get. You have two choices: 1) reimplement it using zenity or similar to get the password, or 2) just change the launcher so it will open up in a terminal.
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au
ajdlinux
 
Posts: 2480
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

Postby cc » 2006-09-30 22:22

thanks,

open it in a terminal works perfectly.
cc
 
Posts: 820
Joined: 2005-06-08 19:14


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable