()
return ("is off." in output), 'show disable-randomization'
Detects the ASLR status. Returns True, False or None.

    None is returned when we can't detect ASLR.
Detects the ASLR status. Returns True, False or None.
Detects the ASLR status . Returns True False or None .
def check_aslr():
    """
    Detects the ASLR status. Returns True, False or None.

    None is returned when we can't detect ASLR.
    """
    # QEMU does not support this concept.
    if pwndbg.qemu.is_qemu():
        return None, 'Could not detect ASLR on QEMU targets'

    # Systemwide ASLR is disabled
    try:
        data = pwndbg.file.get('/proc/sys/kernel/randomize_va_space')
        if b'0' in data:
            return False, 'kernel.randomize_va_space == 0'
    except Exception as e:
        print("Could not check ASLR: can't read randomize_va_space")
        pass

    # Check the personality of the process
    if pwndbg.proc.alive:
        try:
            data = pwndbg.file.get('/proc/%i/personality' % pwndbg.proc.pid)
            personality = int(data, 16)
            return (personality & 0x40000 == 0), 'read status from process\' personality'
        except:
            print("Could not check ASLR: can't read process' personality")
            pass

    # Just go with whatever GDB says it did.
    #
    # This should usually be identical to the above, but we may not have
    # access to procfs.
    output = gdb.execute('show disable-randomization', to_string=True)
    return ("is off." in output), 'show disable-randomization'
def check_aslr ( ) : # QEMU does not support this concept. if pwndbg . qemu . is_qemu ( ) : return None , 'Could not detect ASLR on QEMU targets' # Systemwide ASLR is disabled try : data = pwndbg . file . get ( '/proc/sys/kernel/randomize_va_space' ) if b'0' in data : return False , 'kernel.randomize_va_space == 0' except Exception as e : print ( "Could not check ASLR: can't read randomize_va_space" ) pass # Check the personality of the process if pwndbg . proc . alive : try : data = pwndbg . file . get ( '/proc/%i/personality' % pwndbg . proc . pid ) personality = int ( data , 16 ) return ( personality & 0x40000 == 0 ) , 'read status from process\' personality' except : print ( "Could not check ASLR: can't read process' personality" ) pass # Just go with whatever GDB says it did. # # This should usually be identical to the above, but we may not have # access to procfs. output = gdb . execute ( 'show disable-randomization' , to_string = True ) return ( "is off." in output ) , 'show disable-randomization'