-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract-cookies.sh
executable file
·52 lines (48 loc) · 1.1 KB
/
extract-cookies.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
if [ -t 1 ]; then
>&2 echo "!!! This probably should be redirected to a file"
>&2 echo
fi
if [ -z "$1" ]; then
>&2 echo "!!! A cookies.sqlite file must be provided"
>&2 echo "Usage: $0 FILE"
fi
# This roughly matches the header for these files that is
# used by the Python standard library
echo "# HTTP Cookie File"
echo "# http://curl.haxx.se/rfc/cookie_spec.html"
echo "# This is a generated file! Do not edit."
echo ""
sqlite3 "$1" <<- EOF
.mode tabs
.header off
SELECT
-- In the Netscape Cookie format, HttpOnly cookies are prefixed
-- with "#HttpOnly_".
CASE
WHEN isHttpOnly
THEN '#HttpOnly_' || host
ELSE host
END,
CASE
WHEN host LIKE '.%'
THEN 'TRUE'
ELSE 'FALSE'
END,
path,
CASE
WHEN isSecure
THEN 'TRUE'
ELSE 'FALSE'
END,
expiry,
name,
value
FROM moz_cookies
WHERE
host LIKE '%nytimes.com'
-- Technically, either of these cookies works but we'll grab them
-- both just to help ensure that we have at least one
AND name IN ('NYT-S', 'SIDNY')
;
EOF