Page 1 of 1

QBasic Password program on Windows startup

Posted: Mon Oct 24, 2005 11:06 am
by Pete
Here's another question for you guys to answer:
eraserx wrote:Hello Mr Berg,

Thank you very much for your help.

Isnt there a solution to my problem in QBasic? Because it will be a good exercise for me to make a password program for startup. I am not as good as you in QB programming and I thought that you could help me.

How can we make such a program in QB? I will wait for your helps.

Regards.
My response:
Pete wrote:Pete Berg
to eraserx
The problem is that you'd be running a DOS program in Windows 98. So no matter what, there's always a way to get out of the DOS prompt window. Your brother could press CTRL+ALT+DELETE to go to the close program window, or press the Windows key and have the start menu pop up and show the desktop. There are many other ways to get around this too. It would be very easy to circumvent.

Of course, if you're able to block all these loopholes (disable CTRL+ALT+DELETE, the Windows key, etc.,) you might be able to work.

-Pete
And his response.
eraserx wrote: Hello Mr Berg,

First off all, thanks for your answers. But I made a mistake in asking you for the password program. I wrote "a program for startup" but in fact I meant "a program at bootup". Sorry for this.

Now I made the correction. So How can we write the program in QB then
?

I hope I am not disturbing you.

Regards.
Any ideas?

Posted: Mon Oct 24, 2005 11:35 am
by Z!re
Put it in autoexec.bat.. if he's on Windows 2k or later, he's out of luck.

Posted: Mon Oct 24, 2005 11:38 am
by Xerol
Well, to get it at bootup, if it's Win98 or previous (he didn't say which OS he was running) you could just throw the compiled program into Autoexec.bat. In QB, you can create custom ON KEY events to trap ctrl-alt-del (which would just end up going back to the PW program again anyway), alt-tab, ctrl-break, ctrl-esc(which is the same as the Start key), etc. But, by running it in the autoexec.bat prior to loading windows, there's only 2 ways out of it:

1) Remove it from autoexec.bat AFTER you're logged in. If you shut down the computer whenever you're not using it, you shouldn't have to worry about this.
2) Use F* (not sure about the number, i think it's F6) to change to "line-by-line" autoexec.bat execution. Whoever was using it would just be able to skip over the program. Or if they bypassed autoexec altogether.

As far as the program itself goes, I'd say just do something like the following:

Code: Select all

'Insert ON KEY events here; I'd have to look it up to see the syntax. Basically you'd set keys for ctrl-alt-del, ctrl-break, and every other event you want to 'trap'. Then you'd call ON KEY(n) (where n = the key number you defined; I think custom keys start at 15) and send it to a dummy gosub.

10 input "Password:", z$
if z$ <> "password" then
 print "Invalid password."
 attempts = attempts + 1
 if attempts = 5 then print "Hack attempt detected. Locking Computer.": do: loop
 goto 10
else
 print "Correct password!"
 end
end if

I'd have to look up the syntax again for how to set custom keys (I haven't used them since GWBasic).

Posted: Mon Oct 24, 2005 12:15 pm
by madcrow
Hmm... This reminds me of my big qbasic project that I did ages ago... It was a user account system for DOS that gave people home directories and custom autoexec.bat-type stuff. It was an ugly kludge of a qbasic program and a bunch of BAT files, but it worked...

Posted: Mon Oct 24, 2005 2:35 pm
by {Nathan}
The thing is that with all windows there is a way to bypass the autoexec.bat file. I have tried it... you just have to use the boot menu, and choose interactive startup or safe mode (or, if he was really evil, he would re-install your OS like thieves do).

The only way to do this is to set a password from the BIOs screen when it first starts up. A boot-level password prompy will stop him if he is computer illeterate though... at least, it PROBABLY will... just make sure you have the boot menu disabled.

Posted: Mon Oct 24, 2005 4:09 pm
by Xerol
Nathan1993 wrote:The thing is that with all windows there is a way to bypass the autoexec.bat file. I have tried it... you just have to use the boot menu, and choose interactive startup or safe mode (or, if he was really evil, he would re-install your OS like thieves do).
Yes, I did mention that, although the "best" way to bypass it would be to set it into item-by-item mode, and only choose to not execute the password protection program.

Posted: Mon Oct 24, 2005 7:48 pm
by {Nathan}
Xerol wrote:
Nathan1993 wrote:The thing is that with all windows there is a way to bypass the autoexec.bat file. I have tried it... you just have to use the boot menu, and choose interactive startup or safe mode (or, if he was really evil, he would re-install your OS like thieves do).
Yes, I did mention that, although the "best" way to bypass it would be to set it into item-by-item mode, and only choose to not execute the password protection program.
Item by item mode is interactive startup, as I stated. Mcrap just calls it an interactive startup.

Posted: Mon Oct 24, 2005 10:02 pm
by OlafTheGreat
I made one of these once. What I did to make it come up at startup was name it C:\WIN.EXE
Then I had it run C:\WINDOWS\system32\WIN.COM if the password was correct. I am running XP. The only problem I had with it was when I tried to have mouse support for it.