Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- echo Content-type: text/html
- echo
- host_address=`host $REMOTE_ADDR 2>&1|grep Name|sed 's/.*: *//'`
- cat <<eof
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>IBrowser IP, Host and User Agent</title>
- </head>
- <body>
- Your browser is running at IP address: <b>$REMOTE_ADDR</b>
- <p>
- Your browser is running on hostname: <b>$host_address</b>
- </p><p>
- Your browser identifies as: <b>$HTTP_USER_AGENT</b>
- <p>
- </body>
- </html>
- eof
- #!/usr/bin/perl
- use warnings;
- use CGI qw/:all/;
- use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
- sub authenticate {
- my ($username, $password) = @_;
- chomp($username);
- chomp($password);
- $password_file = "../accounts/$username/password";
- if (!open F, "<$password_file") {
- print "Unknown username!\n";
- } else {
- if ("$password\n" eq (<F>)) {
- print "$username authenticated.\n";
- } else {
- print "Incorrect password!\n";
- }
- }
- close F;
- }
- my $is_cgi = defined($ENV{GATEWAY_INTERFACE});
- if (!$is_cgi) {
- print "username: ";
- my $username = <STDIN>;
- print "password: ";
- my $password = <STDIN>;
- &authenticate($username, $password);
- exit 0;
- }
- print header, start_html('Login');
- warningsToBrowser(1);
- $username = param('username') || '';
- $password = param('password') || '';
- if ($username && $password) {
- $username = substr $username, 0, 256;
- $username =~ s/\W//g;
- &authenticate($username, $password);
- } else {
- print start_form, "\n";
- print hidden(-name => 'password', -value => $password), "\n" if $password;
- print hidden(-name => 'username', -value => $username), "\n" if $username;
- print "Username:\n", textfield(-name => 'username'), "\n" if !$username;
- print "Password:\n", textfield(-name => 'password'), "\n" if !$password;
- print submit(-value => Login), "\n";
- print end_form, "\n";
- }
- print end_html;
- exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement