Skip to content

Instantly share code, notes, and snippets.

@ilyaigpetrov
Last active January 26, 2020 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyaigpetrov/9ba6b86626f7d6cde09ef46fa8bdceaa to your computer and use it in GitHub Desktop.
Save ilyaigpetrov/9ba6b86626f7d6cde09ef46fa8bdceaa to your computer and use it in GitHub Desktop.
Request Kitchen Extension For FireFox And Chromium | https://github.com/ilyaigpetrov/request-kitchen | by https://git.io/ilyaigpetrov

Request Kitchen

Extension for handling requests according to lists added by user (e.g. lists may be hosted on github, npm -- any url will work. Maybe there even will be a special support for popular tabular data editors like google docs/spreadsheets).

The internal workings of the extension are based on PAC scripts.

You just click a specially formed url (e.g. request-kitchen.appspot.com/add-list=https://raw.github.com/foo/bar)

and extension hijacks your click and shows user a big WARNING page, e.g. "You are about to conceive a child by installing this list named 'POOP' which purpose is 'Throw some poops in your browser'. Are you sure?"

User clicks "yes" and his browser gains super powers (or a malware).

Cases:

  • By "sites" I mean domains, because full urls (with path) may be not accessible for https (in contrast to http) inside PAC scripts.
  1. List of sites to proxy (proxy servers are configurable and may be changed by user).

  2. List of sites to block requests to (e.g. by "PROXY localhost:65535", if it's secure).

  3. List of sites to warn user about somehow (showing badge on the icon, showing a whole page with text, unobtrusively or more disturbingly).

    Examples: show a "site blocked" page with a reason of the block (by adblocker, by censorship, by anti-malware) and a button to bypass the block temporary or more consistently.

  4. List of sites to redirect to other pages? Secure? Useful?

    Example 1: redirect from fake sites/mirrors to the true site. User MUST know about the redirect (case 3 above is enough for this).

    Example 2: redirect from a censored site to a registry record explaining why it was blocked.

    Example 3: redirect to google translate or other service to unblock the censored site.

    Many examples are feasible based only on case 3 (showing a page with hypertext and links generated based on the blocked url/domain).

    Code execution on the shown page is dangerous, but simple template rendering may be enough for many tasks yet still restrictive.

    More advanced solution is to use some analogy of eBPF on pages but this will require more work.

  5. Redirect from some error pages to https://downforeveryoneorjustme.com/foobar.com or show user a link to this site. This is a possible application for eBPF-like code that checks if error code is appropriate. Not possible inside PAC scripts only (requires API like declarativeNetRequest).

  6. List of sites after opening which a request is made to a supplied url and additional data is fetched like a title for a extension badge and text for user to show (e.g. number of new messages and their titles). This will allow to add some kind of notifications about events to sites that don't have them.

Problems

  1. Requests inside PAC scripts are not associated with tabs, it's not possible to know if request is inside a top-frame (initiated by address bar or by a page subrequest). So PAC scripts just provide list-to-event subsystem, events must be paired with another APIs (webrequest, declarativewebrequest).

Formats

Proxy and sets from providers

[
  {
    "projectId": "antizapret",
    "project": {
      "ru": {
        "name": "АнтиЗапрет",
        "homepage": "https://antizapret.prostovpn.org",
        "description": "Для обхода блокировок в РФ."
      },
      "en": {
        "name": "AntiZapret"
      }
    },
    "sets": {
      "azDomains": {
        "elements": "domains",
        "sources": [{
          "transport": "http",
          "type": "kitchen1.txt",
          "urls": ["https://antizapret.prostovpn.org/domains-export.txt"]
        }]
      },
      "azIpsV4": {
        "elements": "ips",
        "typeOpts": {
          "ipVersion": "v4"
        },
        "sources": [{
          "transport": "http",
          "type": "kitchen1.txt",
          "urls": ["https://...ips.txt"]
        }]
      },
      "azRangesV4": {
        "elements": "subnets",
        "typeOpts": {
          "ipVersion": "v4"
        },
        "sources": [{
          "transport": "http",
          "type": "kitchen1.txt",
          "urls": ["https://...ranges.txt"]
        }]
      },
      "azSpecial": {
        "elements": "domains",
        "sources": [{
          "transport": "embed",
          "type": "kitchen1.json",
          "list": [
            "kasparov.ru",
            "grani.ru"
          ]
        }]
      }
    },
    "proxies": {
      "azMain": {
        "allowedForSets": ["azDomains", "azIps"],
        "allowedForProjects": ["antizapret"],
        "asObjects": [{
          "type": "SOCKS",
          "host": "localhost",
          "port": 8080
        }]
      }
    }
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment