prove_mem_insecure.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:python-secureconfig 作者: nthmost 项目源码 文件源码
def zerome(string):
    # find the header size with a dummy string
    dummy = "header finder"
    header = ctypes.string_at(id(dummy), sys.getsizeof(dummy)).find(dummy)

    location = id(string) + header
    size     = sys.getsizeof(string) - header  

    if platform.system() == 'Windows':
        memset =  ctypes.cdll.msvcrt.memset
    else:
        libc = find_library('c')
        memset =  ctypes.CDLL(libc).memset

    # For OS X, the above should work, but if it doesn't:
    # memset = ctypes.CDLL('libc.dylib').memset

    print "Clearing 0x%08x size %i bytes" % (location, size)

    memset(location, 0, size)

    #string still with us?
    print ctypes.string_at(location, size)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号