Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 132,270 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,145 people online right now. Registration is fast and FREE... Join Now!




Question on security with a VB Login form.

 
Reply to this topicStart new topic

Question on security with a VB Login form.

Smithy963
post 19 Feb, 2008 - 09:01 AM
Post #1


New D.I.C Head

*
Joined: 19 Feb, 2008
Posts: 5

Hi guys, I'm doing an assignment. The assignment involves a login form, to log in to the form behind it.

Ive already written my code;

CODE

    Sub New(ByVal AccountNo As String, ByVal Password As String, ByRef LoginTrue As Boolean)
        'Constructer - checks if AccoutNo and password are in the database. LoginTrue(ByRef) is
        'set to True when AccountNo and Passwords match.

        'Covert AccountNo from integer to a 4 character string
        AccountNo = ConvertAccountNo(AccountNo)

        'Enters a method to retrieve account details, sending a
        'date through because i dont know how to declare a date type as a const
        GetDetails(AccountNo, m_RandomDate)
        Dim er As Exception

        If AccountNo = SearchFile(0, AccountNo) And Password = m_Password Then 'Correct Details given
            LoginTrue = True
        Else 'They gave the wrong name!
            er = New Exception("The Username or Password is incorrect")
            Throw er
            LoginTrue = False
        End If
    End Sub

This is the constructer for my fileAccess class.
see, as the account number comes through, it does a SearchFile() for that account number, retrieves the data.

(including password) then stores the password as a private variable within this class.

then later in the If statement, checks it against the password the user typed in.

To my question, is this the correct and only way to authenticate a user? simply using the debug tool, I could modify the variable in run time and log myself in with any username simply by checking the password that comes through in my class.

Many thanks in advance,

~Smithy
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 19 Feb, 2008 - 08:35 PM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,923



Thanked 118 times

Dream Kudos: 8475

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


You need to remember that unless the user decompiles your application they wont have access to the code like you do. There are many ways to authenticate the user, you can not ask for the password until you need it, then when they enter it re-search your file for the information then.

I'm not sure I would do all that in the Constructor of your class though, I personally would use an empty Constructor (more personal preference I'm sure), then have a method that does the authentication. You need to remember, doing all that in the constructor causes it to perform the login as soon as the class is instantiated, thus keeping that data in memory probably longer than you would want.

I personally do not see any security issues "out of the norm" in the code you've posted, but since it does involve account numbers & passwords I might think about doing some encryption on the data before it is stored in memory, at least thats the way I would go about it.

Also, this is VB.Net so Im moving this to the VB.Net forum smile.gif
User is offlineProfile CardPM

Go to the top of the page

Smithy963
post 20 Feb, 2008 - 02:00 PM
Post #3


New D.I.C Head

*
Joined: 19 Feb, 2008
Posts: 5

Sorry about the wrong forum thing. I misinterpreted the forum names.

Thank you for answering that, I wanted to make sure I wouldnt lose marks on security. and my module coordinator is less than accessable.

Thanks again,

~Smithy
User is offlineProfile CardPM

Go to the top of the page

RodgerB
post 20 Feb, 2008 - 07:24 PM
Post #4


D.I.C Lover

Group Icon
Joined: 21 Sep, 2007
Posts: 2,126



Thanked 15 times

Dream Kudos: 2200

Expert In: Dot Net Technologies

My Contributions


If you need any additional information about preventing dissassebly, I created a blog entry about the subject, it can be viewed here (Dotfuscator - An awesome solution to disassemblers).

Hope that helps. smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 12:22AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month