What happens when you type google.com into your browser and press enter? (Detailed Analysis)

Hussein Nasser
1 Jan 202045:02

Summary

TLDRIn this comprehensive video, software engineering enthusiast Hussain delves into the intricate processes occurring when you enter 'google.com' into your browser and press enter. Emphasizing the networking and software engineering perspectives, Hussain breaks down the journey into eight detailed parts, excluding keyboard events and low-level operating system details. Starting with the initial URL input to DNS queries and TCP connections, he explains the protocols, ports, and secure communication steps involved. Highlighting aspects like HTTPS, HSTS, DNS over HTTPS, and the mechanics of TCP/IP communication, Hussain provides a deep dive into the technical underpinnings that make web browsing possible on a brand-new machine with the latest browser versions.

Takeaways

  • πŸ’» The video explains the complex process that occurs when you type 'google.com' into a browser and press enter, focusing on the networking and software engineering aspects.
  • πŸ“ˆ It breaks down the process into eight detailed components, starting from the initial typing of the URL to the final rendering of the webpage.
  • πŸ” The first step involves the browser's autocomplete feature that predicts the URL you're typing based on your browsing history.
  • πŸ›© Determining the protocol and port to connect to is crucial, with the browser defaulting to HTTPS (port 443) for security reasons, unless otherwise specified.
  • πŸ“Ά DNS resolution is highlighted as a complex step, where the browser must find the IP address associated with 'google.com' to establish a connection.
  • πŸ“ž The video covers the transition from unencrypted to encrypted DNS queries, including DNS over HTTPS (DoH) and DNS over TLS (DoT), emphasizing privacy concerns.
  • πŸ›« Establishing a TCP connection and the TCP three-way handshake are essential steps for setting up a secure communication channel.
  • πŸ”’ TLS (Transport Layer Security) setup is a key phase for encrypting data before transmission, ensuring secure communication between the client and server.
  • πŸ“¨ The HTTP request, including GET requests for webpage resources, is sent over this secure channel, demonstrating how web content is requested and received.
  • πŸ‘β€πŸ—¨ The final steps involve parsing and rendering the webpage content in the browser, including executing JavaScript and displaying images and CSS.

Q & A

  • What is the main focus of the video?

    -The main focus of the video is to explain what happens under the hood when you type google.com into your browser and hit enter, with a particular emphasis on networking aspects and software engineering.

  • Why were certain low-level details, like keyboard events and operating systems, excluded from the discussion?

    -These details were excluded because the creator is more interested in the networking and software engineering aspects of the process, and deemed those low-level details as not relevant to the core focus.

  • How does the browser decide what to do when you start typing 'google.com'?

    -The browser first checks your history for pages starting with 'g', showing an autocomplete list based on that. If nothing relevant is found in history, it may check a locally cached index or send a request to a server, depending on the browser's functionality.

  • What is HSTS, and why is it important?

    -HSTS stands for HTTP Strict Transport Security. It is a web security policy mechanism that helps to protect websites against man-in-the-middle attacks by enforcing secure connections, ensuring that browsers only use HTTPS to communicate with the website.

  • What determines whether the browser uses HTTP or HTTPS to connect to a website?

    -If the URL entered doesn't specify a protocol (HTTP or HTTPS), the browser must decide which to use. Modern browsers default to HTTPS for security reasons, often guided by HSTS lists that enforce HTTPS for certain websites.

  • What is DNS, and why is it a crucial step in accessing a website?

    -DNS, or Domain Name System, translates human-friendly domain names (like google.com) into IP addresses that computers use to identify each other on the network. It's crucial because it allows users to access websites using easy-to-remember domain names instead of numerical IP addresses.

  • What role does TCP/IP play in accessing a website?

    -TCP/IP (Transmission Control Protocol/Internet Protocol) is fundamental to the operation of the internet, defining how data should be packeted, addressed, transmitted, routed, and received at the destination. A TCP connection is established between the client and the server for reliable communication.

  • Why is TLS negotiation important after establishing a TCP connection?

    -TLS (Transport Layer Security) negotiation is important because it establishes a secure encrypted connection between the client and the server. This ensures that all data transmitted over the connection is secure from eavesdropping and tampering.

  • What is the significance of HTTP/2 in web communications?

    -HTTP/2 improves the efficiency of web communications by allowing multiple simultaneous requests and responses between the client and server over a single TCP connection. This reduces latency, improves page load times, and enhances the overall user experience.

  • How do browsers decide to use HTTP/1.1, HTTP/2, or HTTP/3 for a connection?

    -Browsers and servers negotiate the protocol version to use during the TLS handshake. The choice depends on the protocol versions supported by both the client and the server, with a preference for the most advanced version supported by both for efficiency and security reasons.

Outlines

00:00

🌐 Introduction to the Intricacies of Typing Google.com

The video begins by outlining the intent to explore the detailed processes that occur when google.com is entered into a browser's address bar. Inspired by Alex's GitHub page, which provides a thorough description of the event, the video aims to delve deeper into the networking aspects while omitting low-level details like keyboard events and operating system mechanics. The focus is on the networking and software engineering facets of what transpires behind the scenes. The narrative is set in either 2019 or 2020, using the latest versions of browsers like Chrome and Firefox, and is premised on the scenario of using a brand new machine and browser that has never visited Google before. The video is structured to break down the process into eight parts, promising a comprehensive walkthrough of each step involved in accessing Google's homepage.

05:02

πŸ” From URL Typing to Protocol Determination

This segment details the initial steps from typing Google.com to determining the protocol and port for connection. It starts with the browser checking the user's history for autocomplete suggestions as soon as the first letter is typed. The video explains how the browser decides whether the input is a URL or a search term, and the subsequent action taken. It then covers the transition to determining the correct protocol (HTTP or HTTPS) and port (80 for HTTP and 443 for HTTPS) to use. The importance of HSTS (HTTP Strict Transport Security) is discussed, explaining how it forces browsers to use HTTPS for sites known to support it, enhancing security and mitigating man-in-the-middle attacks.

10:03

🌍 DNS Lookup and Establishing a Connection

This paragraph delves into the complexities of the DNS lookup process and establishing a connection to Google.com. It highlights the role of DNS in translating domain names into IP addresses, explaining the layered approach from browser cache to system files and potentially encrypted DNS queries. The discussion extends to the technicalities of DNS queries, including the use of UDP and the debates surrounding DNS over HTTPS (DoH) versus DNS over TLS (DoT). This step is crucial for initiating a connection by identifying Google's IP address, setting the stage for the subsequent TCP connection establishment and data transmission phases.

15:05

πŸ”Œ TCP Connection and Initial HTTPS Handshake

This part explains the intricacies of establishing a TCP connection with Google.com and the initial steps towards an HTTPS handshake. It outlines the necessity of a TCP connection for secure communication, detailing the three-way handshake process and the subsequent encryption negotiation. The discussion covers how the browser and server agree on encryption protocols and keys, emphasizing the significance of this phase in ensuring data privacy and integrity over the network. The section serves as a bridge to the comprehensive explanation of the TLS handshake and secure data exchange that follows.

20:06

πŸ” Advanced Details of TLS Handshake

