SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Downloaden Sie, um offline zu lesen
The Linux Kernel Internal
Agenda
• Linux Kernel Booting Process
• How To Make Your Own Kernel OS
• Anatomy of Linux Kernel Development
• System Call
• Kernel Security (Bugs/Vulnerability)
And Kernel Fuzzing
Who Am I?
• Cyber Security Researcher
• Bug Bounty Program
(Google, Twitter, Yahoo, Apple, Ebay, Blackberry, etc)
• Linux Exploit Developer
• Malware Analysis
• Linux System Programmer
• Linux Kernel/Device Developer
• Windows System Programmer
• Django Contributor
Type of OS
• Personal OS : Linux, Unix, MaCOS , etc
• Mobile OS : Android, iOS, WinPhone, UIQ, etc
• Real-Time OS : VxWork (NASA), QNX, RTLinux, etc
• Network OS : Router OS, Switch OS, etc
• Distributed OS : Internet, Telephone networks
Linux Kernel
Android Device Linux Kernels Source
• Google: https://android.googlesource.com/kernel/msm/
• HTC: https://www.htcdev.com/devcenter/downloads
• OnePluseOS : https://github.com/OnePlusOSS/android_kernel_oneplus_msm8996
• Moto X : https://github.com/MotorolaMobilityLLC/kernel-
msm
• Sony : https://github.com/sonyxperiadev/kernel
The Linux Boot Process
The Linux Boot Process
• BIOS (Basic Input/Output System)
The processor executes code at a well-known location In a personal
computer (PC), which is stored in flash memory on the
motherboard.
booting Linux begins in the BIOS at address 0xFFFF0.
When your computer boots—and after the POST finishes—the BIOS
looks for a Master Boot Record, or MBR, stored on the boot device
and uses it to launch the bootloader (GRUB).
The BIOS will soon be dead
• UEFI plans to completely replace it with UEFI on all their chipsets by 2020.
BIOS Tools
• apt-cache search bios | grep –i bios
• apt-get source phnxdeco (phonix tech)
• Security advisory (Intel):
https://edk2-docs.gitbooks.io/security-advisory/content/
• Security Tool:
Platform Security Assessment Framework
https://github.com/chipsec/chipsec
• Attacking and Defending BIOS in 2015
• http://c7zero.info/stuff/AttackingAndDefendingBIOS-RECon2015.pdf
Bootkit Malware
What is bootkit?
Malware that executes before the operating system boots.
Malwares:
FIN1 : Network protocols and communication channels for command and control (C2C).
Including: file transfer (http DLL web shell), screen capture, keystroke logging, process injection
BOOTRASH :
File Content : Core.sys, vfs.sys and etc
Including : Services, Run keys, Scheduled tasks, Startup folders
Article :
https://www.fireeye.com/blog/threat-research/2015/12/fin1-
targets-boot-record.html
DISKS, PARTITIONS, VOLUMES
Normal boot process windows
Hijacked boot process
What is UEFI?
• You need to buy new hardware that supports and includes UEFI.
• UEFI firmware can boot from drives of 2.2 TB or larger.
• UEFI can run in 32-bit or 64-bit mode.
• Your boot process is faster.
• UEFI screens can be slicker than BIOS settings screens, including graphics and
mouse cursor support.
• UEFI supports Secure Boot, which means the operating system can be checked
for validity to ensure no malware has tampered with the boot process.
• UEFI support networking features.
• UEFI is modular.
• Analyzing UEFI BIOSes from attacking [ BH 2014 ]
(https://youtu.be/CGBpil0S5NI)
UEFI
UEFI Rootkit Malware (LoJax)
• How malware works:
– Information dumping tool:
– RwDrv.sys driver, attackers reads the information on your UEFI BIOS.
This information is then saved to a text file. This step helps the
malware understand the victim system.
– System Firmware Image Creation :
– Firmware Image of SPI Flash Memory where the UEFI/BIOS is
located. This image is then again saved to a file.
– Rootkit Installation:
– The firmware image is infected. This infected Firmware image is
then installed onto the SPI Flash Memory
OS drivers dangerous for BIOS
Create malware is important for country
ICS (Industrial Control Systems) malware
• 2010 Stuxnet : This cyber weapon was created to target
Iranian centrifuges.
• 2013 Havex : Targeted energy grids, electricity firms,
and many others.
• 2015 BlackEnergy : It targeted critical infrastructure
and destroyed files stored on workstations and servers.
In Ukraine.
• 2015 IronGate : It targeted Siemens control systems
and had functionalities similar to Stuxnet’s.
• 2016 Industroyer : The attack caused a second
shutdown of Ukraine’s power grid.
• 2017 Triton : The attack did not succeed
What Is BootLoader?
• It is the part that starts the system up
and loads the operating system kernel
• Bootloader has two main jobs:
• [1] Initialize the system to a basic level
(MBR) and to [2] Load the kernel.
Type Bootloder
First stage bootloader = MBR
MBR (Master Boot Record)
• MBR :
The first 446 bytes are the primary boot loader, which
contains both executable code and error message text
The next sixty-four bytes are the partition table, which
contains a record for each of four partitions The MBR
ends with two bytes that are defined as the magic
number (0xAA55)
Extracting the MBR
# dd if=/dev/hda of=mbr.bin bs=512 count=1
# od -xa mbr.bin
Partition table information of MBR
• # file mbr.bin
mbr.bin: x86 boot sector; partition 1: ID=0x83, active,
starthead 32, startsector 2048, 19451904 sectors;
partition 2: ID=0x5, starthead 254, startsector 19455998,
2093058 sectors, code offset 0x63
Second stage bootloader
Splash screen is commonly displayed, and Linux and an optional initial RAM
disk (temporary root file system) are loaded into memory.
second-stage, boot loader called the kernel loader. The task at this stage is to load
the Linux kernel and optional initial RAM disk.
Second stage = GRUB and etc
Type of bootloader :
1- Grub
2- LILO
3- GRand
4- …
GRUB
Good knowledge of Linux file system. Instead of using raw
sectors on the disk, as LILO.
GRUB can load a Linux kernel from an ext2 or ext3 file system
Stage 1 (MBR) + Stage 1.5 + Stage 2 (GRUB)
What is stage 1.5?
stage 1.5 boot loader that understands the particular file
system containing the Linux kernel image.
Examples :
CR-ROMs use the iso9660_stage_1_5
Ext2 or ext3 file system use the e2fs_stage1_5
GRUB *.cfg (Stage 1.5  Stage 2 loaded)
GRUB GUIDE
Refs:
https://thestarman.pcministry.com/asm/mbr/GRUB.htm
http://people.ds.cam.ac.uk/fanf2/hermes/src/grub-e1000/
https://www.gnu.org/software/grub/manual/grub/grub.html#Ge
neral-boot-methods
https://github.com/coreos/grub/blob/93fb3dac4ae7a97c080d51
d951d0e5a3109aaac7/grub-core/kern/main.c
Understanding the Various Grub Modules
$ ls /boot/grub/x86_64-efi/
/boot/grub/x86_64-efi/915resolution.mod
…
Grub module :
https://github.com/coreos/grub/tree/2.02-coreos/grub-core
Grub module error: file `/boot/grub/*/*.mod not found.
Load kernel image with GRUB
grub> kernel /bzImage-<version>
[Linux-bzImage, setup=0x1400, size=0x29672e]
grub> initrd /initrd-<version>.img
[Linux-initrd @ 0x5f13000, 0xcc199 bytes]
grub> boot
Uncompressing Linux... Ok, booting the kernel.
Refs install manual : http://tinycorelinux.net/install_manual.html
Count of Line Code Ubuntu Kernel
Count of Line Code Main Kernel
Kernel Boot Road Map
Underestand of Kernel Image
vmlinux: Plain linux ELF file just the way it was created by the
linker, including symbols and everything.
vmlinuz:Gzipped vmlinux file which got stripped of all its
symbols
zImage:bootsect.o + setup.o + misc.o + piggy.o (piggy.o contains
the piggy-backed vmlinuz).
zImage : is bootable because it can decompress and run the
kernel it contains.
bzImage: Same as zImage except that it is built slightly
differently which enables it to carry bigger kernels.
Vmlinux to Vmlinuz (make bzImage)
Vmlinux
• Vmlinux is a ELF format,
• How to get ELF format?
• Download kernel source of https://kernel.com and
compiled, or use $ apt-get source linux
Vmlinuz
• $ sudo file /boot/vmlinuz-4.15.0-041500rc8-generic
• /boot/vmlinuz-4.15.0-041500rc8-generic: Linux kernel
x86 boot executable bzImage, version 4.15.0-
041500rc8-generic (kernel@gloin) #201801142030
SMP Mon Jan 15 01:31:43 UTC 2018, RO-rootFS,
swap_dev 0x7, Normal VGA
Kernel Start Up
Kernel Image Process
• Kernel image (bzImage) load to Memory and kernel stage started …
• Typically zImage compressed image, less than 512KB a bzImage (big compressed
image, greater than 512KB)
• When the bzImage (for an i386 image) is invoked, you begin at
./arch/i386/boot/head.S in the start assembly routine
• The kernel is then decompressed (./arch/i386/boot/compressed/misc.c) through a
call to a C function called decompress_kernel function
• When the kernel is decompressed into memory, it is called. This is yet another
startup_32 function, but this function is in ./arch/i386/kernel/head.S.
• More info : https://www.slideshare.net/itembedded/linux-kernel-image
Kernel Overview
Kernel Source x86
Kernel Source ARM
Kernel Source Tree
• Github linux kernel source tree :
– https://github.com/torvalds/linux
• Bootlin kernel source tree :
– https://elixir.bootlin.com/linux/latest/source
Kernel Type Mode
• Real Mode
• Protected Mode
• Long Mode
Architecture Linux Kernel Initialization
Kernel Boot Paging (Virtual Memory)
Real Mode Kernel
Real Mode Boot sector (header.S)
Kernel Real Mode (setup_header)
Kernel Real Mode (setup_header)
Struct set_header (header.S)
Kernel Real Mode Stack (header.S)
Kernel Real Mode to C (header.S -> main.c)
Kernel Real Mode Main.c
Copy header to zeropage
Start_kernel Initialization

Weitere ähnliche Inhalte

Was ist angesagt?

600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)
600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)
600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)iXsystems
 
Kernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using BuildrootKernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using BuildrootAnne Nicolas
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semSagun Baijal
 
Kernel Configuration and Compilation
Kernel Configuration and CompilationKernel Configuration and Compilation
Kernel Configuration and CompilationBud Siddhisena
 
BeagleBone Black with Upstream Software
BeagleBone Black with Upstream SoftwareBeagleBone Black with Upstream Software
BeagleBone Black with Upstream SoftwareGlobalLogic Ukraine
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchlinuxlab_conf
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
 
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generator
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generatorKernel Recipes 2013 - Crosstool-NG, a cross-toolchain generator
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generatorAnne Nicolas
 
Development platform virtualization using qemu
Development platform virtualization using qemuDevelopment platform virtualization using qemu
Development platform virtualization using qemuPremjith Achemveettil
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot) Omkar Rane
 
2015.10.05 Updated > Network Device Development - Part 2: Firewall 101
2015.10.05 Updated > Network Device Development - Part 2: Firewall 1012015.10.05 Updated > Network Device Development - Part 2: Firewall 101
2015.10.05 Updated > Network Device Development - Part 2: Firewall 101Cheng-Yi Yu
 
Introduction to FreeNAS development by John Hixson
Introduction to FreeNAS development by John HixsonIntroduction to FreeNAS development by John Hixson
Introduction to FreeNAS development by John HixsoniXsystems
 
Andrea Righi - Spying on the Linux kernel for fun and profit
Andrea Righi - Spying on the Linux kernel for fun and profitAndrea Righi - Spying on the Linux kernel for fun and profit
Andrea Righi - Spying on the Linux kernel for fun and profitlinuxlab_conf
 
2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: Switch2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: SwitchCheng-Yi Yu
 

Was ist angesagt? (20)

600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)
600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)
600M+ Unsuspecting FreeBSD Users (MeetBSD California 2014)
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Kernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using BuildrootKernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using Buildroot
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
 
Kernel Configuration and Compilation
Kernel Configuration and CompilationKernel Configuration and Compilation
Kernel Configuration and Compilation
 
BeagleBone Black with Upstream Software
BeagleBone Black with Upstream SoftwareBeagleBone Black with Upstream Software
BeagleBone Black with Upstream Software
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
SwiftyGPIO
SwiftyGPIOSwiftyGPIO
SwiftyGPIO
 
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generator
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generatorKernel Recipes 2013 - Crosstool-NG, a cross-toolchain generator
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generator
 
Development platform virtualization using qemu
Development platform virtualization using qemuDevelopment platform virtualization using qemu
Development platform virtualization using qemu
 
Sweden11
Sweden11Sweden11
Sweden11
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
 
2015.10.05 Updated > Network Device Development - Part 2: Firewall 101
2015.10.05 Updated > Network Device Development - Part 2: Firewall 1012015.10.05 Updated > Network Device Development - Part 2: Firewall 101
2015.10.05 Updated > Network Device Development - Part 2: Firewall 101
 
Introduction to FreeNAS development by John Hixson
Introduction to FreeNAS development by John HixsonIntroduction to FreeNAS development by John Hixson
Introduction to FreeNAS development by John Hixson
 
Mak3
Mak3Mak3
Mak3
 
Andrea Righi - Spying on the Linux kernel for fun and profit
Andrea Righi - Spying on the Linux kernel for fun and profitAndrea Righi - Spying on the Linux kernel for fun and profit
Andrea Righi - Spying on the Linux kernel for fun and profit
 
2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: Switch2015.10.05 Updated > Network Device Development - Part 1: Switch
2015.10.05 Updated > Network Device Development - Part 1: Switch
 
coreboot@Budapest 10.2009 Meetup
coreboot@Budapest 10.2009 Meetupcoreboot@Budapest 10.2009 Meetup
coreboot@Budapest 10.2009 Meetup
 

Ähnlich wie Linux kernel booting

Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theoryEmbedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theoryEmbeddedFest
 
Linux booting process, Dual booting, Components involved
Linux booting process, Dual booting, Components involvedLinux booting process, Dual booting, Components involved
Linux booting process, Dual booting, Components involveddivyammo
 
Introduction to Operating Systems.pptx
Introduction to Operating Systems.pptxIntroduction to Operating Systems.pptx
Introduction to Operating Systems.pptxMohamedSaied877003
 
Android bootup process
Android bootup processAndroid bootup process
Android bootup processSanjay Kumar
 
Linux booting Process
Linux booting ProcessLinux booting Process
Linux booting ProcessGaurav Sharma
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting SequenceJayanta Ghoshal
 
NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNEEVEE Technologies
 
Linux Boot Process
Linux Boot ProcessLinux Boot Process
Linux Boot Processdarshhingu
 
Chromium os architecture report
Chromium os  architecture reportChromium os  architecture report
Chromium os architecture reportAmr Abd El Latief
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
WinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage ToolWinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage ToolBrent Muir
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System AdministrationSreenatha Reddy K R
 
embedded-linux-120203.pdf
embedded-linux-120203.pdfembedded-linux-120203.pdf
embedded-linux-120203.pdftwtester
 

Ähnlich wie Linux kernel booting (20)

Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theoryEmbedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
 
Linux booting process, Dual booting, Components involved
Linux booting process, Dual booting, Components involvedLinux booting process, Dual booting, Components involved
Linux booting process, Dual booting, Components involved
 
Ch04 system administration
Ch04 system administration Ch04 system administration
Ch04 system administration
 
Ch04
Ch04Ch04
Ch04
 
Linux Booting Steps
Linux Booting StepsLinux Booting Steps
Linux Booting Steps
 
Understanding The Boot Process
Understanding The Boot ProcessUnderstanding The Boot Process
Understanding The Boot Process
 
Introduction to Operating Systems.pptx
Introduction to Operating Systems.pptxIntroduction to Operating Systems.pptx
Introduction to Operating Systems.pptx
 
Android bootup process
Android bootup processAndroid bootup process
Android bootup process
 
Linux booting Process
Linux booting ProcessLinux booting Process
Linux booting Process
 
Slim Server Theory
Slim Server TheorySlim Server Theory
Slim Server Theory
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded Linux
 
Linux Boot Process
Linux Boot ProcessLinux Boot Process
Linux Boot Process
 
Chromium os architecture report
Chromium os  architecture reportChromium os  architecture report
Chromium os architecture report
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
WinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage ToolWinFE: The (Almost) Perfect Triage Tool
WinFE: The (Almost) Perfect Triage Tool
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
embedded-linux-120203.pdf
embedded-linux-120203.pdfembedded-linux-120203.pdf
embedded-linux-120203.pdf
 
TMS320DM8148 Embedded Linux
TMS320DM8148 Embedded LinuxTMS320DM8148 Embedded Linux
TMS320DM8148 Embedded Linux
 

Kürzlich hochgeladen

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 

Kürzlich hochgeladen (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 

Linux kernel booting

  • 1. The Linux Kernel Internal
  • 2. Agenda • Linux Kernel Booting Process • How To Make Your Own Kernel OS • Anatomy of Linux Kernel Development • System Call • Kernel Security (Bugs/Vulnerability) And Kernel Fuzzing
  • 3. Who Am I? • Cyber Security Researcher • Bug Bounty Program (Google, Twitter, Yahoo, Apple, Ebay, Blackberry, etc) • Linux Exploit Developer • Malware Analysis • Linux System Programmer • Linux Kernel/Device Developer • Windows System Programmer • Django Contributor
  • 4. Type of OS • Personal OS : Linux, Unix, MaCOS , etc • Mobile OS : Android, iOS, WinPhone, UIQ, etc • Real-Time OS : VxWork (NASA), QNX, RTLinux, etc • Network OS : Router OS, Switch OS, etc • Distributed OS : Internet, Telephone networks
  • 6. Android Device Linux Kernels Source • Google: https://android.googlesource.com/kernel/msm/ • HTC: https://www.htcdev.com/devcenter/downloads • OnePluseOS : https://github.com/OnePlusOSS/android_kernel_oneplus_msm8996 • Moto X : https://github.com/MotorolaMobilityLLC/kernel- msm • Sony : https://github.com/sonyxperiadev/kernel
  • 7. The Linux Boot Process
  • 8. The Linux Boot Process • BIOS (Basic Input/Output System) The processor executes code at a well-known location In a personal computer (PC), which is stored in flash memory on the motherboard. booting Linux begins in the BIOS at address 0xFFFF0. When your computer boots—and after the POST finishes—the BIOS looks for a Master Boot Record, or MBR, stored on the boot device and uses it to launch the bootloader (GRUB).
  • 9. The BIOS will soon be dead • UEFI plans to completely replace it with UEFI on all their chipsets by 2020.
  • 10. BIOS Tools • apt-cache search bios | grep –i bios • apt-get source phnxdeco (phonix tech) • Security advisory (Intel): https://edk2-docs.gitbooks.io/security-advisory/content/ • Security Tool: Platform Security Assessment Framework https://github.com/chipsec/chipsec • Attacking and Defending BIOS in 2015 • http://c7zero.info/stuff/AttackingAndDefendingBIOS-RECon2015.pdf
  • 11. Bootkit Malware What is bootkit? Malware that executes before the operating system boots. Malwares: FIN1 : Network protocols and communication channels for command and control (C2C). Including: file transfer (http DLL web shell), screen capture, keystroke logging, process injection BOOTRASH : File Content : Core.sys, vfs.sys and etc Including : Services, Run keys, Scheduled tasks, Startup folders Article : https://www.fireeye.com/blog/threat-research/2015/12/fin1- targets-boot-record.html
  • 15. What is UEFI? • You need to buy new hardware that supports and includes UEFI. • UEFI firmware can boot from drives of 2.2 TB or larger. • UEFI can run in 32-bit or 64-bit mode. • Your boot process is faster. • UEFI screens can be slicker than BIOS settings screens, including graphics and mouse cursor support. • UEFI supports Secure Boot, which means the operating system can be checked for validity to ensure no malware has tampered with the boot process. • UEFI support networking features. • UEFI is modular. • Analyzing UEFI BIOSes from attacking [ BH 2014 ] (https://youtu.be/CGBpil0S5NI)
  • 16. UEFI
  • 17. UEFI Rootkit Malware (LoJax) • How malware works: – Information dumping tool: – RwDrv.sys driver, attackers reads the information on your UEFI BIOS. This information is then saved to a text file. This step helps the malware understand the victim system. – System Firmware Image Creation : – Firmware Image of SPI Flash Memory where the UEFI/BIOS is located. This image is then again saved to a file. – Rootkit Installation: – The firmware image is infected. This infected Firmware image is then installed onto the SPI Flash Memory
  • 19. Create malware is important for country
  • 20. ICS (Industrial Control Systems) malware • 2010 Stuxnet : This cyber weapon was created to target Iranian centrifuges. • 2013 Havex : Targeted energy grids, electricity firms, and many others. • 2015 BlackEnergy : It targeted critical infrastructure and destroyed files stored on workstations and servers. In Ukraine. • 2015 IronGate : It targeted Siemens control systems and had functionalities similar to Stuxnet’s. • 2016 Industroyer : The attack caused a second shutdown of Ukraine’s power grid. • 2017 Triton : The attack did not succeed
  • 21. What Is BootLoader? • It is the part that starts the system up and loads the operating system kernel • Bootloader has two main jobs: • [1] Initialize the system to a basic level (MBR) and to [2] Load the kernel.
  • 24. MBR (Master Boot Record) • MBR : The first 446 bytes are the primary boot loader, which contains both executable code and error message text The next sixty-four bytes are the partition table, which contains a record for each of four partitions The MBR ends with two bytes that are defined as the magic number (0xAA55)
  • 25. Extracting the MBR # dd if=/dev/hda of=mbr.bin bs=512 count=1 # od -xa mbr.bin
  • 26. Partition table information of MBR • # file mbr.bin mbr.bin: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 19451904 sectors; partition 2: ID=0x5, starthead 254, startsector 19455998, 2093058 sectors, code offset 0x63
  • 27. Second stage bootloader Splash screen is commonly displayed, and Linux and an optional initial RAM disk (temporary root file system) are loaded into memory. second-stage, boot loader called the kernel loader. The task at this stage is to load the Linux kernel and optional initial RAM disk.
  • 28. Second stage = GRUB and etc Type of bootloader : 1- Grub 2- LILO 3- GRand 4- …
  • 29. GRUB Good knowledge of Linux file system. Instead of using raw sectors on the disk, as LILO. GRUB can load a Linux kernel from an ext2 or ext3 file system
  • 30. Stage 1 (MBR) + Stage 1.5 + Stage 2 (GRUB) What is stage 1.5? stage 1.5 boot loader that understands the particular file system containing the Linux kernel image. Examples : CR-ROMs use the iso9660_stage_1_5 Ext2 or ext3 file system use the e2fs_stage1_5
  • 31. GRUB *.cfg (Stage 1.5  Stage 2 loaded)
  • 33. Understanding the Various Grub Modules $ ls /boot/grub/x86_64-efi/ /boot/grub/x86_64-efi/915resolution.mod … Grub module : https://github.com/coreos/grub/tree/2.02-coreos/grub-core
  • 34. Grub module error: file `/boot/grub/*/*.mod not found.
  • 35. Load kernel image with GRUB grub> kernel /bzImage-<version> [Linux-bzImage, setup=0x1400, size=0x29672e] grub> initrd /initrd-<version>.img [Linux-initrd @ 0x5f13000, 0xcc199 bytes] grub> boot Uncompressing Linux... Ok, booting the kernel. Refs install manual : http://tinycorelinux.net/install_manual.html
  • 36.
  • 37. Count of Line Code Ubuntu Kernel
  • 38. Count of Line Code Main Kernel
  • 40. Underestand of Kernel Image vmlinux: Plain linux ELF file just the way it was created by the linker, including symbols and everything. vmlinuz:Gzipped vmlinux file which got stripped of all its symbols zImage:bootsect.o + setup.o + misc.o + piggy.o (piggy.o contains the piggy-backed vmlinuz). zImage : is bootable because it can decompress and run the kernel it contains. bzImage: Same as zImage except that it is built slightly differently which enables it to carry bigger kernels.
  • 41. Vmlinux to Vmlinuz (make bzImage)
  • 42. Vmlinux • Vmlinux is a ELF format, • How to get ELF format? • Download kernel source of https://kernel.com and compiled, or use $ apt-get source linux
  • 43. Vmlinuz • $ sudo file /boot/vmlinuz-4.15.0-041500rc8-generic • /boot/vmlinuz-4.15.0-041500rc8-generic: Linux kernel x86 boot executable bzImage, version 4.15.0- 041500rc8-generic (kernel@gloin) #201801142030 SMP Mon Jan 15 01:31:43 UTC 2018, RO-rootFS, swap_dev 0x7, Normal VGA
  • 45. Kernel Image Process • Kernel image (bzImage) load to Memory and kernel stage started … • Typically zImage compressed image, less than 512KB a bzImage (big compressed image, greater than 512KB) • When the bzImage (for an i386 image) is invoked, you begin at ./arch/i386/boot/head.S in the start assembly routine • The kernel is then decompressed (./arch/i386/boot/compressed/misc.c) through a call to a C function called decompress_kernel function • When the kernel is decompressed into memory, it is called. This is yet another startup_32 function, but this function is in ./arch/i386/kernel/head.S. • More info : https://www.slideshare.net/itembedded/linux-kernel-image
  • 49. Kernel Source Tree • Github linux kernel source tree : – https://github.com/torvalds/linux • Bootlin kernel source tree : – https://elixir.bootlin.com/linux/latest/source
  • 50. Kernel Type Mode • Real Mode • Protected Mode • Long Mode
  • 51. Architecture Linux Kernel Initialization
  • 52. Kernel Boot Paging (Virtual Memory)
  • 54. Real Mode Boot sector (header.S)
  • 55. Kernel Real Mode (setup_header)
  • 56. Kernel Real Mode (setup_header)
  • 58. Kernel Real Mode Stack (header.S)
  • 59. Kernel Real Mode to C (header.S -> main.c)
  • 61. Copy header to zeropage