47일차

47일차

홈으로 돌아가기

Documents and Settings \ 서과장 \ Local Settings \ History \ History.IE5 \ MSHist~~ \ index.dat

자바 다운로드
JavaSetup8u51

빙에서 truecrypt 검색해서 truecrypt.org/news에 접근
그후 
URL 픤?x徠읏욹,徠€Q`h?
 G?:2015081320150814: 서과장@:Host: truecrypt.sourceforge.net

URL `럊x徠`i?,徠'G?€Q`h? G?
濟:2015081320150814: 서과장@http://truecrypt.sourceforge.net/OtherPlatforms.htmlURL 먚qx徠?-徠€Q`h? 
G?:2015081320150814: 서과장@:Host: www.truecrypt.orgURL @댙rx徠@銑-徠'
G?€Q`h? G?:2015081320150814: 서과장@http://truecrypt.sourceforge.net

트루크립토 소스포지로 들어감

오픈스테고로 숨겨놓은 파일을 추출함
0001.png -> TrueCryptSetup 추출

TrueCryptSetup -> TrueCryptSetup.zip으로 수정하고 압축을 해제하면
TrueCryptSetup.txt가 들어있음
Serpent-Twofish-AES
SHA-512
hackersp@ssw0rd
key.txt

비밀번호는
hackersp@ssw0rd

키파일 Dc1.txt와 함께 TrueCrypt로 분석

시나리오4
복구된 파티션 > tc > openstego > 휴지통 > 복구 > 설계도면
산업기밀유출
서과장이 유출한 자료를 찾아라


미션
이미지 : ence.E01
상태 확인후 상태에 이상이 있으면 정상화
1. findx.gif를 찾아라
확장자 분석 > 키워드 분석 > 파일 시그니처 분석 > 카빙
Forensic.py에 
 def carve(): 만들기

2. newmar.jpg를 찾아라
확장자 분석 > 키워드 분석 > 파일 시그니처 분석 > 은닉 파악



encase imager 연습용 usb wipe하기
tools -> wip drive


getdata 
forensic explorer

https://download.getdata.com/support/fex/v5/ForensicExplorer-64bit-(v5.6.8.5970).exe
https://download.getdata.com/support/fex/v5/ForensicExplorer-64bit-(v5.6.8.5838).exe

v5.6.8.5838
v5.6.8.5808
	

C:\Users\PC11\Desktop\20250218\20250218002.001

r'D:\20250219\20250219001.001'
usb 초기화 이후 gif 파일 옮겨놓음
27176

gif
4749463839612000


def find_gif_files(raw_image_path):
    # GIF 파일 시그니처
    GIF_SIGNATURES = [b'GIF89a', b'GIF87a']
    GIF_END = b';'  # GIF 파일의 끝을 나타내는 세미콜론
    
    with open(raw_image_path, 'rb') as file:
        data = file.read()  # 파일을 바이너리 모드로 읽음
        gifs = []
        
        # GIF 파일을 찾기 위한 루프
        for signature in GIF_SIGNATURES:
            print(f"Searching for GIF signature: {signature.decode('utf-8')}")
            pos = data.find(signature)  # 시그니처 찾기
            while pos != -1:
                print(f"Found GIF signature at position {pos}")
                # GIF 파일 시작
                start_pos = pos
                # GIF 파일 끝 찾기
                end_pos = data.find(GIF_END, start_pos) + 1
                if end_pos != -1:
                    print(f"Found GIF end at position {end_pos}")
                    gif_data = data[start_pos:end_pos]
                    gifs.append(gif_data)  # GIF 데이터 저장
                    print(f"GIF found, size: {len(gif_data)} bytes")
                    pos = data.find(signature, pos + 1)  # 다음 시그니처를 찾음
                else:
                    print("GIF end not found!")
        
        # 찾은 GIF 파일 출력
        for idx, gif in enumerate(gifs):
            print(f"Saving GIF #{idx + 1}...")
            with open(f"extracted_gif_{idx + 1}.gif", 'wb') as gif_file:
                gif_file.write(gif)
            print(f"GIF #{idx + 1} saved as extracted_gif_{idx + 1}.gif")
                
        return gifs

# 예시 사용법
raw_image_path = r'D:\20250219\20250219001.001'  # dd로 생성된 raw 이미지 경로
find_gif_files(raw_image_path)


gif 찾고 저장

def find_and_save_gif_files_in_sectors(raw_image_path):
    # GIF 파일 시그니처
    GIF_SIGNATURES = [b'GIF89a', b'GIF87a']
    GIF_END = b';'  # GIF 파일의 끝을 나타내는 세미콜론
    SECTOR_SIZE = 512  # 섹터 크기
    
    with open(raw_image_path, 'rb') as file:
        # 파일 크기 확인
        file.seek(0, 2)  # 파일의 끝으로 이동
        file_size = file.tell()
        print(f"Total file size: {file_size} bytes")
        
        sector_number = 0
        
        # 512바이트씩 건너뛰며 섹터 단위로 파일을 읽음
        for sector_start in range(0, file_size, SECTOR_SIZE):
            file.seek(sector_start)  # 섹터의 시작으로 이동
            sector_data = file.read(SECTOR_SIZE)  # 섹터 데이터 읽기
            print(f"Scanning sector {sector_number} (offset {sector_start})")
            
            # GIF 시그니처 찾기
            for signature in GIF_SIGNATURES:
                pos = sector_data.find(signature)  # 시그니처 찾기
                while pos != -1:
                    print(f"Found GIF signature at position {sector_start + pos} in sector {sector_number}")
                    # GIF 파일 시작
                    start_pos = pos
                    # GIF 파일 끝 찾기
                    end_pos = sector_data.find(GIF_END, start_pos) + 1
                    if end_pos != -1:
                        print(f"Found GIF end at position {sector_start + end_pos} in sector {sector_number}")
                        gif_data = sector_data[start_pos:end_pos]
                        # GIF 데이터가 비어있는지 확인
                        if len(gif_data) > 0:
                            # GIF 즉시 저장
                            gif_filename = f"extracted_gif_{sector_number}_{start_pos}.gif"
                            print(f"Saving GIF immediately as {gif_filename}...")
                            with open(gif_filename, 'wb') as gif_file:
                                gif_file.write(gif_data)
                            print(f"GIF saved as {gif_filename}")
                        else:
                            print("Error: GIF data is empty!")
                    else:
                        print("Error: GIF end not found!")
                    pos = sector_data.find(signature, pos + 1)  # 다음 시그니처를 찾음
            
            sector_number += 1
                
        print("GIF file extraction complete.")
                
        return

# 예시 사용법
raw_image_path = 'your_dd_raw_image.dd'  # dd로 생성된 raw 이미지 경로
find_and_save_gif_files_in_sectors(raw_image_path)


27176 jpg
27256 png
28624 gif

raw_image_path = r'D:\20250219\20250219002.001' 


3가지 유형의 이미지 복구하기

def find_and_save_image_files(raw_image_path):
    # 파일 형식 시그니처
    IMAGE_SIGNATURES = {
        'GIF': [b'GIF89a', b'GIF87a'],
        'JPG': [b'\xFF\xD8\xFF\xE0'],  # JPG의 시작 바이트
        'PNG': [b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'],  # PNG의 시작 바이트
    }
    IMAGE_ENDS = {
        'GIF': b'\00\x3B',  # GIF의 끝 (세미콜론: ;)
        'JPG': b'\xFF\xD9',  # JPG의 끝
        'PNG': b'\x49\x45\x4E\x44\xAE\x42\x60\x82',  # PNG의 끝
    }
    
    with open(raw_image_path, 'rb') as file:
        # 파일 크기 확인
        file.seek(0, 2)  # 파일의 끝으로 이동
        file_size = file.tell()
        print(f"Total file size: {file_size} bytes")
        print(f"파일찾기 시작")     
        file.seek(0)  # 파일의 시작으로 이동
        file_data = file.read()  # 전체 파일 데이터를 읽음
        print(f"Reading entire file of size {file_size} bytes")
        
        # 각 형식에 대해 시그니처 찾기
        for image_type, signatures in IMAGE_SIGNATURES.items():
            for signature in signatures:
                pos = file_data.find(signature)  # 시그니처 찾기
                while pos != -1:
                    print(f"Found {image_type} signature at position {pos}")
                    # 이미지 파일 시작
                    start_pos = pos
                    # 이미지 파일 끝 찾기
                    end_pos = file_data.find(IMAGE_ENDS[image_type], start_pos)
                    if end_pos != -1:
                        end_pos += len(IMAGE_ENDS[image_type])  # 끝을 올바르게 지정
                        print(f"Found {image_type} end at position {end_pos}")
                        image_data = file_data[start_pos:end_pos]
                        # 이미지 데이터가 비어있는지 확인
                        if len(image_data) > 0:
                            # 이미지 즉시 저장
                            image_filename = f"extracted_{image_type}_{start_pos}.jpg" if image_type == 'JPG' else \
                                                 f"extracted_{image_type}_{start_pos}.png" if image_type == 'PNG' else \
                                                 f"extracted_{image_type}_{start_pos}.gif"
                            print(f"Saving {image_type} immediately as {image_filename}...")
                            with open(image_filename, 'wb') as image_file:
                                image_file.write(image_data)
                            print(f"{image_type} saved as {image_filename}")
                        else:
                            print(f"Error: {image_type} data is empty!")
                    else:
                        print(f"Error: {image_type} end not found!")
                    pos = file_data.find(signature, pos + 1)  # 다음 시그니처를 찾음
                
        print("Image file extraction complete.")
                
        return

# 예시 사용법
raw_image_path = r'D:\20250219\20250219002.001'  # dd로 생성된 raw 이미지 경로
find_and_save_image_files(raw_image_path)


2. newmar.jpg 흔적찾기
확장자 불일치 찾기 (Autoexe.bat)
???
파이썬에서 zip파일을 푸는 프로그램

    txt_file_path = r'C:\Users\PC11\Desktop\20250218\Pretty Lady.txt'  # 암호 리스트가 담긴 txt 파일 경로
    zip_file_path = r'C:\Users\PC11\Desktop\20250218\Autoexec.zip'      # 암호가 걸린 zip 파일 경로
    
zip파일 푸는 파이썬

import itertools
import pyzipper
import os

# txt 파일에서 문장을 읽고 단어별로 나누는 함수
def load_words_from_text(text):
    # 문장을 공백 기준으로 나누고 불필요한 구두점 제거
    words = text.split()
    # 단어에서 구두점 제거
    words = [word.strip('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~') for word in words]
    return words

# zip 파일을 열기 위한 함수
def attempt_zip_open(zip_file_path, password_candidate):
    try:
        # pyzipper 사용하여 암호화된 zip 파일 열기
        with pyzipper.AESZipFile(zip_file_path, 'r') as zip_ref:
            zip_ref.setpassword(password_candidate.encode('utf-8'))
            # 파일을 열 수 있는지 테스트
            zip_ref.testzip()  # 파일이 정상인지 확인
        return True
    except (RuntimeError, ValueError):
        return False

# 단어를 섞어서 가능한 순열을 생성하는 함수
def brute_force_zip_open(zip_file_path, words):
    # 가능한 모든 단어 순열을 생성
    for length in range(1, len(words) + 1):
        for perm in itertools.permutations(words, length):

            password_candidate = ' '.join(perm)
            print(f"Trying password: {password_candidate}")
            # zip 파일 열기 시도
            if attempt_zip_open(zip_file_path, password_candidate):
                print(f"Password found: {password_candidate}")
                return password_candidate  # 암호를 찾으면 종료
    return None

# zip 파일을 압축 해제하는 함수
def extract_zip(zip_file_path, password, extract_to):
    with pyzipper.AESZipFile(zip_file_path, 'r') as zip_ref:
        zip_ref.setpassword(password.encode('utf-8'))
        # 압축 해제
        zip_ref.extractall(extract_to)
        print(f"Files extracted to: {extract_to}")

# 메인 함수
def main():
    # 주어진 문장 (txt 파일 대신 직접 입력 가능)
    text = "Don't forget Julie Newmar in Gotham City Central Park!"
    
    # 단어 목록 불러오기
    words = load_words_from_text(text)
    
    # zip 파일 경로
    zip_file_path = r'C:\Users\PC11\Desktop\20250218\Autoexec.zip'      # 암호가 걸린 zip 파일 경로
    
    # 압축 해제할 디렉토리 (현재 디렉토리로 설정)
    extract_to = r'C:\Users\PC11\Desktop\20250218\extracted'
    
    # 순열을 통해 암호 찾기
    password = brute_force_zip_open(zip_file_path, words)
    
    if password:
        print(f"Success! The password is: {password}")
        # 압축 해제
        extract_zip(zip_file_path, password, extract_to)
    else:
        print("Failed to find the password.")

# 실행
if __name__ == "__main__":
    main()



zip파일 풀기 완성

import itertools
import pyzipper
import os

# txt 파일에서 문장을 읽고 단어별로 나누는 함수
def load_words_from_text_file(txt_file_path):
    # 텍스트 파일을 열고 문장을 읽어오기
    with open(txt_file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    # 문장을 공백 기준으로 나누고 불필요한 구두점 제거
    words = text.split()
    # 단어에서 구두점 제거
    words = [word.strip('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~') for word in words]
    return words

# zip 파일을 열기 위한 함수
def attempt_zip_open(zip_file_path, password_candidate):
    try:
        # pyzipper 사용하여 암호화된 zip 파일 열기
        with pyzipper.AESZipFile(zip_file_path, 'r') as zip_ref:
            zip_ref.setpassword(password_candidate.encode('utf-8'))
            # 파일을 열 수 있는지 테스트
            zip_ref.testzip()  # 파일이 정상인지 확인
        return True
    except (RuntimeError, ValueError):
        return False

# 단어를 섞어서 가능한 순열을 생성하는 함수
def brute_force_zip_open(zip_file_path, words):
    # 가능한 모든 단어 순열을 생성
    for length in range(1, len(words) + 1):
        for perm in itertools.permutations(words, length):
            password_candidate = ' '.join(perm)
            print(f"Trying password: {password_candidate}")
            # zip 파일 열기 시도
            if attempt_zip_open(zip_file_path, password_candidate):
                print(f"Password found: {password_candidate}")
                return password_candidate  # 암호를 찾으면 종료
    return None

# zip 파일을 압축 해제하는 함수
def extract_zip(zip_file_path, password, extract_to):
    with pyzipper.AESZipFile(zip_file_path, 'r') as zip_ref:
        zip_ref.setpassword(password.encode('utf-8'))
        # 압축 해제
        zip_ref.extractall(extract_to)
        print(f"Files extracted to: {extract_to}")

# 메인 함수
def main():
    # 텍스트 파일 경로 (Pretty Lady.txt 파일을 사용)
    txt_file_path = r'C:\Users\PC11\Desktop\20250218\Pretty Lady.txt'  # 암호 문장이 담긴 txt 파일 경로
    
    # 단어 목록 불러오기
    words = load_words_from_text_file(txt_file_path)
    
    # zip 파일 경로
    zip_file_path = r'C:\Users\PC11\Desktop\20250218\Autoexec.zip'      # 암호가 걸린 zip 파일 경로
    
    # 압축 해제할 디렉토리 (현재 디렉토리로 설정)
    extract_to = r'C:\Users\PC11\Desktop\20250218\extracted'
    
    # 순열을 통해 암호 찾기
    password = brute_force_zip_open(zip_file_path, words)
    
    if password:
        print(f"Success! The password is: {password}")
        # 압축 해제
        extract_zip(zip_file_path, password, extract_to)
    else:
        print("Failed to find the password.")

# 실행
if __name__ == "__main__":
    main()



쿠쿠 샌드박스

1VMware
2	ubuntu (22.04 버전 , 아나콘다 설치)
3		virtualbox
4			win7
5				python2.7


파이썬 웹프레임워크
Django ,flask

장고에 exe파일 업로드 장고는 파이썬에 악성코드 분석하게
정적 분석 
동적 분석