Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

ctypes 파이썬 외부 함수 라이브러리 본문

Study/Python

ctypes 파이썬 외부 함수 라이브러리

awakerrday 2017. 6. 13. 02:51

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



자세한 내용은 https://docs.python.org/2/library/ctypes.html

'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