Question

For this task you will create a reverse SHA lookup website. A user will be able...

For this task you will create a reverse SHA lookup website. A user will be able to provide a SHA hash value, and you should present the string that created the SHA value. You are given 3 input files, sha1_list.txt, sha224_list.txt, and sha256_list.txt. Each file has the given word followed by its hash value, separated by a colon. Each file uses the algorithm specified in the file name.
2) A user should be able to access an html file called sha.html, and enter a sha hash value that will be submitted to a file called sha.php.
3) The sha.php file should load the information from the 3 text files into a data structure of your choice. (note that the hash values are unique among all 3 files, so you can use the hash value as a key in an associative array). Next, the php script should search for the string that generated the given hash value.
4) Your php script should generate a dynamic html file that displays the hash value that was searched for, along with either the string that generated the hash value, or a message indicating that the value could not be found in the server’s records.
5) You should include a button and an input form that allows the user to search for another string and triggers the same php script again
0 0
Add a comment Improve this question Transcribed image text
Answer #1

sha.html

OUTPUT of sha.html

___________________________________________________________________________________________________

###################################################################################################

sha.php

Explanation is mentioned in comments ;

OUTPUT of sha.php

_______________________________________________________________________________________________

##############################################################################################

Text files ::

RAW CODE ::::

___________________________________________ sha.html _____________________________________________

<!DOCTYPE html>
<html>
<head>
   <title>
       SHA-crack  
   </title>
   <style type="text/css">
       body {
           font-size: 20px;
       }
       fieldset {
           width: 600px;
       }
       input{
           width: 500px;
       }
   </style>
</head>
<body>
   <center>
       <form method="POST" action="sha.php">
           <fieldset>
               <legend>SHA Hashes</legend>
               <br>
               <input type="text" name="hash" placeholder="Enter your hash">
               <br><br>
               <button id="calc">crack</button>
           </fieldset>
       </form>
   </center>
</body>
</html>

####################################################################################################

___________________________________________________ sha.php ________________________________________

<?php
if ( isset($_POST["hash"]) ){
   $hash = $_POST["hash"];
   $type = "none";
   // This preg_match also maintains security for our site
   if (preg_match("/\b([a-f0-9]{40})\b/", $hash)){
       $type = "sha1";
   }elseif (preg_match("/\b([a-f0-9]{56})\b/", $hash)) {
       $type = "sha224";
   }elseif (preg_match("/\b([a-f0-9]{64})\b/", $hash)) {
       $type = "sha256";
   } // First we find out the hash type by the length of that hash
   if ($type !== "none"){ // So that we can get rid of searching all 3 files
       $fn = fopen($type."_list.txt","r"); // we can particularly search only 1 file
       $Arr = array(); // We have used the Array data structues to load the file data
       while(! feof($fn)) { // While loop for reading lines one by one
           $result = fgets($fn); // grabbing the line
           $line = substr($result, 0, strlen($result)-1); //removing '\n'
           if(strlen($line) === 0){ // End of file
               break; // terminating
           }
           $str_arr = explode (":", $line); // split by ':'
           $Arr[$str_arr[1]] = $str_arr[0]; // appending to array ; Arr[hash] = value
       }fclose($fn); // after completion of reading data ; closing the file
       if (array_key_exists($hash, $Arr)){ // If the key means hash exits
           $value = $Arr[$hash]; // Grabbing the value which results in hash
           $msg = $type."('".$value."') => ".$hash; // Making the msg var to output
           // both hash and value ; as sha...('value') => hash | in that way
       }
   }else{
       $msg = "Enter a valid hash"; // If pregmatch failed ; means wrong hash
   }
}else{
   $msg = "Enter a hash value"; // If hash value not sent by vai post
}
?>
<!DOCTYPE html>
<html>
<head>
   <title>Hash</title>
</head>
<body>
   <center>
       <!-- At last printing the msg which we want to output through html -->
       <p><b><?php echo $msg;?></b></p>
       <!-- To crack another hash -->
       <a href="sha.html">To Crack another hash</a>
   </center>
</body>
</html>

################################################################################################

________________________________________ sha1_list.txt _____________________________________________

hello:aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
world:7c211433f02071597741e6ff5a8ea34789abbf43
asdf:3da541559918a808c2402bba5012f6c60b27661c
asdf@123:1b28fb759ac3a1212038d60e8cffbada07093f5d

################################################################################################

_______________________________________ sha224_list.txt ___________________________________________

hello:d222253ccf19d787ecaa84c7dbfe5d3ee0311d19f085ce1d6a6d78fe
world:06d2dbdb71973e31e4f1df3d7001fa7de268aa72fcb1f6f9ea37e0e5
asdf:cda1d665441ef8120c3d3e82610e74ab0d3b043763784676654d8ef1
asdf@123:7c227e7f624e83b2c6463a8894f30229a1b3d411a5c171bc16c27f92

###############################################################################################

_______________________________________ sha256_list.txt __________________________________________

hello:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
world:486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7
asdf:f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b
asdf@123:2ff38c248d716dae4131fc40cb2097f9b3de7227792bdb33e78dedc1e11ffc1c

##############################################################################################

Add a comment
Know the answer?
Add Answer to:
For this task you will create a reverse SHA lookup website. A user will be able...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PHP you need to create a form to allow the user to enter their name, email,...

    PHP you need to create a form to allow the user to enter their name, email, and address information. That information will be sent to a PHP script that will process and display that information. Your assignment should have two pages. The first page is straight html (user_input.html) that has a form with the appropriate form elements to collect the user input. The form should then be submitted using the POST method to a php script (display_user_info.php) that will process...

  • Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file,...

    Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file, "insert-user-form.php", with a form that has the following fields: - First Name (text) - Last Name (text) - Email (text) - Password (text) - Submit button Create another PHP file, "insert-exercise-form.php" with a form that has the following fields: - Exercise Name (text) - Description (text) - Demonstration Image (file) - Submit button Create another PHP file, "login-user-form.php" with a form that has the...

  • (10 points) Image Gallery Search: The following HTML snippet is the skeleton of a . simple image gallery. The gallery s...

    (10 points) Image Gallery Search: The following HTML snippet is the skeleton of a . simple image gallery. The gallery stores all of its images in a directory called im ages. Write a PHP sear ch page for an program called search php to implement the searching feature. An image is onsidered a mat ch" to the search string if the name of the image contains the entirety of the search string. For example, query of "tea" mightmatch 'teajpg" or...

  • You need to implement a web application that is split in three parts, namely, Webpage, PHP and My...

    You need to implement a web application that is split in three parts, namely, Webpage, PHP and MySQL. Each of them will be used accordingly to solve a simple problem described below. Remember to implement the logic in the most secure way of your knowledge. PHP Implement a PHP function that reads in input a string from the user and store it in a table (e.g., in a field called "Content Name"). The function should be able to read the...

  • In this problem, you will create a selectable “To Do” List. To add a task to...

    In this problem, you will create a selectable “To Do” List. To add a task to this list, the user clicks the Add Task button and enters a description of the task. To delete a task from the list, the user selects the task and then clicks the Delete Task button. Open the HTML and JavaScript files provided as start-up files (index.html from within todo_list_Q.zip file). Then, review the HTML in this file. Note, within the div element, there is...

  • PHP - Use of classes This is a further development of the previous task, the participant...

    PHP - Use of classes This is a further development of the previous task, the participant registration. You must use the following Participant class. <?php class Deltaker { private $etterNavn; private $forNavn; private $fAar; function __construct(string $fornavn, string $etternavn, string $aar) { $this->forNavn = $fornavn; $this->etterNavn = $etternavn; $this->fAar = $aar; } function hentEtterNavn() : string { return $this->etterNavn; } function hentForNavn() : string { return $this->forNavn; } function hentFAar() : string{ return $this->fAar; } //Setters function settForNavn(string $fornavn) {...

  • Language: C++ PLEASE INCLUDE SCREENSHOT OF OUTPUT In this assignment, you will consider the problem of organizing a collection of computer user-ids and passwords. Each time a user logs in to the syste...

    Language: C++ PLEASE INCLUDE SCREENSHOT OF OUTPUT In this assignment, you will consider the problem of organizing a collection of computer user-ids and passwords. Each time a user logs in to the system by entering his or her user-id and a secret password, the system must check the validity of this user-id and password to verify that this is a legitimate user. Because this validation must be done many times each day, it is necessary to structure this information in...

  • 1. Write a function that takes as input a directory. The function will search through that...

    1. Write a function that takes as input a directory. The function will search through that directory and its full subdirectory tree, building a count of the files by their extensions. As in the lecture, use a dictionary to keep track of the counts. The return-value of this function will be a dictionary of (key,value) pairs where the key will be the file extension and the value will be the number of files with that extension. For example, for the...

  • Create a python script to manage a user list that can be modified and saved to...

    Create a python script to manage a user list that can be modified and saved to a text file. Input text file consisting of pairs of usernames and passwords, separated by a colon (:) without any spaces User choice: (‘n’-new user account, ‘e’-edit existing user account, ‘d’- delete existing user account, ‘l’- list user accounts, ‘q’-quit) List of user accounts, error messages when appropriate Output text file consisting of pairs of username and passwords, separated by a colon (:) without...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT