head 1.6; access; symbols; locks; strict; comment @# @; 1.6 date 2007.02.04.20.25.10; author syzdek; state Exp; branches; next 1.5; 1.5 date 2007.02.04.17.19.24; author syzdek; state Exp; branches; next 1.4; 1.4 date 2007.02.04.16.43.49; author syzdek; state Exp; branches; next 1.3; 1.3 date 2007.02.04.16.43.12; author syzdek; state Exp; branches; next 1.2; 1.2 date 2007.02.04.16.42.47; author syzdek; state Exp; branches; next 1.1; 1.1 date 2007.02.04.16.40.35; author syzdek; state Exp; branches; next ; desc @@ 1.6 log @*** empty log message *** @ text @#!/usr/local/bin/perl # # $Id: ldap.cgi,v 1.5 2007/02/04 17:19:24 syzdek Exp syzdek $ # # CGI System Tools # Copyright (C) 2007 David M. Syzdek # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # advanced-fs.cgi - CGI shell script for exploring a system # # +-=-=-=-=-=-+ # | | # | Headers | # | | # +-=-=-=-=-=-+ use 5.008; use Net::LDAP; use strict; our $PROGRAM_NAME = 'ldap.cgi'; our $VERSION = '0.01'; our $DESCRIPTION = 'simple LDAP browser'; our $AUTHOR = 'David Syzdek "syzdek@@gmail.com"'; # +-=-=-=-=-=-=-=+ # | | # | Prototypes | # | | # +-=-=-=-=-=-=-=+ sub form_settings(%); # displays config settings sub form_parse($); # parses form data sub main(@@); # main statement # +-=-=-=-=-=-=-+ # | | # | Functions | # | | # +-=-=-=-=-=-=-+ # parses form data sub form_parse($) { # grabs passed args my $query_string = shift; # declares local vars my $buff; my $pair; my $name; my $value; my @@pairs; my %data; # parses linked data if ($ENV{'QUERY_STRING'}) { $buff = $ENV{'QUERY_STRING'}; @@pairs = split(/&/, $buff); foreach $pair (@@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if ($value =~ /^([\.\w]+)$/) { $data{$name} = $1; }; }; }; # clears fields $data{'proto'} = ''; $data{'host'} = ''; $data{'port'} = ''; # detaints data if ($data{'ldapurl'}) { #if ($data{'ldapurl'} =~ /^([\w]+):\/\/([-\w\.]*)(:[\d]+){0,1}\//) #([-\w\.,= ]*)?([-\w,]*)?([\w]+)/) #{ if ($data{'ldapurl'} =~ /^([\w]+):\/\//) { $data{'proto'} = $1; $data{'host'} = $2; $data{'port'} = $3; $data{'basedn'} = $4; $data{'attrs'} = $4; $data{'scope'} = $5; }; } else { $data{'ldapurl'} = 'ldap://localhost/ou=People,o=foo,o=org?uid,cn,gn,sn?one?(uid=jdoe)?'; $data{'proto'} = 'ldap'; $data{'host'} = 'localhost'; $data{'port'} = '389'; $data{'basedn'} = 'ou=People,o=foo,o=org'; $data{'attrs'} = 'uid,gn,sn,cn'; $data{'scope'} = 'one'; }; # ends function return(%data); }; # displays config settings sub form_settings(%) { # grabs passed args my %data = @@_; # declares local vars # prints form printf("
\n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n", $data{'ldapurl'}); printf(" \n"); printf("
LDAP URL:  
\n"); printf("
\n"); printf("
\n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf("
\n"); printf("
\n");
printf("protocol: %s\n", $data{'proto'});
printf("host: %s\n", $data{'host'});
printf("port: %s\n", $data{'port'});
printf("basedn: %s\n", $data{'basedn'});
printf("attrs: %s\n", $data{'attrs'});
printf("scope: %s\n", $data{'scope'});
printf("             
\n"); printf("
\n"); printf("
\n"); # ends function return(0); }; # +-=-=-=-=-=-=-=-=-+ # | | # | Main Section | # | | # +-=-=-=-=-=-=-=-=-+ sub main(@@) { # grabs passed args my @@argv = @@_; # declares local vars my %data; # display headers printf("Content-type: text/html\n\n"); # parses settings %data = form_parse($ENV{'QUERY_STRING'}); # prints settings form printf("
\n"); printf("
\n"); # ends function return(0); }; exit(main(@@ARGV)); # end of script @ 1.5 log @*** empty log message *** @ text @d3 1 a3 1 # $Id: ldap.cgi,v 1.4 2007/02/04 16:43:49 syzdek Exp syzdek $ d88 5 d94 1 a94 1 if ($data{'host'} =~ /^([-\w\.]+)$/) d96 11 a106 7 $data{'host'} = $1; } else { $data{'host'} = ''; }; if ($data{'port'} =~ /^([\d]+)$/) { $data{'port'} = $1; d108 3 d112 3 d118 1 a118 1 return(0); d134 2 a135 29 printf(" LDAP host:  \n"); printf(" \n", $data{'host'}); printf("     \n"); printf(" LDAP port:  \n"); printf(" \n", $data{'port'}); printf(" \n"); printf(" \n"); printf(" LDAP Bind DN:  \n"); printf(" \n", $data{'binddn'}); printf("     \n"); printf(" LDAP Bind Password:  \n"); printf(" \n", $data{'bindpw'}); printf(" \n"); printf(" \n"); printf(" LDAP Base DN:  \n"); printf(" \n", $data{'binddn'}); printf(" \n"); printf(" \n"); printf(" LDAP Filter:  \n"); printf(" \n", $data{'bindpw'}); printf("     \n"); printf(" LDAP Scope:  \n"); printf(" \n"); printf(" \n"); printf(" \n"); d140 17 d180 1 d182 2 @ 1.4 log @*** empty log message *** @ text @d3 1 a3 1 # $Id: ldap.cgi,v 1.3 2007/02/04 16:43:12 syzdek Exp syzdek $ d8 165 d174 2 a175 1 use Net::LDAP;:wq d177 4 d182 1 a182 1 print("Content-type: text/html\n\nhello"); @ 1.3 log @*** empty log message *** @ text @d3 1 a3 1 # $Id: ldap.cgi,v 1.2 2007/02/04 16:42:47 syzdek Exp syzdek $ d6 2 a7 2 # C # @ 1.2 log @ls @ text @d3 1 a3 1 # $Id: $ d5 2 @ 1.1 log @Initial revision @ text @d2 4 @