Dynamic IP Locking: A Poor Mans Multi-factor Authentication - ny-dev | Design & Development Forums
Go Back   ny-dev | Design & Development Forums > Knowledge Bank > Tutorials

Notices


Dynamic IP Locking: A Poor Mans Multi-factor Authentication

Tutorials


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 12-17-2006, 04:57 PM
Taz's Avatar
Taz Taz is offline
Taz has no status.
Junior Member
Newb
 
Join Date: Dec 2006
Posts: 10
Taz will become famous soon enough
Lightbulb Dynamic IP Locking: A Poor Mans Multi-factor Authentication

Dynamic IP locking: A poor mans multi-factor Authentication

As some people know financial institutions have to implement Multi-factor authentication. FIL-103-2005

"What is Multi-Factor?
The authentication factors for humans are generally classified into three cases:

* Something the user is (e.g., fingerprint or retinal pattern, DNA sequence (there are assorted definitions of what is

sufficient), voice pattern (again several definitions), signature recognition, unique bio-electric signals produced by the

living body, or other biometric identifier)
* Something the user has (e.g., ID card, security token, software token or cell phone)
* Something the user knows (e.g., a password, a pass phrase or a personal identification number (PIN))"-wikipedia

So what if you want to implement multi-factor authentication for your simple website and not have to pay for commercial solutions? One that is as easy to use as CAPTCHA that recently sites have implemented.

I present Dynamic IP locking. Which is simply the concept of only allowing login if the user's ip (something they have) matches the one on record.

In the security world there has always been the practice to deny hosts unless they were of a certain IP. However, the problem is that now days on the internet hosts need to access systems and their ips are not fixed. The idea is to put into place a logon system that adds a level of security but by no means is a cure-all. IPs can still be forged just like we use MAC to deny hosts even though they can be spoofed. Your login protocol still checks for a user id and a password while looking if the ip that they signed up with matches the one signing on. So a normal fixed IP person would use their IP. However, a dynamic ip user would enter Whatever.dyndns.com or whaetver.com. The server then would look up the ip of this sub domain and see if it matches the host. The host would be running with in the background a client (https://www.dyndns.com/support/clients/) that
sends their dynamic ip to the trusted third party DNS providers like no-ip.com and etc. Also with the release of Windows Vista all users will be able to be given a ipv6 address with its own sub domain to use from Microsoft called the "Windows Internet Computer Name"-- a unique domain name. This can be treated as a trusted third party. The attackers thus could still forge the address; however he would have to know the sub domain to look up to spoof to the server.

This Dynamic IP locking would not be the only validation the user would still have to match USER ID, PASSWORD, IP checking.

However to the user this would not be an extra step once a client was running in the background reporting the ip to a trusted third party.

One of the main benefits is that current brute forcing software would not have this factor built in for their password cracking attempts. Some might think this would cause problems if a user went to a library and didn't have that Ip allowed to log in. You still can login to your third party and update your Ip to the current place of login. Of course if login in on an untrusted machine you will be exposing yourself. If a third party Dynamic DNS provider was DOSed logins would fail with multiple systems.

At its simplest form the php code would look like this. Of course in actual implantation you your software would be more complex. A non production example of a login with Dynamic Ip locking is at the bottom.
Code:
 
<?php

$ip = gethostbyname('zat.isa-geek.com');


If ($ip ==$_SERVER["REMOTE_ADDR"]){
echo "success";
}else {
echo "fail";
}


?>
It is also best to have this as an option to enable instead of being forced just like AOL users were given the option to use SecureID but not required.


People could just hack into the site you use for your dynamic dns, but then they would have to know which one you use.

If wanting to get into say your message board account they would have to know where your dynamic dns is and crack into an additional pair on login password combination.


The following is example code only and SHOULD NOT be used in production.
Code:
 
<form method="post" action="http://whatever.com/iplogon.php">


<input name="user" type="text">
<input name="pw" type="password">
<input type=submit value="Submit" >

</form>
This is a simple form to use to submit to our php script.


Now we create the mysql entries we will pull. Meow: is user id and password is password. Moo also has the password “password. Zat.isa-ageek.com is the location you want script to look up ip on the hostname.

Code:
#
# Table structure for table `users90`
#

CREATE TABLE `users90` (
 `username` varchar(99) NOT NULL default '',
 `password` varchar(99) NOT NULL default '',
 `ip` varchar(255) NOT NULL default ''
) TYPE=MyISAM;

#
# Dumping data for table `users90`
#

INSERT INTO `users90` VALUES ('meow', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', 'zat.isa-geek.com');
INSERT INTO `users90` VALUES ('moo', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', '127.0.0.1');
   #


<?php
if ($REQUEST_METHOD=="POST") {
check();
}else{
}
function check()
{
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
array_pop($_POST);
if ( get_magic_quotes_gpc() ) {
  $_POST= array_map('stripslashes', $_POST);
stripslashes($_REQUEST['pw']);
}
$username= mysql_real_escape_string(trim($_POST['user']));
$password= mysql_real_escape_string(trim($_REQUEST['pw']));
// I used request because when I was testing the post was coming up empty
$sha1pwd= sha1($password);

$sql= sprintf("SELECT COUNT(*) AS login_match FROM `users90` WHERE
`username` = '%s' AND `password`= '%s'", $username, $sha1pwd);
$res= mysql_query($sql) or die(mysql_error());
$login_match= mysql_result($res, 0, 'login_match');
if ( $login_match == 1 ) {
$result = mysql_query ("SELECT ip FROM users90
WHERE username = '$username'
");
$row= mysql_fetch_array($result);
$iphmm = $row[0];
echo $iphmm . " This is ip from mysql <br>";
$ip = gethostbyname($iphmm);
echo "<br> This is ip from gethost " . $ip;
If ($ip ==$_SERVER["REMOTE_ADDR"]){
echo "You entered the magical place";
}else {
echo "failed";
}
} else {
 echo "failed";
}
}
?>

Last edited by danielmichel; 12-27-2006 at 12:36 PM. Reason: Reverted back to original
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #2 (permalink)  
Old 12-18-2006, 06:40 PM
johnboulder's Avatar
johnboulder has no status.
Administrator
Aficionado
 
Join Date: Mar 2003
Posts: 103
johnboulder is just really nicejohnboulder is just really nice
Send a message via MSN to johnboulder Send a message via Yahoo to johnboulder Send a message via Skype™ to johnboulder
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

Brilliant note here taz.

I tend to stay away from IP or host locking, as with a lot of cases - the users' IP address is not even the same accross requests depending on their ISP.

You could also get multiple requests from the same IP being different users on the same network sharing infrastructure the ISP has.

However, a great post nontheless.

I've moved this post to tutorials, as it's more suited to this particular category.

Regards
__________________
Sean Johnstone
Johnboulder Resources
Tutorials:
CSS: Tabs - Tutorial on creating navigation tabs using CSS
PHP: Custom User Authentication - Tutorial on PHP custom user authentication
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #3 (permalink)  
Old 12-18-2006, 09:32 PM
Taz's Avatar
Taz Taz is offline
Taz has no status.
Junior Member
Newb
 
Join Date: Dec 2006
Posts: 10
Taz will become famous soon enough
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

Quote:
Originally Posted by johnboulder View Post
Brilliant note here taz.

I tend to stay away from IP or host locking, as with a lot of cases - the users' IP address is not even the same accross requests depending on their ISP.

You could also get multiple requests from the same IP being different users on the same network sharing infrastructure the ISP has.

However, a great post nontheless.

I've moved this post to tutorials, as it's more suited to this particular category.

Regards
I would like to point out while the example code is in php there is nothing stoping this concept from being implemented in c++, perl, in anything!

Maybe you want to edit the code for your VNC.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #4 (permalink)  
Old 12-18-2006, 09:36 PM
Taz's Avatar
Taz Taz is offline
Taz has no status.
Junior Member
Newb
 
Join Date: Dec 2006
Posts: 10
Taz will become famous soon enough
Default Re: PHP: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

also now the link that was posted on http://www.digg.com/programming/Dyna...uthentication/
http://www.ny-dev.com/forums/website...tion-1253.html
doesn't work since you moved it and it isn't symlinked
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #5 (permalink)  
Old 12-19-2006, 03:42 PM
johnboulder's Avatar
johnboulder has no status.
Administrator
Aficionado
 
Join Date: Mar 2003
Posts: 103
johnboulder is just really nicejohnboulder is just really nice
Send a message via MSN to johnboulder Send a message via Yahoo to johnboulder Send a message via Skype™ to johnboulder
Default Re: PHP: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

I can move it back if you'd like

The only reason I moved it here was I felt it was more of a tutorial concept.

As an aside, it may be better to reference the post by the thread number, as that isn't changed by the topic being moved. (In this case, http://www.ny-dev.com/forums/showthread.php?t=1263)

I humbly apologise if I've messed you about

Let me know
__________________
Sean Johnstone
Johnboulder Resources
Tutorials:
CSS: Tabs - Tutorial on creating navigation tabs using CSS
PHP: Custom User Authentication - Tutorial on PHP custom user authentication
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #6 (permalink)  
Old 12-19-2006, 03:59 PM
danielmichel's Avatar
danielmichel is working on 3 websites
Administrator
Disciple
 
Join Date: Feb 2003
Age: 28
Posts: 884
Images: 15
danielmichel is a glorious beacon of lightdanielmichel is a glorious beacon of lightdanielmichel is a glorious beacon of light
Send a message via AIM to danielmichel Send a message via MSN to danielmichel Send a message via Yahoo to danielmichel Send a message via Skype™ to danielmichel
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

I'm not sure the link would even be the same if it were moved back.
Good call; no way you could have known about the whole digg thing.

He did however get 9 diggs in a very short time before the digg was retired.
I will re-submit the digg with this URL in a couple days if possible.
__________________
3D Resources - A list of resources for 3D Developers
After Effects Resources - A list of resources for design in motion with Adobe After Effects
Freelance Resources - Usefully resources for freelance web developers
Search Engine Optimization - Tips and discussion about search engine optimization
Tutorials - Tutorials submitted by ny-dev members
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #7 (permalink)  
Old 12-19-2006, 08:16 PM
danielmichel's Avatar
danielmichel is working on 3 websites
Administrator
Disciple
 
Join Date: Feb 2003
Age: 28
Posts: 884
Images: 15
danielmichel is a glorious beacon of lightdanielmichel is a glorious beacon of lightdanielmichel is a glorious beacon of light
Send a message via AIM to danielmichel Send a message via MSN to danielmichel Send a message via Yahoo to danielmichel Send a message via Skype™ to danielmichel
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

The new digg - Dynamic IP Locking: A Poor Mans Multi-factor Authentication
__________________
3D Resources - A list of resources for 3D Developers
After Effects Resources - A list of resources for design in motion with Adobe After Effects
Freelance Resources - Usefully resources for freelance web developers
Search Engine Optimization - Tips and discussion about search engine optimization
Tutorials - Tutorials submitted by ny-dev members
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #8 (permalink)  
Old 12-21-2006, 09:13 AM
iughk's Avatar
iughk has no status.
Moderator
Aficionado
 
Join Date: Feb 2006
Posts: 114
iughk is on a distinguished road
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

Got the #1 Google spot for Dynamic IP Locking search.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #9 (permalink)  
Old 12-21-2006, 10:01 AM
danielmichel's Avatar
danielmichel is working on 3 websites
Administrator
Disciple
 
Join Date: Feb 2003
Age: 28
Posts: 884
Images: 15
danielmichel is a glorious beacon of lightdanielmichel is a glorious beacon of lightdanielmichel is a glorious beacon of light
Send a message via AIM to danielmichel Send a message via MSN to danielmichel Send a message via Yahoo to danielmichel Send a message via Skype™ to danielmichel
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

If only you could combine or edit diggs as the digg author.

This one has 4 diggs - digg - Dynamic IP Locking: A Poor Mans Multi-factor Authentication
This one has 11 diggs - digg - Dynamic IP locking: A Poor Mans Multi-factor Authentication
(broken link)
and the one you linked to has 2 diggs.

I'm going to contact digg about it when i get a chance.
__________________
3D Resources - A list of resources for 3D Developers
After Effects Resources - A list of resources for design in motion with Adobe After Effects
Freelance Resources - Usefully resources for freelance web developers
Search Engine Optimization - Tips and discussion about search engine optimization
Tutorials - Tutorials submitted by ny-dev members
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #10 (permalink)  
Old 01-02-2007, 11:37 PM
SHP's Avatar
SHP SHP is offline
SHP has no status.
Sexual Harassment Panda
Aficionado
 
Join Date: Dec 2004
Posts: 139
SHP will become famous soon enough
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

Another one on Hotscripts
Dynamic IP Locking
__________________
Member Gallery - New York Web Development member gallery
Member Showcase - Community members show off your work
Design Contests - Members compete for bragging rights or prizes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
  #11 (permalink)  
Old 01-12-2007, 09:52 PM
Contention's Avatar
Contention has no status.
Moderator
Aficionado
 
Join Date: Mar 2003
Age: 29
Posts: 160
Contention is on a distinguished road
Default Re: Dynamic IP Locking: A Poor Mans Multi-factor Authentication

This is curious
Detail: Dynamic IP Locking: A Poor Mans Multi-factor Authentication
__________________
Misc Tutorials:
Interval Manager - Tutorial on Flash Interval Managers
Ajax Tutorial - Simple Ajax tutorial for beginners
CSS Tabs - Tutorial on creating CSS tabs
Posting Guide - Some things you should read before posting
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: Custom user authentication johnboulder Tutorials 6 01-03-2007 08:18 PM
Need help on embedded video dynamic size Leo Website Programming 1 10-16-2006 08:25 AM
Dynamic web design. Jacer17 Website Programming 14 05-12-2006 06:45 PM
Poor PC danielmichel Hardware & Software 2 03-24-2006 09:00 PM


All times are GMT -4. The time now is 07:56 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
347media

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24