Solved

Password Protection/IP Addresses

Posted on 1998-11-20
10
179 Views
Last Modified: 2013-12-25
I run a web site which has sections I do not want people to access unless they have proper authorization (are members of the organization).  I would like to know the script to create a prompt for a username and password and I would also like to know how to incorporate the script (like <SCRIPT> tags or whatever).  The second question I have is about IP addresses.  I would like to know how to obtain someone's IP address (so my scripts can assign it a variable) as well as how to incorporate it.  Thanks for your help and if you can answer both questions without leaving me hassles, you will get your well deserved 700 points.
0
Comment
Question by:appletman
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 1

Expert Comment

by:flivauda
ID: 1829701
Here is a perl solution, you will need to be able to run perl scripts

Save the code in a file called adduser
accesspart:
-----
#!/usr/bin/perl

$htgroup = "/u/mypath/.htgroup";
$htpasswd = "/u/mypath/.htpasswd";

if (@ARGV<1)
{ print "\nusage: adduser        [username]\n\n"; exit;
}

print "Add user: $ARGV[0]\nAre you sure? ";

if (<STDIN>!~/^y|Y/)
{ print "Add user aborted.\n\n"; exit;
}

print "Adding user to group file.\n";
system "cp $htgroup $htgroup.old ; sed 's/\$/ $ARGV[0]/g' $htgroup.old > $htgroup";
exec "htpasswd $htpasswd $ARGV[0]";

run that on the command line
% adduser timmy

for the ip addr use the environemnt variable
REMOTE_ADDR

example:
$ip = $ENV{'REMOTE_ADDR'}


0
 
LVL 1

Expert Comment

by:flivauda
ID: 1829702
The % adduer username

code is run locally on the machine and then it will prompt the user to login with the login boxes like you see on this site.  

Let me know if you need anything else
0
 

Author Comment

by:appletman
ID: 1829703
sorry im completely new to cgi-i need a complete walk through-for 700 points id like everything explained thoroughly and how to use the remote_addr
0
 

Author Comment

by:appletman
ID: 1829704
I was completely new to Common Gateway Interface and had no idea as to how to incorporate that script etc.
0
 
LVL 1

Expert Comment

by:dave1968
ID: 1829705
Need some info such as server platform, web server and versions to be able to determine what type of CGI you will be capable of.

You will not use <script> tags in your document if you are trying to do CGI.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:bobline
ID: 1829706
Do you have your cgi-bin directory?
0
 
LVL 1

Expert Comment

by:flivauda
ID: 1829707
We need to know if you have server side access.  Which means can you telnet in and modify your scripts?  Or do you have to use canned solutions provided by someone else that wont really do what you need?  Also do you know before time all the people you want to give username/password access to? What lanuage are you using for your scripts?

So answer these questions for me and we can get you taken care of:
1) Do you have access to run cgi scripts in the first place, (ie can you telnet in and modify scripts)
2) Do you know where your cgi-bin directory is?
3) Do you know ahead of time people you want to give user/password access to?
4) Are you using perl for your scripts?  If not can you?

As for the second part of your question about IP address if you are using perl, all you have to do to assign the person's ip address to a variable is this:
$ip = $ENV{'REMOTE_ADDR'}

where $is is the variable name and $ENV tell it to read from the environment the remote_addr which will be their ip adress

0
 
LVL 8

Expert Comment

by:shlomoy
ID: 1829708
If your server is using apache you can use htaccess to restrict some files or some directories from some users (you decide which ones and which files) from accessing your data.

I can suggest a link to a web-page with all the necessary data:
http://www.apacheweek.com/features/userauth

0
 

Accepted Solution

by:
genuinegenius earned 700 total points
ID: 1829709
1. This would depend on whether you have access to the server. If so you can use CGI scripts and properly protect your site. If this is the case then good luck but I know no more. However, if you do not have access to the server you can write or find a java applet that requires a password before it takes you to a page. Once past the lock there is nothing to stop the user bookmarking the page and entering again, but as long as they don't know the name of the page the lock will take them to they will need to pass the lock at least once. Such an applet can be simply made using a program called Raida Lock, which can be downloaded free at

www.tucows.com

in the java section.

2. To find the IP address of a computer you must know the domain name e.g www.microsoft.com

this is difficult with users of ISP's as their domain names are hard to find. If you do find the DN then you can PING this to reveal the IP.

Alternatively your friend could run an IP poster. These programs 'post' your IP address to a webpage of your choice. Many can be found at

www.tucows.com

As well.

Good Luck (especialy if you have read all of this)
0
 

Expert Comment

by:genuinegenius
ID: 1829710
Cheers!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now