SlideShare a Scribd company logo
FORENSIC)INSIGHT;)
DIGITAL)FORENSICS)COMMUNITY)IN)KOREA
forensic.n0fate.com
Extracting typing history in
Unix Memory Image
forensicinsight.org
Contents
• Introduction to bash history	

• history management	

• Extracting bash history	

• Case study	

• Conclusion
forensicinsight.org
Bash
• Bourne-again shell	

• GNU 프로젝트를 위해 Brian Fox가 작성한 유
닉스 셸	

• GNU OS, Linux, Mac OS X 기본 셸	

• Cygwin이나 MinGW로 윈도에서 사용 가능	

• 명령 히스토리, 디렉터리 스택, $RANDOM
POSIX 형식 명령어 치환, 명령어 자동 완성
forensicinsight.org
Bash
• When started as an interactive login shell:	

• /etc/profile, ~/.bash_profile, ~/.bash_login,
/.profile	

• When a login shell exits : ~/.bash_logout	

• When started as an interactive shell :
~/.bashrc
forensicinsight.org
History Storage
• 사용자 명령어를 저장하여 추 후 해당 명령어
를 바로 실행 시킬 수 있게 함	

• ![HISTORY NUMBER]	

• 시간 값은 정의되어 있지 않으며, 실행한 명령
어를 ~/.bash_history에 순차적으로 기록	

• Mac OS X는 500개의 히스토리를 기록
forensicinsight.org
History Storage
• The history list is an array of history
entries
typedef void * histdata_t;	
typedef struct _hist_entry {	
char *line;	
char *timestamp;	
histdata_t data;	
} HIST_ENTRY;
/*	
* A structure used to pass around the current state of the history.	
*/	
typedef struct _hist_state {	
HIST_ENTRY **entries; /* Pointer to the entries themselves. */	
int offset; /* The location pointer within this array. */	
int length; /* Number of elements within this array. */	
int size; /* Number of slots allocated to this array. */	
int flags;	
} HISTORY_STATE;
reference : http://linux.die.net/man/3/history
forensicinsight.org
History Storage
HISTORY_STATE
HIST_ENTRY**
HIST_ENTRY
char* line
char* timestamp
void* data
HIST_ENTRY
char* line
char* timestamp
void* data
sudo port install build-essential
Thu Oct 24 08:35:36 2013
length	

(number of elements)
size (number of slots
allocated)
forensicinsight.org
Extracting bash history
• 1. Live Forensics	

• ~/.bash_history 파일 추출	

• History Functions 이용 (GNU History
library)	

• 2. Memory Forensics	

• 맵핑된history 파일 추출	

• bash 프로세스 영역에서 HIST_ENTRY 추출
forensicinsight.org
Extracting bash history
memory image
bash memory 1
bash memory 2
bash memory 3
bash memory 4
bash memory 5
bash process memory
TEXT
DATA
STACK
HEAP Space
LIBRARY
HEAP
0x7fdf68d00240 0x7fdf68d00240
0x7fdf68d00000
0x7fdf68e00000
HEAP
HEAP
forensicinsight.org
Extracting bash history
• DEMO
forensicinsight.org
Case Study
• 히스토리 타임스탬프 대부분이 동일한 이유	

!
• history -c 명령 이 후에도 추출 가능한가	

!
• 원격 접속 세션에서 history -c 실행
forensicinsight.org
Case Study
• 히스토리 타임스탬프 대부분이 동일한 이유?	

• 히스토리 파일에 시간 정보가 없음	

• 프로세스가 히스토리 파일을 로드하고, 로드
시간으로 파일 내의 모든 히스토리 시간 정보
를 저장	

• 즉, 신규 입력된 명령어 이전의 히스토리의 시
간 정보를 명령어 실행 시간으로 오해하면 안됨.
forensicinsight.org
Case Study
• 히스토리 타임스탬프 대부분이 동일한 이유?
0x6DCB74A8 11746 1 255 0 com.apple.audio. _netbios(501,20) (501,20) Fri Nov 15 04:45:30 2013 	

0x161C0C9E8 11767 1 255 0 com.apple.WebKit _netbios(501,20) (501,20) Fri Nov 15 04:48:47 2013 	

0x163B0AA80 11935 247 255 0 Terminal chainbreaker(501,20) (501,20) Fri Nov 15 05:19:13 2013 	

0x1F8E8F000 11944 11935 255 0 login chainbreaker(0,20) (0,20) Fri Nov 15 05:19:22 2013 	

0x16110E950 11945 11944 255 0 bash chainbreaker(501,20) (501,20) Fri Nov 15 05:19:22 2013 	

0x8917D7E0 11987 303 255 0 mdworker _spotlight(89,89) (89,89) Fri Nov 15 05:23:47 2013 	

0x18E5ED000 11988 11945 255 0 sudo chainbreaker(0,20) (0,20) Fri Nov 15 05:23:48 2013 	

0x87DFF748 11989 11988 255 0 osxpmem chainbreaker(0,0) (0,0) Fri Nov 15 05:23:48 2013 	

0x8657E540 11990 8781 255 0 thnuclnt chainbreaker(501,20) (501,20) Fri Nov 15 05:24:06 2013
11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o lsof	

11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o ps -x 1541	

11945 bash Fri Nov 15 05:19:22 2013 ls	

11945 bash Fri Nov 15 05:19:22 2013 file 1541-bash-	

11945 bash Fri Nov 15 05:19:22 2013 file 1541-bash-*	

11945 bash Fri Nov 15 05:19:22 2013 rm 1541-bash-*	

11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o ps | grep securityd	

11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o ps -x 14	

11945 bash Fri Nov 15 05:19:22 2013 ls	

11945 bash Fri Nov 15 05:19:22 2013 ls	

11945 bash Fri Nov 15 05:19:22 2013 clear	

11945 bash Fri Nov 15 05:19:22 2013 ls
forensicinsight.org
Case Study
• history -c 명령어 이 후 추출 가능 여부	

• 실험 방법	

• bash 프로세스 실행	

• 메모리 덤프 후 히스토리 추출	

• history -c 명령 실행 후, 히스토리 추출	

• 결론 : 시간 정보만 존재하고 명령어 삭제
forensicinsight.org
Case Study
• history -c 명령어 이 후 추출 가능 여부
11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:19:22 2013 	

11945 bash Fri Nov 15 05:23:41 2013 ./osxpmem -f raw historyc.bin	

11945 bash Fri Nov 15 05:23:48 2013 sudo ./osxpmem -f raw historyc.bin	

11945 bash Fri Nov 15 05:23:29 2013 ls	

11945 bash Fri Nov 15 05:20:05 2013
forensicinsight.org
Case Study
• 원격으로 붙은 쉘에서 history -c 를 실행	

• 실험 방법	

• bash 프로세스 여러 개 실행	

• 하나의 bash 프로세스에서 history -c 실행	

• 메모리 덤프 후 분석	

• 결론 : 해당 bash history 내역만 삭제
forensicinsight.org
Case Study
chainbreaker@testmachine:~/volafox$ python vol.py -i ../dump2.bin -o bash_history	

[+] PID : 328, PROCESS: bash, HISTORY COUNT: 40	

[+] PID : 586, PROCESS: bash, HISTORY COUNT: 19	

[+] PID : 619, PROCESS: bash, HISTORY COUNT: 0	

[+] PID : 769, PROCESS: bash, HISTORY COUNT: 4	

PID PROCESS TIME (UTC+0) CMD	

328 bash Fri Nov 15 06:11:12 2013 ls	

328 bash Fri Nov 15 06:12:24 2013 python vol.py -i ../after.bin -o uname	

328 bash Fri Nov 15 06:11:39 2013 cd volafox	

328 bash Fri Nov 15 05:31:35 2013 cd /tmp/	

328 bash Fri Nov 15 06:11:04 2013 ls	

328 bash Fri Nov 15 05:32:27 2013 sudo ./osxpmem -f raw after.bin	

328 bash Fri Nov 15 06:13:09 2013 clear	

328 bash Fri Nov 15 06:11:07 2013 sudo mv after.bin ~	

328 bash Fri Nov 15 05:31:27 2013 cat ~/.bash_history 	

328 bash Fri Nov 15 05:31:36 2013 ls	

328 bash Fri Nov 15 06:11:39 2013 ls	

328 bash Fri Nov 15 05:32:18 2013 ls -al	

328 bash Fri Nov 15 06:11:20 2013 sudo chown n0fate:staff after.bin 	

328 bash Fri Nov 15 06:11:27 2013 sudo chown chainbreaker:staff after.bin 	

328 bash Fri Nov 15 05:31:11 2013 ls	

328 bash Fri Nov 15 05:31:11 2013 ./osxpmem -f raw historyc.bin	

328 bash Fri Nov 15 05:31:11 2013 sudo ./osxpmem -f raw historyc.bin	

328 bash Fri Nov 15 05:31:11 2013 ls	

328 bash Fri Nov 15 05:31:11 2013 ls -al	

328 bash Fri Nov 15 05:31:11 2013 sudo mv *.bin ~	

328 bash Fri Nov 15 05:31:11 2013 cd ~	

328 bash Fri Nov 15 05:31:11 2013 sudo chown chainbreaker:staff *.bin	

328 bash Fri Nov 15 05:31:11 2013 chmod 664 *.bin	

328 bash Fri Nov 15 05:31:11 2013 ls -al	

328 bash Fri Nov 15 05:31:11 2013 cd volafox	

328 bash Fri Nov 15 05:31:11 2013 python vol.py -i ../dump.bin -o ps	

328 bash Fri Nov 15 05:31:11 2013 python vol.py -i ../dump.bin -o bash_history	

328 bash Fri Nov 15 05:31:11 2013 python vol.py -i ../historyc.bin -o bash_history	

328 bash Fri Nov 15 05:31:11 2013 sudo reboot	

328 bash Fri Nov 15 06:11:12 2013 cd ~	

328 bash Fri Nov 15 05:32:15 2013 lsa	

328 bash Fri Nov 15 05:32:11 2013 sudo chown -R root:wheel OSXPMem	

328 bash Fri Nov 15 05:32:02 2013 chown -R root:wheel OSXPMem	

328 bash Fri Nov 15 06:13:17 2013 history	

328 bash Fri Nov 15 05:32:15 2013 cd OSXPMem/	

328 bash Fri Nov 15 06:11:44 2013 python vol.py -i ../after.bin -o ps	

328 bash Fri Nov 15 06:12:47 2013 python vol.py -i ../after.bin -o ps	

328 bash Fri Nov 15 06:11:36 2013 sudo chmod 644 after.bin 	

328 bash Fri Nov 15 06:12:44 2013 python vol.py -i ../after.bin -o kextstat	

328 bash Fri Nov 15 06:13:51 2013 history	

586 bash Fri Nov 15 05:31:43 2013 cd Downloads/	

586 bash Fri Nov 15 05:31:41 2013 cd ~	

586 bash Fri Nov 15 05:31:41 2013 python vol.py -i ../dump.bin -o bash_history	

586 bash Fri Nov 15 05:31:41 2013 cd volafox	

586 bash Fri Nov 15 05:31:41 2013 python vol.py -i ../dump.bin -o ps	

586 bash Fri Nov 15 05:31:41 2013 ls -al	

586 bash Fri Nov 15 05:31:41 2013 sudo chown chainbreaker:staff *.bin	

586 bash Fri Nov 15 05:31:41 2013 chmod 664 *.bin	

586 bash Fri Nov 15 05:31:41 2013 ls	

586 bash Fri Nov 15 05:31:41 2013 ls	

586 bash Fri Nov 15 05:31:41 2013 sudo mv *.bin ~	

586 bash Fri Nov 15 05:31:41 2013 ./osxpmem -f raw historyc.bin	

586 bash Fri Nov 15 05:31:41 2013 sudo ./osxpmem -f raw historyc.bin	

586 bash Fri Nov 15 05:31:43 2013 ls	

586 bash Fri Nov 15 05:31:41 2013 python vol.py -i ../historyc.bin -o bash_history	

586 bash Fri Nov 15 05:31:41 2013 sudo reboot	

586 bash Fri Nov 15 05:31:41 2013 ls -al	

586 bash Fri Nov 15 05:31:48 2013 tar xvf OSXPMem-RC1.tar 	

586 bash Fri Nov 15 05:31:54 2013 mv OSXPMem /tmp	

769 bash Fri Nov 15 06:14:08 2013 cd OSXPMem/	

769 bash Fri Nov 15 06:14:22 2013 sudo ./osxpmem -f raw dump2.bin	

769 bash Fri Nov 15 06:14:01 2013 cd /tmp/	

769 bash Fri Nov 15 06:14:01 2013 ls	

chainbreaker@testmachine:~/volafox$
forensicinsight.org
Q & A
n0fate@n0fate.com

More Related Content

ODP
Linux Capabilities - eng - v2.1.5, compact
KEY
Python setup
PDF
Deploying Prometheus stacks with Juju
ODP
Eat my data
ODP
DiUS Computing Lca Rails Final
PDF
slides.pdf
KEY
Active Web Development
PDF
David container security-with_falco
Linux Capabilities - eng - v2.1.5, compact
Python setup
Deploying Prometheus stacks with Juju
Eat my data
DiUS Computing Lca Rails Final
slides.pdf
Active Web Development
David container security-with_falco

What's hot (20)

PDF
Git: An introduction of plumbing and porcelain commands
PPTX
eBPF Workshop
PDF
今日から始めるPlan 9 from Bell Labs
PPTX
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
PDF
Version Control and Git - GitHub Workshop
PDF
CentOS 7 入門
PDF
Bpf performance tools chapter 4 bcc
PDF
Low Overhead System Tracing with eBPF
PDF
Docker to the Rescue of an Ops Team
PDF
Python by Martin Geisler
PDF
Deconstruct 2017: All programmers MUST learn C and Assembly
PDF
IL: 失われたプロトコル
PDF
Linux System Monitoring with eBPF
PDF
Как HeadHunter удалось безопасно нарушить RFC 793 (TCP) и обойти сетевые лову...
ODP
Как HeadHunter удалось безопасно нарушить RFC 793 (TCP) и обойти сетевые лову...
PPTX
Git Crash Course
PDF
ch8-pv1-the-virtual-filesystem
PPTX
Understanding eBPF in a Hurry!
DOC
Update Lexia 3 DiagBox 7.61
PDF
Trace kernel code tips
Git: An introduction of plumbing and porcelain commands
eBPF Workshop
今日から始めるPlan 9 from Bell Labs
EuroPython 2014 - How we switched our 800+ projects from Apache to uWSGI
Version Control and Git - GitHub Workshop
CentOS 7 入門
Bpf performance tools chapter 4 bcc
Low Overhead System Tracing with eBPF
Docker to the Rescue of an Ops Team
Python by Martin Geisler
Deconstruct 2017: All programmers MUST learn C and Assembly
IL: 失われたプロトコル
Linux System Monitoring with eBPF
Как HeadHunter удалось безопасно нарушить RFC 793 (TCP) и обойти сетевые лову...
Как HeadHunter удалось безопасно нарушить RFC 793 (TCP) и обойти сетевые лову...
Git Crash Course
ch8-pv1-the-virtual-filesystem
Understanding eBPF in a Hurry!
Update Lexia 3 DiagBox 7.61
Trace kernel code tips
Ad

Viewers also liked (20)

