ctypes 파이썬 외부 함수 라이브러리 본문
ctypes 라이브러리를 이용하면 C의 데이터타입, 라이브러리 함수를 사용할 수 있다.
gray hat python 예제:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from ctypes import * msvcrt = cdll.msvcrt message_string = "Hello world!\n" msvcrt.printf("Testing: %s", message_string) seitz = c_char_p("loves the python") print seitz.value class barley_amount(Union): _fields_ = [ ("barley_long", c_long), ("barley_int", c_int), ("barley_char", c_char * 8), ] value = raw_input("Enter the amount of barley to put into the beer vat:") my_barley = barley_amount(int(value)) print "Barley amount as a long: %ld" %my_barley.barley_long print "Barley amount as an int: %d" %my_barley.barley_int print "Barley amount as a char: %s" %my_barley.barley_char | cs |
'Study > Python' 카테고리의 다른 글
코드 인젝션 활용 (0) | 2017.07.09 |
---|---|
윈도우 DEP 우회 (0) | 2017.07.03 |
PyDbg 접근 위반 핸들 (0) | 2017.07.03 |
윈도우 디버거 구현 (0) | 2017.07.03 |
소켓 랜덤채팅 (0) | 2017.07.03 |
Comments