uroboros-diversification/src/disasm/extern_symbol_process.py
def globalvar(filepath):
    """
    This code aims at solving glibc global variables issue some of the code contains comments like this:
        401599:       48 8b 3d 70 6c 20 00    mov    0x206c70(%rip),%rdi        # 608210 <stdout>
    instructions like this should be translated into:
        mov stdout,%rdi
    :param filepath: path to target executable
    """

    with open(filepath + '.temp') as f:
        lines = f.readlines()

    pat_d = re.compile(r'0x[0-9a-f]+\(%rip\)')
    pat_s = re.compile(r'<([^@]+)(@@(?!Base).*)?>')

    for i in range(len(lines)):
        l = lines[i]
        if "#" in l and not "+" in l:
            m_s = pat_s.search(l)
            m_d = pat_d.search(l)
            if m_s and m_d:
                src = m_s.group(1)
                des = m_d.group(0)
                l = l.split('#')[0]
                l = l.replace(des, src)
                lines[i] = l + '\n'

    with open(filepath + '.temp', 'w') as f:
        f.writelines(lines)

    This code aims at solving glibc global variables issue some of the code contains comments like this:
        401599:       48 8b 3d 70 6c 20 00    mov    0x206c70(%rip),%rdi        # 608210 <stdout>
    instructions like this should be translated into:
        mov stdout,%rdi
    :param filepath: path to target executable
    
This code aims at solving glibc global variables issue some of the code contains comments like this:
401599:       48 8b 3d 70 6c 20 00    mov    0x206c70(%rip),%rdi        # 608210 
instructions like this should be translated into:
mov stdout,%rdi
This code aims at solving glibc global variables issue some of the code contains comments like this : 401599 : 48 8b 3d 70 6c 20 00 mov 0x206c70 ( %rip ) %rdi # 608210 instructions like this should be translated into : mov stdout %rdi
def globalvar(filepath):
    with open(filepath + '.temp') as f:
        lines = f.readlines()
    pat_d = re.compile(r'0x[0-9a-f]+\(%rip\)')
    pat_s = re.compile(r'<([^@]+)(@@(?!Base).*)?>')
    for i in range(len(lines)):
        l = lines[i]
        if "#" in l and not "+" in l:
            m_s = pat_s.search(l)
            m_d = pat_d.search(l)
            if m_s and m_d:
                src = m_s.group(1)
                des = m_d.group(0)
                l = l.split('#')[0]
                l = l.replace(des, src)
                lines[i] = l + '\n'
    with open(filepath + '.temp', 'w') as f:
        f.writelines(lines)
def globalvar ( filepath ) : with open ( filepath + '.temp' ) as f : lines = f . readlines ( ) pat_d = re . compile ( r'0x[0-9a-f]+\(%rip\)' ) pat_s = re . compile ( r'<([^@]+)(@@(?!Base).*)?>' ) for i in range ( len ( lines ) ) : l = lines [ i ] if "#" in l and not "+" in l : m_s = pat_s . search ( l ) m_d = pat_d . search ( l ) if m_s and m_d : src = m_s . group ( 1 ) des = m_d . group ( 0 ) l = l . split ( '#' ) [ 0 ] l = l . replace ( des , src ) lines [ i ] = l + '\n' with open ( filepath + '.temp' , 'w' ) as f : f . writelines ( lines )
This code aims at solving glibc global variables issue some of the code contains comments like this:
401599:       48 8b 3d 70 6c 20 00    mov    0x206c70(%rip),%rdi        # 608210 <stdout>
instructions like this should be translated into:
mov stdout,%rdi
This code aims at solving glibc global variables issue some of the code contains comments like this : 401599 : 48 8b 3d 70 6c 20 00 mov 0x206c70 ( %rip ) %rdi # 608210 <stdout > instructions like this should be translated into : mov stdout %rdi
"""
    This code aims at solving glibc global variables issue some of the code contains comments like this:
        401599:       48 8b 3d 70 6c 20 00    mov    0x206c70(%rip),%rdi        # 608210 <stdout>
    instructions like this should be translated into:
        mov stdout,%rdi
    :param filepath: path to target executable
    """
filepath
path to target executable
path to target executable