In this segment, the video provides an in-depth analysis of the TLS handshake process, crucial for establishing a secure connection. It covers the generation and exchange of keys, the negotiation of symmetric encryption for data transfer, and the selection of ciphers. The role of ALPN (Application Layer Protocol Negotiation) and SNI (Server Name Indication) in this process is also highlighted, explaining their importance in determining the specific protocols and domains for the secure session. This detailed exploration showcases the complex mechanisms at play to secure communication between the client and Google.com.

25:08

🌐 Sending the HTTP Request and Receiving the Response

This paragraph focuses on the final steps of sending the HTTP GET request to Google.com and processing the received response. It explains how, after establishing a secure TCP connection and negotiating TLS, the browser sends an encrypted HTTP request to the server. The server then responds with the requested web page, which is decrypted by the client. This section also touches on the use of HTTP/2 for efficient communication, describing how it allows multiple requests and responses to be multiplexed over a single connection. The explanation underscores the complexity and efficiency of modern web communication protocols.

30:09

πŸ”§ Advanced HTTP/2 Features and Security Considerations

This segment elaborates on the nuances of HTTP/2, including server push capabilities and potential security implications. It discusses how servers can preemptively send resources to clients, potentially improving load times. Additionally, it addresses security features like content type headers to prevent MIME sniffing attacks, illustrating how browsers and servers work together to ensure data integrity and privacy. The detailed overview of HTTP/2's features and the emphasis on security measures highlight the ongoing evolution of web standards to enhance performance and safeguard user data.

35:10

πŸ–₯️ Comprehensive Breakdown of Web Page Rendering

The final part of the video script offers a comprehensive breakdown of the web page rendering process once the data is received from Google.com. It delves into how the browser interprets the content type of the received data, parsing HTML, executing JavaScript, and rendering images based on the MIME types. The discussion also revisits the potential for HTTP/2 server push to optimize resource loading and the complexities involved in secure, efficient web communication. This conclusive segment underscores the intricate web of processes that work in concert to display a web page, from initial request to final rendering, highlighting the complexity behind seemingly simple user actions like typing Google.com into a browser.

Mindmap

Keywords

πŸ’‘DNS (Domain Name System)

DNS is a hierarchical and decentralized naming system for computers, services, or any resource connected to the Internet or a private network. It translates more readily memorized domain names to the numerical IP addresses needed for locating and identifying computer services and devices with the underlying network protocols. In the video, DNS is described as a critical step in the process of accessing a website like google.com. The narrator explains how the browser checks its cache, the operating system, and then potentially makes a query to a DNS server to resolve the domain name into an IP address, emphasizing the significance of DNS in establishing a connection to a website.

πŸ’‘HTTPS (Hypertext Transfer Protocol Secure)

HTTPS is an extension of the Hypertext Transfer Protocol (HTTP). It is used for secure communication over a computer network and is widely used on the Internet. In HTTPS, the communication protocol is encrypted using Transport Layer Security (TLS), or formerly, its predecessor, Secure Sockets Layer (SSL). The video highlights the importance of HTTPS in providing a secure connection to google.com, indicating how browsers decide whether to use HTTP or HTTPS based on factors like the presence of the site in the HSTS list, which enforces secure connections.

πŸ’‘HSTS (HTTP Strict Transport Security)

HSTS is a web security policy mechanism that helps to protect websites against man-in-the-middle attacks such as protocol downgrade attacks and cookie hijacking. It allows web servers to declare that web browsers (or other complying user agents) should only interact with it using secure HTTPS connections, and never via the insecure HTTP protocol. The video discusses how browsers use HSTS lists to determine whether to connect to a site using HTTPS, highlighting the role of HSTS in enhancing web security.

πŸ’‘TCP/IP (Transmission Control Protocol/Internet Protocol)

TCP/IP is a set of communication protocols used to interconnect network devices on the internet. TCP/IP can also be used as a communications protocol in a private network (an intranet or an extranet). When you access a website, your browser uses TCP/IP to make a connection to the server and send requests and receive responses. The video describes the process of establishing a TCP connection, emphasizing its importance in the data exchange between the client (browser) and the server (google.com).

πŸ’‘IP Address

An IP address is a unique address that identifies a device on the internet or a local network. IP stands for 'Internet Protocol,' a set of rules governing the format of data sent via the internet or local network. The video details the necessity of resolving a domain name to an IP address through DNS to establish a connection, underlining the concept that IP addresses are crucial for the browser to connect and communicate with the server hosting google.com.

πŸ’‘TLS (Transport Layer Security)

TLS is a cryptographic protocol designed to provide communications security over a computer network. Websites use TLS to secure all communications between their servers and web browsers. The video discusses establishing a TLS connection as a step after establishing a TCP connection, emphasizing TLS's role in encrypting data and ensuring secure communication between the client and google.com.

πŸ’‘HTTP/2

HTTP/2 is the second major version of the HTTP network protocol, used by the World Wide Web. It brings key improvements over HTTP/1.x such as reduced latency by enabling full request and response multiplexing, more efficient use of network resources, and improved perceived performance of web browsing. The video explains how after establishing a secure connection, the browser might use HTTP/2 to communicate with google.com, taking advantage of its benefits for faster and more efficient data exchange.

πŸ’‘SNI (Server Name Indication)

SNI is an extension to the TLS protocol that indicates which hostname the client is attempting to connect to at the start of the handshaking process. This allows a server to present multiple certificates on the same IP address and TCP port number and hence allows multiple secure (HTTPS) websites (or any other service over TLS) to be served by the same IP address without requiring all those sites to use the same certificate. The video references SNI in the context of TLS handshaking, showing its importance in the modern web where a single server can host multiple secure websites.

πŸ’‘NAT (Network Address Translation)

NAT is a method of remapping one IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic routing device. The video illustrates how NAT is used in the process of establishing a connection to google.com, especially in translating the private IP addresses of devices on a local network to a public IP address before the data leaves the network.

πŸ’‘SSL Stripping

SSL stripping is a technique for circumventing the security enforcement of SSL/TLS by converting a secure HTTPS connection into an unsecured HTTP connection. This man-in-the-middle attack can lead to sensitive information being transmitted in plain text and easily intercepted. The video briefly mentions SSL stripping when discussing the importance of HTTPS over HTTP, underlining the security risks associated with not securing web communications.

Highlights

Introduction to the intricate process that unfolds when typing google.com in the browser.

Differentiation between history lookup and autocomplete in the browser.

Explanation of how the browser decides whether input is a URL or search term.

Discussion on protocol determination, emphasizing HTTP vs HTTPS.

Introduction of HSTS to enforce secure connections.

Deep dive into DNS resolution and caching mechanisms.

Exploration of DNS over HTTPS and DNS over TLS controversies.

Explanation of UDP packet handling for DNS queries.

Detailing the process of MAC address resolution and IP packet forwarding.

TCP connection establishment through a three-way handshake.

Discussion on the intricacies of TLS and secure communication setup.

Presentation of HTTP/2 and its benefits for optimizing web traffic.

Handling of HTTP GET requests and server-client communication.

Details on the rendering and parsing process in the browser.

Consideration of HTTP/2 server push and its impact on web performance.

Transcripts

play00:00

in this video i want to go through what

play00:02

really happens under the hood when you

play00:05

type google.com

play00:07

and you hit enter in your browser this

play00:10

video is inspired by alex's github page

play00:13

below i'm going to reference it below it

play00:15

has a great detailed description of what

play00:18

