카테고리

asm (27) bootloader_x86_grub (1) C (92) compile (11) config (76) CPP (13) CSS (1) debugging (7) gimp (1) Go (1) html (1) Java (1) JavaScript (1) kernel (19) LibreOffice (3) Linux system progamming (21) MFC (1) opencv (4) OpenGL (1) PHP (1) Python (4) qemu (29) shell (3) socket (7) troubleshooting (2) ubuntu18.04 (2) windows (1)

2018/12/22

해쉬 알고리즘을 사용한 리눅스 CLI.

파일 또는 문자열들을 디스크 가져 와 해시 알고리즘을 통해 해시 값을 생성.

데이터 무결성 확인.
- 복사 된 항목이 원본과 정확히 일치하는지 확인.
- 원래 항목이 손상되지 않았는지 확인.

자주 사용되는 해싱 알고리즘.
- MD5(Message Digest 5)
- SHA-1(보안 해쉬 알고리즘)
- SHA-2(SHA-244, SHA-256, SHA-384, SHA-512)

String, 파일, or Disk -----> 알고리즘: MD5, SHA-1, or SHA-2 -----> 해쉬 값: 83e431dkf


파일 1 ----->   알고리즘: MD5, SHA-1, or SHA-2 -----> 해쉬 값: 83e431dkf
copy of 파일1-> 알고리즘: MD5, SHA-1, or SHA-2 -----> 해쉬 값: 83e431dkf
파일 2 ----->   알고리즘: MD5, SHA-1, or SHA-2 -----> 해쉬 값: 83e431ee8

HASHING TOOLS해싱 도구
GNU Coreutils(md5sum)
- 우분투 기본 설치

md5deep
- sudo apt-get install md5deep
- 재귀 적으로 전체 디렉토리 트리 검사.
- 해시 목록을 수락하고 입력 파일 집합과 비교.
- 예상 시간을 산출.

ssdeep
- sudo apt-get install ssdeep
- Fuzzy-hashing

GNU Coreutils
- md5sum : md5 합을 사용하여 해시 생성.
- sha1sum : sha1 합을 사용하여 해시 생성.
- sha256sum : 가장 많이 사용. sha256 합을 사용하여 해시 생성.

md5deep : 해쉬값 모음
- sd5deep 
- sha1deep
- sha256deep
- tigerdeep
- whirlpooldeep

ssdeep
- ssdeep

MD5
- 128-bit 해쉬 값 생성
- 알려진 충돌로 인해 취약.
-- forensics에 좋음 
-- 암호화 보안 좋지 않음. 

SHA-1
- 160-bit 해쉬 값 생성
- 알려진 충돌이 없지만 이론적인 충돌있음

SHA-2
- 244, 256, 384, or 512 bit 해쉬 값 생성
- SHA-1 또는 MD5와 같이 널리 사용되지 않음.
- SHA-2 SHA-256 및 SHA-512가 가장 많이 사용 SHA-2.

shell> touch file1 file2

md5 파일 적용
shell> md5sum file1
d41d8cd98f00b204e9800998ecf8427e  file1
shell> mod5sum file2
d41d8cd98f00b204e9800998ecf8427e  file2

파일 변경.
shell> vi file2
This is a Test.

변경된 파일 md5 적용.
shell> mod5sum file2
66d64d41eb16e6eb4efc10480e52239a  file2

변경 전 후 해쉬 값 바교
file2 변경전 해쉬값: d41d8cd98f00b204e9800998ecf8427e  file2
file2 변경후 해쉬값: 66d64d41eb16e6eb4efc10480e52239a  file2

해쉬 값 정보 저장
shell> md5sum file1 > hash.txt
shell> md5sum file2 >> hash.txt

shell> cat hash.txt
d41d8cd98f00b204e9800998ecf8427e  file1
66d64d41eb16e6eb4efc10480e52239a  file2

sha1sum 해쉬 값 길이
shell> sha1sum file1 >> hash.txt

sha256sum 해쉬 값 길이
shell> sha256sum file >> hash.txt

해쉬값 표현 길이 차이 확인
shell> cat hash.txt
d41d8cd98f00b204e9800998ecf8427e  file1
66d64d41eb16e6eb4efc10480e52239a  file2
da39a3ee5e6b4b0d3255bfef95601890afd80709  file1
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  file1


shell> sudo fdisk -l

하드디스크 파티션 md5sum 확인(소요 시간 있음)
shell> sudo md5sum /dev/sdc1 >> hast.txt

shell> cat hast.txt

hash 세션 구문 추가.
shell> cat hash.txt

해쉬 값 생성.
shell> md5deep file1 >> hash.txt
shell> md5deep file2 >> hash.txt
shell> sha1deep file1 >> hash.txt
shell> sha256deep file1 >> hash.txt
shell> tigerdeep file1 >> hash.txt
shell> whirlpooldeep file1 >> hash.txt
shell> sudo md5deep -e /dev/sdc1 >> hash.txt

해쉬 생성 값 표현 길이 확인.
shell> cat hash.txt

파티션 정보 확인.
shell> sudo fdisk -l

이미지 생성.
shell> sudo dc3dd if=/dev/sdc1 of=/home/username/Desktop/flash.img

실행 권한.
shell> sudo chmod 777 flash.img

해시값 생성.
shell> md5deep -e flash.img > hash1.txt
shell> sudo md5deep -e /dev/sdc1 >> hash1.txt

생성된 해시 값 확인.
shell> cat hast1.txt

원본 파티션 파일 변경
shell> cd /media/username/Backup/
shell> vi 기본_텍스트파일.txt
This is a Test.

변경된 파일 해쉬 값 생성.
shell> sudo md5deep -e /dev/sdc1 >> hash1.txt

변경 해쉬 값 확인
shell> cat hash1.txt

shell> ssdeep flash.img > fuzzyhash.txt
shell> sudo ssdeep /dev/sdc1 >> fuzzyhash.txt

이미지와 파일 변경 사항 해시 값 확인
shell> ssdeep flash.img > fuzzyflash
shell> sudo ssdeep -m fuzzyflash /dev/sdc1

댓글 없음:

댓글 쓰기