'Dump all ROP gadgets in specific memory range
Note: only for simple gadgets, for full ROP search try: http://ropshell.com
Warning: this can be very slow, do not run for big memory range
Usage:
MYNAME start end [keyword] [depth]
MYNAME mapname [keyword]
default gadget instruction depth is: 5'

def dumprop(self, *arg):

    (start, end, keyword, depth) = normalize_argv(arg, 4)
    filename = peda.getfile()
    if (filename is None):
        warning_msg('please    specify    a    filename    to    debug')
        return
    filename = os.path.basename(filename)
    mapname = None
    if (start is None):
        mapname = 'binary'
    elif (end is None):
        mapname = start
    elif (to_int(end) is None):
        mapname = start
        keyword = end
    if (depth is None):
        depth = 5
    result = {}
    warning_msg('this    can    be    very    slow,    do    not    run    for    large    memory    range')
    if mapname:
        maps = peda.get_vmmap(mapname)
        for (start, end, _, _) in maps:
            if (not peda.is_executable(start, maps)):
                continue
            result.update(peda.dumprop(start, end, keyword))
    else:
        result.update(peda.dumprop(start, end, keyword))
    text = 'Not    found'
    if (len(result) > 0):
        text = ''
        outfile = ('%s-rop.txt' % filename)
        fd = open(outfile, 'w')
        msg(('Writing    ROP    gadgets    to    file:    %s    ...' % outfile))
        for (code, addr) in sorted(result.items(), key=(lambda x: len(x[0]))):
            text += ('0x%x:    %s\n' % (addr, code))
            fd.write(('0x%x:    %s\n' % (addr, code)))
        fd.close()
    pager(text)
    return
