언어/python

데모 PE -

파아랑새 2018. 2. 12. 18:02
import pprint as ppr
from openpyxl import Workbook
from openpyxl.styles import Font, Alignment, PatternFill, Color

wb = Workbook() # 객체 생성
ws = wb.active
alphabetList = [chr(n) for n in range(ord('A'), ord('Q'))]
target_f = open(file="C:\\Users\\sleep\\Desktop\\a.exe",
mode='rb')

IMAGE_DOS_HEADER = target_f.read(0x40)
lineJump = 0
LineCnt = 1
t_indx = 1
for indx in range(0, len(IMAGE_DOS_HEADER)):
element = hex(IMAGE_DOS_HEADER[indx])[2:]
j = indx%16

if len(element) == 1:
element = '0' + element
lineJump += 1
print("{}".format(element), end=" ")
if lineJump == 16:
lineJump = 0
print ()

movIndx = alphabetList[j] + str(LineCnt)
ws[movIndx] = element
ws[movIndx].font = Font(name="consolas", size=16, bold=True)
ws[movIndx].alignment = Alignment(horizontal='center', vertical='center')
ws[movIndx].fill = PatternFill(patternType='solid', fgColor=Color('FFC000'))
t_indx += 1
if (t_indx == 17):
t_indx = 1
LineCnt += 1
wb.save(filename="image_dos_header.xlsx")