Language

์š”์ฆ˜ ํ•ซํ•œ ChatGPT๋ฅผ ์‚ฌ์šฉํ•ด๋ณด์ž:)

๐“›๐“พ๐“ฌ๐“ฎ๐“ฝ๐“ฎ_๐“ข๐“ฝ๐“ฎ๐“ต๐“ต๐“ช 2023. 1. 24.
728x90
๋ฐ˜์‘ํ˜•

ํ•ด๋‹น ๋ธ”๋กœ๊ทธ๋Š” ํ•ดํ‚น ๋ฐ ๋ณด์•ˆ ๋ธ”๋กœ๊ทธ๋กœ ๊ณต๋ถ€ ๋ฐ ์—ฐ๊ตฌ์šฉ์œผ๋กœ ์ž‘์„ฑ๋˜์–ด์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜์˜ ๋‚ด์šฉ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ดํ‚น ์‹œ๋„ ๋ฐ ์‹ค์ œ ๊ณต๊ฒฉ์„ ์‹œ๋„ํ•˜์—ฌ ์ผ์–ด๋‚˜๋Š” ๋ชจ๋“  ์ฑ…์ž„์€ ๋ณธ์ธ(๋”ฐ๋ผํ•œ์ž)์—๊ฒŒ ์žˆ์Œ์„ ์•Œ๋ ค๋“œ๋ฆฌ๋ฉฐ, ๊ธ€์“ด์ด๋Š” ์•„๋ฌด๋Ÿฐ ์ฑ…์ž„์„ ์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ผญ ๊ณต๋ถ€ ๋ฐ ์—ฐ๊ตฌ์šฉ์œผ๋กœ๋งŒ ์‚ฌ์šฉํ•˜์—ฌ ์ฃผ์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

์‚ฌ์‹ค chatGPT๊ฐ€ ์ฒ˜์Œ ๋‚˜์™”์„๋•Œ ์—„์ฒญ ์ธ๊ธฐ๊ฐ€ ๋งŽ์•„์„œ ํ•œ๋ฒˆ ์‚ฌ์šฉํ•ด๋ณผ๊นŒ ํ–ˆ๋Š”๋Ž… ์•ˆํ•˜๋‹ค๊ฐ€ ์š”์ฆ˜์—๋„ ๊ณ„์† ์ธ๊ธฐ๊ฐ€ ๋งŽ์•„์„œ ํ•œ๋ฒˆ ์‚ฌ์šฉ์„ ํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. 

https://chat.openai.com/auth/login

ํ•ด๋‹น ํ™ˆํŽ˜์ด์ง€์—์„œ ๊ฐ€์ž…์„ ํ•˜๋ฉด๋˜๋Š”๋ฐ ๊ตฌ๊ธ€ ์•„์ด๋””๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐ€์ž…์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ์ ‘์†์„ํ•˜๋ฉด ....

์ด๋Ÿฌํ•œ ๋ฌธ๊ตฌ๊ฐ€ ๋‚˜์˜จ๋‹ค... ๋” ์ด์ƒ ๋ฐ›์•„๋“ค์ผ ์ˆ˜ ์—†๋‹ค๊ณ  ํ•˜๋Š”๋ฐ ... ํ•ด๋‹น ๋ฌธ๊ตฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์‹œํฌ๋ฆฟ๋ชจ๋“œ๋กœ ์ ‘์†ํ•˜์—ฌ ์ƒˆ๋กœ๊ณ ์นจ์„ ํ•˜๋ฉด ์ ‘์†ํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ตฌ๊ธ€์•„์ด๋””๋ฅผ ์ด์šฉํ•˜์—ฌ ์ ‘์†์„ ํ•˜๋ฉด ์ด์ œ ChatGPT๋ฅผ ์‚ฌ์šฉํ• ์ˆ˜์žˆ๋Š”๋ฐ ํ  ์ •๋ง ์‹ ๊ธฐํ•˜๋‹ค.

์ฒ˜์Œ์œผ๋กœ ChatGPT์—๊ฒŒ ๋ง์„ ๊ฑธ์–ด๋ณด์•˜๋‹ค.

