Top Banner
Chrome Extensions What are they good for, anyway?
53

Chrome Extensions at Manhattan JS

Apr 16, 2017

Download

Internet

Cory Forsyth
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chrome Extensions at Manhattan JS

Chrome ExtensionsWhat are they good for, anyway?

Page 2: Chrome Extensions at Manhattan JS

Cory Forsyth

@bantic

Page 3: Chrome Extensions at Manhattan JS

201 Created

Consultants in New York City

Page 4: Chrome Extensions at Manhattan JS

Browsers, Then & Now

Page 5: Chrome Extensions at Manhattan JS

Browsers Then20+ Years Old

Text, Links, small GIFs

Credit: Indolering (Own work) [CC0], via Wikimedia Commons

<blink>

Page 6: Chrome Extensions at Manhattan JS

Browsers Now• 10M Lines of Code

• Ubiquitous

• Indispensable

• WebGL, Location

• Orientation, Battery

• High-performance

• Text-to-speech, Audio

• Sentient?

Page 7: Chrome Extensions at Manhattan JS

Browsers Now

• TV, Play, Communication, Relaxing

• Filters to the world

• For “working hard and hardly working”

Page 8: Chrome Extensions at Manhattan JS

Browsers Now

Page 9: Chrome Extensions at Manhattan JS

Extensions: Intro

Page 10: Chrome Extensions at Manhattan JS

Internet

Extensions

Browser

Page 11: Chrome Extensions at Manhattan JS

Chrome Extensions• Installable, App-like, JS+CSS+HTML

• Look-over-your-shoulder; and

• Liminal: between your browser and the world

• Powerful position!

• Democratic, open like the web

Page 12: Chrome Extensions at Manhattan JS

Chrome Extensions

Put icons herePut icons hereRead page contents

Watch/change history

Page 13: Chrome Extensions at Manhattan JS

Chrome Extensions

Filter network requests

Add DevTool Panes

Page 14: Chrome Extensions at Manhattan JS

Chrome Extensions

Take pictures of tab contentOpen, close, reorder tabs

Change textChange icon

Page 15: Chrome Extensions at Manhattan JS

Capabilities• alarms

• manage bookmarks, tabs (open/close/move)

• contentSettings — cookies, javascript

• notifications

• tabCapture — take pictures

• text-to-speech

• override built-in pages (new-tab, bookmarks, history)

• geolocation

• omnibox

• history

Page 16: Chrome Extensions at Manhattan JS

Extensions: Anatomy

Page 17: Chrome Extensions at Manhattan JS

manifest.json

• the “outline”

• name, description, icons

• permissions

• describes which files to include, and how

Page 18: Chrome Extensions at Manhattan JS

manifest.json{ "name": "My extension", "version": "1.0", "description": "Hard to describe.", "icons": { "128": "icon128.png" },

"manifest_version": 2,manifest.json

Page 19: Chrome Extensions at Manhattan JS

content scripts• Injected js in each tab

• “Bookmarklet on steroids”

• Can read/write DOM

• Can only access chrome message-passing APIs

• No access to other `chrome.*` APIs

• Operates in “isolated world”

"content_scripts": [ { "matches": ["<all_urls>"], "js": [ "jquery.js", "content_script.js" ] } ],

manifest.json

Page 20: Chrome Extensions at Manhattan JS

background page (script)• Accesses Chrome Extension APIs (`chrome.*`)

• Read/change browser state (tabs, windows, etc)

• Add listeners for Chrome API events (toolbar icon clicks, network requests, tab changes, history updated, etc.)

• No access to DOM

• Uses message-passing to coordinate w/ content script

• Only 1 instance per extension (not per tab)

Page 21: Chrome Extensions at Manhattan JS

background page (script)

"background": { "scripts": [ "background.js" ] },

manifest.json1 background script

Content Script injected

Content Script injected

2 Tabs

Page 22: Chrome Extensions at Manhattan JS

page / browser action• Icon in or near toolbar

• Optional “badge” text

• Animatable

• Pop-up (configured via manifest.json); or

• Add click listener (via background page (script))

Page 23: Chrome Extensions at Manhattan JS

page / browser action

Browser ActionPage Action

"browser_action": { "default_icon": "icon.png", "default_title": "My action" },

manifest.json

"page_action": { "default_icon": "icon.png", "default_title": "My action" },

manifest.json

Page 24: Chrome Extensions at Manhattan JS

Distribution

Page 25: Chrome Extensions at Manhattan JS

• “Developer mode”

• Chrome Web Store

• Inline Install

• Developer Dashboard

Distribution

Page 26: Chrome Extensions at Manhattan JS

Security

Page 27: Chrome Extensions at Manhattan JS
Page 28: Chrome Extensions at Manhattan JS

Security

Page 29: Chrome Extensions at Manhattan JS

Security

Page 30: Chrome Extensions at Manhattan JS

Security

Not kidding. At all.

Page 31: Chrome Extensions at Manhattan JS
Page 32: Chrome Extensions at Manhattan JS

Chrome Security

• Automatic Static Analysis

• limit Inline Install

• Expectation: Malicious Keyloggers

Page 33: Chrome Extensions at Manhattan JS

“Unwanted Software”• Like 90s Toolbars

• Change default search prefs or new tab page

• Search Engine + Affiliate Code

• Inject Ads

• Binaries that sideload extensions

• “.exe” from “free-tv.com” sites, e.g.

Page 34: Chrome Extensions at Manhattan JS

“Unwanted Software”

• New Chrome (v48) shows all extensions

• “Chrome Cleanup” Tool

• like a virus scanner…for a browser

Page 35: Chrome Extensions at Manhattan JS

Debugging Extensions

Page 36: Chrome Extensions at Manhattan JS
Page 37: Chrome Extensions at Manhattan JS

Chrome Extensions: Tips & Tricks

Chrome Extension Source Viewer (meta!)

• “Developer Mode” at chrome://extensions

• background page link — opens DevTools

• “inspect popup” — opens DevTools

Page 38: Chrome Extensions at Manhattan JS

Examples

Page 40: Chrome Extensions at Manhattan JS
Page 42: Chrome Extensions at Manhattan JS
Page 44: Chrome Extensions at Manhattan JS
Page 45: Chrome Extensions at Manhattan JS
Page 46: Chrome Extensions at Manhattan JS
Page 47: Chrome Extensions at Manhattan JS
Page 48: Chrome Extensions at Manhattan JS

WSJ Bypass• WSJ has paywall in front of articles

• but allows Google to crawl its content

• How?

• Referer + User-Agent detection

• Solution? Chrome Ext strips referer, changes User-Agent

• Blog Post by Isoroku Yamamoto

Page 49: Chrome Extensions at Manhattan JS
Page 50: Chrome Extensions at Manhattan JS
Page 51: Chrome Extensions at Manhattan JS

1 user. Wat

Page 53: Chrome Extensions at Manhattan JS

Chrome Extensions: Helpful References

• Manifest.json — The portal into every extension

• hacking-the-browser repo — Lots of simple examples

Chrome Extension Source Viewer

• BPM Browser by Brett Stiller

• Decodelia by Melanie Hoff

• Passtime by Marc Abbey

• Chrome Blog Inline Install Policy Post