hashpwd

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Code generated by "script/generate_lookup.go"; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cli.Command{
	Category: "Crypto",
	Name:     "hashpwd",
	Usage:    "A tool for query password hash offline",
	Commands: []*cli.Command{

		&cli.Command{
			Name:    "generate",
			Aliases: []string{"g"},
			Usage:   "Generate password hash form password dict",
			Flags: []cli.Flag{
				&cli.StringFlag{
					Name:    "filepath",
					Aliases: []string{"f", "file"},
					Usage:   "password dict file",
				},
				&cli.StringFlag{
					Name:    "output",
					Aliases: []string{"o", "out"},
					Usage:   "Save password hash dict",
					Value:   "hash.dic",
				},
			},
			Action: func(c *cli.Context) (err error) {
				fpath := c.String("filepath")
				fs, err := os.Stat(fpath)
				if err != nil {
					return errors.WithStack(err)
				}
				if fs.IsDir() {
					return errors.Errorf("%s is not a file", fpath)
				}
				return GenerateHashDict(fpath, c.String("output"))
			},
		},

		&cli.Command{
			Name:    "lookup",
			Aliases: []string{"l"},
			Usage:   "Generate password hash form password dict",
			Flags: []cli.Flag{
				&cli.StringFlag{
					Name:    "dict",
					Aliases: []string{"f", "file"},
					Usage:   "password hash dict file",
					Value:   "hash.dic",
				},
				&cli.StringFlag{
					Name:    "hash",
					Aliases: []string{"p"},
					Usage:   "password hash",
				},
			},
			Action: func(c *cli.Context) (err error) {
				p := c.String("hash")
				if p == "" {
					return errors.Errorf("plz input password hash")
				}
				fpath := c.String("dict")
				fs, err := os.Stat(fpath)
				if err != nil {
					return errors.WithStack(err)
				}
				if fs.IsDir() {
					return errors.Errorf("%s is not a file", fpath)
				}
				pwd, err := LookupHashDict(fpath, p)
				if err != nil {
					return err
				}
				if pwd == "" {
					return errors.Errorf("Not found hash: %s", p)
				}
				logger.SuccessF("Found password: %s", pwd)
				return nil
			},
		},
	},
}
View Source
var MethedLen = map[EncMethed]int{
	MySQL:     17,
	NTLMv1:    32,
	MD5:       32,
	MD5x2:     32,
	MD5x3:     32,
	SHA1MD5:   32,
	SHA1:      40,
	SHA1x2:    40,
	MD5SHA1:   40,
	SHA256:    64,
	MD5SHA256: 64,
}

Functions

func Encrypt

func Encrypt(passwd string) string

FIXME: 多重加密使用原始数据加密,可能会有问题 golang: md5(md5(xxx)) == php: md5(md5(xxx,true)) != php: md5(md5(xxx))

func GenerateHashDict

func GenerateHashDict(fpath, output string) error

func GetPlaintext

func GetPlaintext(line string) string

func LookUp

func LookUp(line, pwd string) bool

func LookupHashDict

func LookupHashDict(fpath, pwd string) (string, error)

FEAT: 逐行读取文件,一次查询多个密码? 目前每查询一次密码就检索整个文件

Types

type EncMethed

type EncMethed int
const (
	MySQL EncMethed = iota
	NTLMv1
	MD5 // MD5MID // == MD5[8:-8]
	MD5x2
	MD5x3
	SHA1MD5
	SHA1
	SHA1x2 // MySQL5 // == SHA1x2
	MD5SHA1
	SHA256
	MD5SHA256
)

func (EncMethed) String

func (i EncMethed) String() string

type Glimit

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

func New

func New(n int) *Glimit

initialization Glimit struct

func (*Glimit) Run

func (g *Glimit) Run(f func(string), p string)

Run f in a new goroutine but with limit.

type SyncWriter

type SyncWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

func (*SyncWriter) Write

func (w *SyncWriter) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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