libBootleg

package module
v0.0.0-...-ad62306 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2022 License: GPL-3.0 Imports: 17 Imported by: 5

README

libBootleg

Simple toolkit to move small amounts of data (i.e. text, light media) in a quick and secure manner across a potentially hostile environment.

Think a multiplatform, open source and cryptoanarchist AirDrop.

Motivation

Basically I wrote this for these reasons:

  • I was tired to manually copy passwords, tokens, urls across systems
  • I wanted to get my feet wet with Go
  • I kinda wanted to write something using noise handshakes

Feel free to use it and/or contribute; consider it beta/active development, so think twice before using it in a life or death scenario.

How it works

So, this is the part where we talk about Alice & Bob. Let's say Alice wants to share one of those 20 characters, strong passwords with Bob; she could show it to him from the screen of her phone, but Bob would hate every second typing it. She could share a text file, but you gotta wonder what's the point of making a strong password, if you put it on a network share in plaintext. And, of course, they could use something mature and robust like gpg or scp, but Alice and Bob are lazy and don't always want to export their keys on all their systems. They want something quick, portable, multi-platform, secure enough without feeling like it is an overkill, so they both grab a copy of the bootlegger tool they found in the tools folder of this repo. Here's how the thing happens:

  • Bob creates a new token:
bob$ bootlegger make secret 
  • Then Bob shares his token with Alice off-channel, using a QRcode:
bob$ bootlegger show secret qr
  • Alice scans the QRcode, extracts the token and saves it on her machine:
alice$ bootlegger -token bobstoken secret make
  • The token can be stored on both Bob's and Alice's system in an encrypted form, so, if they plan to share more stuff in the future, they can do so without creating new tokens every time.
  • Bob starts listening:
bob$ bootlegger receive
  • Alice sends her long, untypable password with:
alice$ send superuglypassword

The sender and the receiver find each other using a multicast, TOTP authenticated, discovery protocol; then they use libdisco to implement a Noise NNpsk2 handshake and move data in a secure way.

If multicast is not an option, both sender and receiver can customize ip, port etc. Look at bootlegger -h to have list of what's possible.

In the real world, usually Alice is my phone (from where I can access my password manager etc) and Bob is some random system that, for one reason or another, has no access to my stuff, but needs some of it una tantum.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2Uint32

func Bytes2Uint32(_d []byte) (val uint32, err error)

func CheckDir

func CheckDir(_path string) error

func DecodeReadableSecret

func DecodeReadableSecret(_readable string) ([]byte, error)

func DecryptSecret

func DecryptSecret(_secret []byte, _password string) ([]byte, error)

func DecryptText

func DecryptText(_secret []byte, _cipherText string) (text string, err error)

func DoesFileExist

func DoesFileExist(_path string) bool

func EncryptSecret

func EncryptSecret(_secret []byte, _password string) []byte

func EncryptText

func EncryptText(_secret []byte, _text string) string

func GetDotDirPath

func GetDotDirPath() (string, error)

func GetHomePath

func GetHomePath() (string, error)

func GetLocalIps

func GetLocalIps() []string

func GetOutboundIp

func GetOutboundIp() string

func GetOutboundIpInfo

func GetOutboundIpInfo() (net.IP, error)

func Insert

func Insert(_a []byte, _idx int, _el byte) []byte

func IsEncryptedSecret

func IsEncryptedSecret(_secret []byte) bool

func LoadSecret

func LoadSecret(_path string, _secret *[]byte) (err error)

func LoadSecretEncrypted

func LoadSecretEncrypted(_path string, _secret *[]byte, _pass string) (err error)

func MakeDiscoverPacket

func MakeDiscoverPacket(_secret *[]byte) []byte

func MakeHash

func MakeHash(_secret []byte) []byte

func MakeOtp

func MakeOtp(_secret []byte, _ephemeral []byte) (otp string, err error)

OTP---

func MakeSecret

func MakeSecret() ([]byte, error)

make a random 32bytes secret

func MakeSecretReadable

func MakeSecretReadable(_secret []byte) string

func MakeTotp

func MakeTotp(_secret []byte) (otp string, err error)

func MarkSecretEncrypted

func MarkSecretEncrypted(_secret *[]byte)

func MarkSecretPlainText

func MarkSecretPlainText(_secret *[]byte)

func PathJoin

func PathJoin(_path1 string, _path2 string) string

func ReceiveProbes

func ReceiveProbes(_ni *NetInfo, _secret *[]byte) error

func ReceiveProbesDefault

func ReceiveProbesDefault(_secret *[]byte) error

func ResetFile

func ResetFile(_path string) error

func SaveSecret

func SaveSecret(_secret []byte, _path string) error

func SaveSecretEncrypted

func SaveSecretEncrypted(_secret []byte, _path string, _pass string) error

func SendDataPack

func SendDataPack(_ni *NetInfo, _secret []byte, _dp *DataPack, _bVerbose bool) error

func SendFile

func SendFile(_ni *NetInfo, _secret []byte, _fName string, _d []byte) error

func SendFilePath

func SendFilePath(_ni *NetInfo, _secret []byte, _pth string) error

func SendProbe

func SendProbe(_ni *NetInfo, _secret []byte) error

func SendText

func SendText(_ni *NetInfo, _secret []byte, _msg string) error

func Uint322Bytes

func Uint322Bytes(_val uint32) []byte

Types

type DataHeader

type DataHeader struct {
	// contains filtered or unexported fields
}

func (*DataHeader) GetFileName

