Linux Forensics. Newbug Tseng Oct

Similar documents
Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1

Advanced Systems Security: Ordinary Operating Systems

File System (FS) Highlights

Important Dates. October 27 th Homework 2 Due. October 29 th Midterm

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

Design Choices 2 / 29

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

CS , Spring Sample Exam 3

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

The course that gives CMU its Zip! I/O Nov 15, 2001

Files and Directories Filesystems from a user s perspective

Operating System Labs. Yuanbin Wu

Lecture 23: System-Level I/O

structs as arguments

17: Filesystem Examples: CD-ROM, MS-DOS, Unix

File I/O. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Automated Test Generation in System-Level

Contents. NOTICE & Programming Assignment #1. QnA about last exercise. File IO exercise

UNIX System Calls. Sys Calls versus Library Func

System Calls. Library Functions Vs. System Calls. Library Functions Vs. System Calls

CS 201. Files and I/O. Gerson Robboy Portland State University

Operating System Labs. Yuanbin Wu

File I/O. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Memento: Time Travel for the Web

Contents. Programming Assignment 0 review & NOTICE. File IO & File IO exercise. What will be next project?

Thesis, antithesis, synthesis

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

System- Level I/O. Andrew Case. Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron

CS631 - Advanced Programming in the UNIX Environment

This is an example C code used to try out our codes, there several ways to write this but they works out all the same.

All the scoring jobs will be done by script

System-Level I/O. Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O

File Systems. q Files and directories q Sharing and protection q File & directory implementation

Contents. NOTICE & Programming Assignment 0 review. What will be next project? File IO & File IO exercise

All the scoring jobs will be done by script

File Systems. Today. Next. Files and directories File & directory implementation Sharing and protection. File system management & examples

System calls and assembler

HEC POSIX I/O API Extensions Rob Ross Mathematics and Computer Science Division Argonne National Laboratory

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

X86 Review Process Layout, ISA, etc. CS642: Computer Security. Drew Davidson

UNIX FILESYSTEM STRUCTURE BASICS By Mark E. Donaldson

System-Level I/O Nov 14, 2002

A Typical Hardware System The course that gives CMU its Zip! System-Level I/O Nov 14, 2002

Files and Directories Filesystems from a user s perspective

CS642: Computer Security

CSE 565 Computer Security Fall 2018

Penetration Testing with Kali Linux

Shell Code For Beginners

39. File and Directories

Master Calcul Scientifique - Mise à niveau en Informatique Written exam : 3 hours

Systems Programming/ C and UNIX

About unchecked management SMM & UEFI. Vulnerability. Patch. Conclusion. Bruno Pujos. July 16, Bruno Pujos

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows

File Input and Output (I/O)

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Files and Directories

Hackveda Training - Ethical Hacking, Networking & Security

Protecting Against Unexpected System Calls

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher

which maintain a name to inode mapping which is convenient for people to use. All le objects are

Strategic Infrastructure Security

Fundamentals of Linux Platform Security

Fundamentals of Linux Platform Security. Hands-On Network Security. Roadmap. Security Training Course. Module 1 Reconnaissance Tools

Reverse Engineering II: The Basics

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES

MODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE

Operating Systems. Processes

CSC209F Midterm (L0101) Fall 1999 University of Toronto Department of Computer Science

ELEC-C7310 Sovellusohjelmointi Lecture 3: Filesystem

OPERATING SYSTEMS: Lesson 2: Operating System Services

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software.

UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.

The x86 Architecture

Return-orientated Programming

Is stack overflow still a problem?

CSC 405 Computer Security Shellcode

Syscall Proxying. Simulating Remote Execution. Maximiliano Cáceres.

CSci 4061 Introduction to Operating Systems. File Systems: Basics

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

Function Call Convention

Hands-on Ethical Hacking: Preventing & Writing Buffer Overflow Exploits

Program Security and Vulnerabilities Class 2

Buffer Overflow Vulnerability

CSE 509: Computer Security

CSC 271 Software I: Utilities and Internals

Biography. Background

Università Ca Foscari Venezia

Files and Directories

Shellbased Wargaming

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19

Data Security and Privacy. Unix Discretionary Access Control

ETHICAL HACKING & COMPUTER FORENSIC SECURITY

Experiment 3 3 Basic Input Output

CSC369 Lecture 2. Larry Zhang

20: Exploits and Containment

System-Level I/O March 31, 2005

Chapter 2: System Structures

