Lecture 1 Introduction
Total Page:16
File Type:pdf, Size:1020Kb
Lecture 1 Introduction. Basic Exploration Tools Computer and Network Security 30th of September 2019 Computer Science and Engineering Department CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 1/52 Outline Introduction Things You Need to Know Tools of the Trade (That You May or May Now Know) Basic Tools for Exploration Demo Conclusion CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 2/52 On this class I Computer and Network Security I offensive security, hacking, reverse engineering, runtime application security I programming/practical oriented I focus on binary exploitation (pwn levels in CTFs) I lecture: Monday, 6pm-8pm, room PR002, R˘azvan I labs: I Monday, 4pm-6pm, room PR706, S, tefania I Monday, 8pm-10pm, room PR706, Mihai I Monday, 8pm-10pm, room EG106, Adrian I Monday, 8pm-10pm, room EG306, Dennis I http://ocw.cs.pub.ro/cns/ I but first: https://ocw.cs.pub.ro/courses/cns/need-to-know I labs start on Monday, 30th of September 2019, 8pm I last instance of the first lab on Monday, 7th of October 2019, 4pm, room PR706 CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 3/52 The Team I R˘azvanDeaconescu: lectures, lecture tests, exam I Mihai Dumitru: labs, infrastructure I S, tefania Popescu: labs I Dennis Plosceanu: labs I Adrian S, endroiu: labs, assignments, lectures CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 4/52 Resources I wiki (content): http://ocw.cs.pub.ro/cns/ I Moodle (news, deadlines, exam, dicussions, links to content, feedback) I SRIC (enrolable) I SCPD (enrolable) I common/meta (not-enrolable, actually used) I Facebook (news, trivia): http://facebook.com/cns.upb I mailing list (news, dicussions): https://ocw.cs.pub.ro/courses/cns/resources/mailing-list I assignment write-only mailing-list (assignments): http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/oss-support I calendar & planning: https://ocw.cs.pub.ro/courses/cns/calendar I virtual machines (labs, assignments, CTFs): https://ocw.cs.pub.ro/courses/cns/resources/vm I CTF platform (assignments, labs): https://cns-ctf.security.cs.pub.ro/home I lab rooms: PR706, EG106, EG306 I team: to yell at CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 5/52 Lab Split I happens on the acs.curs.pub.ro Discussion forum I threads for each of the 4 lab slots I almost complete I you need to be enroled I you can enrol by yourself by accessing the CNS acs.curs.pub.ro instance I limit is 16 students per lab slot CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 6/52 Class Keywords I reverse engineering I shell execution I binary inspection I exploiting I stack overflow I runtime application security I buffer overflow I return oriented programming I shellcode I CTF (Capture the Flag) CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 7/52 Table of Contents planning: https://ocw.cs.pub.ro/courses/cns/calendar 1. Introduction. Basic Exploration Tools 2. Program Analysis 3. The Stack. Buffer Management 4. Exploiting. Shellcodes 5. Exploiting. Shellcodes (part 2) 6. Exploit Protection Mechanisms 7. Strings. Information Leaks 8. Return Oriented Programming 9. Return Oriented Programming (part 2) 10. Use After Free 11. Practical Attacks (part 1) 12. Practical Attacks (part 2) 13. Guest Lecture CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 8/52 Bibliography I Robert Seacord { Secure Coding in C and C++, Addison Wesley Professional, 2005 I Robert Seacord { The CERT C Secure Coding Standard, Addison Wesley Professional, 2008 I Anton Chuvakin, Cyrus Peikari { Security Warrior, O'Reilly, 2004 I Grey Hat Hacking. The Ethical Hacker's Handbook, 3rd Edition, McGraw Hill, 2011 I Enrico Perla, Massimiliano Oldani { A Guide to Kernel Exploitation, Syngress, 2011 I Jon Erickson { The Art of Exploitation, 2nd Edition, No Starch, 2008 I Michael A. Davis, Sean M. Bodmer, Aaron LeMasters { Hacking Exposed. Malware and Rootkits, McGraw Hill, 2010 I Bruce Schneier { Applied Cryptography, John Wiley & Sons, 1996 CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 9/52 Grading I 2 points { lab involvement I 4.5 points { 3 assignments I 2 points { lecture tests I 2.5 points { final exam CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 10/52 Tests during Lectures I at the beginning of lectures 3, 5, 7, 9, 11, from the past two lectures I start at 6:05pm; please don't be late I 10 minutes, 4 short questions I 0.4 points each CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 11/52 Final Exam I one part is a multiple answer questions test (22 questions, 20 minutes) I the other part is an on paper test (60 minutes) CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 12/52 CTF { Capture the Flag I computer security competition I educational, practice I attack/defense vs. jeopardy I web, stegano/forensics, crypto, binary/reverse, pwn/exploit, protocol, misc I wargames I may equate assignment points CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 13/52 Outline Introduction Things You Need to Know Tools of the Trade (That You May or May Now Know) Basic Tools for Exploration Demo Conclusion CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 14/52 C Programming Language I lingua franca of low-level programming I powerful enough to build amazing software and flexible enough to shoot yourself in the foot I close to hardware, everything is at some point coming from C code I direct access to memory management (buffers, strings, arrays, pointers): mixed blessing CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 15/52 Linux / Unix CLI. Shell Scripting I move around quickly I investigate, analyze system I quickly develop, build, debug, analyze applications I automate tasks CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 16/52 Assembly Language I everything turns to machine code I one may not have access to the source code, but it can be disassembled I hardware specific { the \guts" of the computer I required knowledge to fully be able to exploit and protect the system CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 17/52 Data Representation I binary, octal, hexadecimal I ASCII I signed / unsigned integers: size, range, 2's complement representation I endianess I there are 10 types of people in the world . I disassembled code, addresses and hardware instructions are shown in hexadecimal I one is required to easily convert hexadecimal to decimal and the other way around CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 18/52 Operating Systems I system and application inner workings I process virtual address space I application run time: CPU, memory, I/O usage I system calls, kernel space CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 19/52 Process Investigation I processes and resource usage: ps, pstree, pgrep, procfs filesystem I memory mappings: pmap I open file descriptors: lsof CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 20/52 If You Feel Lacking I this is a master class, you need to be on the level I work, work, work I C programming: https://ocw.cs.pub.ro/courses/programare I Linux / Unix CLI, shell scripting: https://ocw.cs.pub.ro/courses/uso I assembly language + hexadecimal: https://ocw.cs.pub.ro/courses/iocla I operating systems + process investigation: https://ocw.cs.pub.ro/courses/so CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 21/52 Outline Introduction Things You Need to Know Tools of the Trade (That You May or May Now Know) Basic Tools for Exploration Demo Conclusion CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 22/52 Scripting Languages I Python, Perl I automation I generate/print binary data and feed it to an executable I generate strings, generate variating integers & addresses I do redirects, make conversions, process strings CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 23/52 Python I quick'n'dirty scripting language I more powerful than shell scripting I create binary payloads (use struct package) I convert data I work with strings I work with files I work with processes (use subprocess package) I advanced exploit techniques (use pwn package) I use Python3, FTW!!! CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 24/52 Hex Viewers and Editors I dump and edit data in binary files (object files, executables, encrypted files) I hexdump, xxd, od: make hexdumps I hte: terminal hex editor I ghex, Bless: GUI hex editor CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 25/52 GDB I dynamic analysis I default debugger on Unix systems I may be used to trace programs, check variables and return values CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 26/52 PEDA I Python Exploit Development Assistance for GDB I enhance GDB for exploit development I improved commands I improved views I search for ROP gadgets I generate shellcodes I generate buffer cyclic patterns I http://ropshell.com/peda/ CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 27/52 Binary Code Analysis I inspect object and executable files I disassembling: objdump I forensics: strings I executable parsing: readelf, nm I dependencies: ldd CSE Dep, ACS, UPB Lecture 1, Introduction. Basic Exploration Tools 28/52 Call Tracing I dynamic analysis I capture system calls, function callls of program I check out system call arguments I check out system call return values I see whether process blocks in a system call I strace, ltrace CSE Dep, ACS, UPB Lecture 1, Introduction.