[Tutor] bruteforce match word in text file
bob gailer
bgailer at gmail.com
Thu Jan 22 02:19:03 CET 2009
David wrote:
>
> Thanks Bob,
> I changed the wordlist.txt to
> next
> block
> is
> meat
> <snip>
> and the program;
>
> #!/usr/bin/python
> password = 'loser'
> wordlist = '/home/david/Challenge-You/wordlist.txt'
> try:
> words = open(wordlist, 'r').readlines()
> except IOError, e:
> print "Sorry no words"
> for word in words:
> word = word.replace("\n","")
> if password in word:
> print "The password is: ", word
> else:
> pass
Good work!
>
> I could not figure out how to split the file into words.
look up the string method split.
Also take a look at the syntax of the for statement and notice it has an
else clause.
--
Bob Gailer
Chapel Hill NC
919-636-4239
More information about the Tutor
mailing list