Esempio n. 1
0
def _compile(code, werror, flags, libs):
    digest = md5sumhex(code + str(werror) + str(flags) + str(libs))
    if digest in __cache:
        return __cache[digest]
    sopath = os.path.join(__tempdir, digest + '.so')
    try:
        if os.path.exists(sopath):
            return CDDL(sopath)
    except:
        pass
    cpath = os.path.join(__tempdir, digest + '.c')
    with open(cpath, 'w') as f:
        f.write(code)
    flags += ['-fPIC', '-shared', '-O3', '-march=native', '-mtune=native',
              '-Wall']
    if werror:
        flags.append('-Werror')
    cmd = ['gcc'] + flags + ['-o', sopath, cpath] + libs
    p = Popen(cmd, stderr = PIPE)
    _, s = p.communicate()
    s = s.replace(cpath + ':', '').replace(cpath, '')
    if p.returncode <> 0:
        log.error('GCC error (%s):' % cpath)
        log.trace(s)
        sys.exit(p.returncode)
    elif s <> '':
        log.warning('GCC warning (%s):' % cpath)
        log.trace(s)
    return CDLL(sopath)
Esempio n. 2
0
def _compile(code, werror, flags, libs):
    digest = md5sumhex(code + str(werror) + str(flags) + str(libs))
    if digest in __cache:
        return __cache[digest]
    sopath = os.path.join(__tempdir, digest + '.so')
    try:
        if os.path.exists(sopath):
            return CDDL(sopath)
    except:
        pass
    cpath = os.path.join(__tempdir, digest + '.c')
    with open(cpath, 'w') as f:
        f.write(code)
    flags += [
        '-fPIC', '-shared', '-O3', '-march=native', '-mtune=native', '-Wall'
    ]
    if werror:
        flags.append('-Werror')
    cmd = ['gcc'] + flags + ['-o', sopath, cpath] + libs
    p = Popen(cmd, stderr=PIPE)
    _, s = p.communicate()
    s = s.replace(cpath + ':', '').replace(cpath, '')
    if p.returncode <> 0:
        log.error('GCC error (%s):' % cpath)
        log.trace(s)
        sys.exit(p.returncode)
    elif s <> '':
        log.warning('GCC warning (%s):' % cpath)
        log.trace(s)
    return CDLL(sopath)
Esempio n. 3
0
def splash():
    log.trace('\x1b[G\x1b[?25l')
    for c in range(8):
        for line in _lines:
            log.trace(color(c % 8, line) + '\n')
            sleep(0.005)
        for _ in _lines:
            log.trace('\x1b[F')
    for line in _lines:
        log.trace(line + '\n')
    log.trace('\x1b[?25h')
Esempio n. 4
0
def splash():
    """Put this at the beginning of your exploit to create the illusion that your sploit is enterprisey and top notch quality"""
    log.trace('\x1b[G\x1b[?25l')
    for c in range(8):
        for line in _lines:
            log.trace(color(c % 8, line) + '\n')
            sleep(0.005)
        for _ in _lines:
            log.trace('\x1b[F')
    for line in _lines:
        log.trace(line + '\n')
    log.trace('\x1b[?25h')
Esempio n. 5
0
def splash():
    """Put this at the beginning of your exploit to create the illusion that your sploit is enterprisey and top notch quality"""
    log.trace('\x1b[G\x1b[?25l')
    for c in range(8):
        for line in _lines:
            log.trace(color(c % 8, line) + '\n')
            sleep(0.005)
        for _ in _lines:
            log.trace('\x1b[F')
    for line in _lines:
        log.trace(line + '\n')
    log.trace('\x1b[?25h')