Skip to content
/ multicode Public

💱 Decode bits, bytes, hex, base64 and protobuf recursively with a single command

License

Notifications You must be signed in to change notification settings

sj14/multicode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multicode

Build Status Go Report Card GoDoc

multicode allows to input a (nested) bits, bytes, hex, base64 or proto (protocol buffers) encoded sequence and will recursively try to decode it. This is helpful when you get encoded data but don't exactly know how it was encoded or decoding might lead to cumbersome command concatenation.

Installation

CLI

Precompiled Binaries

Binaries are available for all major platforms. See the releases page.

Homebrew

Using the Homebrew package manager for macOS:

brew install sj14/tap/multicode

Manually

It's also possible to install the current development snapshot with go get:

go get -u github.com/sj14/multicode/cmd/decode

Web Interface

Demo

go get -u github.com/sj14/multicode/cmd/decode-web

CLI Usage

  -base64
        use base64 decoding (default true)
  -bit
        use bit decoding (default true)
  -byte
        use byte decoding (default true)
  -hex
        use hex decoding (default true)
  -proto
        use proto decoding (default true)
  -verbose
        verbose output mode
  -version
        print version information

CLI Examples

Decode byte input

$ decode "72 101 108 108 111 32 87 111 114 108 100"
Hello World

Decode nested decodings

First, let's encode a string with hex and base64 encoding:

$ echo hello there | xxd -p | base64
Njg2NTZjNmM2ZjIwNzQ2ODY1NzI2NTBhCg==

Decode:

$ decode Njg2NTZjNmM2ZjIwNzQ2ODY1NzI2NTBhCg==
hello there

Decode using the pipe:

$ echo Njg2NTZjNmM2ZjIwNzQ2ODY1NzI2NTBhCg== | decode
hello there

Decode in verbose mode:

$ decode -v Njg2NTZjNmM2ZjIwNzQ2ODY1NzI2NTBhCg==
- applied decoding 'base64':
68656C6C6F207468657265

- applied decoding 'hex':
hello there

- result:
hello there

Disable hex decoding:

$ decode -v -hex=false Njg2NTZjNmM2ZjIwNzQ2ODY1NzI2NTBhCg==
- applied decoding 'base64':
68656C6C6F207468657265

- result:
68656C6C6F207468657265

Protobuf

We can decode protocol buffer encodings without specifying a proto file. Based on the missing definition file, it's unfortunately not possible, to output the field names. Field names will be replaced by the field id.

Let's assume the following proto message:

message Message {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
  enum Corpus {
      UNIVERSAL = 0;
      WEB = 1;
  }
  Corpus corpus = 4;
}

And we initialize the message like this:

Message{
  Query:      "my query",
  PageNumber: 42,
  Corpus:     ComplexMessage_NEWS,
}

The hex decoded proto message (0a086d79207175657279102a2006) will be decoded as:

$ decode 0a086d79207175657279102a2004
1:"my query" 2:42 4:6

Using with Docker

CLI Version

docker build -f Dockerfile.decode -t decode .
docker run --rm -it decode

Web Version

docker build -f Dockerfile.decode-web -t decode-web .
docker run --rm -it -p 8080:8080 decode-web

About

💱 Decode bits, bytes, hex, base64 and protobuf recursively with a single command

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages