contrib/devtools/security-check.py
def check_ELF_NX(executable) -> bool:
    '''
    Check that no sections are writable and executable (including the stack)
    '''
    elf = pixie.load(executable)
    have_wx = False
    have_gnu_stack = False
    for ph in elf.program_headers:
        if ph.p_type == pixie.PT_GNU_STACK:
            have_gnu_stack = True
        if (ph.p_flags & pixie.PF_W) != 0 and (ph.p_flags & pixie.PF_X) != 0: # section is both writable and executable
            have_wx = True
    return have_gnu_stack and not have_wx

    Check that no sections are writable and executable (including the stack)
    
Check that no sections are writable and executable (including the stack)
Check that no sections are writable and executable ( including the stack )
def check_ELF_NX(executable) -> bool:
    elf = pixie.load(executable)
    have_wx = False
    have_gnu_stack = False
    for ph in elf.program_headers:
        if ph.p_type == pixie.PT_GNU_STACK:
            have_gnu_stack = True
        if (ph.p_flags & pixie.PF_W) != 0 and (ph.p_flags & pixie.PF_X) != 0: 
            have_wx = True
    return have_gnu_stack and not have_wx
def check_ELF_NX ( executable ) -> bool : elf = pixie . load ( executable ) have_wx = False have_gnu_stack = False for ph in elf . program_headers : if ph . p_type == pixie . PT_GNU_STACK : have_gnu_stack = True if ( ph . p_flags & pixie . PF_W ) != 0 and ( ph . p_flags & pixie . PF_X ) != 0 : have_wx = True return have_gnu_stack and not have_wx
Check that no sections are writable and executable (including the stack)
Check that no sections are writable and executable ( including the stack )
'''
    Check that no sections are writable and executable (including the stack)
    ''' # section is both writable and executable
executable