python - I'm getting the following error and can't work it out -
i'm learning python , started putting below code. i'm trying fread
function working correctly i'm getting error.
i've tried few ways fix of course if don't know what's causing i'm never going fix it.
i'm hoping me out.
error
unknown@ubuntu:~$ ./attack.py -f wordfile.txt traceback (most recent call last): file "./attack.py", line 63, in <module> print fread(list) file "./attack.py", line 20, in fread flist = open(list).readlines() typeerror: coercing unicode: need string or buffer, type found`
code
#!/usr/bin/python import sys, getopt, socket, fileinput, traceback import dns.query, dns.message, dns.name, adns queue import queue threading import thread def usage(): print "-h --help: help\n" print "-f --file: file read bruteforce domain list from.\n" print "-p --proxy: proxy address , port. e.g http://192.168.1.64:8080\n" print "-d --domain: domain bruteforce.\n" print "-t --thread: thread count.\n" print "-e: turn debug on.\n" sys.exit() def fread(list, *args): flist = open(list).readlines() return flist def addcheck(fcontent): data =[] c=adns.init() sub in file: subdomain = fcontent + domain data[subdomain] = c.synchronous(subdomain, adns.rr.a) return data def main(argv): list = none proxy = none domain = none file= none try: opts, argv =getopt.getopt(argv, "h:f:p:d:t:e",["help", "file=", "proxy=", "domain=", "thread="]) except getopt.getopterror err: print str(err) usage() sys.exit(2) opt, arg in opts: if opt in ("-h", "--help"): usage() sys.exit() elif opt in ("-f", "--file"): list = arg elif opt in ("-p", "--proxy"): proxy = arg elif opt in ("-d", "--domain"): domain = arg elif opt in ("-t", "--thread"): thread = arg elif opt in '-e': global _debug print fread(list) if __name__ == "__main__": main(sys.argv[1:])
you passing in list
type object here:
print fread(list)
this outside of main
function, list
still bound built-in type.
you meant line part of main()
function. if so, indent further match rest of code in function.
you should not use list
variable name, however. there built-in type of name; result indentation error gave confusing exception message. perhaps fname
or filename
have been better choice.
Comments
Post a Comment