-
-
Save stefansundin/ecf51b0dad7fee535df0d0f385f86647 to your computer and use it in GitHub Desktop.
#!/bin/bash -eo pipefail | |
# Log in to Slack in a web browser and open the network tools to inspect the traffic. | |
# Filter the requests with "/api/" and pick one to inspect. | |
# You need the xoxc token from the request body, and a copy of the cookies. It is the "d" cookie that is important, but you can copy all of them. Make sure that the cookie value is percent encoded! | |
# Paste the values below. | |
# You need to have curl and jq installed. | |
# You can also get the xoxc token from localStorage. Run this in the JavaScript console: | |
# Object.entries(JSON.parse(localStorage.localConfig_v2)["teams"]).reduce((o,e) => Object.assign(o, { [e[1]["name"]]: e[1]["token"] }), {}) | |
SLACK_TOKEN="xoxc-...." | |
COOKIES="d=...." | |
data=$(curl -q -sS -b "$COOKIES" "https://slack.com/api/emoji.list?token=$SLACK_TOKEN") | |
if echo "$data" | jq -e '.error?' > /dev/null; then | |
echo "$data" | |
exit 1 | |
fi | |
echo "$data" > data.json | |
echo "$data" | jq -Mr '.emoji | to_entries | .[] | select(.value | startswith("http")) | "\(.key) \(.value)"' | sort | while read name url; do | |
fn="$name.${url##*.}" | |
[[ -f "$fn" ]] && continue | |
echo "$fn" | |
curl -q -sS -o "$fn" "$url" | |
done |
Hi. I was having the same issue for my slack irc gateway: https://github.com/ltworf/localslackirc
I solved it by sniffing the network traffic from the browser development tools and getting both token and cookies.
Couldn't get this to work even with a valid token. Had to pull the list from a browser (using that token), creating a local emojilist.json
from the earlier output. I then replaced curl -q -s "URL"
with cat emojilist.json
and it worked as expected.
I updated the script and added better instructions. Let me know if anything isn't working.
Worked perfectly for me. Thank you!
This worked great for me, thank you!
I get an
{
"ok": false,
"error": "invalid_auth"
}
for:
curl -q -sS -b "$COOKIES" "https://slack.com/api/emoji.list?token=$SLACK_TOKEN"
I used the sniffed xoxc (q=JSON.parse(localStorage.localConfig_v2)["teams"]; q[Object.keys(q)[0]]["token"]) and the d cookie but no joy.
Any hints?
@donnels I suspect your cookie value is not encoded. It does seem like curl needs the data to already be percent encoded. I'll update the instructions to note this.
This does not appear to work anymore (at least not withxoxc
tokens).. I tried but wasn't able to figure out what I need to change.Edit: The script has been updated.