Skip to content

Commit 28131e5

Browse files
authored
Add input wordlist functionality (#33)
1 parent 47e5784 commit 28131e5

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ pencode - complex payload encoder v0.3
1818
1919
Usage: ./pencode FUNC1 FUNC2 FUNC3...
2020
21-
./pencode reads input from stdin, which is typically piped from another process.
21+
./pencode reads input from stdin by default, which is typically piped from another process.
22+
23+
OPTIONS:
24+
-input reads input from a file, line by line.
2225
2326
ENCODERS
2427
b64encode - Base64 encoder

cmd/pencode/main.go

+32-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ import (
1313
func main() {
1414
chain := pencode.NewChain()
1515

16+
inputWordlist := flag.String("input", "", "A wordlist to encode")
17+
1618
flag.Usage = func() {
1719
fmt.Printf("pencode - complex payload encoder v%s\n\n", pencode.VERSION)
1820
fmt.Printf("Usage: %s FUNC1 FUNC2 FUNC3...\n\n", os.Args[0])
19-
fmt.Printf("%s reads input from stdin, which is typically piped from another process.\n\n", os.Args[0])
21+
fmt.Printf("%s reads input from stdin by default, which is typically piped from another process.\n\n", os.Args[0])
22+
fmt.Printf("OPTIONS:\n-input reads input from a file, line by line.\n\n")
2023
chain.Usage()
2124
}
2225

@@ -34,19 +37,41 @@ func main() {
3437
os.Exit(1)
3538
}
3639

37-
err := chain.Initialize(os.Args[1:])
40+
err := chain.Initialize(flag.Args())
3841
if err != nil {
3942
flag.Usage()
4043
fmt.Printf("\n[!] %s\n", err)
4144
os.Exit(1)
4245
}
4346

44-
input := readInput()
45-
output, err := chain.Encode([]byte(input))
46-
if err != nil {
47-
fmt.Printf(" [!] %s\n", err)
47+
if *inputWordlist != "" {
48+
// read the input wordlist and output to stdout
49+
file, err := os.Open(*inputWordlist)
50+
51+
if err != nil {
52+
fmt.Println(err)
53+
}
54+
55+
defer file.Close()
56+
57+
fs := bufio.NewScanner(file)
58+
fs.Split(bufio.ScanLines)
59+
60+
for fs.Scan() {
61+
output, err := chain.Encode(fs.Bytes())
62+
if err != nil {
63+
fmt.Printf(" [!] %s\n", err)
64+
}
65+
fmt.Println(string(output))
66+
}
67+
} else {
68+
input := readInput()
69+
output, err := chain.Encode([]byte(input))
70+
if err != nil {
71+
fmt.Printf(" [!] %s\n", err)
72+
}
73+
fmt.Print(string(output))
4874
}
49-
fmt.Print(string(output))
5075
}
5176

5277
func readInput() string {

0 commit comments

Comments
 (0)