Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Buffer Overflow and Mitigations

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Buffer Overflow and Mitigations. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

How does a buffer overflow attack work, and what are the modern mitigations against it (ASLR, DEP)?

Implement a simulator that classifies whether an overwritten return address leads to a successful exploit. Model an overflow, a code target or stack target, ASLR offset guesses, and DEP.

The function receives scalar inputs and returns one status string: no-overflow, blocked-by-aslr, blocked-by-dep, invalid-target, or exploitable.

Constraints

  • 0 <= write_length, buffer_size <= 10^9
  • target_type is either "stack" or "code"
  • 0 <= code_start <= code_end <= 10^9
  • 0 <= target_offset, actual_aslr_offset, guessed_aslr_offset <= 10^9
  • Boolean mitigation flags are valid booleans

Function Signature

def classify_overflow(write_length, buffer_size, target_type, target_offset, code_start, code_end, aslr_enabled, actual_aslr_offset, guessed_aslr_offset, dep_enabled):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output