반응형
# 문자열의 문자 빈도수, HEX 빈도수를 검사하여 가장 큰 빈도를 출력하는 프로그램
CODE
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 | # Made by hyeonbell # 2018/01/21 import sys filename = sys.argv[1] f = open(filename) data = f.read() result = {} hexdata = data.encode("hex") s = '' i = 0 while i < len(hexdata): cursor = hexdata[i:i+2] if not (cursor in result): result[cursor] = 1 else: result[cursor] = result[cursor] + 1 i = i + 2 inverse = [(value, key) for key, value in result.items()] maxv = max(inverse) print("-"*28+"\n\t[RESULT]\n"+"-"*28+"\n") print("Max frequency hex is " + str(maxv[1]) + " = " + str(maxv[0])) print("Character is " + maxv[1].decode("hex")) print("\n"+"-"*28) | cs |
RUN
GITHUB
https://github.com/HyeonBell/Char-Frequency-Analyzer
반응형
'Programming > Python' 카테고리의 다른 글
Python/IPython 설치 (0) | 2018.03.15 |
---|---|
Python/자료 목록/Python Exploit Development (0) | 2018.03.12 |
Programming/Python/모듈 다루기 (0) | 2018.01.17 |
Python Pentration Testing Essentials -1- (0) | 2017.03.31 |
[ERROR] a byte-like object is required, not 'str' (0) | 2017.03.31 |