PDF
(141031) #fitalk os x yosemite artifacts
PDF
(121013) #fitalk ie 10 forensics
PDF
(121202) #fitalk trends in d forensics (nov, 2012)
PDF
(130427) #fitalk digital evidence requires a c.a.
PDF
(120128) #fitalk sql server anti-forensics
PDF
Drama 1400
PDF
Drama Cempaka Berdarah
PDF
(120211) #fitalk sq lite record recovery
PDF
Drama Forum Remaja 2020
PPT
Internet Marketing
PDF
Lombokのススメ
PDF
(Fios#03) 1. 실전 윈도 악성코드 메모리 분석
PPTX
Hikayat Raja Pasai
PDF
(130608) #fitalk trends in d forensics (may, 2013)
PDF
(131102) #fitalk get windows logon password in memory dump
PDF
(130119) #fitalk all about physical data recovery
PDF
(130216) #fitalk potentially malicious ur ls
PDF
(130727) #fitalk rp log tracker
PDF
(130202) #fitalk trends in d forensics (jan, 2013)
PDF
(140716) #fitalk digital evidence from android-based smartwatch
(141031) #fitalk os x yosemite artifacts
(121013) #fitalk ie 10 forensics
(121202) #fitalk trends in d forensics (nov, 2012)
(130427) #fitalk digital evidence requires a c.a.
(120128) #fitalk sql server anti-forensics
Drama 1400
Drama Cempaka Berdarah
(120211) #fitalk sq lite record recovery
Drama Forum Remaja 2020
Internet Marketing
Lombokのススメ
(Fios#03) 1. 실전 윈도 악성코드 메모리 분석
Hikayat Raja Pasai
(130608) #fitalk trends in d forensics (may, 2013)
(131102) #fitalk get windows logon password in memory dump
(130119) #fitalk all about physical data recovery
(130216) #fitalk potentially malicious ur ls
(130727) #fitalk rp log tracker
(130202) #fitalk trends in d forensics (jan, 2013)
(140716) #fitalk digital evidence from android-based smartwatch
Ad

Similar to (131116) #fitalk extracting user typing history on bash in mac os x memory (20)

PDF
Linux 系統管理與安全:基本 Linux 系統知識
PDF
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
PDF
Linuxcommands 091018105536-phpapp01
PDF
Linux Commands - 3
PDF
Pledge in OpenBSD
PPTX
Linux command for beginners
PDF
Linea de comandos bioface zem800
PDF
Building an EmPyre with Python
PPTX
Linux for Security Professionals (Tips and Tricks) - Init 6 10/2012
PDF
Keynote 1 - Engineering Software Analytics Studies
ODP
Unix tips and tricks
PDF
unix_ref_card.pdf
PDF
unix_ref_card.pdf
PDF
unix_ref_card.pdf
PPT
Linux day 1
DOCX
Really useful linux commands
PDF
Linux seccomp(2) vs OpenBSD pledge(2)
PPTX
Linux training
DOCX
Linux audit-rules
PPT
Unix 5 en
Linux 系統管理與安全:基本 Linux 系統知識
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
Linuxcommands 091018105536-phpapp01
Linux Commands - 3
Pledge in OpenBSD
Linux command for beginners
Linea de comandos bioface zem800
Building an EmPyre with Python
Linux for Security Professionals (Tips and Tricks) - Init 6 10/2012
Keynote 1 - Engineering Software Analytics Studies
Unix tips and tricks
unix_ref_card.pdf
unix_ref_card.pdf
unix_ref_card.pdf
Linux day 1
Really useful linux commands
Linux seccomp(2) vs OpenBSD pledge(2)
Linux training
Linux audit-rules
Unix 5 en

More from INSIGHT FORENSIC (20)

PDF
(160820) #fitalk fileless malware forensics
PDF
(150124) #fitalk advanced $usn jrnl forensics (korean)
PDF
(150124) #fitalk advanced $usn jrnl forensics (english)
PDF
(140118) #fitalk detection of anti-forensics artifacts using ioa fs
PDF
(140118) #fitalk 2013 e-discovery trend
PDF
(141031) #fitalk plaso 슈퍼 타임라인 분석 도구 활용 방안
PDF
(140716) #fitalk 전자금융사고에서의 디지털 포렌식
PDF
(140625) #fitalk sq lite 소개와 구조 분석
PDF
(140407) #fitalk d trace를 이용한 악성코드 동적 분석
PDF
(140625) #fitalk sq lite 삭제된 레코드 복구 기법
PDF
(130216) #fitalk reverse connection tool analysis
PDF
(130202) #fitalk china threat
PDF
(130119) #fitalk sql server forensics
PDF
(130119) #fitalk apt, cyber espionage threat
PDF
(130105) #fitalk trends in d forensics (dec, 2012)
PDF
(130105) #fitalk criminal civil judicial procedure in korea
PDF
(130928) #fitalk cloud storage forensics - dropbox
PDF
(130907) #fitalk generating volatility linux profile
PDF
(130727) #fitalk pfp (portable forensic platform), #2 story
PDF
(130727) #fitalk anonymous network concepts and implementation
(160820) #fitalk fileless malware forensics
(150124) #fitalk advanced $usn jrnl forensics (korean)
(150124) #fitalk advanced $usn jrnl forensics (english)
(140118) #fitalk detection of anti-forensics artifacts using ioa fs
(140118) #fitalk 2013 e-discovery trend
(141031) #fitalk plaso 슈퍼 타임라인 분석 도구 활용 방안
(140716) #fitalk 전자금융사고에서의 디지털 포렌식
(140625) #fitalk sq lite 소개와 구조 분석
(140407) #fitalk d trace를 이용한 악성코드 동적 분석
(140625) #fitalk sq lite 삭제된 레코드 복구 기법
(130216) #fitalk reverse connection tool analysis
(130202) #fitalk china threat
(130119) #fitalk sql server forensics
(130119) #fitalk apt, cyber espionage threat
(130105) #fitalk trends in d forensics (dec, 2012)
(130105) #fitalk criminal civil judicial procedure in korea
(130928) #fitalk cloud storage forensics - dropbox
(130907) #fitalk generating volatility linux profile
(130727) #fitalk pfp (portable forensic platform), #2 story
(130727) #fitalk anonymous network concepts and implementation

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Electronic commerce courselecture one. Pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation theory and applications.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Spectroscopy.pptx food analysis technology
Assigned Numbers - 2025 - Bluetooth® Document
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
The AUB Centre for AI in Media Proposal.docx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Network Security Unit 5.pdf for BCA BBA.
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Electronic commerce courselecture one. Pdf
sap open course for s4hana steps from ECC to s4
Encapsulation theory and applications.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced methodologies resolving dimensionality complications for autism neur...

(131116) #fitalk extracting user typing history on bash in mac os x memory

  • 2. forensicinsight.org Contents • Introduction to bash history • history management • Extracting bash history • Case study • Conclusion
  • 3. forensicinsight.org Bash • Bourne-again shell • GNU 프로젝트를 위해 Brian Fox가 작성한 유 닉스 셸 • GNU OS, Linux, Mac OS X 기본 셸 • Cygwin이나 MinGW로 윈도에서 사용 가능 • 명령 히스토리, 디렉터리 스택, $RANDOM POSIX 형식 명령어 치환, 명령어 자동 완성
  • 4. forensicinsight.org Bash • When started as an interactive login shell: • /etc/profile, ~/.bash_profile, ~/.bash_login, /.profile • When a login shell exits : ~/.bash_logout • When started as an interactive shell : ~/.bashrc
  • 5. forensicinsight.org History Storage • 사용자 명령어를 저장하여 추 후 해당 명령어 를 바로 실행 시킬 수 있게 함 • ![HISTORY NUMBER] • 시간 값은 정의되어 있지 않으며, 실행한 명령 어를 ~/.bash_history에 순차적으로 기록 • Mac OS X는 500개의 히스토리를 기록
  • 6. forensicinsight.org History Storage • The history list is an array of history entries typedef void * histdata_t; typedef struct _hist_entry { char *line; char *timestamp; histdata_t data; } HIST_ENTRY; /* * A structure used to pass around the current state of the history. */ typedef struct _hist_state { HIST_ENTRY **entries; /* Pointer to the entries themselves. */ int offset; /* The location pointer within this array. */ int length; /* Number of elements within this array. */ int size; /* Number of slots allocated to this array. */ int flags; } HISTORY_STATE; reference : http://linux.die.net/man/3/history
  • 7. forensicinsight.org History Storage HISTORY_STATE HIST_ENTRY** HIST_ENTRY char* line char* timestamp void* data HIST_ENTRY char* line char* timestamp void* data sudo port install build-essential Thu Oct 24 08:35:36 2013 length (number of elements) size (number of slots allocated)
  • 8. forensicinsight.org Extracting bash history • 1. Live Forensics • ~/.bash_history 파일 추출 • History Functions 이용 (GNU History library) • 2. Memory Forensics • 맵핑된history 파일 추출 • bash 프로세스 영역에서 HIST_ENTRY 추출
  • 9. forensicinsight.org Extracting bash history memory image bash memory 1 bash memory 2 bash memory 3 bash memory 4 bash memory 5 bash process memory TEXT DATA STACK HEAP Space LIBRARY HEAP 0x7fdf68d00240 0x7fdf68d00240 0x7fdf68d00000 0x7fdf68e00000 HEAP HEAP
  • 11. forensicinsight.org Case Study • 히스토리 타임스탬프 대부분이 동일한 이유 ! • history -c 명령 이 후에도 추출 가능한가 ! • 원격 접속 세션에서 history -c 실행
  • 12. forensicinsight.org Case Study • 히스토리 타임스탬프 대부분이 동일한 이유? • 히스토리 파일에 시간 정보가 없음 • 프로세스가 히스토리 파일을 로드하고, 로드 시간으로 파일 내의 모든 히스토리 시간 정보 를 저장 • 즉, 신규 입력된 명령어 이전의 히스토리의 시 간 정보를 명령어 실행 시간으로 오해하면 안됨.
  • 13. forensicinsight.org Case Study • 히스토리 타임스탬프 대부분이 동일한 이유? 0x6DCB74A8 11746 1 255 0 com.apple.audio. _netbios(501,20) (501,20) Fri Nov 15 04:45:30 2013 0x161C0C9E8 11767 1 255 0 com.apple.WebKit _netbios(501,20) (501,20) Fri Nov 15 04:48:47 2013 0x163B0AA80 11935 247 255 0 Terminal chainbreaker(501,20) (501,20) Fri Nov 15 05:19:13 2013 0x1F8E8F000 11944 11935 255 0 login chainbreaker(0,20) (0,20) Fri Nov 15 05:19:22 2013 0x16110E950 11945 11944 255 0 bash chainbreaker(501,20) (501,20) Fri Nov 15 05:19:22 2013 0x8917D7E0 11987 303 255 0 mdworker _spotlight(89,89) (89,89) Fri Nov 15 05:23:47 2013 0x18E5ED000 11988 11945 255 0 sudo chainbreaker(0,20) (0,20) Fri Nov 15 05:23:48 2013 0x87DFF748 11989 11988 255 0 osxpmem chainbreaker(0,0) (0,0) Fri Nov 15 05:23:48 2013 0x8657E540 11990 8781 255 0 thnuclnt chainbreaker(501,20) (501,20) Fri Nov 15 05:24:06 2013 11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o lsof 11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o ps -x 1541 11945 bash Fri Nov 15 05:19:22 2013 ls 11945 bash Fri Nov 15 05:19:22 2013 file 1541-bash- 11945 bash Fri Nov 15 05:19:22 2013 file 1541-bash-* 11945 bash Fri Nov 15 05:19:22 2013 rm 1541-bash-* 11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o ps | grep securityd 11945 bash Fri Nov 15 05:19:22 2013 python vol.py -i ../test.mem -o ps -x 14 11945 bash Fri Nov 15 05:19:22 2013 ls 11945 bash Fri Nov 15 05:19:22 2013 ls 11945 bash Fri Nov 15 05:19:22 2013 clear 11945 bash Fri Nov 15 05:19:22 2013 ls
  • 14. forensicinsight.org Case Study • history -c 명령어 이 후 추출 가능 여부 • 실험 방법 • bash 프로세스 실행 • 메모리 덤프 후 히스토리 추출 • history -c 명령 실행 후, 히스토리 추출 • 결론 : 시간 정보만 존재하고 명령어 삭제
  • 15. forensicinsight.org Case Study • history -c 명령어 이 후 추출 가능 여부 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:19:22 2013 11945 bash Fri Nov 15 05:23:41 2013 ./osxpmem -f raw historyc.bin 11945 bash Fri Nov 15 05:23:48 2013 sudo ./osxpmem -f raw historyc.bin 11945 bash Fri Nov 15 05:23:29 2013 ls 11945 bash Fri Nov 15 05:20:05 2013
  • 16. forensicinsight.org Case Study • 원격으로 붙은 쉘에서 history -c 를 실행 • 실험 방법 • bash 프로세스 여러 개 실행 • 하나의 bash 프로세스에서 history -c 실행 • 메모리 덤프 후 분석 • 결론 : 해당 bash history 내역만 삭제
  • 17. forensicinsight.org Case Study chainbreaker@testmachine:~/volafox$ python vol.py -i ../dump2.bin -o bash_history [+] PID : 328, PROCESS: bash, HISTORY COUNT: 40 [+] PID : 586, PROCESS: bash, HISTORY COUNT: 19 [+] PID : 619, PROCESS: bash, HISTORY COUNT: 0 [+] PID : 769, PROCESS: bash, HISTORY COUNT: 4 PID PROCESS TIME (UTC+0) CMD 328 bash Fri Nov 15 06:11:12 2013 ls 328 bash Fri Nov 15 06:12:24 2013 python vol.py -i ../after.bin -o uname 328 bash Fri Nov 15 06:11:39 2013 cd volafox 328 bash Fri Nov 15 05:31:35 2013 cd /tmp/ 328 bash Fri Nov 15 06:11:04 2013 ls 328 bash Fri Nov 15 05:32:27 2013 sudo ./osxpmem -f raw after.bin 328 bash Fri Nov 15 06:13:09 2013 clear 328 bash Fri Nov 15 06:11:07 2013 sudo mv after.bin ~ 328 bash Fri Nov 15 05:31:27 2013 cat ~/.bash_history 328 bash Fri Nov 15 05:31:36 2013 ls 328 bash Fri Nov 15 06:11:39 2013 ls 328 bash Fri Nov 15 05:32:18 2013 ls -al 328 bash Fri Nov 15 06:11:20 2013 sudo chown n0fate:staff after.bin 328 bash Fri Nov 15 06:11:27 2013 sudo chown chainbreaker:staff after.bin 328 bash Fri Nov 15 05:31:11 2013 ls 328 bash Fri Nov 15 05:31:11 2013 ./osxpmem -f raw historyc.bin 328 bash Fri Nov 15 05:31:11 2013 sudo ./osxpmem -f raw historyc.bin 328 bash Fri Nov 15 05:31:11 2013 ls 328 bash Fri Nov 15 05:31:11 2013 ls -al 328 bash Fri Nov 15 05:31:11 2013 sudo mv *.bin ~ 328 bash Fri Nov 15 05:31:11 2013 cd ~ 328 bash Fri Nov 15 05:31:11 2013 sudo chown chainbreaker:staff *.bin 328 bash Fri Nov 15 05:31:11 2013 chmod 664 *.bin 328 bash Fri Nov 15 05:31:11 2013 ls -al 328 bash Fri Nov 15 05:31:11 2013 cd volafox 328 bash Fri Nov 15 05:31:11 2013 python vol.py -i ../dump.bin -o ps 328 bash Fri Nov 15 05:31:11 2013 python vol.py -i ../dump.bin -o bash_history 328 bash Fri Nov 15 05:31:11 2013 python vol.py -i ../historyc.bin -o bash_history 328 bash Fri Nov 15 05:31:11 2013 sudo reboot 328 bash Fri Nov 15 06:11:12 2013 cd ~ 328 bash Fri Nov 15 05:32:15 2013 lsa 328 bash Fri Nov 15 05:32:11 2013 sudo chown -R root:wheel OSXPMem 328 bash Fri Nov 15 05:32:02 2013 chown -R root:wheel OSXPMem 328 bash Fri Nov 15 06:13:17 2013 history 328 bash Fri Nov 15 05:32:15 2013 cd OSXPMem/ 328 bash Fri Nov 15 06:11:44 2013 python vol.py -i ../after.bin -o ps 328 bash Fri Nov 15 06:12:47 2013 python vol.py -i ../after.bin -o ps 328 bash Fri Nov 15 06:11:36 2013 sudo chmod 644 after.bin 328 bash Fri Nov 15 06:12:44 2013 python vol.py -i ../after.bin -o kextstat 328 bash Fri Nov 15 06:13:51 2013 history 586 bash Fri Nov 15 05:31:43 2013 cd Downloads/ 586 bash Fri Nov 15 05:31:41 2013 cd ~ 586 bash Fri Nov 15 05:31:41 2013 python vol.py -i ../dump.bin -o bash_history 586 bash Fri Nov 15 05:31:41 2013 cd volafox 586 bash Fri Nov 15 05:31:41 2013 python vol.py -i ../dump.bin -o ps 586 bash Fri Nov 15 05:31:41 2013 ls -al 586 bash Fri Nov 15 05:31:41 2013 sudo chown chainbreaker:staff *.bin 586 bash Fri Nov 15 05:31:41 2013 chmod 664 *.bin 586 bash Fri Nov 15 05:31:41 2013 ls 586 bash Fri Nov 15 05:31:41 2013 ls 586 bash Fri Nov 15 05:31:41 2013 sudo mv *.bin ~ 586 bash Fri Nov 15 05:31:41 2013 ./osxpmem -f raw historyc.bin 586 bash Fri Nov 15 05:31:41 2013 sudo ./osxpmem -f raw historyc.bin 586 bash Fri Nov 15 05:31:43 2013 ls 586 bash Fri Nov 15 05:31:41 2013 python vol.py -i ../historyc.bin -o bash_history 586 bash Fri Nov 15 05:31:41 2013 sudo reboot 586 bash Fri Nov 15 05:31:41 2013 ls -al 586 bash Fri Nov 15 05:31:48 2013 tar xvf OSXPMem-RC1.tar 586 bash Fri Nov 15 05:31:54 2013 mv OSXPMem /tmp 769 bash Fri Nov 15 06:14:08 2013 cd OSXPMem/ 769 bash Fri Nov 15 06:14:22 2013 sudo ./osxpmem -f raw dump2.bin 769 bash Fri Nov 15 06:14:01 2013 cd /tmp/ 769 bash Fri Nov 15 06:14:01 2013 ls chainbreaker@testmachine:~/volafox$