ํ  ... ๋‚จ๋“ค์ด ํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ํ•œ๋ฒˆ ์งœ๋ณด๋„๋ก ํ•˜์ž

ํด๋” ๋‚ด์— ์žˆ๋Š” ํŒŒ์ผ์˜ ๋Œ€ํ•œ ํ•ด์‹œ๊ฐ’์„ ์งœ๋Š” ์ฝ”๋“œ๋ฅผ python์œผ๋กœ ์งœ๋‹ฌ๋ผ๊ณ  ์š”์ฒญํ•ด๋ณด์•˜๋‹ค.

import hashlib
import os

def hash_files_in_folder(folder_path, algorithm='sha256'):
    """
    Returns a dictionary of file hashes for all files in a given folder.
    :param folder_path: The path to the folder.
    :param algorithm: The hash algorithm to use (default sha256)
    :return: A dictionary of file hashes.
    """
    hasher = hashlib.new(algorithm)
    file_hashes = {}
    for root, dirs, files in os.walk(folder_path):
        for file in files:
            file_path = os.path.join(root, file)
            with open(file_path, 'rb') as f:
                buf = f.read()
                hasher.update(buf)
                file_hashes[file_path] = hasher.hexdigest()
    return file_hashes

 

 

ChatGPT๋Š” ํ•ด๋‹น ์ฝ”๋“œ๋ฅผ ์งœ์ฃผ์—ˆ๋‹ค.

๊ณผ๊ฑฐ์— ๋‚ด๊ฐ€ ์ง  ์ฝ”๋“œ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

#-*-coding : utf-8-*-

import os
import hashlib
import glob

f = open('/Users/lucete/Desktop/hash.txt','w')

def file_md5(filename):
    md5 = hashlib.md5()
    with open(filename,'rb') as f:
        for chunk in iter(lambda: f.read(8192),b""):
            md5.update(chunk)
    return md5.hexdigest()

path = '/Users/lucete/Downloads'
array = os.listdir(path)

i=0
for path, dirs, files in os.walk(path):
    for file in files:
        flist = glob.glob(os.path.join(path, file))

        for i in flist:
            print(i,os.path.getsize(i),file_md5(i))
            f.write(i+' : '+file_md5(i)+'\n')
f.close()

์ƒ๊ฐ ๋ณด๋‹ค ๋น„์Šทํ•˜๋ฉด์„œ ์ฝ”๋“œ๋ฅผ ์ž˜์งœ์ฃผ๋Š” ๊ฒƒ๊ฐ™๋‹ค.

ChatGPT๋ฅผ ์ด์šฉํ•˜๋ฉด ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฉด์œผ๋กœ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•  ๊ฒƒ์œผ๋กœ ๋ณด์ด๋Š”๋ฐ ์นจํ•ด์‚ฌ๊ณ ๋‚˜ forensic ์ทจ์•ฝ์  ๊ด€๋ จ์—…๋ฌด๋ฅผ ํ• ๋•Œ ์‚ฌ์šฉํ• ์ˆ˜ ์žˆ๋Š” ๋ฐฉ์•ˆ์„ ์ฐพ์•„๋ณด๋ฉด ์ƒ๊ฐ๋ณด๋‹ค ์ข‹์€ ๊ตฌ์ƒ์„ ๋งŒ๋“ค์–ด ๋‚ผ์ˆ˜ ์žˆ์„๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค.

์ด๋Ÿฌํ•œ ๋‚ด์šฉ๋“ค์„ ์ ์ ˆํ•˜๊ฒŒ ์‚ฌ์šฉํ•˜์—ฌ ๋ณด๋ฉด ๊ธฐ์กด์˜ ์ง€์‹๊ณผ ํ•ฉ์น˜๋ฉด ๋” ์ข‹์€ ๊ฒฐ๊ณผ๋ฌผ์„๋งŒ๋“ค์–ด ๋‚ผ์ˆ˜ ์žˆ์„ ๊ฒƒ๊ฐ™๋‹ค.

์ž์ฃผ์ž์ฃผ ์ด์šฉํ•˜๋ฉด์„œ ํ•œ๋ฒˆ ์‚ฌ์šฉํ•ด๋ด์•ผ๊ฒ ๋‹ค.

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€