Skip to content

Commit

Permalink
Updated readme and added preview image
Browse files Browse the repository at this point in the history
  • Loading branch information
brittonhayes committed Dec 6, 2020
1 parent 06359dc commit 42939b8
Show file tree
Hide file tree
Showing 9 changed files with 364 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .gomarkdoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
output: "{{.Dir}}/README.md"
repository:
url: https://github.com/brittonhayes/pillager
defaultBranch: main
path: /
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Pillager

![Image](./images/brand_image.png)

## Table of Contents

1. [Installation](#installation)
2. [Usage](#usage)

## Installation

### Command line

If you have Go setup on your system, you can install Pillager with `go get`

```shell script
go get github.com/brittonhayes/pillager
```

If you're looking for the binary, check the [bin](./bin) directory or latest release for the executable that matches your system

### Usage

To see all of the commands available with `pillager`

```shell
# To see instructions for the entire application
pillager

# From any subcommand
pillager [cmd] --help
```
26 changes: 24 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@ module pillager
go 1.14

require (
github.com/Microsoft/go-winio v0.4.15 // indirect
github.com/cheggaaa/pb/v3 v3.0.5 // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/gookit/color v1.3.2
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/magiconair/properties v1.8.4 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mingrammer/commonregex v1.0.1
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/afero v1.1.2
github.com/mitchellh/mapstructure v1.4.0 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/princjef/gomarkdoc v0.1.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/spf13/afero v1.4.1
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c // indirect
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb // indirect
golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.4 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
214 changes: 214 additions & 0 deletions go.sum

Large diffs are not rendered by default.

Binary file added images/brand_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
//go:generate gomarkdoc ./pkg/...
package main

import "pillager/cmd"
Expand Down
74 changes: 74 additions & 0 deletions pkg/hunter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->

# hunter

```go
import "pillager/pkg/hunter"
```

## Index

- [func CheckPath(fs afero.Fs, path string) string](<#func-checkpath>)
- [type Hunter](<#type-hunter>)
- [func NewHunter(system afero.Fs, patterns []*regexp.Regexp, location string) *Hunter](<#func-newhunter>)
- [func (h Hunter) Hunt() error](<#func-hunter-hunt>)
- [func (h Hunter) Inspect(path string, fs afero.Fs)](<#func-hunter-inspect>)
- [type Hunting](<#type-hunting>)


## func [CheckPath](<https://github.com/brittonhayes/pillager/blob/main/pkg/hunter/helpers.go#L11>)

```go
func CheckPath(fs afero.Fs, path string) string
```

CheckPath checks if a filepath exists and returns it if so\, otherwise returns a default path

## type [Hunter](<https://github.com/brittonhayes/pillager/blob/main/pkg/hunter/filepaths.go#L14-L18>)

```go
type Hunter struct {
System afero.Fs
Patterns []*regexp.Regexp
BasePath string
}
```

### func [NewHunter](<https://github.com/brittonhayes/pillager/blob/main/pkg/hunter/filepaths.go#L29>)

```go
func NewHunter(system afero.Fs, patterns []*regexp.Regexp, location string) *Hunter
```

NewHunter creates an instance of the Hunter type

### func \(Hunter\) [Hunt](<https://github.com/brittonhayes/pillager/blob/main/pkg/hunter/filepaths.go#L35>)

```go
func (h Hunter) Hunt() error
```

Hunt walks over the filesystem at the configured path\, looking for sensitive information it implements the Inspect method over an entire directory

### func \(Hunter\) [Inspect](<https://github.com/brittonhayes/pillager/blob/main/pkg/hunter/filepaths.go#L58>)

```go
func (h Hunter) Inspect(path string, fs afero.Fs)
```

Inspect digs into the provided file and concurrently scans it for sensitive information

## type [Hunting](<https://github.com/brittonhayes/pillager/blob/main/pkg/hunter/filepaths.go#L23-L26>)

Hunting is the primary API interface for the hunter package

```go
type Hunting interface {
Hunt() error
Inspect(path string, fs afero.Fs)
}
```



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
21 changes: 11 additions & 10 deletions pkg/hunter/filepaths.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,22 @@ type Hunter struct {

var _ Hunting = Hunter{}

// Hunting is the primary API interface for the hunter package
type Hunting interface {
Hunt() error
inspect(path string, fs afero.Fs)
}

var contentRegexes = []*regexp.Regexp{
reg.CreditCardRegex,
reg.VISACreditCardRegex,
reg.GitRepoRegex,
Inspect(path string, fs afero.Fs)
}

// NewHunter creates an instance of the Hunter type
func NewHunter(system afero.Fs, patterns []*regexp.Regexp, location string) *Hunter {
return &Hunter{System: system, Patterns: patterns, BasePath: location}
}

// Hunt walks over the filesystem at the configured path, looking for sensitive information
// it implements the Inspect method over an entire directory
func (h Hunter) Hunt() error {
var files []string
filter := afero.NewRegexpFs(h.System, regexp.MustCompile(`(?i).*\.(go|rtf|txt|csv|js|php|java|json|xml|rb|md|markdown)`))
filter := afero.NewRegexpFs(h.System, regexp.MustCompile(`(?i).*\.(go|rtf|txt|csv|js|php|java|json|xml|rb|md|markdown|y(am|m)l)`))
if err := afero.Walk(filter, h.BasePath, func(path string, info os.FileInfo, err error) error {
// Parse files for loot
if info.IsDir() {
Expand All @@ -50,13 +47,15 @@ func (h Hunter) Hunt() error {
}

for _, f := range files {
h.inspect(f, h.System)
h.Inspect(f, h.System)
}

return nil
}

func (h Hunter) inspect(path string, fs afero.Fs) {
// Inspect digs into the provided file and concurrently scans it for
// sensitive information
func (h Hunter) Inspect(path string, fs afero.Fs) {
//foundLoot := false
// Print file found message
plus := color.Bold.Text("[+]")
Expand Down Expand Up @@ -113,6 +112,8 @@ func (h Hunter) inspect(path string, fs afero.Fs) {
}
}

// matchPattern accepts a channel of jobs and looks for pattern matches
// in each of jobs
func matchPattern(jobs <-chan string, results chan<- string, wg *sync.WaitGroup, pattern []*regexp.Regexp) {
// Mark task finished once done
defer wg.Done()
Expand Down
4 changes: 3 additions & 1 deletion pkg/hunter/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"os"
)

func (h Hunter) CheckPath(fs afero.Fs, path string) string {
// CheckPath checks if a filepath exists and
// returns it if so, otherwise returns a default path
func CheckPath(fs afero.Fs, path string) string {
ok, err := afero.Exists(fs, path)
if err != nil {
log.Printf("ERROR: %s", err.Error())
Expand Down

0 comments on commit 42939b8

Please sign in to comment.