kieri097 / slackdump

A command line utility to create and save an archive of slack public and private messages and threads, files, and users.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slack Dumper

Buy me a cup of tea

Join discussion

A set up guide on Medium.com

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.

Usage

  1. Download the archive from the Releases page for your operating system. (NOTE: MacOS users should download darwin release file).
  2. Unpack
  3. Change directory to where you have unpacked the archive.
  4. Run ./slackdump -h to see help.

How to authenticate

Getting the authentication data

  1. Open up your Slack in browser and login.
TOKEN
  1. Open your browser Developer Console.
  2. Go to the Network tab
  3. In the toolbar, switch to Fetch/XHR view.
  4. Open any channel or private conversation in Slack. You'll see a bunch of stuff appearing in Network panel.
  5. In the list of requests, find the one starting with channels.prefs.get?, click it and click on Headers tab in the opened pane.
  6. Scroll down, until you see Form Data
  7. 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.

COOKIE
  1. Switch to Application tab and select Cookies in the left navigation pane.
  2. Find the cookie with the name "d". That's right, just the letter "d".
  3. Double-click the Value of this cookie.
  4. Press Ctrl+C or Cmd+C to copy it's value to clipboard.
  5. Save it for later.

Setting up the application

  1. Create the file named .env next to where the slackdump executable in any text editor.

  2. Add the token and cookie values to it. End result should look like this:

    SLACK_TOKEN=xoxc-<...elided...>
    COOKIE=12345472908twp<...elided...>
    
  3. Save the file and close the editor.

Dumping conversations

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.

Example

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

Dumping users

To view all users, run:

slackdump -u

As a library

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
}

FAQ

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.

Bulletin Board

Messages that were conveyed with the donations:

  • 25/01/2022: Stay away from TheSignChef.com, ya hear, they don't pay what they owe to their employees.

About

A command line utility to create and save an archive of slack public and private messages and threads, files, and users.

License:GNU General Public License v3.0


Languages

Language:Go 97.6%Language:Makefile 2.1%Language:Shell 0.3%