473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Admin login security code

2
Hi there,

I am Gerard, 1st year student of Perl at the university.
I came across some lines of code from a script done by an ex student that left uni and did not left any explanation of the code.

The only thing I know is that the script reads an external file that contains 2 lines of code.
The 1st and 2nd lines on this file are:


BEGIN!! Addr:* Name:John
-
4DZWJMZMX44ZiaZ4 END!!

I think it compares both lines on the script and return true if equal.

Could some one please explain me better, and how can I create the second line? is it in HExadecimal or what?

Below is the code on the script:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $const{'code_validate'} = sub {
  3.     my $p_decode = sub {
  4.         local $_;
  5.         my $code = defined($_[0]) ? $_[0] : '';
  6.         my %map = ();
  7.         my $i = 0;
  8.         foreach (48..57,65..90,97..122) {
  9.             $map{chr($_)} = $i % 16;
  10.             $i++;
  11.         }
  12.         $code =~ s!\s|\r|\n|\015|\012!!sg;
  13.         my $text = '';
  14.         my $frag = '';
  15.         $i = 0;
  16.         while ($frag = substr($code, $i, 2)) {
  17.             $i += 2;
  18.             my $chn = 16 * $map{substr($frag,0,1)};
  19.             $chn += $map{substr($frag,1,1)};
  20.             my $ch = chr($chn);
  21.             $text .= $ch;
  22.         }
  23.         $text = unpack('u',$text);
  24.         return $text;
  25.     };
  26.     local $_;
  27.     my $code = defined($_[0]) ? $_[0] : '';
  28.     return 0 unless ($code);
  29.     my $is_valid = 0;
  30.     $code =~ s!BEGIN!!sg;
  31.     $code =~ s!END!!sg;
  32.     if ($code =~ m!^\s*(.*)\s*\-\s*(.*?)\s*$!s) {
  33.         my ($pub, $pri) = ($1,$2);
  34.         $pri = &$p_decode($pri);
  35.         $pub =~ s!(\s|\r|\n)!!sg;
  36.         $pri =~ s!(\s|\r|\n)!!sg;
  37.         if ($pub eq $pri) {
  38.             $is_valid = 1;
  39.         }
  40.     }
  41.     return $is_valid;
  42. };
  43.  

Thanks for all your help
Gerard
Oct 18 '07 #1
3 1327
KevinADC
4,059 Expert 2GB
same stuff you posted on perlguru where I said that the code you posted seemed to have nothing to do with the question you asked.

There is no need to use that code for anything I can think of.
Oct 18 '07 #2
gsruk
2
Hi Kevin

The script I use reads the text file and compares both lines(like the ones above the code), than if those lines are equal the script assign administrator privileges or secretary priv.

I just would like to know how can I create a script to create the what I think is the hexadecimal code from the second line equal to the written text from the first line.

In that way I can create more privileges to other students according to their Year of studies.

Regards Gerard
Oct 19 '07 #3
KevinADC
4,059 Expert 2GB
Sorry, the code is quite confusing. Too bad the author didn't include some comments.
Oct 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Google Mike | last post by:
You know, while working on my moonlight corporation's LAMP project at home this weekend, I couldn't help but wonder if people writing similar projects are solving similar problems with having to...
5
by: Max | last post by:
I have a collection of system admin scripts (on Win 2k) that I would like to automate the execution of. However, some of them require the use of logins with admin rights, and would therefore prefer...
0
by: jamesa | last post by:
I am a beginner and trying my first C# application. Any reason why I am getting the message Login failed for user 'admin' I have thoroughly checked the security settings in the sql server. Find...
0
by: Astra | last post by:
Hi All I've been creating a number of admin systems now for my classic ASP sites and although they seem to keep the wolves from the door, I just wanted to ask if you have any additional security...
1
by: Laphan | last post by:
Hi All I've created an admin side for my ASP site and I use session vars to provide page security. Just as a bit of advice, I want to know if I should expire each admin page so that others...
3
by: Dalibor | last post by:
How to protect administration pages from entering. I put login form on my start page (index.php), and if user put correct data, script redirect him on page admin/admin.php. That works fine! But if...
1
by: 2005.ravikumar | last post by:
Hello sir How to create Oscommerce admin login? Please give me sample code.
0
by: Big Charles | last post by:
Hello, Programming in VS2003-ASP.NET 1.1, I have this problem: Using DirectoryEntry and without any admin user, how can I check if a domain account, that try to login, has expired? Scenario: User...
12
by: tvnaidu | last post by:
I have Two kinds of web pagess, one is for control page for only admin login, another one is to view status for user login. initially both html files can view with 192.168.0.10/control.htm and other...
9
by: adweaver | last post by:
Hello All, I'm new to the world of php. I've just had a site designed for me by a company, and I'm now trying to manage and grow it, so it will suit my needs. The site was built in a folder...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.