Adventure Game Studio

Community => General Discussion => Topic started by: Snake on Wed 03/12/2008 14:28:51

Title: Password protect a single text file?
Post by: Snake on Wed 03/12/2008 14:28:51
Hey, guys,

I'm running Windows XP Home Edition

So far I found out that if I zip the folder containing the file I can add a password to that, but that's not what I want to do. I would like to have a single text file require a password before viewing it's contents.

Is there a way to do this in Windows without having to download any programs?

I know that in Word you can have a password, but I'm almost sure that if I saved it as a word document that it wouldn't work anymore - it can't have any funky characters in it, it must stay as a plain text file.

The file that I have is the Hosts file and I open it with Notepad. And the reason for wanting a password is so that I am the only one who is waranted to edit it.

Much thanks in advance.

/--EDIT--/
I've been searching for an answer all morning but I've been unable to find anything besides the zipping idea and that Word allows a password.
Title: Re: Password protect a single text file?
Post by: Dualnames on Wed 03/12/2008 14:43:16
http://www.monkeyjob.com/FileMonk/FMExamp/Encrypt-Files.htm

Check this link..

http://www.freevbcode.com/ShowCode.asp?ID=6230
and this one..
Title: Re: Password protect a single text file?
Post by: Tuomas on Wed 03/12/2008 14:59:10
A nice way to hide the nude pictures of your girlfriend too ;)
Title: Re: Password protect a single text file?
Post by: MrColossal on Wed 03/12/2008 15:27:47
encryption might also not work because the hosts file needs to be read by the computer

You could set the file to readonly and then set it to hidden and turn of hidden files in windows? That might be a solution? Unless the kid looking for porn is computer savvy and knows enough to unhide files and unlock them.

Spyboy also has an option to lock the hosts file but that might just set it to readonly which you can do yourself
Title: Re: Password protect a single text file?
Post by: Radiant on Wed 03/12/2008 15:32:42
The standard ways of protecting files include hiding them and encryption. Of course, both of those would interfere with the function of the Hosts file.

You might be able to hide the file (write-protecting it won't help or matter either way) and disallowing said user access to the option to "show hidden files".

Other than that, without third-party software, you're out of luck.
Title: Re: Password protect a single text file?
Post by: Snake on Wed 03/12/2008 16:53:58
Huh.

Thanks for the info/links, guys.

I tried and zipped the "etc" folder and made it password protected. I was thinking that it would render the hosts file unreadable, but it still worked.

I guess I'll go with that for now.

Thanks again!
Title: Re: Password protect a single text file?
Post by: OneDollar on Wed 03/12/2008 21:07:28
As an alternative you could move the hosts file somewhere that it won't be found, replace it with a dummy then change the registry key that points to it (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters then set the DataBasePath key to point to the new one).

Are you sure that a zipped, password protected hosts file works? I would have thought it was more likely that IE can't find it so just doesn't use it. Unfortunately I can't think of anything better than the above (and a search for hosts would still find it) unless you have multiple users and change the permissions on the folder so that only the administrator can edit the contents.
Title: Re: Password protect a single text file?
Post by: Pumaman on Wed 03/12/2008 22:09:00
Yeah, you can't just zip up and delete the "etc" folder and expect it to work. Either it is being ignored, or Windows has copied back an older version from a System Restore point.

It is not possible to password-protect a text file like the HOSTS file, for the simple reason that the file format has no such capability.

If you want to prevent other people editing it, then use the Security permissions on the file to restrict editing to your username only.
Title: Re: Password protect a single text file?
Post by: InCreator on Wed 03/12/2008 23:26:37
Hosts file cannot be renamed or modified much, so I probably can't help here.

But for regular files, simply changing file type does wonders usually. Like renaming jpg to a dat/mp3/whatever file or something.

For more secure protection (work mostly), I use AxCrypt (http://www.axantum.com/AxCrypt/), truly wonderful and free 128-bit security tool.

Anyway, I'm still wondering why over more than 15 years, Microsoft hasn't integrated simple (and working!) folder & file password-accessing into Windows. This should be so... essential?
Title: Re: Password protect a single text file?
Post by: GarageGothic on Thu 04/12/2008 00:15:04
You may be able to use your router's internal DNS routing table (such as dnsmasq) instead of the hosts file. Though this could possibly be circumvented by setting Windows to directly access a specified DNS server rather than contacting it through the router. There may be countermeasures for this, but it depends on your router software.
Title: Re: Password protect a single text file?
Post by: Dualnames on Thu 04/12/2008 08:16:55
Quote from: Snake on Wed 03/12/2008 16:53:58
Huh.

Thanks for the info/links, guys.

I tried and zipped the "etc" folder and made it password protected. I was thinking that it would render the hosts file unreadable, but it still worked.

I guess I'll go with that for now.

Thanks again!

GUYS? I send you the links..Damn you Tuomas, you 've taken the GLOOOOOORYYYYYYYY ;D
Title: Re: Password protect a single text file?
Post by: Snake on Thu 04/12/2008 15:45:39
Heh, you guys are right - of course!

I don't know why I thought the host file was still working with the ETC folder zipped... hmm. Maybe the machine had to be restarted because for some reason I remember testing - which I always do after editing - and it worked just fine.

I downloaded AxCrypt and I must say that it's pretty neat. Although it won't work with the hosts file (internet can't open it up to read it) I'm sure I could find it handy in the future (I'm planning on making somebody a little quick adventure game for Christmas and I could use this to hide it!).

OneDollar:
I think that the alternative that you gave me will have to be the way that I do it.
One quick question. I noticed that the DataBasePath key points to the ETC folder and not just the hosts file. Do I have to copy the whole folder or does the DataBasePath only look for the hosts file?
Thank you very much, by the way.

Dualnames, don't be upset, you're a nice guy and all, but, Tuomas has a bigger genitalia :-*
Title: Re: Password protect a single text file?
Post by: OneDollar on Thu 04/12/2008 16:42:17
It'll always look for a file called hosts (which is why you can't rename it) so the DataBasePath will need to point to a folder with the hosts file in it. As to whether you need the whole folder.... not sure to be honest, I've never done it myself. I'd guess that you do need a copy of all the files in your new folder. Test it: if you managed to compress and encrypt the etc folder before (effectively the same as removing it) then restart the computer without it dying then you shouldn't do too much irrepairable damage by making a copy of the files and changing the pointer to them.

...famous last words
Title: Re: Password protect a single text file?
Post by: Snake on Thu 04/12/2008 17:15:22
It doesn't seem to work even after restarting...

This is the path I put in:
C:\Documents and Settings\Tom and Kristen\My Documents\second

In the "second" folder are all the files from the etc folder, including the hosts.

//--EDIT--//
It appears that it is still reading from system32\drivers\etc...

I just tried and replaced the dummy hosts file with the real one and it works.

Title: Re: Password protect a single text file?
Post by: RickJ on Thu 04/12/2008 17:51:40
I have an idea for you that may take just a little effort.  I was thinking that maybe you could create your very own spyware to solve your problem.

Suppose you created a program that runs as a service that would periodically check the hosts file to see if it was changed.   If so then it could restore the hosts file, shutdown the machine, disable internet access, or perform other annoying operations.   You could even have it play a recording of you or mom scolding the kid "Billy, you perverted little shit, if you don't stop looking at porn were gonna have your balls cut off..." ;).     

It sounds like a lot of work I know but it may not be as difficult as you think to pull off.  I recently found this little scripting language called AutoIt.  It's pretty cool and is used by administrators to automate their routine tasks.   It is designed so that keystrokes and mouse clicks can be sent to any window in any application.  There is a GUI builder but GUI's are not required.   The script language is not any more difficult  than AGS's script language. 

If you would like to give it a try you can find it at http://www.autoitscript.com/autoit3/index.shtml.  It's free and they have a support forum.  I could also answer some questions but I am a newbie also so my knowledge is limited.  Anyway, good luck.
Title: Re: Password protect a single text file?
Post by: Snake on Thu 04/12/2008 18:00:54
Haha, wow, Rick, that sounds like a sweet little tool. I think I'll give that a shot at one point.... heh, definately.

Does anyone know what I may have done wrong or am not doing?

I've edited the DataBasePath and changed %SystemRoot%\System32\Drivers\etc
to
C:\Documents and Settings\Tom and Kristen\My Documents\second.
It's looking like it is still looking in the default folder for the hosts file.

What am I not doing right?
Title: Re: Password protect a single text file?
Post by: OneDollar on Sat 06/12/2008 16:43:30
Maybe because you've got spaces in the path? Sorry, don't really know
Title: Re: Password protect a single text file?
Post by: Snake on Sat 06/12/2008 16:56:26
Thanks, OneDollar. No, that makes sence. I'll try that and see what happens. I'll try just putting it in a seperate folder in System32.
Title: Re: Password protect a single text file?
Post by: RickJ on Sat 06/12/2008 18:37:05
You can try substituting %20 for the space characters or try enclosing the path in quotes.

"C:\Documents and Settings\Tom and Kristen\My Documents\second"

C:\Documents and Settings\Tom%20and%20Kristen\My Documents\second
Title: Re: Password protect a single text file?
Post by: Snake on Sat 06/12/2008 19:47:49
Tried all of the above and I got nothing. It's still looking in the default folder no matter what I change it to. I even changed it it "SHIT HEAD" and it still did nothing, everything ran as normal. I got a feeling that something else is reading from the etc folder and not that databasepath thing.

I'll put everything back to the way I had it and try Rick's idea with that program when I've got the time.

Thanks anyway guys.