How to Create a Wordlist with specific alphabets and length?

I want to create a wordlist with specific alphabets and numbers with required length in Golang.
For example specific characters = abcd123 , Now for length = 5.
So it prints out :-
aaaaa
aaaab
aaaac
aaaad
aaaa1
…and So on…So it covers all combination. Please Help me out with the Code.

1 Like

For example so:

package main

import (
	"fmt"
	"strings"

	"github.com/klaidliadon/next"
)

func main() {
	temp := strings.Split("abcd123", "")
	arr := make([]interface{}, len(temp))
	for i, v := range temp {
		arr[i] = v
	}
	for v := range next.Combination(arr, 5, true) {
		fmt.Println(v)
	}
}

https://play.golang.org/p/ky4WFb0Aq68

2 Likes

but the it is coming in brackets like [a a a a a] , As I want in to come aaaaa

1 Like

Well I don’t like the package because one must convert from and to interface but I wanted give you idea and not the full code. But of course you can join result in string like so:

package main

import (
	"fmt"
	"strings"

	"github.com/klaidliadon/next"
)

func join(arr []interface{}) string {
	buf := ""
	for _, v := range arr {
		buf += v.(string)
	}
	return buf
}

func main() {
	temp := strings.Split("abcd123", "")
	arr := make([]interface{}, len(temp))
	for i, v := range temp {
		arr[i] = v
	}
	for v := range next.Combination(arr, 5, true) {
		fmt.Println(join(v))
	}
}
2 Likes

now i wanted to implement hash which is sha256. so i get every word converted to sha256 hash.

the code:-
package main

import (
“fmt”
“strings”
“crypto/sha256”
github.com/next-master
)

func join(arr []interface{}) string {
buf := “”
for _, v := range arr {
buf += v.(string)
}
return buf
}

func main() {
temp := strings.Split(“abcd123”, “”)
arr := make([]interface{}, len(temp))
for i, v := range temp {
arr[i] = v
}
for v := range next.Combination(arr, 5, true) {
hash := sha256.Sum256([]byte(join(v)))
fmt.Println(join(v), hash)
}
}

its giving something like:-
22233 [192 184 2 146 34 114 163 128 90 105 209 158 34 71 234 86 143 151 45 155 64 115 30 236 247 0 56 33 188 126 105 9]
22333 [155 51 181 123 34 89 209 32 15 50 217 240 247 132 176 125 210 136 241 152 67 153 123 201 170 52 200 213 179 45 63 97]
23333 [228 1 162 245 51 232 83 113 62 234 33 184 120 193 146 28 25 250 156 139 136 124 21 71 199 113 236 228 110 19 247 102]
33333 [33 110 104 63 240 210 210 81 101 184 187 123 166 8 201 166 40 239 41 153 36 202 73 171 152 30 199 210 254 205 109 173]
but it is not hashing correctly. Please help where i did wrong in the code?

1 Like

Why do you think that hash is incorrect? With what are you comparing it?

1 Like

according to example:-
for 33333 it should give 216E683FF0D2D25165B8BB7BA608C9A628EF299924CA49AB981EC7D2FECD6DAD

but it is giving [33 110 104 63 240 210 210 81 101 184 187 123 166 8 201 166 40 239 41 153 36 202 73 171 152 30 199 210 254 205 109 173]

link to check sha256:- convert to sha256

I wanted to create a wordlist and also the hash256
like aaaaa ED968E840D10D2D313A870BC131A4E2C311D7AD09BDF32B3418147221F51A6E2

In python it is easy…but Golang it is difficult.

1 Like

But it’s just different representation. If you will print bytes in hexadecimal format you get exactly what are you want to get:

fmt.Printf("%s %X\n", join(v), hash)

1 Like

Not really. You already asked about sha256 here How to generate list of set of numbers and generate sha256 in golang

2 Likes

i checked again but no luck.
package main

import (
“fmt”
“strings”
“crypto/sha256”
github.com/next-master
“strconv”
)

func join(arr []interface{}) string {
buf := “”
for _, v := range arr {
buf += v.(string)
}
return buf
}

func main() {
temp := strings.Split(“abcd123”, “”)
arr := make([]interface{}, len(temp))
for i, v := range temp {
arr[i] = v
}
for v := range next.Combination(arr, 5, true) {
hash := sha256.Sum256([]byte(strconv.Itoa(join(v))))
fmt.Println("%s %X\n",join(v), hash)
}
}

its giving same error …go:26:52: cannot use join(v) (type string) as type int in argument to strconv.Itoa

1 Like

Yes, because it doesn’t have any sense at all. Ok, let’s take all parts together:

package main

import (
	"crypto/sha256"
	"fmt"
	"strings"

	"github.com/klaidliadon/next"
)

func join(arr []interface{}) string {
	buf := ""
	for _, v := range arr {
		buf += v.(string)
	}
	return buf
}

func main() {
	temp := strings.Split("abcd123", "")
	arr := make([]interface{}, len(temp))
	for i, v := range temp {
		arr[i] = v
	}

	for v := range next.Combination(arr, 5, true) {
		hash := sha256.Sum256([]byte(join(v)))
		fmt.Printf("%s %X\n", join(v), hash)
	}
}

https://play.golang.org/p/-iAmaJkplhN

2 Likes

Thanks,…now its working… So was my mistake about between fmt.Printf and fmt.Println?

I wanted to know where you learned So much about Golang , I would do it if possible. please let me know.

1 Like

Sorry to Ask Again But This code stops if i change abcd123 to abcdef0123456789 and length 5 to 64 . Don’t know whats going.
it only displayed one line and stopped? why?

1 Like

From my point of view Go is really simple language (I have some experience with C++ so I can compare :D), there is excellent documentation, many articles, welcoming community here on forum.

Main thing that should learn any developer is how to formulate right question. After that you just learn specific things of one or other language. And better way to do it is working on interesting tasks. Because without wish to accomplish them learning process is really hard.

3 Likes

That easy - there very large numbers of combinations. And by very large I mean really very big number.

1 Like

But it should run slowly i think but don’t know why is it stopping like this. any solution for this?

1 Like

Of course - use another package or implement algorithm by hand without memory allocation for result.

1 Like

Omg. Now I reached Dead End. Looks like I have to start from beginning. one more thing should I start with c or C++ to learn. so golang will be easier? as yesterday only i got to know about some placeholders like %x %c %s %d.
thanks for your Support.

1 Like

No. Forget about C, C++ and all that stuff if you can :slight_smile:

The key almost always in the algorithm not in implementation. There are must be some effective algorithms but you can start from simple one from here:

Combinations with repetitions

2 Likes

hello GreyShatter, I got Some Other code from github but there is one thing … Its sha256 is not matching… please see this code and help me out.

package main
import (
"fmt"
"math/big"
"crypto/sha256"
)

func main() {
// Print header
fmt.Printf("%64s %64s\n", "Raw-sha256", "hash-256",)

// Initialise big numbers with small numbers
count, one := big.NewInt(0), big.NewInt(1)

// Create a slice to pad our count to 32 bytes
padded := make([]byte, 32)

// Loop forever because we're never going to hit the end anyway
for {
	// Increment our counter
	count.Add(count, one)
    
	
	// Copy count value's bytes to padded slice
	copy(padded[32-len(count.Bytes()):], count.Bytes())
    
	
	
	sha256 := sha256.Sum256([]byte(padded))     

	
	
	// Print keys
	fmt.Printf("%x %x\n", padded, sha256)
}
}
1 Like