Login Register


Whats wrong with my code? text file cracker filter_list
Author
Message
Whats wrong with my code? text file cracker #1
im trying to create a text file cracker here is the code i cant see any problems so far?

Code:
import optparse from threading import Thread def cracktextfile(tFile,word): try: tfile.extractall(pwd=word) print ' [+++] Found pwd: ' + word print ' [++] Extract' except: pass def main(): parser = optparse.OptionParser("usage: %prog" + "-t <textfile> -w <wordlist") parser.add_option('-t', dest='tname', type='string', help='enter text file') parser.add_option('-w', dest='dname', type='string', help='enter wordlist') (options,args) = parser.parse_args() if (options.tFile == None) | (options.dname == None): print parser.usage exit(0) zname = options.tname dname = options.dname tFile = textfile.TextFile(tname) passFile = open(dname) for line in passFile.readlines(): word = line.strip('\n') t = Thread(target=cracktextfile, args=(tFile,word)) t.strart() if __name__ == '__main__': main()

Please any help much thankfull

Reply

Whats wrong with my code? text file cracker #2
im trying to create a text file cracker here is the code i cant see any problems so far?

Code:
import optparse from threading import Thread def cracktextfile(tFile,word): try: tfile.extractall(pwd=word) print ' [+++] Found pwd: ' + word print ' [++] Extract' except: pass def main(): parser = optparse.OptionParser("usage: %prog" + "-t <textfile> -w <wordlist") parser.add_option('-t', dest='tname', type='string', help='enter text file') parser.add_option('-w', dest='dname', type='string', help='enter wordlist') (options,args) = parser.parse_args() if (options.tFile == None) | (options.dname == None): print parser.usage exit(0) zname = options.tname dname = options.dname tFile = textfile.TextFile(tname) passFile = open(dname) for line in passFile.readlines(): word = line.strip('\n') t = Thread(target=cracktextfile, args=(tFile,word)) t.strart() if __name__ == '__main__': main()

Please any help much thankfull

Reply

RE: Whats wrong with my code? text file cracker #3
See: http://www.hackcommunity.com/Thread-Tuto...-Questions
Quote:Getting help for a programming problem:
  • Post the exact error message.
  • If there is no error, explain what you expect and what happens instead. Do not just say "it doesn't work".
  • If your code is large, try to trim it down to a compileable little code example that has the same problem/error. Codesnippets that are not compileable are often not enough to help, because the cause of the problem might be elsewhere.
  • Make your code readable, maybe use comments to help others understand; use english language for coding.
  • It can be relevant which operating system and compiler/IDE you use as well as the version of your programming language (i.e. Python 2.7 vs Python 3). So post this information, if you are unsure.

Also: Your indentation seems to be wrong. It is important that you post the indentation correctly for languages like Python.
My guess about your problem: You create new threads until no more resources are left to do so.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Whats wrong with my code? text file cracker #4
See: http://www.hackcommunity.com/Thread-Tuto...-Questions
Quote:Getting help for a programming problem:
  • Post the exact error message.
  • If there is no error, explain what you expect and what happens instead. Do not just say "it doesn't work".
  • If your code is large, try to trim it down to a compileable little code example that has the same problem/error. Codesnippets that are not compileable are often not enough to help, because the cause of the problem might be elsewhere.
  • Make your code readable, maybe use comments to help others understand; use english language for coding.
  • It can be relevant which operating system and compiler/IDE you use as well as the version of your programming language (i.e. Python 2.7 vs Python 3). So post this information, if you are unsure.

Also: Your indentation seems to be wrong. It is important that you post the indentation correctly for languages like Python.
My guess about your problem: You create new threads until no more resources are left to do so.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Whats wrong with my code? text file cracker #5
What's wrong? SEVERAL things are wrong.

Code:
def cracktextfile(tFile,word):

Not following the style guides, should've been; crack_text_file()

Code:
try: tfile.extractall(pwd=word) print ' [+++] Found pwd: ' + word print ' [++] Extract' except: pass

Here's a massive lack of indentation.

Code:
parser = optparse.OptionParser("usage: %prog" + "-t <textfile> -w <wordlist") parser.add_option('-t', dest='tname', type='string', help='enter text file') parser.add_option('-w', dest='dname', type='string', help='enter wordlist') (options,args) = parser.parse_args() if (options.tFile == None) | (options.dname == None): print parser.usage exit(0)

Stop using optparse, it's old and inefficient.

Here's how it would look in argparse. Notice, that I already have included a check, to see if both arguments are in use.
Code:
parser = argparse.ArgumentParser(prog="fileCracker") parser.add_argument('-t', '--target', help="specifies the targeted textilfe", required=True) parser.add_argument('-w', '--wordlist', help="specifies the wordlist.", required=True) args = parser.parse_args()

