Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit ceb45d7

Browse files
authored
Initial concept release (#1)
Releasing initial concept release with support for the following options and transformations. ## Options: ``` -f value Read additional files for input. -i value Starting index for transformations if applicable. Accepts ranges separated by '-'. (default 0) -k value Only keep items in a file. -m int Minimum numerical frequency to include in output. -r value Only keep items not in a file. -rm string Replacement mask for transformations if applicable. (default "uldsb") -t string Transformation to apply to input. -tf value Read additional files for transformations if applicable. -u value Read additional URLs for input. -v Show verbose output when possible. The '-f', '-k', '-r', '-tf', and '-u' flags can be used multiple times. ``` ## Transformations: ``` -t append -t append-remove -t append-shift -t prepend -t prepend-remove -t prepend-shift -t insert -i [index] -t overwrite -i [index] -t toggle -i [index] -t encode -t mask -rm [uldsb] -v -t dehex -t hex -t remove -rm [uldsb] -v -t retain -rm [uldsb] -tf [file] -t match -tf [file] -t fuzzy-swap -tf [file] -t swap -tf [file] ```
1 parent e4f85b2 commit ceb45d7

File tree

19 files changed

+3337
-2
lines changed

19 files changed

+3337
-2
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.swp
2+
README.md
3+
Dockerfile
4+
.git
5+
.gitattributes
6+
.gitignore
7+
LICENSE

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.swp

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:alpine as build-env
2+
RUN mkdir src/app
3+
WORKDIR /src/app
4+
ADD ./main.go .
5+
ADD ./go.mod .
6+
ADD ./go.sum .
7+
ADD ./pkg ./pkg
8+
RUN go build .
9+
10+
FROM alpine
11+
RUN addgroup --gid 10001 --system nonroot \
12+
&& adduser --uid 10000 --system --ingroup nonroot --home /home/nonroot nonroot; \
13+
apk update; apk add --no-cache tini bind-tools
14+
15+
COPY --from=build-env /src/app/ptt /sbin/ptt
16+
ENTRYPOINT ["/sbin/tini", "--", "/sbin/ptt"]
17+
WORKDIR /data
18+
USER nonroot

README.md

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,113 @@
1-
# ptt
2-
password transformation tool
1+
`ptt` or Password Transformation Tool is a multi-tool for working with files, URLs, and standard input for password cracking.
2+
3+
## Features:
4+
- Transform input strings with various modes.
5+
- Creates `Hashcat` rules and masks from input strings.
6+
- Transforms input strings with a variety of functions for password cracking.
7+
- Accepts input from standard input, files, and URLs.
8+
- Works with multiple files and URLs for input and transformations.
9+
- All transformations support multibyte characters.
10+
11+
```
12+
$ ptt -h
13+
Usage of Password Transformation Tool (ptt) version (0.0.0):
14+
15+
ptt [options] [...]
16+
Accepts standard input and/or additonal arguments.
17+
18+
Options:
19+
-f value
20+
Read additional files for input.
21+
-i value
22+
Starting index for transformations if applicable. Accepts ranges separated by '-'. (default 0)
23+
-k value
24+
Only keep items in a file.
25+
-m int
26+
Minimum numerical frequency to include in output.
27+
-r value
28+
Only keep items not in a file.
29+
-rm string
30+
Replacement mask for transformations if applicable. (default "uldsb")
31+
-t string
32+
Transformation to apply to input.
33+
-tf value
34+
Read additional files for transformations if applicable.
35+
-u value
36+
Read additional URLs for input.
37+
-v Show verbose output when possible.
38+
39+
The '-f', '-k', '-r', '-tf', and '-u' flags can be used multiple times.
40+
41+
Transformation Modes:
42+
-t append
43+
Transforms input into append rules.
44+
-t append-remove
45+
Transforms input into append-remove rules.
46+
-t append-shift
47+
Transforms input into append-shift rules.
48+
-t prepend
49+
Transforms input into prepend rules.
50+
-t prepend-remove
51+
Transforms input into prepend-remove rules.
52+
-t prepend-shift
53+
Transforms input into prepend-shift rules.
54+
-t insert -i [index]
55+
Transforms input into insert rules starting at index.
56+
-t overwrite -i [index]
57+
Transforms input into overwrite rules starting at index.
58+
-t toggle -i [index]
59+
Transforms input into toggle rules starting at index.
60+
-t encode
61+
Transforms input by URL, HTML, and Unicode escape encoding.
62+
-t mask -rm [uldsb] -v
63+
Transforms input by masking characters with provided mask.
64+
-t dehex
65+
Transforms input by decoding $HEX[...] formatted strings.
66+
-t hex
67+
Transforms input by encoding strings into $HEX[...] format.
68+
-t remove -rm [uldsb] -v
69+
Transforms input by removing characters with provided mask characters.
70+
-t retain -rm [uldsb] -tf [file]
71+
Transforms input by creating masks that still retain strings from file.
72+
-t match -tf [file]
73+
Transforms input by keeping only strings with matching masks from a mask file.
74+
-t fuzzy-swap -tf [file]
75+
Transforms input by swapping tokens with fuzzy matches from another file.
76+
-t swap -tf [file]
77+
Transforms input by swapping tokens with exact matches from a ':' separated file.
78+
```
79+
80+
## Getting Started:
81+
82+
>[!NOTE]
83+
> This tool is still in development and considered early access. Please report any issues, bugs, or feature requests to the GitHub repository.
84+
85+
Documentation on usage and examples can be found in the `/docs` directory or on the repository here: [link](https://github.com/JakeWnuk/ptt/docs)
86+
87+
## Install:
88+
89+
### Source:
90+
Fast method with Go installed:
91+
```
92+
TODO
93+
```
94+
Slow method with Go installed:
95+
```
96+
git clone https://github.com/JakeWnuk/ptt && cd ptt && go build ./main.go && mv ./ptt ~/go/bin/ptt && ptt
97+
```
98+
99+
### Docker:
100+
Pull the latest image from Docker Hub:
101+
```
102+
docker run -it -v ${PWD}:/data jwnuk/ptt
103+
```
104+
Build the Docker image from the Dockerfile:
105+
```
106+
git clone https://github.com/JakeWnuk/ptt && cd ptt && docker build -t ptt . && docker run -it -v ${PWD}:/data ptt
107+
```
108+
109+
### Binary:
110+
Download the latest release from the GitHub repository:
111+
```
112+
TODO
113+
```

docs/USAGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module ptt
2+
3+
go 1.22.0
4+
5+
require golang.org/x/net v0.24.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
2+
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=

main.go

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Package main controls the user interaction logic for the application
2+
package main
3+
4+
import (
5+
"bufio"
6+
"flag"
7+
"fmt"
8+
"os"
9+
"ptt/pkg/format"
10+
"ptt/pkg/models"
11+
"ptt/pkg/transform"
12+
"ptt/pkg/utils"
13+
"sync"
14+
)
15+
16+
var version = "0.0.0"
17+
var wg sync.WaitGroup
18+
var mutex = &sync.Mutex{}
19+
var retain models.FileArgumentFlag
20+
var remove models.FileArgumentFlag
21+
var readFiles models.FileArgumentFlag
22+
var readURLs models.FileArgumentFlag
23+
var transformationFiles models.FileArgumentFlag
24+
var intRange models.IntRange
25+
var primaryMap map[string]int
26+
var err error
27+
28+
func main() {
29+
// Parse command line arguments
30+
flag.Usage = func() {
31+
fmt.Fprintf(os.Stderr, "Usage of Password Transformation Tool (ptt) version (%s):\n\n", version)
32+
fmt.Fprintf(os.Stderr, "ptt [options] [...]\nAccepts standard input and/or additonal arguments.\n\n")
33+
fmt.Fprintf(os.Stderr, "Options:\n")
34+
flag.PrintDefaults()
35+
fmt.Fprintf(os.Stderr, "\nThe '-f', '-k', '-r', '-tf', and '-u' flags can be used multiple times.\n")
36+
fmt.Fprintf(os.Stderr, "\nTransformation Modes:\n")
37+
fmt.Fprintf(os.Stderr, " -t append\n\tTransforms input into append rules.\n")
38+
fmt.Fprintf(os.Stderr, " -t append-remove\n\tTransforms input into append-remove rules.\n")
39+
fmt.Fprintf(os.Stderr, " -t append-shift\n\tTransforms input into append-shift rules.\n")
40+
fmt.Fprintf(os.Stderr, " -t prepend\n\tTransforms input into prepend rules.\n")
41+
fmt.Fprintf(os.Stderr, " -t prepend-remove\n\tTransforms input into prepend-remove rules.\n")
42+
fmt.Fprintf(os.Stderr, " -t prepend-shift\n\tTransforms input into prepend-shift rules.\n")
43+
fmt.Fprintf(os.Stderr, " -t insert -i [index]\n\tTransforms input into insert rules starting at index.\n")
44+
fmt.Fprintf(os.Stderr, " -t overwrite -i [index]\n\tTransforms input into overwrite rules starting at index.\n")
45+
fmt.Fprintf(os.Stderr, " -t toggle -i [index]\n\tTransforms input into toggle rules starting at index.\n")
46+
fmt.Fprintf(os.Stderr, " -t encode\n\tTransforms input by URL, HTML, and Unicode escape encoding.\n")
47+
fmt.Fprintf(os.Stderr, " -t mask -rm [uldsb] -v\n\tTransforms input by masking characters with provided mask.\n")
48+
fmt.Fprintf(os.Stderr, " -t dehex\n\tTransforms input by decoding $HEX[...] formatted strings.\n")
49+
fmt.Fprintf(os.Stderr, " -t hex\n\tTransforms input by encoding strings into $HEX[...] format.\n")
50+
fmt.Fprintf(os.Stderr, " -t remove -rm [uldsb] -v\n\tTransforms input by removing characters with provided mask characters.\n")
51+
fmt.Fprintf(os.Stderr, " -t retain -rm [uldsb] -tf [file]\n\tTransforms input by creating masks that still retain strings from file.\n")
52+
fmt.Fprintf(os.Stderr, " -t match -tf [file]\n\tTransforms input by keeping only strings with matching masks from a mask file.\n")
53+
fmt.Fprintf(os.Stderr, " -t fuzzy-swap -tf [file]\n\tTransforms input by swapping tokens with fuzzy matches from another file.\n")
54+
fmt.Fprintf(os.Stderr, " -t swap -tf [file]\n\tTransforms input by swapping tokens with exact matches from a ':' separated file.\n")
55+
}
56+
57+
// Define command line flags
58+
verbose := flag.Bool("v", false, "Show verbose output when possible.")
59+
minimum := flag.Int("m", 0, "Minimum numerical frequency to include in output.")
60+
transformation := flag.String("t", "", "Transformation to apply to input.")
61+
replacementMask := flag.String("rm", "uldsb", "Replacement mask for transformations if applicable.")
62+
flag.Var(&retain, "k", "Only keep items in a file.")
63+
flag.Var(&remove, "r", "Only keep items not in a file.")
64+
flag.Var(&readFiles, "f", "Read additional files for input.")
65+
flag.Var(&transformationFiles, "tf", "Read additional files for transformations if applicable.")
66+
flag.Var(&intRange, "i", "Starting index for transformations if applicable. Accepts ranges separated by '-'. (default 0)")
67+
flag.Var(&readURLs, "u", "Read additional URLs for input.")
68+
flag.Parse()
69+
70+
// Parse any retain, remove, or transformation file arguments
71+
fs := &models.RealFileSystem{}
72+
retainMap := utils.ReadFilesToMap(fs, retain)
73+
removeMap := utils.ReadFilesToMap(fs, remove)
74+
readFilesMap := utils.ReadFilesToMap(fs, readFiles)
75+
transformationFilesMap := utils.ReadFilesToMap(fs, transformationFiles)
76+
readURLsMap, err := utils.ReadURLsToMap(readURLs)
77+
if err != nil {
78+
fmt.Println("Error reading URLs:", err)
79+
return
80+
}
81+
82+
// Read from stdin if provided
83+
stat, _ := os.Stdin.Stat()
84+
if (stat.Mode() & os.ModeCharDevice) == 0 {
85+
primaryMap, err = utils.LoadStdinToMap(bufio.NewScanner(os.Stdin))
86+
if err != nil {
87+
fmt.Println("Error reading from stdin:", err)
88+
return
89+
}
90+
}
91+
92+
// Combine stdin with any additional files
93+
if len(primaryMap) == 0 && len(readFilesMap) == 0 && len(readURLsMap) == 0 {
94+
flag.Usage()
95+
return
96+
} else if len(primaryMap) == 0 {
97+
primaryMap = utils.CombineMaps(readFilesMap, readURLsMap)
98+
} else {
99+
primaryMap = utils.CombineMaps(primaryMap, readFilesMap, readURLsMap)
100+
}
101+
102+
// Apply transformation if provided
103+
if *transformation != "" {
104+
primaryMap = transform.TransformationController(primaryMap, *transformation, intRange.Start, intRange.End, *verbose, *replacementMask, transformationFilesMap)
105+
}
106+
107+
// Process retain and remove maps if provided
108+
if len(retainMap) > 0 || len(removeMap) > 0 {
109+
primaryMap, err = format.RetainRemove(primaryMap, retainMap, removeMap)
110+
if err != nil {
111+
fmt.Println("Error processing retain and remove flags:", err)
112+
return
113+
}
114+
}
115+
116+
// Remove items under minimum frequency if provided
117+
if *minimum > 0 {
118+
primaryMap = format.RemoveMinimumFrequency(primaryMap, *minimum)
119+
}
120+
121+
// Print output to stdout
122+
format.PrintArrayToSTDOUT(primaryMap, *verbose)
123+
}

0 commit comments

Comments
 (0)