Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multithreading #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 42 additions & 17 deletions snallygaster
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import dns.resolver
import dns.query
import dns.zone
import urllib3

from multiprocessing.dummy import Pool as ThreadPool

STANDARD_PHP_FILES = ['index.php', 'wp-config.php', 'configuration.php',
'config.php', 'config.inc.php', 'settings.php']
Expand Down Expand Up @@ -673,6 +673,10 @@ parser.add_argument("-j", "--json", action="store_true",
help="Produce JSON output")
parser.add_argument("-d", "--debug", action="store_true",
help="Show detailed debugging info")
parser.add_argument("-l","--list", nargs=1,
help="get list of subdomains")
parser.add_argument("-c","--concurency", nargs=1, default=['5'],
help="no of threads(works only with -l)")
args = parser.parse_args()

# Initializing global pool manager
Expand Down Expand Up @@ -702,30 +706,51 @@ if len(path) > 0 and path[0] != "/":
if path != "":
pdebug("Path: %s" % path)

hosts = list(args.hosts)
if not args.nowww:
for h in args.hosts:
hosts.append("www." + h)

for i, h in enumerate(hosts):
hosts[i] = h.encode("idna").decode("ascii")
if h != hosts[i]:
pdebug("Converted %s to %s" % (h, hosts[i]))
def mThreader(domain,test):
hosts = []
hosts.append(domain)
if not args.nowww:
hosts.append("www." + domain)
try:
for i, h in enumerate(hosts):
hosts[i] = h.encode("idna").decode("ascii")
if h != hosts[i]:
pdebug("Converted %s to %s" % (h, hosts[i]))
pdebug("All hosts: %s" % ",".join(hosts))
except Exception as e:
print(hosts)

pdebug("All hosts: %s" % ",".join(hosts))
json_out = []
for host in hosts:
# pdebug("Scanning %s" % host)

pdebug(("Running %s test for %s") % (test.__name__, host))

json_out = []
for host in hosts:
pdebug("Scanning %s" % host)
for test in tests:
pdebug("Running %s test" % test.__name__)
if hasattr(test, '_is_hostname_test'):
test(host)
else:
if not args.nohttp:
test("http://" + host + path)
if not args.nohttps:
test("https://" + host + path)
if args.json:
print(json.dumps(json_out))
if args.json:
print(json.dumps(json_out))

if args.list:
with open (args.list[0]) as domains:
domains=domains.readlines()
domains=[x.strip() for x in domains]
print("Threading set to "+ str(args.concurency[0]))
pool=ThreadPool(int(args.concurency[0]))

list=[]
for test in tests:
for domain in domains:
list.append((domain,test))
pool.starmap(mThreader,list)
pool.close()
pool.join()
else:
for test in tests:
mThreader(args.hosts[0],test)