really happens when you do that thing

play00:20

right i did however add more details

play00:23

like the networking aspects of things

play00:25

and i also removed stuff that like

play00:27

keyboard events and low-level operating

play00:29

systems that i i don't really care about

play00:31

i i'm really interested in the

play00:32

networking aspect and the software

play00:35

engineering aspect of it all right so if

play00:37

you're interested to know what really

play00:39

happened when you type google.com and

play00:40

hit enter stay tuned are you here

play00:43

welcome my name is hussain and this

play00:45

channel we discuss all sorts of software

play00:47

engineering by example so if you want to

play00:49

become a better software engineer

play00:51

consider subscribing and hit that bell

play00:52

icon so you get notified every time i

play00:55

upload a new software engineering video

play00:57

with that said let's just jump

play00:59

into this video

play01:00

all right i'm gonna break up this video

play01:02

into eight parts eight components to

play01:05

talk through right and we're gonna go

play01:07

through each component one by

play01:10

one and i am assuming that i'm hitting

play01:13

google.com it is 2020 or 2019 latest so

play01:18

it's i'm using the latest chrome version

play01:20

the latest there is a firefox version

play01:22

i'm not going to specify which browser

play01:23

i'm going to use because i'm going to

play01:24

talk i want to talk through different

play01:26

browsers technologies and

play01:29

that is the most important thing this is

play01:31

a brand new machine assuming this is a

play01:32

brand new machine this is a brand new

play01:34

browser i never visited google

play01:37

ever i this is a brand new machine

play01:39

nobody ever opened the browser so

play01:42

google.com will be the first page i ever

play01:45

visit okay so that's that's the caveat i

play01:49

want it i want to go that's the context

play01:51

i want to go through okay that's there

play01:53

first step initial typing you start

play01:56

typing g

play01:57

o o g l e dot com you start typing and

play02:01

the first letter you type g

play02:04

what happened is

play02:06

many things

play02:07

the browser will either start looking

play02:10

for your history and pages that start

play02:13

with the letter g

play02:15

in your recent visited history and start

play02:17

showing you an autocomplete list

play02:20

or

play02:21

some browser will actually do a search

play02:26

to an index that is local through this

play02:29

locally searched index that is cached

play02:32

some browsers might actually send the

play02:34

request to a server to this default

play02:37

search engine

play02:39

baked into the browser right i'm not

play02:42

going to go through any of those i'm

play02:43

going to go through the first step where

play02:45

you're listing the visited

play02:48

the history of the pages that you

play02:50

visited okay let's assume that so you're

play02:51

getting a list of the visual pages which

play02:54

is nothing because universe visited any

play02:55

pages okay so all right so

play02:58

that's the first step

play03:04

you finished typing google.com second

play03:06

step google.com has finished typing in

play03:09

and you're about to hit enter you didn't

play03:12

add any http slash you didn't add

play03:14

anything you just type google.com and

play03:16

hit enter so the browser does is now it

play03:20

accepted that that's what alex is start

play03:22

explaining it's like okay there's a

play03:24

keyboard event that you're listening to

play03:25

i don't want to go through this i want

play03:27

to go through actual networking aspects

play03:30

and the software engineering high level

play03:31

stuff right so you hit that now you have

play03:34

google.com as a string

play03:36

the browser will stop parsing this thing

play03:38

and it asks a question

play03:39

is this a url or is this a search term

play03:43

all right if it's a search term it

play03:45

actually does a search and i'm not gonna

play03:47

go through that okay if it's a url it

play03:50

visits that page all right it starts the

play03:53

process to visit the google.com page

play03:56

okay and we're going through this route

play03:58

okay we're going to google.com it's a

play04:01

page i figured out it's a page it's a

play04:03

website so i want to establish a

play04:05

connection with that website and i want

play04:08

to send a get request to that website so

play04:10

that's the next thing we need to do okay

play04:12

so step two done okay we know it's a url

play04:15

we know it's a page

play04:17

let's go ahead and visit it

play04:23

third step

play04:25

determining which protocol

play04:27

and which port to connect to right

play04:31

why do we need to know which protocol

play04:33

well we know it's a page so it's either

play04:35

http or https so that's the trick is it

play04:38

http unencrypted port 80 or is it https

play04:44

encrypted on port 443

play04:46

because

play04:47

the user didn't tell us it only he only

play04:50

or she only told us google.com it didn't

play04:53

tell us http colon slash slash that

play04:56

would be easier for the browser right or

play04:58

it didn't say https colon slash slash

play05:02

google.com it says just google.com so

play05:04

the browser has to figure out what's the

play05:07

protocol okay and by default

play05:10

prior to certain version

play05:12

browsers were always going to uh

play05:16

http let's always assume that it's http

play05:18

which is unencrypted that causes a lot

play05:21

of man in the middle attacks

play05:23

and we we talked about a video called

play05:25

ssl stripping and hsts i want you to go

play05:28

and check our video out to learn more

play05:30

about why it is bad to visit for the

play05:33

user to visit a as website as a plain

play05:35

http it's so bad right

play05:39

even that the web server has actually

play05:40

supports https right so

play05:44

this the browser invented concepts

play05:46

called hsts and we made a video about

play05:48

that i'm going to reference it below go

play05:50

ahead and check it out but hsts stands

play05:53

for http strict transport security and

play05:57

it's essentially a list that the

play06:00

browsers keep

play06:02

cached in it's

play06:04

in a local database and it has the most

play06:08

famous

play06:09

web pages that forces

play06:12

users or clients to communicate only

play06:14

through https

play06:17

so what does what the client does is it

play06:19

looks through this list and says hey is

play06:22

google.com an https site or is just a

play06:25

normal http if if found that in hsts

play06:29

list then

play06:31

it uses the https protocol

play06:34

that means the port will be 443 okay if

play06:37

it if it's not in the list then it will

play06:39

be forced to use http which is unsecure

play06:43

which which means that the port is 80.

play06:46

okay so that is essentially the step so

play06:50

i know the protocol now let's assume we

play06:52

went through the https part okay which

play06:55

is port 443 and i know it's secure so

play06:58

now i will only establish a secure

play07:01

communication to the google.com first

play07:05

right before i actually establish

play07:08

i do anything i need to establish a

play07:10

communication if animatic i'm gonna have

play07:13

to start adding a lot of f's here right

play07:16

if google.com was not in the hsts list

play07:19

then the protocol will be http then the

play07:23

port will be 80 then the tcp connection

play07:26

will go through the 80 port which is a

play07:28

completely different connection okay

play07:31

we're going through https let's jump

play07:34

into it step four

play07:40

dns the most complicated step here okay

play07:44

here's the thing

play07:45

dns domain name server okay or systems

play07:50

i know google.com

play07:51

i know the port i know the protocol the

play07:54

port is 443

play07:56

the protocol https but i don't know the

play07:59

iep i need to know the ip address in

play08:02

order to communicate with google.com

play08:05

right because that's how how tcp works

play08:08

right everything's through tcp the

play08:10

network layer i need to know the iep

play08:11

address and you know the ipads i know i

play08:13

need to know even something lower than

play08:15

that called the mac address which we're

play08:16

going to talk about in a minute

play08:18

so how do i know the ip address of the

play08:20

google.com i ask a dns query and here

play08:23

are the layers of dns right first thing

play08:26

the browser will check okay google.com

