2013년 12월 17일 화요일

[Python] Where file search utility

This utility searches all the paths in a semi-colon delimited environment variable list for files matching a given filespec. By default, PATH is used for the enviroment. For example, on my computer

C:\>where note*.exe
C:\WINNT\system32\notepad.exe
C:\WINNT\NOTEPAD.EXE


소스코드:

"""Searches a path for a specified file.
"""

__author__ = "Bill McNeill <billmcn@speakeasy.net>"
__version__ = "1.0"

import sys
import os
import os.path
import glob

def help():
        print """\
where (Environment) Filespec

Searches the paths specified in Environment for all files matching Filespec.
If Environment is not specified, the system PATH is used.\
"""

if len(sys.argv) == 3:
        paths = os.environ[sys.argv[1]]
        file = sys.argv[2]
elif len(sys.argv) == 2:
        paths = os.environ["PATH"]
        file = sys.argv[1]
else:
        help()
        sys.exit(0)

for path in paths.split(";"):
        for match in glob.glob(os.path.join(path, file)):
                print match

Reentrancy Attack: 블록체인 스마트 컨트랙트의 치명적인 취약점

블록체인 기술이 전 세계적으로 주목받으면서 스마트 컨트랙트(Smart Contract)의 사용이 급격히 증가하고 있습니다. 하지만 그만큼 보안 취약점도 함께 늘어나고 있는데, 그 중에서도 Reentrancy Attack(재진입 공격)은 매우 치명적이고...