Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you have written the following piece of code:# test _ eval.pyimport sysimport osdef run _ code ( string ) : Evaluate

Suppose you have written the following piece of code:# test_eval.pyimport sysimport osdef run_code(string):""" Evaluate the passed string as code """try:eval(string,{})except Exception as e:print(repr(e))if __name__=="__main__":run_code(sys.argv[1])Consider a scenario where an attacker is trying to exploit this piece of code to find out the contents of a directory where an application is running. The attacker tries to list the contents of the current folder using the following code:$ python2 test_eval.py "os.system('ls -a')"The given code results in an error. Why did the error occur?Each correct answer represents a part of the solution. Choose two.This type of question contains radio buttons and checkboxes for selection of options. Use Tab for navigation and Enter or space to select the option.Aoption ABecause the second argument is passed as an empty dictionaryBoption BBecause Python is unable to resolve the os nameCoption CBecause eval is safeDoption DBecause the code is incomplete

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions