David wrote:
bob gailer wrote:
David wrote:
I have to ask for a pointer, not sure what I am doing wrong.
The first thing you are doing "wrong" is failing to tell us what is
in the wordlist file and what results you get when you run the program.
Please re-post with that information.
#!/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 word
else:
print 'You are a loser'
wordlist.txt
next block is the meat the script will go through the list of words
create our form with information encode that form and then apply that
loser get source added comments above each line to help you understand
results;
./py_bruteforce.py
next block is the meat the script will go through the list of words
create our form with information encode that form and then apply that
loser get source added comments above each line to help you understand
You are a loser
Thank you. Please always post the relevant information, and if you get
an exception, post the full traceback.
It looks like the file contains 1 line. So the for statement will put
that line in word. 'loser' is in word so the print statement prints the
line.
The program is working as written.
Now what can you change to get it to do what (I assume) you want -
examine each "word" in the file, print the word if 'loser' is in it, and
print 'You are a loser' ONLY if no words match.
--
Bob Gailer
Chapel Hill NC
919-636-4239
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor