Page 1 of 1

username & Passwored exe

Posted: Thu Jul 07, 2005 8:37 am
by System-Psycho
Hi,

I know littel qbaisc, and to be honest i dont really want to learn the hole of qbais to make this one littel program.

I am trying to creat a prgram that asks for a username and password.
The code i have at the moment is below;

Code: Select all

CLS
PRINT "Remote Access Server."
PRINT "Admins Only!"
PRINT ""
INPUT "password:", usr$
IF urs$ = "owned" OR usr$ = "happyhacker" OR usr$ = "netstorm" THEN GOTO 1 ELSE GOTO 2

1 PRINT "Welcome"
PRINT "You now have access to or online command prompt shell, uploading file to are ftp or uploading to the website, Our online chat and are exclusive members area"
PRINT " Enjoy System-Psycho"
end

2 PRINT "Access is denine"
The proplem is as follows; i would like ther to be a different thing heppen depending on the username typed but i cant figer this out.
my question is, How would i have something different happen depending on the input?
Thanks sp

Posted: Thu Jul 07, 2005 9:42 am
by Rattrapmax6
You could do a simple thing like print the usr$ behind welcome for a personal greeting:

Code: Select all

CLS 
PRINT "Remote Access Server." 
PRINT "Admins Only!" 
PRINT "" 
INPUT "password:", usr$ 
IF urs$ = "owned" OR usr$ = "happyhacker" OR usr$ = "netstorm" THEN GOTO 1 ELSE GOTO 2 

1 PRINT "Welcome"; usr$
PRINT "You now have access to or online command prompt shell, uploading file to are ftp or uploading to the website, Our online chat and are exclusive members area" 
PRINT " Enjoy System-Psycho" 
end 

2 PRINT "Access is denine"
Or maybe use multiple IFs for different domains.. say Owned is the main Admin, and the others Sub-admins:

Code: Select all

CLS 
PRINT "Remote Access Server." 
PRINT "Admins Only!" 
PRINT "" 
INPUT "password:", usr$ 
IF urs$ = "owned" THEN GOTO 1
IF  usr$ = "happyhacker" OR usr$ = "netstorm" THEN GOTO 2
PRINT "Access is denine" 
END

1 PRINT "Welcome to Main Log." 
PRINT "You now have access to or online command prompt shell, uploading file to are ftp or uploading to the website, Our online chat and are exclusive members area" 
PRINT " Enjoy System-Psycho" 
end 

2 PRINT "Welcome to Sub Log"
PRINT "You now have access to our online chat and are exclusive members area" 
PRINT " Enjoy System-Psycho" 
end 
And also a cool tip, use UCASE$() or LCASE$() to make input case-insensitive:

Code: Select all

IF UCASE$(usr$) = "OWNED" THEN ...

Code: Select all

IF LCASE$(usr$) = "owned" THEN ...
NOTE: UCASE$() makes string all caps, and LCASE make it lower case.. So if you input: Owned, OwNeD, or OWNED it would still work by using these converters.. :wink: You only need one of the two tho, I normally just use UCASE$, other might prefer LCASE$.. but the end result is the same as for case-insensitivity

Posted: Thu Jul 07, 2005 9:50 am
by {Nathan}
Select case.

Code: Select all

SELECT CASE usr$
CASE "Netstorm"
(netstorm stuff goes here)
CASE "HappyHackey"
(happyhacker stuff goes here)
CASE "Owned"
(owned stuff goes here)
END SELECT
And, you may want to use UCASE$ and LCASE$ to check the varibles.

Posted: Thu Jul 07, 2005 9:57 am
by Rattrapmax6
Hi, Nathan... I already told him about UCASE$ and LCASE$... :P

Here's how it goes with that exapmle tho: I preffer IF.. THEN, but this is good too.. :wink:

Code: Select all

CLS 
PRINT "Remote Access Server." 
PRINT "Admins Only!" 
PRINT "" 
INPUT "password:", usr$

SELECT CASE UCASE$(usr$)
CASE "NETSTORM" 
'(netstorm stuff goes here) 
CASE "HAPPYHACKEY" 
'(happyhacker stuff goes here) 
CASE "OWNED" 
'(owned stuff goes here) 
END SELECT

Posted: Thu Jul 07, 2005 1:09 pm
by {Nathan}
...
...
(deleting this word for sake of not being banned)

Posted: Thu Jul 07, 2005 6:45 pm
by moneo
I'm using Rattrapmax6's last posted code as a base.

I'm changing the input prompt from "password" to "Admin Username" because none of the code so far is checking for passwords.

I'm adding CASE ELSE logic to handle the case of an invalid username.

I structured the CASE logic.

Code: Select all

CLS 
PRINT "Remote Access Server." 
PRINT "Admins Only!" 
PRINT "" 
INPUT "Admin Username:", usr$ 

