Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 613 Bytes

Python Sandboxes Bypass.md

File metadata and controls

26 lines (21 loc) · 613 Bytes
  • Code 1

def test_subprocess(command):
    try:
        result = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
        print("Command Output:\n", result.decode())
    except subprocess.CalledProcessError as e:
        print("Error (return code {}):".format(e.returncode), e.output.decode())

test_subprocess('id')

  • Code 2
def test_file_read(filename):
    try:
        with open(filename, 'r') as file:
            content = file.read()
            print("File Content:\n", content)
    except Exception as e:
        print("Error:", e)

test_file_read('/etc/passwd')