How to Create a Wordlist with specific alphabets and length?


( Kvaz1r) #9

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


(Pradhan Banra) #10

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


( Kvaz1r) #11

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


(Pradhan Banra) #12

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.


(Pradhan Banra) #13

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?


( Kvaz1r) #14

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.


( Kvaz1r) #15

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


(Pradhan Banra) #16

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


( Kvaz1r) #17

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


(Pradhan Banra) #18

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.


( Kvaz1r) #19

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


(Pradhan Banra) #20

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)
}
}

( Kvaz1r) #21

Do you want have string “1” for 1 or wide of string should be some specific wide?


(Pradhan Banra) #22

full one line to hash in sha256 and same continues…
means example:- 000000000000000000000000000000000000000000000000000000000000077a

gives 02C62AE7237817928D659F1004A920030FAE9556A6B6FEBF6701B60AD5285961

as sha256


(Pradhan Banra) #23

Did you got any result? waiting for correct code.:slightly_smiling_face:


( Kvaz1r) #24

Code below works for me, you just should know about print-specifiers (%x, %d, %s ,…)

package main

import (
	"crypto/sha256"
	"fmt"
	"math/big"
	"strings"
)

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)

	// Loop forever because we're never going to hit the end anyway
	for i := 0; i < 100; i++ {
		// Increment our counter
		count.Add(count, one)

		str := count.String()
		str = strings.Repeat("0", 64-len(str)) + str
		sha256 := sha256.Sum256([]byte(str))

		// Print keys

		fmt.Printf("%s %X\n", str, sha256)

	}
}

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


(Pradhan Banra) #25

Code is Nice But But my Charactars are missing abcdef0123456789 and it only has numbers.


( Kvaz1r) #26

Ah, sorry, I just forgot that your task still to variate “abcdef0123456789” string. Fixed:

package main

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

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 i := 0; i < 100; i++ {
		// 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(fmt.Sprintf("%X", padded)))

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

https://play.golang.org/p/4ZfK6qXUDoI

So I only add convertion to hex here:

fmt.Sprintf("%X", padded)

because you must hash exactly the string which display after in hex.


(Pradhan Banra) #27

This is the Extract Code. For this Solution. Great Work :clap: , Grey Shatter and I learned alot. now i merge this code with another code in github and will look, if it fits in or not.


(system) closed #28

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.