SELECT CASE UCASE$(usr$) 
            CASE "NETSTORM" 
                     '(netstorm stuff goes here) 
            CASE "HAPPYHACKEY" 
                     '(happyhacker stuff goes here) 
            CASE "OWNED" 
                     '(owned stuff goes here) 
            CASE ELSE
                     PRINT "Invalid Username, access denied."
                     SYSTEM
END SELECT
Not a big difference, but a little cleaner and more complete.
*****

Posted: Fri Jul 08, 2005 8:06 pm
by Rattrapmax6
Right.. I sat back and wrote a more simulated Password system, it asks for username, then the password.. and while you type the pasword it displays it as: "******"..

Very nice, and something you can play with, look over, and learn from maybe.. :wink:

Psssys.bas (Made in FreeBasic, Tested in QBasic.. Runs well in both..)

Code: Select all

'Username/Password system by Rattrapmax6(Kevin(x.t.r.GRAPHICS))
' Two test usernames: User1 and Admin
'Passwords: User1 = Enter || Admin = LetMeIn
' System is case-insensitive.. :)

CLS 'Clear screen
PRINT "Welcome!"
PRINT "Enter User:";
DO
    LOCATE 2, 12: PRINT dspl$; "   " 'Display storing varible
    press$ = INKEY$
    IF press$ <> "" THEN 'On press
        'Filter Backspace, subtract varible
        IF press$ = CHR$(8) AND LEN(dspl$) > 0 THEN
            sb = LEN(dspl$)
            Ndspl$ = MID$(dspl$, 1, (sb - 1))
            dspl$ = Ndspl$
        'Filter Enter, Exit for checking
        ELSEIF press$ = CHR$(13) THEN
            EXIT DO
        'Add up user input to varible
        ELSE
            dspl$ = dspl$ + press$
        END IF
    END IF
LOOP

SELECT CASE UCASE$(dspl$)
CASE "USER1"
    PRINT "Enter Pasword:";
    usr$ = dspl$
    dspl$ = ""
    DO
        LOCATE 3, 15: PRINT pss$; "   "' NEW, print the ** for the varible
        press$ = INKEY$
        IF press$ <> "" THEN
            IF press$ = CHR$(8) AND LEN(dspl$) > 0 THEN
                sb = LEN(dspl$)
                Ndspl$ = MID$(dspl$, 1, (sb - 1))
                Npss$ = MID$(pss$, 1, (sb - 1)) 'NEW, Subtract ***
                dspl$ = Ndspl$
                pss$ = Npss$ 'Restore the ***
            ELSEIF press$ = CHR$(13) THEN
                EXIT DO
            ELSE
               dspl$ = dspl$ + press$
               pss$ = pss$ + "*" 'NEW, calculate how many ***
            END IF
        END IF
    LOOP
    IF UCASE$(dspl$) = "ENTER" THEN 
        PRINT "Welcome to our servers, "; usr$; "!"
        PRINT "Press any key to end..."
        SLEEP
        END
    ELSE
        PRINT "Username and password to not compute!"
        PRINT "Press any key do end..."
        SLEEP
        END
    END IF
CASE "ADMIN"
    PRINT "Enter Pasword:";
    usr$ = dspl$
    dspl$ = ""
    DO
        LOCATE 3, 15: PRINT pss$; "   "
        press$ = INKEY$
        IF press$ <> "" THEN
            IF press$ = CHR$(8) AND LEN(dspl$) > 0 THEN
                sb = LEN(dspl$)
                Ndspl$ = MID$(dspl$, 1, (sb - 1))
                Npss$ = MID$(pss$, 1, (sb - 1))
                dspl$ = Ndspl$
                pss$ = Npss$
            ELSEIF press$ = CHR$(13) THEN
                EXIT DO
            ELSE
               dspl$ = dspl$ + press$
               pss$ = pss$ + "*"
            END IF
        END IF
    LOOP
    IF UCASE$(dspl$) = "LETMEIN" THEN 
        PRINT "Welcome to our servers, "; usr$; "!"
        PRINT "Press any key to end..."
        SLEEP
        END
    ELSE
        PRINT "Username and password do not compute!"
        PRINT "Press any key to end..."
        SLEEP
        END
    END IF
CASE ELSE
    PRINT "No user under that name: Try again..."
    PRINT "Press any key to end..."
    SLEEP
    END
END SELECT 

Posted: Sat Jul 09, 2005 11:51 am
by {Nathan}
To complicated for me... ahh...

Posted: Mon Jul 11, 2005 11:42 am
by Seb McClouth
Rattrapmax6, can I use your routine in qbinux, for the security-console?

grtz
Seb

Posted: Mon Jul 11, 2005 3:15 pm
by Rattrapmax6
Sure,. won't hurt my feelings, I'll be most glad it wasn't a code waisted.. :wink:

Posted: Mon Jul 11, 2005 4:32 pm
by Seb McClouth
Thx mate. I'll give ya credit...

grtz
Seb