我正在获取通过读取文件生成的列表,并尝试获取每个项目并将其连接到另一个输入字符串。我能理解错误;我无法用字符串连接列表项。但是如何将列表中的每个项目转换为字符串。我试过' '.join(list)
,但这也不起作用。
我收到以下错误:
错误
Traceback (most recent call last):
File "./attack2.py", line 40, in <module>
print subcheck(returned_list, ['--domain'])
File "./attack2.py", line 31, in subcheck
socket.gethostbyname(sub + domain)
TypeError: cannot concatenate 'str' and 'list' objects
CODE
#!/usr/bin/python
"""
Description:
Basic Domain bruteforcer
Usage:
attack2.py (-f <file>) (-d <domain>) [-t 10] [-v]
attack2.py -h | --help
Arguments:
-f --file File to read potential Sub-domains from. (Required)
-d --domain Domain to bruteforce. (Required)
Options:
-h --help Show this screen.
-p --proxy Proxy address and port. [default: http://127.0.0.1:8080] (Optional)
-t --thread Thread count. (Optional)
-v --verbose Turn debug on. (Optional)
"""
import socket
from docopt import docopt
def fread(dwords):
flist = open(dwords).readlines()
return [s.replace('\n', '.') for s in flist]
def subcheck(subdomain, domain):
for sub in subdomain:
socket.gethostbyname(sub + domain)
return output
if __name__ == "__main__":
arguments = docopt(__doc__, version='0.1a')
print arguments
print fread(arguments['--file'])
returned_list = fread(arguments['--file'])
print subcheck(returned_list, ['--domain'])
答案 0 :(得分:4)
print subcheck(returned_list, ['--domain'])
您的意思是从arguments对象中检索域选项吗?
print subcheck(returned_list, arguments['--domain'])