wormhole

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

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

Go to latest
Published: Mar 27, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

README

git-wormhole

git-wormhole logo

git-wormhole is a tool for generating partial commit hash collisions. You can see an example here.

Installation

go install github.com/tncardoso/git-wormhole/cmd/git-wormhole

Examples

There are two strategies available for finding a collision: changing the author/commit time or adding a suffix to the commit message. You will need to provide two files, the template and target. The template is a golang format template. The Target is the file that will be generated by rendering the template. An example template would be:

version = "{{ .Prefix }}"

Running git-wormhole with a 0000 prefix would result in the following file:

version = "0000"
Using the 'comment' strategy
$ # inside the repository you want to generate a collision
$
$ git-wormhole -strategy=comment -prefix=0000 FILE.template TARGET
...
...
Found collision.
Run the following command:

GIT_AUTHOR_DATE="raw:1616871477 -0300" GIT_COMMITTER_DATE="raw:1616871477 -0300" git commit -a -m 'git-wormhole
119798'
Using the 'time' strategy
$ # inside the repository you want to generate a collision
$ # if no collision is found, you can increase the allowed jitter
$
$ git-wormhole -strategy=time -prefix=0000 FILE.template TARGET
...
...
Found collision.
Run the following command:

GIT_AUTHOR_DATE="raw:1616871509 -0300" GIT_COMMITTER_DATE="raw:1616871279 -0300" git commit -a -m 'git-wormhole'

Usage

$ git-wormhole -h
Usage of git-wormhole:
  git-wormhole TEMPLATE TARGET

  -comment string
    	comment that should be used on commit (default "git-wormhole")
  -delta int
    	max time change in author date in seconds (default: 6 hours) (default 21600)
  -diff int
    	max difference between author and commit dates (default: 1 hour) (default 3600)
  -prefix string
    	git commit hash prefix
  -strategy string
    	[comment|time] (default "time")
  -tests int
    	maximum number of tests in comment strategy (default 2147483648)
  -version
    	show version

Limitations

  • The repository should be clean, with no unstaged changes.
  • The target file should already exist.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TreeHash

func TreeHash(tree *object.Tree, prefix string, overrides map[string]plumbing.Hash) plumbing.Hash

Types

type CommentStrategy

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

func NewCommentStrategy

func NewCommentStrategy(maxTests int) *CommentStrategy

func (*CommentStrategy) Producer

func (cs *CommentStrategy) Producer(inputChan chan Commit, doneChan chan bool, base Commit)

type Commit

type Commit struct {
	TestId     int
	Config     *config.Config
	TreeHash   plumbing.Hash
	ParentHash plumbing.Hash
	AuthorTime time.Time
	CommitTime time.Time
	Comment    string
}

func (Commit) Bytes

func (commit Commit) Bytes() []byte

func (Commit) Hash

func (commit Commit) Hash() plumbing.Hash

type Strategy

type Strategy interface {
	Producer(inputChan chan Commit, doneChan chan bool, base Commit)
}

type Target

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

func New

func New(targetPath string, templatePath string) (*Target, error)

func (*Target) Brute

func (target *Target) Brute(repo *git.Repository, strategy Strategy, targetPrefix []byte, comment string) (*Commit, error)

type TemplateData

type TemplateData struct {
	Prefix []byte
}

type TimeStrategy

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

func NewTimeStrategy

func NewTimeStrategy(maxDelta int64, maxDiff int64) *TimeStrategy

func (*TimeStrategy) Producer

func (ts *TimeStrategy) Producer(inputChan chan Commit, doneChan chan bool, base Commit)

Directories

Path Synopsis
cmd
git-wormhole command

Jump to

Keyboard shortcuts

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