2013년 12월 13일 금요일

[Python] Linux에서 이더넷 정보 가져오기

#!/usr/bin/env python
"""
ifconfig
exman@medialand.co.kr
"""

import string,socket,fcntl,IN

def ifconfig(ifname):
    s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    ifr = ifname+'\0'*(16-len(ifname))+chr(socket.AF_INET)+15*'\0'

    try:
        r= fcntl.ioctl(s.fileno(),0x8927,ifr)
        hwaddr = map(ord,r[18:24])
    except IOError:
        s.close()
        return None

    try:
        r= fcntl.ioctl(s.fileno(),0x8915,ifr)
        addr = string.join(map(str,map(ord,r[20:24])),'.')
    except IOError:
        s.close()
        return None

    try:
        r= fcntl.ioctl(s.fileno(),0x8919,ifr)
        broadaddr = string.join(map(str,map(ord,r[20:24])),'.')
    except IOError:
        s.close()
        return None

    try:
        r= fcntl.ioctl(s.fileno(),0x891b,ifr)
        netmask = string.join(map(str,map(ord,r[20:24])),'.')
    except IOError:
        s.close()
        return None

    s.close()
    return hwaddr,addr,broadaddr,netmask

if __name__=='__main__':
    print ifconfig('eth0')
    print ifconfig('eth0:0')
    print ifconfig('eth0:1')
    print ifconfig('eth1')
    print ifconfig('lo')

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

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