hink about how ASLR makes life harder for the bad guy

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
#include <stdio.h>
int main() {
long local;
int (*mainptr)(void); /* declare a "pointer to function returning int" */
mainptr = main; /* address of main */
printf("%p,%p\n",&local,mainptr); /* print the two addresses */
return 0;
}
The printf statement outputs the address of the variable “local”, which should be on the stack right
after the return address, and then the address of the code for “main”.
Start by creating a source file aslrtest.c on your VM containing the above C program. Compile
it into an executable with the same name:
bash$ gcc -o aslrtest aslrtest.c
(As always, the “bash$” in the above represents the prompt and is not part of the command you
type.)
a. Turn off ASLR with the command:
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
Once you have ASLR disabled, run aslrtest 10 times. The following shell script will do that,
(assuming your shell is bash, which it is unless you’ve changed it yourself):
bash$ for i in {1..10}
> do
> ./aslrtest
> done
What range of output values to you observe for the first and second arguments?
b. Now re-enable ASLR (change “0” to “2” in the above command) and run the command again
100 times by replacing “10” with “100” in the above command. You will want to append the
output to a file:
bash$ for i in {1..100}
> do
> ./aslrtest >> testout
> done
This should produce a file with 100 lines, with 2 comma-separated numbers each. What range
of values do you observe in the first and second columns this time? (Hint: Read the file into
Excel and use the min and max functions to determine the minimum and maximum values
in each column. Or you can just do it by hand, or write a program to do it.) Does ASLR
randomize the address of pieces of code?

Think about how ASLR makes life harder for the bad guys.

Expert Solution
Step 1: Outline of the given question

The question asks you to conduct an experiment to observe the impact of Address Space Layout Randomization (ASLR) on memory address randomization in a C program. Specifically, it requests you to run the program with ASLR both disabled and enabled, and then analyze how memory addresses for local variables and functions behave under these conditions. The goal is to understand how ASLR adds unpredictability to memory layouts, enhancing security by making it more difficult for attackers to exploit vulnerabilities.

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Security Techniques and tools
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education