Here's your whole main() function, which also lacks indentation.
Code:
def main(): parser = optparse.OptionParser("usage: %prog" + "-t <textfile> -w <wordlist") parser.add_option('-t', dest='tname', type='string', help='enter text file') parser.add_option('-w', dest='dname', type='string', help='enter wordlist') (options,args) = parser.parse_args() if (options.tFile == None) | (options.dname == None): print parser.usage exit(0) zname = options.tname dname = options.dname tFile = textfile.TextFile(tname) passFile = open(dname) for line in passFile.readlines(): word = line.strip('\n') t = Thread(target=cracktextfile, args=(tFile,word)) t.strart()

It's clear to me, that you're both new to Python and programming in general. I know for sure, that the Python interpreter would throw you a lot of easily debuggable errors if you tried to run this 'program'. Rule nr. 1 when troubleshooting/debugging; READ THE ERROR MESSAGES!

Besides from the things I've pointed out, you have quite a few bad variable namings. "tFile", how am I supposed to know what tFile it? Name is something like 'target', 'texftile' etc. Same goes for 'dFile', name is 'wordlist' instead.

I've spent five minutes removing the most obvious errors in your code, and even implemented argparse for you. Also, I've removed the threading, you're clearly not ready to use that yet. Don't think this code, will actually do what you're trying to do. I've simply removed all the errors for you, now it's your turn to add some function/logic to this, to make it do what you want to do.

Code:
import argparse def crack_text_file(textfile, word): try: textfile.extractall(pwd = word) print(" [+++] Found pwd: " + word) print(" [++] Extract") except: pass def main(): parser = argparse.ArgumentParser(prog="fileCracker") parser.add_argument('-t', '--target', help="specifies the targeted textilfe", required=True) parser.add_argument('-w', '--wordlist', help="specifies the wordlist.", required=True) args = parser.parse_args() textfile = args.target wordlist = args.wordlist passFile = open(wordlist) for line in passFile.readlines(): word = line.strip('\n') if __name__ == '__main__': main()

Reply

RE: Whats wrong with my code? text file cracker #6
What's wrong? SEVERAL things are wrong.

Code:
def cracktextfile(tFile,word):

Not following the style guides, should've been; crack_text_file()

Code:
try: tfile.extractall(pwd=word) print ' [+++] Found pwd: ' + word print ' [++] Extract' except: pass

Here's a massive lack of indentation.

Code:
parser = optparse.OptionParser("usage: %prog" + "-t <textfile> -w <wordlist") parser.add_option('-t', dest='tname', type='string', help='enter text file') parser.add_option('-w', dest='dname', type='string', help='enter wordlist') (options,args) = parser.parse_args() if (options.tFile == None) | (options.dname == None): print parser.usage exit(0)

Stop using optparse, it's old and inefficient.

Here's how it would look in argparse. Notice, that I already have included a check, to see if both arguments are in use.
Code:
parser = argparse.ArgumentParser(prog="fileCracker") parser.add_argument('-t', '--target', help="specifies the targeted textilfe", required=True) parser.add_argument('-w', '--wordlist', help="specifies the wordlist.", required=True) args = parser.parse_args()

Here's your whole main() function, which also lacks indentation.
Code:
def main(): parser = optparse.OptionParser("usage: %prog" + "-t <textfile> -w <wordlist") parser.add_option('-t', dest='tname', type='string', help='enter text file') parser.add_option('-w', dest='dname', type='string', help='enter wordlist') (options,args) = parser.parse_args() if (options.tFile == None) | (options.dname == None): print parser.usage exit(0) zname = options.tname dname = options.dname tFile = textfile.TextFile(tname) passFile = open(dname) for line in passFile.readlines(): word = line.strip('\n') t = Thread(target=cracktextfile, args=(tFile,word)) t.strart()

It's clear to me, that you're both new to Python and programming in general. I know for sure, that the Python interpreter would throw you a lot of easily debuggable errors if you tried to run this 'program'. Rule nr. 1 when troubleshooting/debugging; READ THE ERROR MESSAGES!

Besides from the things I've pointed out, you have quite a few bad variable namings. "tFile", how am I supposed to know what tFile it? Name is something like 'target', 'texftile' etc. Same goes for 'dFile', name is 'wordlist' instead.

I've spent five minutes removing the most obvious errors in your code, and even implemented argparse for you. Also, I've removed the threading, you're clearly not ready to use that yet. Don't think this code, will actually do what you're trying to do. I've simply removed all the errors for you, now it's your turn to add some function/logic to this, to make it do what you want to do.

Code:
import argparse def crack_text_file(textfile, word): try: textfile.extractall(pwd = word) print(" [+++] Found pwd: " + word) print(" [++] Extract") except: pass def main(): parser = argparse.ArgumentParser(prog="fileCracker") parser.add_argument('-t', '--target', help="specifies the targeted textilfe", required=True) parser.add_argument('-w', '--wordlist', help="specifies the wordlist.", required=True) args = parser.parse_args() textfile = args.target wordlist = args.wordlist passFile = open(wordlist) for line in passFile.readlines(): word = line.strip('\n') if __name__ == '__main__': main()

Reply







Users browsing this thread: 1 Guest(s)