Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread bob gailer

David wrote:


Thanks Bob,
I changed the wordlist.txt to
next
block
is
meat

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
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread David



#!/usr/bin/python
import re
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

I could not figure out how to split the file into words.



I removed the import re as that was left over from my experimenting.

--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread David

bob gailer wrote:

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'




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.



Thanks Bob,
I changed the wordlist.txt to
next
block
is
meat

and the program;

#!/usr/bin/python
import re
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

I could not figure out how to split the file into words.


--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread bob gailer

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


Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread David

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


--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bruteforce match word in text file

2009-01-21 Thread bob gailer

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'




--
Bob Gailer
Chapel Hill NC
919-636-4239
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] bruteforce match word in text file

2009-01-21 Thread David

I have to ask for a pointer, not sure what I am doing wrong.
thanks
-david

#!/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'

--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor