Password protect a single text file?

Started by Snake, Wed 03/12/2008 14:28:51

Previous topic - Next topic

Snake

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.
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Tuomas

A nice way to hide the nude pictures of your girlfriend too ;)

MrColossal

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
"This must be a good time to live in, since Eric bothers to stay here at all"-CJ also: ACHTUNG FRANZ!

Radiant

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.

Snake

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!
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

OneDollar

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.

Pumaman

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.

InCreator

#8
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, 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?

GarageGothic

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.

Dualnames

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
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Snake

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 :-*
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

OneDollar

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

Snake

#13
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.

Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

RickJ

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.

Snake

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?
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

OneDollar

Maybe because you've got spaces in the path? Sorry, don't really know

Snake

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.
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

RickJ

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

Snake

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.
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

SMF spam blocked by CleanTalk