play08:28

do i have an ip address for google.com

play08:31

ever right

play08:33

it's a it's it's in its own cache it has

play08:35

its own cache of this local dns right

play08:39

every browser have that it says hey did

play08:40

i ever visit google.com well no if it

play08:43

did we're gonna pull up the ipads from

play08:45

its cache which is very quick

play08:47

if it doesn't right which which is our

play08:50

case because we never opened any page

play08:53

before right it's going to move to the

play08:55

next thing it's going to ask the

play08:55

operating system hey

play08:57

os

play08:59

do you know this google.com thingy ever

play09:02

and uh i don't know if you hacked ever

play09:04

by a windows machine old days in the 90s

play09:07

there's a host's file we always used to

play09:10

play with that file and that's

play09:11

essentially a mapping between a host and

play09:14

it's ip you can hard code that list in a

play09:16

host file and we used to do it in all

play09:19

the time we can we can we can fix the

play09:22

fix an ip address for a given especially

play09:24

when we do an online gaming bet on 90 we

play09:26

want to force an ip address that is

play09:28

highly available we were doing all this

play09:30

goofy stuff back then all right so

play09:34

the host file it looks through the host

play09:36

file is google.com in the host file is

play09:38

there an ip address associated with it

play09:41

well obviously we don't have anything in

play09:43

the host file so it jumps and here's the

play09:45

thing

play09:46

there is something new wish there's a

play09:50

and there are a lot of drama

play09:53

people talking about is called

play09:55

dns over https and there's another thing

play09:58

called dns over tls okay there's a lot

play10:01

of drama controversy around this stuff

play10:03

right some people wants one over the

play10:06

other here's the thing about dns guys

play10:08

dns if you don't know is a udp

play10:11

service uh listening on portfolio 53

play10:14

okay

play10:15

and it's unencrypted so anyone can know

play10:19

which

play10:21

domains you're going anyone on the

play10:23

internet if you're using dns right

play10:25

people know that you're going through

play10:27

dns okay well

play10:29

there's a question mark there but sure

play10:32

okay so dns requests

play10:34

are visible to your isp so all your isp

play10:36

your work actually know which page

play10:40

you're going to you're going to

play10:41

facebook.com you're going to google.com

play10:43

but they cannot know these days 2019

play10:46

2020 they they cannot see what you're

play10:48

searching for right let's be honest

play10:50

unless they're using a terminating proxy

play10:53

a tls proxy terminating proxy that

play10:56

if they are not

play10:58

then they cannot see anything except

play10:59

this thing and people are starting to

play11:01

solve this problem the dns encrypted

play11:03

versus unencrypted so how do they solve

play11:05

it

play11:06

two technologies were involved

play11:09

dns over tls so let's establish a tls

play11:11

connection and do dns over that or let's

play11:14

do dns over https because

play11:17

it's just we noticed dps

play11:20

we can use http 2 because beautiful

play11:22

bi-directional streaming technology and

play11:25

we can stream over that okay so we we

play11:27

can use the existing tech why do we have

play11:30

to create a custom port for dns right

play11:33

and there's a file between networking

play11:35

admins and and and the web

play11:38

security gurus right

play11:40

and i kind of leaned towards doh to be

play11:44

honest

play11:45

the the admin guys want to know to not

play11:48

to monitor but because they can't but

play11:50

they want to see dns requests

play11:53

they want to differentiate dns requests

play11:55

from regular network web traffics right

play11:58

okay and if you're using doh you cannot

play12:01

do that right you just hide all the dns

play12:03

requests will become

play12:05

normal stuff right so long story short

play12:08

doh right if the browser supports doh

play12:12

which is dns over https

play12:16

it will

play12:17

do that through the dos right the dns

play12:21

is going to do the dns over https so it

play12:24

will see what is your default https dns

play12:27

provider maybe cloud frame maybe google

play12:30

and it will establish a tls connection

play12:32

that's a different thing i'm not going

play12:33

to talk about it right and it's going to

play12:35

do the dns over there

play12:37

let's assume it's disabled which is as

play12:39

if 2019 december

play12:42

27 today right 27 december 27th 2019

play12:47

this thing is disabled by default right

play12:49

a lot of problems right so it's still

play12:51

controversy right so it's disabled so

play12:53

let's assume it's disabled on my browser

play12:55

so i'm not going to do a encrypted dns

play12:57

so people will see my request so the

play12:59

final step is to actually do a dns so

play13:02

what do we do is we're going to do a dns

play13:05

to find out my ip address you see how

play13:08

complicated this thing is guys right i

play13:10

hope you're still watching this video

play13:12

because

play13:13

it is is a long process i'm just talking

play13:15

about and i'm skipping through so much

play13:17

stuff okay so if i'm connecting to a

play13:21

if i'm connecting

play13:23

if i want to know that google.com ipad

play13:25

is i'm going to establish a udp there's

play13:28

no udp connection by the way it's just

play13:30

i'm going to send a udb

play13:33

datagram user datagram to

play13:36

the my default dns provider which

play13:39

usually is configured on my router which

play13:41

is usually provided my

play13:44

by my isp which is in this case a

play13:47

frontier i did change mine to b111

play13:52

which is the cloud frayer default

play13:54

dns

play13:57

right

play13:58

okay

play13:59

so my dns is one one one one okay

play14:03

1.1.1.1 or maybe yours could be google

play14:06

so a2.8.8.a

play14:08

okay so you have to know the ip address

play14:10

of the dns because you want to send a

play14:12

packet so what do you do

play14:14

you send a packet right so

play14:16

let's go through that okay let's go

play14:18

through the details of how do we send a

play14:20

a packet

play14:22

to

play14:24

1.1.1.1 on port 53. okay

play14:28

so i am a client right

play14:30

and let's assume my machine here that's

play14:33

the first communication with the outside

play14:34

world here guys right

play14:36

let's assume my ipad is 1002

play14:40

and my gateway which is the router is

play14:42

100

play14:44

and the dns provider that i want to

play14:46

communicate with is

play14:47

1.1.1.1 okay and my mac address is aaa

play14:51

and

play14:52

my router mac address is ff right and

play14:54

that's

play14:55

all what we need to know so far okay i

play14:57

want to send a udp request what do we do

play15:00

we

play15:02

create an ip packet okay and the iep

play15:05

packet will have in its layer three will

play15:08

have the destination ipad is saying

play15:10

1.1.1.1 okay

play15:13

and it will have the port 53 and the

play15:16

source

play15:17

ip will be 1001 which is me i am the

play15:20

client and the port the source port will

play15:23

be a random port let's say three three

play15:26

three three okay random okay

play15:28

so now

play15:30

what we do is

play15:32

before we send that packet we need to

play15:34

encapsulate into a frame okay and the

play15:36

frame is a layer two thingy okay which

play15:39

needs a mac address right what the heck

play15:41

is the mac address for 1.1.1.1 so we

play15:44

asked ourselves this question and he

play15:45

says well

play15:47

1.1.1.1 is not in my subnet which is

play15:49

1001 because i my subnet mask does not

play15:53

fit this thing right so since it's not

play15:56

in my subnet i cannot send it locally so

play15:59

i cannot know it's my address so who the

play16:02

heck knows the mac address of this thing

play16:05

i don't know right the answer to that is

play16:07

the gateway okay if you don't know where

play16:10

to send it you always send it to the

play16:12

gateway and my gateway is

play16:14

10.0.0.1 which is my router right

play16:17

usually usually it's my router and and i

play16:20

have like just a plain router in this

play16:22

case okay sweet

play16:24

right so

play16:25

i know that my router mac address is ff

play16:28

so i'm going to send it to raw my router

play16:30

my source is a a mac address and i send

play16:33

it to the router

play16:34

the router will receive the packet right

play16:36

and says okay you want to i received the

play16:39

packet the frame right it's ff but i

play16:41

look at it and you is

play16:44

it looks like the client want to go to

play16:45

1.1.1.1

play16:47

okay so what do we do how do we send it

play16:50

to 1.1.1 i'm going to take care of this

play16:52

i'm going to go through it and do it

play16:53

exactly the same process is this in my

play16:55

subnet right

play16:57

but

play16:58

i need to do some changing first i'm

play17:00

going to do a nat because i cannot send

play17:02

this packet on the internet naked like

play17:06

that because who the heck knows what the

play17:08

source

play17:10

ip10.0.0.2 is because that's my that's

play17:13

an internal thing so we need to change

play17:15

it to the public ip of the router which

play17:18

is i forgot to say but it's 44.1.2.4

play17:22

so i'm going to change that thing and

play17:24

i'm going to send it through the wire

play17:26

and then and then i'm going to use the

play17:28

same port 3333 and i'm going to add a

play17:31

nat table this thing network address

play17:33

translation because i need to remember

play17:35

it's because it's a very stateful thing

play17:37

right the whole thing i'm going to add

play17:39

an entry in my nat table saying that hey

play17:42

1002 on port 333 is actually going to

play17:46

one one one one on port 53 and it's

play17:48

going and i converted it to my powerball

play17:51

so whenever we give back a response

play17:54

we're gonna forward this to swizzle it

play17:55

back and send it back to the client

play17:57

because that's what we do so we send it

play17:58

over we communicate with the one one one

play18:00

one and we get a response okay

play18:03

we get back a response saying hey

play18:05

what is google.com

play18:07

right is google.com we received the ip

play18:10

errors from google.com and it is

play18:12

4.1.2. and we receive a response and the

play18:16

1.1.1 server will actually reply to my

play18:20

public router

play18:22

saying that hey this is my response for

play18:24

the 21.23 is the answer you're looking

play18:26

for distance to forty four one two four

play18:28

on port three three three three because

play18:30

that's the port i am looking for again

play18:32

the dns doesn't know my client which is

play18:35

ten zero zero two it knows only the

play18:36

router the router receives it and says

play18:38

oh port 333 oh yeah i know where this is

play18:41

going this is supposed to go to ip

play18:43

address 1002 because i looked up the nat

play18:45

table and then it goes back and then

play18:47

goes to that

play18:48

and the router

play18:50

just forwards back the packets right and

play18:53

it does maybe another arp request and it

play18:55

sends the information back to the client

play18:59

okay

play19:00

now

play19:01

i know

play19:02

the ip address

play19:04

of google.com

play19:07

how long was that okay that was a long

play19:09

time all right all right dns done step

play19:12

four done

play19:18

now next tcp connection the most

play19:20

interesting part tcp what do we do with

play19:22

the tcb guys the tcp connection is

play19:26

to establish a tcp connection

play19:28

unlike the udp as there's no it's a

play19:30

connectionless system i know we made a

play19:32

video between tcp and udp i'm going to

play19:33

reference it here but gcp is a

play19:35

connection system so there's a three-way

play19:37

handshake that happens and i'm not going

play19:38

to go through details about this but if

play19:41

i establish a tcp connection

play19:43

i need to tell you the ip address where

play19:45

i'm going which i know now

play19:47

right it is

play19:48

4.1.2.3 that's the ip address of google

play19:51

okay so 4.223 which port i'm going to go

play19:55

to port 443 because i want to go

play19:57

securely https

play19:59

what's my internal ip address it is

play20:03

10.0.0.2 okay and what's my internal

play20:06

round random port number that's a

play20:07

different port because the 333 was

play20:09

reserved for something else i'm gonna

play20:12

use

play20:13

two two two two okay two two two two

play20:16

four twos

play20:17

send it okay so

play20:19

again do the same thing right is 4.1.23

play20:24

is in mind subnet no it's not so i

play20:28

cannot send it directly right

play20:31

i cannot do an arp request on this

play20:33

address resolution protocol so what do i

play20:35

do

play20:36

i need

play20:37

to send it to who the gateway what's my

play20:40

gateway mac address it's it's 10 0 0 1

play20:43

which i did an r before and i found out

play20:46

it's an ff so i know the mac address of

play20:48

this thing and i'm going to send that

play20:50

packet to my router instead my router

play20:53

receives that thing and it looks at it

play20:55

and says yeah you want to go to 4.1 due

play20:58

to three on port 443

play21:02

and you are 1002 i'm sorry i cannot send

play21:05

you naked like that i need to change

play21:07

your source ip address to mine which is

play21:10

public i know how to talk to the

play21:11

internet it's very dangerous to go out

play21:14

there like that so i'm going to change

play21:16

you to 44.124 which is my public ip

play21:19

address

play21:20

and i send

play21:22

that information and then the port the

play21:24

internal port is 2222 so i'm sending it

play21:26

to 44123 and then

play21:29

we send it over okay

play21:31

now that's just the one single tcp

play21:34

connection establishment

play21:36

the reverse comes back again

play21:38

right

play21:39

and then we establish a tcp connection

play21:42

so let's assume this happened right so

play21:44

the three-way handshake happened now

play21:47

we have a full

play21:49

tcp connection between a client and

play21:52

google.com which is four one two three

play21:54

okay and there's a nat table in the

play21:56

router telling that hey four four three

play21:59

four one two three

play22:02

public ipr is four four one two four

play22:04

which is me on port two two two two is

play22:07

actually

play22:07

ten zero zero two which is that client

play22:10

type address okay now we have a tcp

play22:13

connection

play22:14

we did rp within an rp we did a nat

play22:19

which is a network address translation

play22:21

there's a thing that can happen here

play22:23

right let's let's throw a monkey wrench

play22:25

what if my client has a proxy in it if

play22:28

it if that client has a proxy

play22:32

what type of proxy is it a sox proxy is

play22:35

this an https proxy is this an http

play22:38

proxy okay

play22:40

if it's an http proxy nothing changes

play22:43

because i'm using https still

play22:45

communicating google directly if i'm

play22:47

using https proxy then the destination

play22:51

will be the ip address of the proxy and

play22:55

instead the ip address of google.com

play22:58

okay

play22:59

i'm not gonna go through that path

play23:01

because that will take me another hour

play23:02

to explain okay made a lot of videos

play23:04

about proxies check them out guys

play23:07

let's throw another monkey wrench let's

play23:09

assume we're communicating through http

play23:12

1-1 which is unsecure

play23:14

which which we are not by the way but

play23:16

let's assume right so since we assume

play23:21

since we established one tcp connection

play23:23

if we already communicated with http 1 1

play23:27

then we the browser might actually

play23:29

establish five other tcp connections

play23:32

because

play23:33

this is how browsers does pipelining

play23:36

again something not we're not going to

play23:38

talk about this so the browser can send

play23:41

multiple requests at the same time to

play23:43

multiple tcp connections instead of

play23:45

waiting right i talked about that in the

play23:47

http videos go check them out cool

play23:51

enough monkey wrenches jump to the next

play23:54

step we have a tcpa connections what's

play23:56

next i still didn't send a single byte

play23:58

of data yet guys right i have a tcp

play24:01

connection of bi-directional between my

play24:04

client

play24:05

and the google.com i have it it's nice

play24:07

it's just swizzled between

play24:09

many routers like there's like a lot of

play24:12

nat tables and routers and changing

play24:14

everything is a stateful thing between

play24:17

me and the google.com

play24:23

tls

play24:25

here's the interesting part the next

play24:27

step after the tcp connection is

play24:30

immediately we're going to establish the

play24:33

tls

play24:34

connection which is the encryption which

play24:36

is transport layer security and i made a

play24:38

video about the ls i'm going to

play24:39

reference it here if you want to know

play24:40

the details of it

play24:42

but here's in a nutshell i'm assuming

play24:44

that my browser is the latest it's 2020

play24:47

almost so

play24:49

i'm using tls 1.3 it will be

play24:52

embarrassing if google.com doesn't

play24:54

support ts 1.3

play24:56

which i'm pretty sure they do okay so

play24:58

they do even my my my

play25:01

my site supports ds 1.3 for god's way

play25:04

okay so

play25:05

i'm assuming i'm version 1. try 1.3 so

play25:08

let's just say so it's

play25:10

this is the latest stuff it's a single

play25:12

round trip to do everything let's go

play25:14

through it

play25:15

okay so version is 1.3 so i'm going to

play25:18

send the first thing i'm going to send

play25:20

is

play25:20

yo

play25:22

client hello to do the client hello that

play25:25

first request after the tacp established

play25:30

is here's the things

play25:32

i'm going to establish a public key and

play25:34

a private key

play25:36

right in my client and i'm going to

play25:39

merge them

play25:40

because i'm going to do a diffie-hellman

play25:41

i'm going to merge these skills through

play25:43

magic mathematics all right i'm going to

play25:45

these two numbers that i just generate

play25:47

the huge prime numbers when merged they

play25:50

cannot be broken they can they can be

play25:52

merged right but that's very difficult

play25:55

to break them okay

play25:56

that's the first information that we

play25:58

need to send okay

play26:00

the second information we need to sing

play26:01

is the public key itself that we

play26:03

generated okay so we send public key and

play26:06

we send the merged information of the

play26:08

two and we send it but before we send it

play26:12

we also send some information says hey

play26:14

server

play26:16

we're doing this handshake so we can

play26:19

agree on a symmetric key to encrypt our

play26:21

stuff right in order to encrypt our

play26:24

stuff right what do we do

play26:26

we need to agree on a symmetric key okay

play26:30

in order to agree on symmetric key we

play26:32

need to agree on a symmetric key we need

play26:34

to establish this symmetry key so that's

play26:35

why i'm doing all that stuff i'm going

play26:37

to send you this merged

play26:39

keys

play26:40

and i'm going to send you the public key

play26:41

which even if someone sniffed the public

play26:43

key it's public anyway who cares even if

play26:46

someone sniffed the merch key they

play26:47

cannot get anything over because it's

play26:49

extremely difficult to break those two

play26:51

numbers okay it's like there's a magic

play26:53

mathematics that i don't understand okay

play26:55

and i'm gonna also tell you what ciphers

play26:57

i support for this symmetrical

play26:59

information that we can agree on i

play27:01

support eas i support ds hopefully not

play27:04

okay it's about blowfish i don't know

play27:07

what other symmetrical

play27:09

ciphers are there there's a lot of fancy

play27:11

stuff

play27:12

okay es 256 maybe maybe more than that

play27:16

okay and then i'm gonna send that before

play27:19

i send that more information do i

play27:21

support

play27:22

uh alpn which is the application layer

play27:25

protocol negotiation do i support

play27:28

server name indications okay which is

play27:30

things we talked about before in this

play27:32

channel okay

play27:33

and why do we do why do we need the

play27:35

application layer progression

play27:36

negotiation because we are cool because

play27:39

the alpine is the best protocol out

play27:42

there okay

play27:43

it

play27:44

negotiates it tells the client in the

play27:47

server that hey by the way i'm gonna

play27:49

about to communicate with you https but

play27:52

i also support http 2

play27:55

and i might even support http 3 right

play27:58

in case of chrome i don't want to throw

play28:00

another monkey wrench but chrome

play28:02

communicates with google

play28:04

in

play28:05

quick api which is the future http 3 in

play28:08

the future but i'm not gonna let's not

play28:10

go there yet okay let's assume i want to

play28:12

support http 2. so in the same client

play28:15

hello i'm going to tell you that hey i

play28:17

support http 2 these are the ciphers

play28:19

here's my public keys and private keys

play28:21

and all this stuff and here's the sni

play28:23

the server name indication because

play28:25

you

play28:26

might be a public ip address serving

play28:29

hundreds of domains right i need to tell

play28:32

you which

play28:33

domain i'm actually

play28:35

communicating with okay and i'm okay

play28:38

with google.com because your public

play28:40

ideas which is what 4.1.23

play28:44

might serve

play28:46

gmail.com or might serve

play28:49

mail.google.com isn't that the same

play28:51

thing i think it's the same thing so i'm

play28:53

telling you the same thing

play28:55

put google.com that's my host name

play28:57

that's the sni okay

play28:59

send it over http i think that's that's

play29:01

the whole thing right quick all that

play29:03

jazz firefox will only communicate i

play29:05

think with uh h2 right i might be wrong

play29:08

but if chrome it might actually

play29:10

communicate with google.com and it's

play29:13

specific quick protocol which is uh i

play29:16

think it stands for quick over udp

play29:18

something like that i forgot what it

play29:20

means

play29:20

right

play29:21

but that's the future http 3 which is

play29:24

basically

play29:25

in a nutshell

play29:26

the http 2 protocol

play29:28

but

play29:29

in a udp

play29:31

connectionless thingy right

play29:34

so powerful stuff because of tcp because

play29:36

what we're doing like tcp there's always

play29:37

a handshake and and three-way handshake

play29:40

and it's very expensive to to to to do

play29:44

right so that's why they they want to

play29:45

minimize these

play29:47

round trip as much as possible okay

play29:50

all right we sent the client hello oh my

play29:52

god we're still in the client hello guys

play29:54

yeah we the server

play29:56

right the client hello will be packed

play29:58

into an ip packet destined to four

play30:02

one two three port 443 source is

play30:06

what was the uh port i port two two two

play30:09

two and this destination the source ip

play30:11

is ten zero zero two do i ma do an arp

play30:15

uh i i need to send it to the router

play30:16

because four four one two is not there

play30:18

i'm gonna send it to the router do an at

play30:21

change it i cannot let you go out there

play30:23

naked let me change your

play30:25

public address to four four one two

play30:26

three one two four and then change send

play30:29

it over and we receive finally

play30:31

google.com receives the client hello

play30:33

check that generates the public no

play30:36

generates the

play30:37

private its private key

play30:40

merges it with that merged key so we get

play30:44

three keys and that three keys the

play30:46

public

play30:47

right and the private and the private

play30:50

makes the symmetric key for the sim

play30:53

for makes an input

play30:55

called the hash or whatever it's called

play30:57

secret right that will go

play31:00

to

play31:00

uh to the

play31:02

decided cipher right so they said okay

play31:05

let's use you support es you support

play31:08

blowfish you support all the jazz

play31:10

symmetric algorithm let's pick aes 256

play31:13

right i might be wrong i don't know

play31:15

what's the actual name i'm not a

play31:16

security engineer right i'm so i'm

play31:18

software engineer right so we picked

play31:20

that best algorithm ever hopefully we

play31:23

didn't get down a downgrade attack in

play31:26

the middle right so we give that i'm

play31:28

just i'm securing that i'm gonna use

play31:31

that input from the three keys to

play31:33

generate the symmetric key for this es

play31:36

encryption algorithm and then

play31:39

i'm gonna tell my server hello

play31:41

send it's a certificate because now i

play31:44

know

play31:44

which host do you want to connect to

play31:46

from the sni right the server name and

play31:49

indication so now i know that you want

play31:52

that certificate for gmail.com or that

play31:55

certificate for google.com or that

play31:57

certificate for

play31:59

i don't know lively.com

play32:01

lively was a

play32:02

was it was a site for google back in

play32:05

early 2000 i remember

play32:07

okay

play32:08

i don't know if you guys remember or

play32:10

google plus right so now i know i'm

play32:12

gonna serve you the exact certificate

play32:14

that you actually asked for

play32:16

server back right here's the

play32:19

here's my private key merged with the

play32:21

public key because nobody can break it

play32:23

send it over

play32:24

here is my

play32:26

certificate here is other stuff as well

play32:28

okay

play32:29

send it back

play32:31

to the router because that's the public

play32:33

ip address that people see which is four

play32:36

four one two four send it back router

play32:38

does an at change it back to tinder 0

play32:41

002 send it back the server hello

play32:43

receives it and they the client now has

play32:47

the two private keys one from the server

play32:50

and one the public there and it has its

play32:53

own obviously emerge the three together

play32:55

and then generates the input which now

play32:58

it knows this agreed about cipher was

play33:00

eas take the ies and then

play33:04

what it does is it takes that generates

play33:06

the symmetric key now both guys have the

play33:08

symmetric key they can now encrypt right

play33:12

and they can have live happily ever

play33:14

after

play33:16

whoa okay

play33:18

we have finally

play33:20

the encryption mechanism everyone

play33:22

can now start sending data because both

play33:25

have the symmetric key they can encrypt

play33:28

and decrypt with the same key because

play33:29

that's the fastest thing ever guys okay

play33:33

all right

play33:38

next step is

play33:41

almost done

play33:42

we're going to send this first

play33:44

http request which is a get request

play33:46

we're going to send a get request

play33:48

because now

play33:49

the enter we're still hitting enter guys

play33:52

all of this happened while this

play33:54

single

play33:55

key hit right we're still not done yet

play33:57

so we're sending a get request

play34:00

get slash

play34:02

take that right

play34:03

add some headers because we've we're

play34:05

building an http header right it says

play34:07

hey i'm visiting git slash the host

play34:10

header is google.com still we need that

play34:12

information okay

play34:14

um

play34:15

and then uh

play34:17

we might compress these headers content

play34:19

type if google.com ever had cookies

play34:22

before it's gonna start

play34:25

sending those cookies building those

play34:27

cookies in the browser and sending them

play34:29

over with the request right

play34:32

because assuming we're building the

play34:33

browser that might change

play34:35

right if you're actually clicking a link

play34:38

versus visiting a browser that's a

play34:39

completely different things right okay

play34:42

so now

play34:43

made that get request poof

play34:47

we have the data we have the headers we

play34:49

have the body the body is just literally

play34:50

there's nobody for get requests anyway

play34:52

so we're not sending anybody we're

play34:54

sending header we're sending those stuff

play34:56

and keys perhaps and then oof before we

play34:59

send

play35:00

it we agreed by the way on http 2. but i

play35:04

forgot to mention that in the during the

play35:07

tls handshake server says yo

play35:10

you cool you want to

play35:11

because we did a lpn right and the same

play35:15

client hello server agreed to http 2.

play35:17

okay let's assume i'm using firefox not

play35:19

not chrome okay

play35:21

and then i agree to http 2 pure http 2.

play35:24

so now the client says oh oh this guy

play35:27

wants to communicate http i know http 2.

play35:29

and if you use using chrome you might

play35:31

agree you have agreed to using http 2

play35:34

over quick all right or maybe http 3 if

play35:38

you're watching this three years from

play35:39

now okay

play35:40

so now i got this now i have the http 3

play35:43

i got all that stuff right

play35:45

and now

play35:48

i'm going to commute to hdbc so i i

play35:50

build this get this get request and then

play35:54

i

play35:55

have one tcp connection and i need to

play35:57

convince http 2. http 2 uses streams so

play36:00

i'm going to build one stream of data

play36:03

i'm going to put my headers along and

play36:05

put my buddy along i don't have anybody

play36:06

because i'm sending a good request so

play36:08

it's just just a stream with the headers

play36:11

i'm going to compress it because hdb2 is

play36:13

awesome like that that i can present i'm

play36:15

going to make it into a binary format i

play36:17

have the piece of data i want to send

play36:19

next i take my symmetric key encryption

play36:21

which i did from the tls and i encrypt

play36:24

that piece of data and i send it across

play36:26

the binary protocol the beautiful http

play36:29

across the tcp connection which is what

play36:32

put the destination ip address at four

play36:34

one two three but the destination port

play36:37

is four four three and do that i'll jazz

play36:39

the exact same thing exact same thing

play36:41

we're not accepting a new tcp connection

play36:42

it's the same thing we're just going

play36:44

through the same route maybe the routes

play36:46

might change in the in the future but we

play36:48

don't care

play36:49

okay so it goes and

play36:50

goes through that stuff right establish

play36:52

tcp connections

play36:54

sweet all right

play36:56

the

play36:57

whole packet the stream receives at the

play37:00

server the server says yo this is this

play37:03

is get request and now it's up to the

play37:06

google google might receive that request

play37:08

and it's a load balancer so it might

play37:10

switch establish a connection on the

play37:12

back end if it's a layer 4

play37:14

if it's a layer 4 load balancer then it

play37:16

doesn't really establish a tcp

play37:17

connection it just streams it back to

play37:19

the destination final back end if it's a

play37:22

layer seven actually terms tls

play37:25

i'm not gonna go through that there's so

play37:26

much work there i'm gonna take me

play37:28

another two hours to explain that stuff

play37:29

so i'm gonna terminate that stuff i'm

play37:31

gonna receive it it says get slash what

play37:33

do you want for this slash right are

play37:35

there any rules are there any

play37:37

index.html pages let's assume there's a

play37:39

simple index of html pages which has the

play37:42

google search i don't know how google

play37:44

works on the backend i've never seen

play37:46

that

play37:46

so i'm going to assume there's an

play37:48

index.html probably not but

play37:51

yeah let's assume there is something

play37:52

like that and then we're gonna

play37:55

start building my headers because the

play37:56

server now to send the response for that

play37:59

request right so it's gonna build the

play38:01

headers and says hey the content type is

play38:03

actually html uh uh

play38:05

yeah i want you to set these cookies

play38:07

because i want i wanna know you i'm

play38:09

gonna track you

play38:10

sorry that's how google works we're

play38:12

gonna track everybody so yeah i know you

play38:14

i wanna this is the this is how i track

play38:16

you this is the cookies please set these

play38:19

cookies on your on your machine please

play38:21

and then do all that jazz and then

play38:24

here's the thing this is the html page i

play38:26

want to uh this is a streaming page

play38:27

maybe it has a css link javascript some

play38:31

what else has other

play38:33

goofy stuff maybe esi who cares right

play38:36

and then

play38:38

take the html that's a body right

play38:41

and then create a stream for the body

play38:43

create a stream for headers send it over

play38:45

the same tcp connection destined to my

play38:48

public ip address of the router four

play38:50

four one two four

play38:51

uh i forgot the port was two two two two

play38:53

yeah two two two two and then send it

play38:54

back data

play38:56

before we send it we compress it because

play38:58

http is cool like that because we know

play39:00

how to compress thing in http 2.

play39:03

okay and take that thing

play39:05

and

play39:06

we

play39:08

encrypt it because i have the symmetric

play39:10

key i forgot the step that was actually

play39:12

we need we had to decrypt the data

play39:14

before actually we look at it right and

play39:16

we can declare it because we have a

play39:17

symmetric key right i keep forgetting

play39:20

stuff but you're hopefully you're still

play39:22

with me guys so i encrypt that stuff

play39:24

encrypted send it over the network and

play39:28

once we send it over the network

play39:29

encrypted nobody can look at it right

play39:32

and then

play39:33

it goes to the router router does not

play39:35

reverse that

play39:36

send it back to the same machine

play39:39

my client receives this encrypted

play39:41

garbage and uses its symmetric key

play39:44

lock it

play39:45

unencrypt and unlock it look at the data

play39:48

a content type is html and here's the

play39:51

thing okay if it's html the browser

play40:00

will automatically start parsing it if

play40:02

the content type is image

play40:05

then the browser will start to render

play40:06

this image if the content type is

play40:09

something else the css that is

play40:11

javascript the browser will start to

play40:13

execute that javascript okay that's how

play40:16

that's how browsers work right there are

play40:18

some attacks like called mime sniffing

play40:20

where some servers didn't add this

play40:22

content type before right so they will

play40:25

just miss adding it because

play40:27

uh web administrator back in the 90s or

play40:29

early 2000s they were very lazy because

play40:32

you have to go manually and tell okay

play40:33

this this is actually a picture oh this

play40:35

is actually an

play40:36

html oh

play40:37

we can go only on by the index by the

play40:41

you're going to go by the extension

play40:43

because that's not enough right then

play40:45

extension because you can you can

play40:46

actually send the responses without

play40:48

extensions does not really have to be

play40:49

files on disk for god's sake right

play40:52

you're sending data back you have to

play40:54

tell me what kind of data is this

play40:57

so there was this attack called my

play40:58

sniffing and we made a video about it

play40:59

i'm gonna reference it here go check it

play41:01

out but

play41:02

browsers

play41:04

if they don't see the content type they

play41:06

try browsers try to be

play41:09

too clever by half and what they do is

play41:11

actually oh there is no content type

play41:14

well let me look at the body because

play41:16

from the body i can actually infer

play41:19

what's the type so to start parsing the

play41:21

body and we'll say hey this is html let

play41:23

me execute it this is a jpeg let me show

play41:25

it and this caused a lot of attacks back

play41:28

in the back in the days okay now there's

play41:30

another header called the ss nef don't

play41:33

sniff please or whatever of a goal is

play41:35

this there's a header that tells this

play41:37

browser do not sniff

play41:40

it's weird okay anyway let's back back

play41:43

back back

play41:44

let's continue all right so we received

play41:46

that decrypted look at that content type

play41:48

html yeah let me parse it

play41:51

before we

play41:53

reach here

play41:54

let's add

play41:56

let's add

play41:57

let's continue let's continue okay so

play41:59

html receive it parse it look at it oh

play42:02

this is html okay let me parse it uh

play42:04

well there is a javascript file that we

play42:06

need to download there's a css file

play42:08

there's a couple of images let's go and

play42:10

load those so what do we do right so we

play42:13

turn around and make

play42:15

additional git requests for those

play42:18

resources and we're lucky because we're

play42:20

using http 2

play42:22

one tcp connection can do the whole

play42:25

thing for us because the whole thing

play42:27

will get its own stream stream id4 image

play42:30

once another stream for image two

play42:31

another stream for image three another

play42:33

stream for css another stream for

play42:35

javascript and send it in parallel

play42:37

because we are cool like that okay we're

play42:39

sending everything in parallel server

play42:41

receives it and then

play42:43

start sending back the data and you you

play42:46

get idea there's an encryption

play42:47

decryption going around and then we get

play42:49

every file and then the page gets

play42:52

rendered for us let's throw some

play42:55

monkey wrenches guys

play42:56

let's throw the monkey wrenches

play42:59

let's assume the first get request that

play43:01

we sent the server

play43:03

my server supports http 2 push okay

play43:07

if the server support http 2 push which

play43:09

i'm not sure google supports it i'm

play43:11

pretty sure it does but i'm not sure if

play43:13

it's activated or not because it has its

play43:15

own problem

play43:16

right if it does support it before the

play43:19

html actually gets sent

play43:21

right back to the client

play43:23

the brow the server will determine that

play43:26

hey by the way

play43:28

you're gonna need

play43:29

you you're i'm gonna send you index.html

play43:32

but you're gonna need this file and this

play43:34

file and this file in this file anyway

play43:36

so i'm gonna send you

play43:38

multiple streams back watch out that's

play43:40

called http 2 push

play43:43

http h2 push is essentially like

play43:46

responses for requests that the client

play43:48

never made okay so

play43:50

that could be another path that things

play43:52

can go through okay and essentially

play43:55

that's that's how how it's done right

play43:58

final thing

play43:59

if

play44:00

we're using http1 the same thing will be

play44:02

exactly the same there will be no

play44:04

encryption because http1 doesn't support

play44:06

encryption wait a second that's wrong

play44:08

okay yeah

play44:09

http 1 if it's on https yes it does

play44:12

support uh it does support encryption

play44:14

efficiently even what if we're using

play44:16

http one then that browser will

play44:18

establish six connections and we'll

play44:20

start piping those requests into six

play44:23

connections instead of one so you will

play44:25

have different internal ports

play44:27

essentially in your router all right

play44:28

guys

play44:29

whoo that was a long video okay and

play44:32

that's how essentially what happens when

play44:34

you type google.com and hit enter hope

play44:36

you enjoyed this video guys right it was

play44:38

very short i know i know i guys yeah

play44:41

okay i'm pretty sure i missed a lot of

play44:43

things i'd love for all of you to type

play44:46

in the comment section below to let me

play44:49

know what i missed or and what did i say

play44:51

wrong if i said anything wrong because i

play44:54

want to become a better software

play44:54

engineer that's my goal right and i want

play44:57

to become better and uh appreciate

play44:59

everything you guys stay awesome see you

play45:01

on the next one

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
NetworkingSoftware EngineeringInternet ProtocolsWeb BrowsingDNSTCP/IPHTTPSWeb SecurityGoogleBrowser MechanicsHTTP2TLS Handshake