blob: a261cb7f617c961a54bd6dde922639323f1d853e (
plain) (
blame)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
#!/bin/sh
set -eu
service=$1
email=${2:-$(git config fetchemail.imapUser)}
generate() {
openssl rand -base64 33
}
copy() {
printf '%s' "$1" | pbcopy
}
unwrap() {
sed '
:x
/=$/ {
N
s/=\n//g
bx
}
'
}
asciinema() {
echo 'Fetching CSRF token...'
jar=$(mktemp -t sup)
trap 'rm "${jar}"' EXIT
csrf=$(
curl -Ss -c "${jar}" 'https://asciinema.org/login/new' |
sed -n 's/.*name="_csrf_token".*value="\([^"]*\)".*/\1/p'
)
echo 'Submitting form...'
curl -Ss -X POST -b "${jar}" \
-F "_csrf_token=${csrf}" -F "login[email]=${email}" \
'https://asciinema.org/login' \
>/dev/null
echo 'Waiting for email...'
url=$(
git fetch-email -i -M Trash \
-F 'hello@asciinema.org' -T "${email}" \
-S 'Login to asciinema.org' |
grep -m 1 '^https://asciinema\.org/session/new'
)
open "${url}"
}
bugzilla() {
echo 'Fetching CSRF token...'
csrf=$(
curl -Ss "${bugzillaBase}/" |
sed -n '
/name="token"/N
s/.*name="token"[[:space:]]*value="\([^"]*\)".*/\1/p
' | head -n 1
)
echo 'Submitting form...'
curl -Ss -X POST \
-F "loginname=${email}" -F "token=${csrf}" -F 'a=reqpw' \
"${bugzillaBase}/token.cgi" \
>/dev/null
echo 'Waiting for email...'
token=$(
git fetch-email -i -M Trash \
-F "${bugzillaFrom}" -T "${email}" \
-S 'Bugzilla Change Password Request' |
sed -n 's/.*t=3D\([^&]*\).*/\1/p' |
head -n 1
)
password=$(generate)
echo 'Setting password...'
curl -Ss -X POST \
-F "t=${token}" -F 'a=chgpw' \
-F "password=${password}" -F "matchpassword=${password}" \
"${bugzillaBase}/token.cgi" \
>/dev/null
copy "${password}"
open "${bugzillaBase}/"
}
freebsdbugzilla() {
bugzillaBase='https://bugs.freebsd.org/bugzilla'
bugzillaFrom='bugzilla-noreply@freebsd.org'
bugzilla
}
discogs() {
echo 'Submitting form...'
curl -Ss -X POST \
-F "email=${email}" -F 'Action.EmailResetInstructions=submit' \
'https://www.discogs.com/users/forgot_password' \
>/dev/null
echo 'Waiting for email...'
url=$(
git fetch-email -i -M Trash \
-F 'noreply@discogs.com' -T "${email}" \
-S 'Discogs Account Password Reset Instructions' |
sed -n 's/^To proceed, follow the instructions here: \(.*\)/\1/p'
)
echo 'Fetching token...'
token=$(curl -ISs --url "${url}" | sed -n 's/.*[?]token=\([^&]*\).*/\1/p')
password=$(generate)
echo 'Setting password...'
curl -Ss -X POST \
-F "token=${token}" \
-F "password0=${password}" -F "password1=${password}" \
-F 'Action.ChangePassword=submit' \
'https://www.discogs.com/users/forgot_password' \
>/dev/null
copy "${password}"
open 'https://discogs.com/login'
}
liberapay() {
echo 'Fetching CSRF token...'
csrf=$(
curl -Ss 'https://liberapay.com/sign-in' |
sed -n 's/.*name="csrf_token".*value="\([^"]*\)".*/\1/p'
)
echo 'Submitting form...'
curl -Ss -X POST \
-b "csrf_token=${csrf}" -F "csrf_token=${csrf}" \
-F "log-in.id=${email}" \
'https://liberapay.com/sign-in' \
>/dev/null
echo 'Waiting for email...'
url=$(
git fetch-email -i -M Trash \
-F 'support@liberapay.com' -T "${email}" \
-S 'Log in to Liberapay' |
grep -m 1 '^https://liberapay\.com/'
)
open "${url}"
}
lobsters() {
: ${lobstersBase:=https://lobste.rs}
: ${lobstersFrom:=nobody@lobste.rs}
echo 'Fetching CSRF token...'
csrf=$(
curl -Ss "${lobstersBase}/login/forgot_password" |
sed -n 's/.*name="authenticity_token" value="\([^"]*\)".*/\1/p'
)
echo 'Submitting form...'
curl -Ss -X POST \
-F "authenticity_token=${csrf}" \
-F "email=${email}" -F 'commit=submit' \
"${lobstersBase}/login/reset_password" \
>/dev/null
echo 'Waiting for email...'
token=$(
git fetch-email -i -M Trash \
-F "${lobstersFrom}" -T "${email}" \
-S 'Reset your password' |
sed -n 's|^https://.*[?]token=\([^&]*\).*|\1|p'
)
echo 'Fetching CSRF token...'
csrf=$(
curl -Ss "${lobstersBase}/login/set_new_password?token=${token}" |
sed -n 's/.*name="authenticity_token" value="\([^"]*\)".*/\1/p'
)
password=$(generate)
echo 'Setting password...'
curl -Ss -X POST \
-F "authenticity_token=${csrf}" -F "token=${token}" \
-F "password=${password}" -F "password_confirmation=${password}" \
-F 'commit=submit' \
"${lobstersBase}/login/set_new_password" \
>/dev/null
copy "${password}"
open "${lobstersBase}/login"
}
patreon() {
readonly patreonAPI='https://www.patreon.com/api'
echo 'Submitting form...'
curl -Ss -X POST -d @- \
-H 'Content-Type: application/vnd.api+json' \
"${patreonAPI}/auth/forgot-password?json-api-version=1.0" <<-EOF
{"data":{"email":"${email}"}}
EOF
echo 'Waiting for email...'
url=$(
git fetch-email -i -M Trash \
-F 'password@patreon.com' -T "${email}" \
-S 'Patreon Password Reset' |
unwrap |
grep -o -m 1 'https://email[.]mailgun[.]patreon[.]com/.*'
)
echo 'Fetching token...'
location=$(curl -ISs --url "${url}" | grep -i '^Location: ' | tr -d '\r')
u=$(echo "${location}" | sed 's/.*[?&]u=\([^&]*\).*/\1/')
sec=$(echo "${location}" | sed 's/.*[?&]sec=\([^&]*\).*/\1/')
password=$(generate)
echo 'Setting password...'
curl -Ss -X POST -d @- \
-H 'Content-Type: application/vnd.api+json' \
"${patreonAPI}/auth/forgot-password/change?json-api-version=1.0" <<-EOF
{
"data":{
"user_id":"${u}",
"security_token":"${sec}",
"password":"${password}"
}
}
EOF
copy "${password}"
open 'https://www.patreon.com/login'
}
tildenews() {
lobstersBase='https://tilde.news'
lobstersFrom='nobody@tilde.news'
lobsters
}
$service
|