-1

I was writing a script in Python to generate brute force wordlists. I already can concatenate only strings, but I cant concatenate some random numbers in the final of each word in list, because it says that I cannot concatenate str and int objects...

The code:

wList = []

words = raw_input("[+]Insert the words that you wish: ")
outputFile = raw_input("[+]Insert the path to save the file: ")

wordList = words.split(",")

for x in wordList:
    for y in wordList:
        wList.append(x + y)
        wList.append(y + x)
        wList.append(x + "-" + y)
        wList.append(y + "-" + x)
        wList.append(x + "_" + y)
        wList.append(y + "_" + x)
        wList.append(x + "@" + y)
        wList.append(y + "@" + x)


for num in wordList:
    for num2 in wordList:
        for salt in range(1,10):
            wList.append(num + num2 + int(salt))
            wList.append(num2 + num + int(salt))
martineau
  • 119,623
  • 25
  • 170
  • 301
Jonas Rita
  • 25
  • 7

2 Answers2

1

In python the + operator after a sequence calls concat with the sequence before the operator and whatever is after the operator. In python string is a sequence. The concat function only works on two sequences of the same type, i.e. two strings or two arrays. In your code you use this operator for string and int.

You need to change all of the places you concatenate strings with ints. Here are two possible ways to do this.

You could make all the ints into strings. For example:

wList.append(str(x) + "-" + str(y))

Or you could use %-formatting. For example:

wList.append("%d-%d"%(x, y))
morsecodist
  • 907
  • 7
  • 14
0

You can only concatenate a string with another string in Python.

Change the last two lines to below:

wList.append(num + num2 + str(salt))
wList.append(num2 + num + str(salt))
Jason
  • 686
  • 1
  • 6
  • 13