File Systems. CS 450: Operating Systems Sean Wallace Computer Science. Science

Transcription:

Linux Forensics Newbug Tseng Oct. 2004.

Contents Are u ready Go Real World Exploit Attack Detect

Are u ready

Linux File Permission OWNER 4 2 1 GROUP 4 2 1 OTHER 4 2 1 R R R W SUID on exection 4000 X W SGID on execution 2000 X W Sticky bit 1000 X

File Information man 2 stat struct stat { dev_t ino_t mode_t nlink_t uid_t gid_t dev_t off_t blksize_t blkcnt_t time_t time_t time_t }; st_dev; /* device */ st_ino; /* inode */ st_mode; /* protection */ st_nlink; /* number of hard links */ st_uid; /* user ID of owner */ st_gid; /* group ID of owner */ st_rdev; /* device type (if inode device) */ st_size; /* total size, in bytes */ st_blksize; /* blocksize for filesystem I/O */ st_blocks; /* number of blocks allocated */ st_atime; /* time of last access */ st_mtime; /* time of last modification */ st_ctime; /* time of last status change */

Go

Exploit Exploit: 1. A way of breaking into a system. 2 An exploit takes advantage of a weakness in a system in order to hack it.

Memory Layout Memory layout of a linux process

Stack Layout Low memory High memory a typical stack region

Stack Overflow

Stack Overflow (cont.)

Stack Overflow (cont.) Before overflow After overflow

Assembly Registers 32 bits EAX EBX ECX EDX 16 bits AX BX CX DX Intel-x86 8 bits (high) AH BH CH DH 8 bits (low) AL BL CL DL

Assembly (cont.) MOV move a value in a register. mov $0x4, %al mov %eax, %ebx PUSH Put a value in the stack POP Get a value from the stack and store it in a register of in a variable INT interrupt call int $0x80 it gives the control to the kernel

Shellcode

Shellcode (cont.)

Shellcode (cont.)

Shellcode (cont.)

Shellcode (cont.) Find System call number newbug@bugjun:/tmp$ grep write /usr/include/asm/unistd.h #define NR_write 4 Find System call arguments ssize_t write(int fd, const void *buf, size_t count); eax == write syscall no. ebx == fd ecx == address of buf edx == write length

Shellcode (cont.)

Shellcode (cont.)

Shellcode (cont.)

Simple Exploit

Simple Exploit (cont.)

Simple Exploit (cont.) General Overflow technique: 1. Stack based. 2. Heap based. 3. Format string.

Simple Exploit (cont.) By pass technique 1. ret-into-libc. 2. etc

Real World Exploit

Cdrecord Problem Description: Max Vozeler found that the cdrecord program, which is suid root, fails to drop euid=0 when it exec()s a program specified by the user through the $RSH environment variable. This can be abused by a local attacker to obtain root privileges.

Cdrecord (cont.)

Samba Problem Description: The problem is that an anonymous user can gain remote root access due to a buffer overflow vulnerability caused by a StrnCpy () into a character array fname using a non-constant length namelen : line 252 of smbd/trans2.c StrnCpy(fname,pname,namelen);

Samba (cont.)

Samba (cont.)

Samba (cont.)

Ptrace/kmod Problem Description: When a process requests a feature which is in a module, the kernel spawns a child process, sets its euid and egid to 0 and calls execve("/sbin/modprobe") The problem is that before the euid change the child process can be attached to with ptrace(). Game over, the user can insert any code into a process which will be run with the superuser privileges.

Ptrace/kmod (cont.)

Ptrace/kmod (cont.)

mremap Problem Description A critical security vulnerability has been found in the Linux kernel memory management code inside the mremap(2) system call due to missing function return value check.

mremap (cont.)

Attack

Before Attack Lock on Target / Just attack Collect information Vulnerability ( nessus / nmap etc) Remote Service Attack ( gain shell / DoS )

DNS Zone Transfer

Whois

Nmap

Nessus

Nessus (cont.)

Nessus (cont.)

Nessus (cont.)

Nessus (cont.)

After Local 0wn3d Password save / crack Hidden Yourself Backdoor Find sensitive information Find the way to intranet Find other targets Etc

Rip the password

Hide Yourself

Hide Yourself (cont.)

Hide Yourself (cont.)

Hide Yourself (cont.)

Hide Yourself (cont.) Others: All log in /var/log

B4ckd00r Suid Shell

B4ckd00r (cont.)

B4ckd00r (cont.) Bind Port

