Purpose: dump slack messages, users and files using browser token and cookie.
Typical usecase scenarios:
- You want to archive your private convesations from slack but the administrator does not allow you to install applications.
- You are allowed to install applications in Slack but don't want to use the "cloud" tools for privacy concerns - god knows what those third party apps are retaining in their "clouds".
The library is "fit-for-purpose" quality and provided AS-IS. Can't say it's ready for production, as it lacks most of the unit tests, but will do for ad-hoc use.
- Download the archive from the Releases page for your operating system.
- Unpack
- Run
slackdump -h
to see help.
- Open up your Slack in browser and login.
- Open your browser Developer Console.
- Go to the Network tab
- In the toolbar, switch to
Fetch/XHR
view. - Open any channel or private conversation in Slack. You'll see a bunch of stuff appearing in Network panel.
- In the list of requests, find the one starting with
channels.prefs.get?
, click it and click on Headers tab in the opened pane. - Scroll down, until you see Form Data
- Grab the token: value (it starts with
xoxc-
), by right clicking the value and choosing "Copy Value".
If you don't see the token value in Poogle Chrome - switch to Payload tab, your token is waiting for you there.
- Switch to Application tab and select Cookies in the left navigation pane.
- Find the cookie with the name "
d
". That's right, just the letter "d". - Double-click the Value of this cookie.
- Press Ctrl+C or Cmd+C to copy it's value to clipboard.
- Save it for later.
Create the file named
.env
next to where the slackdump executable in any text editor.Add the token and cookie values to it. End result should look like this:
SLACK_TOKEN=xoxc-<...elided...> COOKIE=12345472908twp<...elided...>
Save the file and close the editor.
Firstly, dump the channel list to choose what you want to dump:
slackdump -c
You will get the output resembling the following:
2021/10/31 17:32:34 initializing... 2021/10/31 17:32:35 retrieving data... 2021/10/31 17:32:35 done ID Arch Saved What CHXXXXXXX - - #everything CHXXXXXXX - - #everyone CHXXXXXXX - - #random DHMAXXXXX - - @slackbot DNF3XXXXX - - @alice DLY4XXXXX - - @bob
You'll need the value in the ID column.
To dump the channel, run the following command:
slackdump <ID1> [ID2] ... [IDn]
By default, slackdump generates a json file with the convesation. If
you want the convesation to be saved to a text file as well, use the
-r text
command line parameter. See example below.
Say, you want to dump convesations with @alice and @bob to the text files and also want to save all the files that you all shared in those convesations:
slackdump -r text -f DNF3XXXXX DLY4XXXXX ------- -- --------- --------- | | | | | | | +-: @alice | | +-----------: @bob | +----------------: save files +----------------------: text file output
To view all users, run:
slackdump -u
Download:
go get github.com/rusq/slackdump
Use:
import "github.com/rusq/slackdump"
func main() {
sd, err := slackdump.New(os.Getenv("TOKEN"), os.Getenv("COOKIE"))
if err != nil {
// handle
}
// ... read the docs
}
Q: Do I need to create a Slack application?
A: No, you don't. You need to grab that token and cookie from the browser Slack session. See Usage in the top of the file.
Q: I'm getting ``invalid_auth``
A: Go get the new Cookie from the browser.