| View previous topic :: View next topic |
| Author |
Message |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun Apr 06, 2008 1:45 pm Post subject: [C#] Verification for a Program |
|
|
I made a program, and i dont want some of the things to get into the wrong hands....
I was wondering if there is a way to make a verification for my C# program where it checks there IP address and the password they enter... If the password and IP dont match, the progam exits. If it is correct, they get to go to this certain C# program.
Thank you!
_________________
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Sun Apr 06, 2008 2:02 pm Post subject: |
|
|
| Code: | namespace NKUtilities
{
using System;
using System.Net;
public class DNSUtility
{
public static int Main (string [] args)
{
String strHostName = new String ("");
if (args.Length == 0)
{
// Getting Ip address of local machine...
// First get the host name of local machine.
strHostName = DNS.GetHostName ();
Console.WriteLine ("Local Machine's Host Name: " + strHostName);
}
else
{
strHostName = args[0];
}
// Then using host name, get the IP address list..
IPHostEntry ipEntry = DNS.GetHostByName (strHostName);
IPAddress [] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
Console.WriteLine ("IP Address {0}: {1} ", i, addr[i].ToString ());
}
return 0;
}
}
} |
That will get you the IP address. Then just compare it with whatever they enter in the text box. Or how ever you are obtaining the pass.
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sun Apr 06, 2008 2:04 pm Post subject: |
|
|
this would do it in delphi:
function LocalIP:string;
var
WSA : TWSAData;
ILen : integer;
PHst : PChar;
PHEn : PHostEnt;
begin
WSAStartup( $0101, WSA );
ILen := $FF;
PHst := StrAlloc( ILen );
gethostname( PHst, ILen );
PHEn := gethostbyname( PHst );
with PHEn^ do result:=format(
'%d.%d.%d.%d',
[ord(h_addr^[ 0 ]), ord(h_addr^[ 1 ]),
ord(h_addr^[ 2 ]), ord(h_addr^[ 3 ])]
);
{Nuke the string}
StrDispose( PHst );
{Dust and Clean}
WSACleanup;
end;
Last edited by Anden100 on Sun Apr 06, 2008 2:06 pm; edited 1 time in total |
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Sun Apr 06, 2008 2:06 pm Post subject: |
|
|
| Anden100 wrote: | | in delphi, LocalIP would show you the users IP (its a read-only property, that returns the users IP adress) |
hehe, silly Anden and your delphi...xD
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sun Apr 06, 2008 2:10 pm Post subject: |
|
|
| Overload wrote: | | Anden100 wrote: | | in delphi, LocalIP would show you the users IP (its a read-only property, that returns the users IP adress) |
hehe, silly Anden and your delphi...xD |
sorry, forgot the actual procedure... forgot that i was reading it from another unit..., and btw, its only the local IP adress...
|
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun Apr 06, 2008 2:34 pm Post subject: |
|
|
Okay, well should i make a database that holds that passwords and the IP address? Because i just want the person to add the password, and then i can get the IP address on my own.
So i kind of have getting the IP address and getting the password done, now i just need a way to check to see if those two correspond with each other on a list. Ideas?
_________________
|
|
| Back to top |
|
 |
Overload Master Cheater
Reputation: 0
Joined: 08 Feb 2008 Posts: 293
|
Posted: Sun Apr 06, 2008 2:43 pm Post subject: |
|
|
| bam2550 wrote: | Okay, well should i make a database that holds that passwords and the IP address? Because i just want the person to add the password, and then i can get the IP address on my own.
So i kind of have getting the IP address and getting the password done, now i just need a way to check to see if those two correspond with each other on a list. Ideas? |
compare them? O.o
like, you can get the IP address, sent it to a textbox or a label or something, then compare it to the password they entered. Something like this?
| Code: | if (label1.Text == textBox1.Text)
{
//your code here
}
else
{
//your code here
} |
_________________
Blog
| Quote: | Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that |
|
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun Apr 06, 2008 2:49 pm Post subject: |
|
|
Thanks all I think i can take it from here.
Since i am only a beginner, i am not totally sure where or how to put these things in :p ... go figure
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Apr 06, 2008 3:39 pm Post subject: |
|
|
| Anden100 wrote: | this would do it in delphi:
function LocalIP:string;
var
WSA : TWSAData;
ILen : integer;
PHst : PChar;
PHEn : PHostEnt;
begin
WSAStartup( $0101, WSA );
ILen := $FF;
PHst := StrAlloc( ILen );
gethostname( PHst, ILen );
PHEn := gethostbyname( PHst );
with PHEn^ do result:=format(
'%d.%d.%d.%d',
[ord(h_addr^[ 0 ]), ord(h_addr^[ 1 ]),
ord(h_addr^[ 2 ]), ord(h_addr^[ 3 ])]
);
{Nuke the string}
StrDispose( PHst );
{Dust and Clean}
WSACleanup;
end; |
Credit the work of others if you are going to post their code:
http://www.geocities.com/macrotech_tr/net/web2.html
http://www.delphipraxis.net/topic2902.html
_________________
- Retired. |
|
| Back to top |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Mon Apr 07, 2008 3:55 am Post subject: |
|
|
| Wiccaan wrote: | | Anden100 wrote: | this would do it in delphi:
function LocalIP:string;
var
WSA : TWSAData;
ILen : integer;
PHst : PChar;
PHEn : PHostEnt;
begin
WSAStartup( $0101, WSA );
ILen := $FF;
PHst := StrAlloc( ILen );
gethostname( PHst, ILen );
PHEn := gethostbyname( PHst );
with PHEn^ do result:=format(
'%d.%d.%d.%d',
[ord(h_addr^[ 0 ]), ord(h_addr^[ 1 ]),
ord(h_addr^[ 2 ]), ord(h_addr^[ 3 ])]
);
{Nuke the string}
StrDispose( PHst );
{Dust and Clean}
WSACleanup;
end; |
Credit the work of others if you are going to post their code:
http://www.geocities.com/macrotech_tr/net/web2.html
http://www.delphipraxis.net/topic2902.html |
Im sorry, but i got no idea where i got the code from... (all my sources are messed up, i aint very organized...)
|
|
| Back to top |
|
 |
|