B4ckd00r (cont.)

B4ckd00r (cont.) Reverse connection backdoor

B4ckd00r (cont.)

B4ckd00r (cont.) Kernel b4ckd00r adore

B4ckd00r (cont.)

B4ckd00r (cont.)

B4ckd00r (cont.)

B4ckd00r (cont.)

B4ckd00r (cont.) Others ( icmp/telnetd/xinetd/portmap etc. )

Sniffer NIC turn to Promiscous Mode

Detect

DETECT User Indications Failed log-in attempts Log-ins to accounts that have not been used for an extended period of time Log-ins during hours other than non-working hours The presence of new user accounts that were not created by the system administrator su entries or logins from strange places, as well as repeated failed attempts

DETECT System Indications Modifications to system software and configuration files Gaps in system accounting that indicate that no activity has occurred for a long period of time Unusually slow system performance System crashes or reboots Short or incomplete logs Logs containing strange timestamps Logs with incorrect permissions or ownership Missing logs Abnormal system performance Unfamiliar processes Unusual graphic displays or text messages.

Netstat SYN scan

IPLog What is IPLog? iplog is a TCP/IP traffic logger. Currently, it is capable of logging TCP, UDP and ICMP traffic. Needed packages libpcap -- http://www.tcpdump.org/release/libpcap-0.8.3.tar.gz

IPLog (cont.) Install

IPLog (cont.) Nmap SYN scan

IPLog (cont.) Nmap FIN scan

IPLog (cont.) Nmap Xmas scan

IPLog (cont.) Nmap null scan

IPLog (cont.) Nessus scan

Analyze logfiles ~/.bash_history

Analyze logfiles (cont.) /var/log/sudo.log

Analyze logfiles (cont.) /var/log/auth.log

Analyze logfiles (cont.) /var/log/messages

Analyze logfiles (cont.) /var/log/secure

Analyze logfiles (cont.) /var/log/xferlog

Analyze logfiles (cont.) /var/log/samba/*

Analyze Traffic Use tcpdump tcpdump -i eth0 host 192.168.1.101 and port 9999

Analyze Traffic (cont.) Use sniffit

Detect Sniffer

Detect Sniffer (cont.)

Find B4ckd00r (cont.) Find Suid R00t backdoor

Find B4ckd00r (cont.) Find by timestamp (mtime)

Find B4ckd00r (cont.) Find by timestamp (ctime)

Find B4ckd00r (cont.) Use string

Find B4ckd00r (cont.) Use md5check

Find B4ckd00r (cont.) Use /proc

Find B4ckd00r (cont.) Use library hook

Find B4ckd00r (cont.)

Find B4ckd00r (cont.) lsof What is lsof? Lsof is a Unix-specific diagnostic tool. Its name stands for LiSt Open Files, and it does just that. It lists information about any files that are open by processes currently running on the system. It can also list communications open by each process.

Find B4ckd00r (cont.) Install

Find B4ckd00r (cont.) lsof grep daemon (daemon_active)

Find B4ckd00r (cont.) lsof grep daemon (daemon_passive)

Find B4ckd00r (cont.) chkrootkit What is chkrootkit? locally checks for signs of a rootkit.

Find B4ckd00r (cont.) Install

Find B4ckd00r (cont.)

Find B4ckd00r (cont.)

Find B4ckd00r (cont.)

Questions?

Reference The art of exploitation The Shellcoder s Handbook Adore lkm backdoor -- http://www.packetstormsecurity.org/groups/teso/adore-0.42.tgz Wipe -http://packetstormsecurity.org/unix/penetration/log-wipers/wipesniffit Page -http://reptile.rug.ac.be/~coder/sniffit/sniffit.html Tcpdump -- http://www.tcpdump.org/

Reference (cont.) Cdrecord Vuln http://www.securityfocus.com/advisories/7152 Ptrace/kmod Vuln -http://www.securityfocus.com/archive/1/315635 Samba Vuln -http://www.securityfocus.com/bid/7294/discussion/ Mremap Vuln -http://www.securityfocus.com/archive/1/355781 Lsof project -- http://freshmeat.net/projects/lsof/

Reference (cont.) Nmap http://www.insecure.org/nmap/index.html Nessus -- http://www.nessus.org/ Iplog -- http://ojnk.sourceforge.net/ Chkrootkit -- http://www.chkrootkit.org/ John the Ripper password cracker -http://www.openwall.com/john/

Thanks!