func (dh *DataHeader) GetFileName() string

func (*DataHeader) GetRaw

func (dh *DataHeader) GetRaw() []byte

func (*DataHeader) GetSize

func (dh *DataHeader) GetSize() int

func (*DataHeader) GetType

func (dh *DataHeader) GetType() DataType

func (*DataHeader) SetFromData

func (dh *DataHeader) SetFromData(_d *[]byte)

type DataPack

type DataPack struct {
	Header DataHeader
	Data   []byte
}

data---

func (*DataPack) GetRaw

func (dp *DataPack) GetRaw() []byte

func (*DataPack) LoadFile

func (dp *DataPack) LoadFile(_pth string) (err error)

func (*DataPack) SaveFile

func (dp *DataPack) SaveFile() error

func (*DataPack) SetFile

func (dp *DataPack) SetFile(_fName string, _d []byte)

func (*DataPack) SetFromRaw

func (dp *DataPack) SetFromRaw(_d *[]byte)

func (*DataPack) SetProbe

func (dp *DataPack) SetProbe()

func (*DataPack) SetText

func (dp *DataPack) SetText(_txt string)

type DataType

type DataType byte

header---

const (
	DATA_TEXT  DataType = 't'
	DATA_FILE  DataType = 'f'
	DATA_PROBE DataType = 'p'
	DATA_NONE  DataType = 'n'
)

func Byte2DataType

func Byte2DataType(_byte byte) DataType

type Discoverable

type Discoverable struct {
	// contains filtered or unexported fields
}

Discoverable makes itself discoverable

func (*Discoverable) Init

func (d *Discoverable) Init(secret *[]byte)

Init initializes the discoverable object

func (*Discoverable) IsPublishing

func (d *Discoverable) IsPublishing() bool

IsPublishing returns true if the discoverable object is publishing itself

func (*Discoverable) StartPublishing

func (d *Discoverable) StartPublishing()

StartPublishing starts to publish the discoverable object

func (*Discoverable) StopPublishing

func (d *Discoverable) StopPublishing()

StopPublishing stops the discoverable object

type Discoverer

type Discoverer struct {
	// contains filtered or unexported fields
}

Discoverer tries to find a listening bootleg instance

func (*Discoverer) Discover

func (d *Discoverer) Discover(timeout int) (discovered []peerdiscovery.Discovered, err error)

Discover discovers listening bootleg instances

func (*Discoverer) Init

func (d *Discoverer) Init(secret *[]byte)

Init initializez the discoverer

type DiscoveryListener

type DiscoveryListener struct {
	CIp    chan string
	Secret *[]byte
	// contains filtered or unexported fields
}

func (*DiscoveryListener) GetFoundIps

func (dl *DiscoveryListener) GetFoundIps() []string

func (*DiscoveryListener) IsRunning

func (dl *DiscoveryListener) IsRunning() bool

func (*DiscoveryListener) ReceiveReply

func (dl *DiscoveryListener) ReceiveReply(_ip string) ([]string, error)

func (*DiscoveryListener) Start

func (dl *DiscoveryListener) Start(_ip string)

func (*DiscoveryListener) Stop

func (dl *DiscoveryListener) Stop()

type Listener

type Listener struct {
	BufSize int
	// contains filtered or unexported fields
}

Listener---

func (Listener) HasListener

func (_l Listener) HasListener() bool

func (Listener) HasNetInfo

func (_l Listener) HasNetInfo() bool

func (Listener) HasSecret

func (_l Listener) HasSecret() bool

func (Listener) IsListening

func (_l Listener) IsListening() bool

func (Listener) IsReady

func (_l Listener) IsReady() bool

func (*Listener) SetNetInfo

func (_l *Listener) SetNetInfo(_ip string, _port int)

func (*Listener) SetSecret

func (_l *Listener) SetSecret(_secret []byte)

func (*Listener) SetupAndListen

func (_l *Listener) SetupAndListen(_ip string, _port int, _secret []byte, _data chan DataPack) bool

func (*Listener) StartListening

func (_l *Listener) StartListening(_data chan DataPack) bool

func (*Listener) StopListening

func (_l *Listener) StopListening()

type NetInfo

type NetInfo struct {
	Ip   string
	Port int
}

func MakeDefaultMulticastNetInfo

func MakeDefaultMulticastNetInfo() NetInfo

func (NetInfo) String

func (_ni NetInfo) String() string

func (NetInfo) UDPAddr

func (_ni NetInfo) UDPAddr() (*net.UDPAddr, error)

type TokenHash

type TokenHash struct {
	// contains filtered or unexported fields
}

TokenHash---

func (*TokenHash) SetFromReadableSecret

func (_th *TokenHash) SetFromReadableSecret(_name string, _readable string)

func (*TokenHash) SetFromSecret

func (_th *TokenHash) SetFromSecret(_name string, _s []byte)

type TokenTank

type TokenTank struct {
	// contains filtered or unexported fields
}

HashTank---

func (*TokenTank) AddReadable

func (_tt *TokenTank) AddReadable(_name string, _s string)

func (*TokenTank) AddSecret

func (_tt *TokenTank) AddSecret(_name string, _s []byte)

func (*TokenTank) AddTokenHash

func (_tt *TokenTank) AddTokenHash(_th *TokenHash)

func (*TokenTank) CheckReadableToken

func (_tt *TokenTank) CheckReadableToken(_readable string) (bool, string)

func (*TokenTank) CheckToken

func (_tt *TokenTank) CheckToken(_s []byte) (bool, string)

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL