Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that John writes the following php script to access his database. He is worried that the script can be read by an adversary and

Suppose that John writes the following php script to access his database.

$username = userdb_5648;

$password = 7F519X-X_;

$hostname = localhost;

$dbh = mysql_connet($hostname, $username, $password)

if ($dbh){

print Connected to MySQL ;

}

...

?>

He is worried that the script can be read by an adversary and he wants to protect the login information. Given that this script is only accessed by an administrator, John decides to write code that places a magic value within the cookie of the administrator and then somehow use this value to hide all critical information in the above PHP script (specifically the raw value of $username and $password). Note that the magic value can be accessed from within the script in the following way:

_COOKIE[mymagic]

a) Write a modified PHP script that achieves Johns objective. Explain what the magic value will be.

b) What is the main defect of Johns approach?

c) What would be a better way to achieve Johns objective?

PLEASE ANSWER ALL PARTS OF THE QUESTION AND SHOW WORK.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions