NeoVertex1 /
SuperPrompt
SuperPrompt is an attempt to engineer prompts that might help us understand AI agents.
81/100 healthLoading repository data…
alex / repository
An attempt to answer the age old interview question "What happens when you type google.com into your browser and press enter?"
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
This repository is an attempt to answer the age-old interview question "What happens when you type google.com into your browser's address box and press enter?"
Except instead of the usual story, we're going to try to answer this question in as much detail as possible. No skipping out on anything.
This is a collaborative process, so dig in and try to help out! There are tons of details missing, just waiting for you to add them! So send us a pull request, please!
This is all licensed under the terms of the Creative Commons Zero_ license.
Read this in 简体中文_ (simplified Chinese), 日本語_ (Japanese), 한국어_
(Korean) and Spanish_. NOTE: these have not been reviewed by the alex/what-happens-when
maintainers.
.. contents:: :backlinks: none :local:
The following sections explain the physical keyboard actions and the OS interrupts. When you press the key "g" the browser receives the event and the auto-complete functions kick in. Depending on your browser's algorithm and if you are in private/incognito mode or not various suggestions will be presented to you in the dropdown below the URL bar. Most of these algorithms sort and prioritize results based on search history, bookmarks, cookies, and popular searches from the internet as a whole. As you are typing "google.com" many blocks of code run and the suggestions will be refined with each keypress. It may even suggest "google.com" before you finish typing it.
To pick a zero point, let's choose the Enter key on the keyboard hitting the bottom of its range. At this point, an electrical circuit specific to the enter key is closed (either directly or capacitively). This allows a small amount of current to flow into the logic circuitry of the keyboard, which scans the state of each key switch, debounces the electrical noise of the rapid intermittent closure of the switch, and converts it to a keycode integer, in this case 13. The keyboard controller then encodes the keycode for transport to the computer. This is now almost universally over a Universal Serial Bus (USB) or Bluetooth connection, but historically has been over PS/2 or ADB connections.
In the case of the USB keyboard:
The USB circuitry of the keyboard is powered by the 5V supply provided over pin 1 from the computer's USB host controller.
The keycode generated is stored by internal keyboard circuitry memory in a register called "endpoint".
The host USB controller polls that "endpoint" every ~10ms (minimum value declared by the keyboard), so it gets the keycode value stored on it.
This value goes to the USB SIE (Serial Interface Engine) to be converted in one or more USB packets that follow the low-level USB protocol.
Those packets are sent by a differential electrical signal over D+ and D- pins (the middle 2) at a maximum speed of 1.5 Mb/s, as an HID (Human Interface Device) device is always declared to be a "low-speed device" (USB 2.0 compliance).
This serial signal is then decoded at the computer's host USB controller, and interpreted by the computer's Human Interface Device (HID) universal keyboard device driver. The value of the key is then passed into the operating system's hardware abstraction layer.
In the case of Virtual Keyboard (as in touch screen devices):
When the user puts their finger on a modern capacitive touch screen, a
tiny amount of current gets transferred to the finger. This completes the
circuit through the electrostatic field of the conductive layer and
creates a voltage drop at that point on the screen. The
screen controller then raises an interrupt reporting the coordinate of
the keypress.
Then the mobile OS notifies the currently focused application of a press event in one of its GUI elements (which now is the virtual keyboard application buttons).
The virtual keyboard can now raise a software interrupt for sending a 'key pressed' message back to the OS.
This interrupt notifies the currently focused application of a 'key pressed' event.
The keyboard sends signals on its interrupt request line (IRQ), which is mapped
to an interrupt vector (integer) by the interrupt controller. The CPU uses
the Interrupt Descriptor Table (IDT) to map the interrupt vectors to
functions (interrupt handlers) which are supplied by the kernel. When an
interrupt arrives, the CPU indexes the IDT with the interrupt vector and runs
the appropriate handler. Thus, the kernel is entered.
WM_KEYDOWN message is sent to the appThe HID transport passes the key down event to the KBDHID.sys driver which
converts the HID usage into a scancode. In this case, the scan code is
VK_RETURN (0x0D). The KBDHID.sys driver interfaces with the
KBDCLASS.sys (keyboard class driver). This driver is responsible for
handling all keyboard and keypad input in a secure manner. It then calls into
Win32K.sys (after potentially passing the message through 3rd party
keyboard filters that are installed). This all happens in kernel mode.
Win32K.sys figures out what window is the active window through the
GetForegroundWindow() API. This API provides the window handle of the
browser's address box. The main Windows "message pump" then calls
SendMessage(hWnd, WM_KEYDOWN, VK_RETURN, lParam). lParam is a bitmask
that indicates further information about the keypress: repeat count (0 in this
case), the actual scan code (can be OEM dependent, but generally wouldn't be
for VK_RETURN), whether extended keys (e.g. alt, shift, ctrl) were also
pressed (they weren't), and some other state.
The Windows SendMessage API is a straightforward function that
adds the message to a queue for the particular window handle (hWnd).
Later, the main message processing function (called a WindowProc) assigned
to the hWnd is called in order to process each message in the queue.
The window (hWnd) that is active is actually an edit control and the
WindowProc in this case has a message handler for WM_KEYDOWN messages.
This code looks within the 3rd parameter that was passed to SendMessage
(wParam) and, because it is VK_RETURN knows the user has hit the ENTER
key.
KeyDown NSEvent is sent to the appThe interrupt signal triggers an interrupt event in the I/O Kit kext keyboard
driver. The driver translates the signal into a key code which is passed to the
OS X WindowServer process. Resultantly, the WindowServer dispatches an
event to any appropriate (e.g. active or listening) applications through their
Mach port where it is placed into an event queue. Events can then be read from
this queue by threads with sufficient privileges calling the
mach_ipc_dispatch function. This most commonly occurs through, and is
handled by, an NSApplication main event loop, via an NSEvent of
NSEventType KeyDown.
When a graphical X server is used, X will use the generic event
driver evdev to acquire the keypress. A re-mapping of keycodes to scancodes
is made with X server specific keymaps and rules.
When the scancode mapping of the key pressed is complete, the X server
sends the character to the window manager (DWM, metacity, i3, etc), so the
window manager in turn sends the character to the focused window.
The graphical API of the window that receives the character prints the
appropriate font symbol in the appropriate focused field.
The browser now has the following information contained in the URL (Uniform Resource Locator):
Protocol "http"
Use 'Hyper Text Transfer Protocol'
Resource "/"
Retrieve main (index) page
When no protocol or valid domain name is given the browser proceeds to feed the text given in the address box to the browser's default web search engine. In many cases the URL has a special piece of text appended to it to tell the search engine that it came from a particular browser's URL bar.
a-z,
A-Z, 0-9, -, or ..google.com there won't be any, but if there were
the browser would apply Punycode_ encoding to the hostname portion of the
URL.downgrade attack_, which is why the HSTS list is included in modern web
browsers.)chrome://net-internals/#dns <chrome://net-internals/#dns>_).gethostbyname library function (varies by
OS) to do the lookup.gethostbyname checks if the hostname can be resolved by reference in the
local hosts file (whose location varies by OS_) before trying to
resolve the hostname through DNS.gethostbyname does not have it cached nor can find it in the hosts
file then it makes a request to the DNS server configured in the network
stack. This is typically the local router or the ISP's caching DNS server.ARP process below for the DNS server.ARP process below for the default gateway IP.In order to send an ARP (Address Resolution Protocol) broadcast the network stack library needs the target IP address to lookup. It also needs to know the MAC address of the interface it will use to send out the ARP broadcast.
The ARP cache is first checked for an ARP entry for our target IP. If it is in the cache, the library function returns the result: Target IP = MAC.
If the entry is not in the ARP cache:
The route table is looked up, to see if the Target IP address is on any of the subnets on the local route table. If it is, the library uses the interface associated with that subnet. If it is not, the library uses the interface that has the subnet of our default gateway.
The MAC address of the selected network interface is looked up.
The network library sends a Layer 2 (data link layer of the OSI model_)
ARP request:
ARP Request::
Sender MAC: interface:mac:address:here
Sender IP: interface.ip.goes.here
Target MAC: FF:FF:FF:FF:FF:FF (Broadcast)
Target IP: target.ip.goes.here
Depending on what type of hardware is between the computer and the router:
Directly connected:
ARP Reply (see below)Hub:
Selected from shared topics, language and repository description—not editorial ratings.
NeoVertex1 /
SuperPrompt is an attempt to engineer prompts that might help us understand AI agents.
81/100 healthAllar /
An attempt to make Unreal Engine 4 projects more consistent
94/100 healthroidrage /
An attempt to tame Rails' default policy to log everything.
asadoughi /
Notes and exercise attempts for "An Introduction to Statistical Learning"
75/100 healthksm /
An attempt to gather all that is in flux in Swift.
64/100 healthC0nw0nk /
A Anti-DDoS script to protect Nginx web servers using Lua with a HTML Javascript based authentication puzzle inspired by Cloudflare I am under attack mode an Anti-DDoS authentication page protect yourself from every attack type All Layer 7 Attacks Mitigating Historic Attacks DoS DoS Implications DDoS All Brute Force Attacks Zero day exploits Social Engineering Rainbow Tables Password Cracking Tools Password Lists Dictionary Attacks Time Delay Any Hosting Provider Any CMS or Custom Website Unlimited Attempt Frequency Search Attacks HTTP Basic Authentication HTTP Digest Authentication HTML Form Based Authentication Mask Attacks Rule-Based Search Attacks Combinator Attacks Botnet Attacks Unauthorized IPs IP Whitelisting Bruter THC Hydra John the Ripper Brutus Ophcrack unauthorized logins Injection Broken Authentication and Session Management Sensitive Data Exposure XML External Entities (XXE) Broken Access Control Security Misconfiguration Cross-Site Scripting (XSS) Insecure Deserialization Using Components with Known Vulnerabilities Insufficient Logging & Monitoring Drupal WordPress Joomla Flash Magento PHP Plone WHMCS Atlassian Products malicious traffic Adult video script avs KVS Kernel Video Sharing Clip Bucket Tube sites Content Management Systems Social networks scripts backends proxy proxies PHP Python Porn sites xxx adult gaming networks servers sites forums vbulletin phpbb mybb smf simple machines forum xenforo web hosting video streaming buffering ldap upstream downstream download upload rtmp vod video over dl hls dash hds mss livestream drm mp4 mp3 swf css js html php python sex m3u zip rar archive compressed mitigation code source sourcecode chan 4chan 4chan.org 8chan.net 8ch 8ch.net infinite chan 8kun 8kun.net anonymous anon tor services .onion torproject.org nginx.org nginx.com openresty.org darknet dark net deepweb deep web darkweb dark web mirror vpn reddit reddit.com adobe flash hackthissite.org dreamhack hack hacked hacking hacker hackers hackerz hackz hacks code coding script scripting scripter source leaks leaked leaking cve vulnerability great firewall china america japan russia .gov government http1 http2 http3 quic q3 litespeedtech litespeed apache torrents torrent torrenting webtorrent bittorrent bitorrent bit-torrent cyberlocker cyberlockers cyber locker cyberbunker warez keygen key generator free irc internet relay chat peer-to-peer p2p cryptocurrency crypto bitcoin miner browser xmr monero coinhive coin hive coin-hive litecoin ethereum cpu cycles popads pop-ads advert advertisement networks banner ads protect ovh blazingfast.io amazon steampowered valve store.steampowered.com steamcommunity thepiratebay lulzsec antisec xhamster pornhub porn.com pornhub.com xhamster.com xvideos xvdideos.com xnxx xnxx.com popads popcash cpm ppc
88/100 health