Skip to content
This repository was archived by the owner on Apr 11, 2021. It is now read-only.

Commit 0097b98

Browse files
author
Mehtab Zafar
authored
Move upgradeFiles function to a new file (#32)
Move upgradeFiles function to a new file
2 parents 4509a08 + a776373 commit 0097b98

File tree

2 files changed

+104
-86
lines changed

2 files changed

+104
-86
lines changed

domained.py

Lines changed: 6 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import os
2424
import requests
2525
import smtplib
26-
import subprocess
2726
import time
2827
from signal import signal, alarm, SIGALRM
28+
from installer import upgradeFiles
2929

3030
today = datetime.date.today()
3131

@@ -226,84 +226,6 @@ def eyewitness(filename):
226226
print("\a")
227227

228228

229-
def upgradeFiles():
230-
binpath = os.path.join(script_path, "bin")
231-
old_wd = os.getcwd()
232-
if not os.path.exists(binpath):
233-
os.makedirs(binpath)
234-
else:
235-
print("Removing old bin directory: {}".format(binpath))
236-
os.system("rm -rf {}".format(binpath))
237-
os.makedirs(binpath)
238-
print("Changing into domained home: {}".format(script_path))
239-
os.chdir(script_path)
240-
unameChk = str(subprocess.check_output(["uname", "-am"]))
241-
if "kali" not in unameChk:
242-
print("\n\033[1;31mKali Linux Recommended!\033[1;37m")
243-
time.sleep(1)
244-
sublist3rUpgrade = (
245-
"git clone https://github.com/aboul3la/Sublist3r.git ./bin/Sublist3r"
246-
)
247-
print("\n\033[1;31mInstalling Sublist3r \033[1;37m")
248-
os.system(sublist3rUpgrade)
249-
subInstallReq = "pip install -r bin/Sublist3r/requirements.txt"
250-
os.system(subInstallReq)
251-
print("Sublist3r Installed\n")
252-
eyeWitnessUpgrade = "git clone https://github.com/FortyNorthSecurity/EyeWitness.git ./bin/EyeWitness"
253-
print("\n\033[1;31mInstalling EyeWitness \033[1;37m" + eyeWitnessUpgrade)
254-
os.system(eyeWitnessUpgrade)
255-
eyeInstallReq = "bash bin/EyeWitness/setup/setup.sh"
256-
print("\n\033[1;31mRunning Command: \033[1;37m")
257-
os.system(eyeInstallReq)
258-
cpphantomjs = "cp phantomjs ./bin/EyeWitness/bin/"
259-
os.system(cpphantomjs)
260-
movephantomjs = "mv phantomjs bin/"
261-
os.system(movephantomjs)
262-
print("\nEyeWitness Installed\n")
263-
enumallUpgrade = "git clone https://github.com/jhaddix/domain.git ./bin/domain"
264-
print("\n\033[1;31mInstalling Enumall \033[1;37m")
265-
print("\nenumall Installed\n")
266-
os.system(enumallUpgrade)
267-
knockpyUpgrade = "git clone https://github.com/guelfoweb/knock.git ./bin/knockpy"
268-
print("\n\033[1;31mInstalling Knock \033[1;37m")
269-
os.system(knockpyUpgrade)
270-
print("\nKnockpy Installed\n")
271-
sublstUpgrade = "git clone https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056 ./bin/sublst"
272-
print("\n\033[1;31mCopying JHaddix All Domain List: \033[1;37m")
273-
print("\nJHaddix All Domain List Installed\n")
274-
os.system(sublstUpgrade)
275-
SLsublstUpgrade = "wget -O ./bin/sublst/sl-domains.txt https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/DNS/sortedcombined-knock-dnsrecon-fierce-reconng.txt"
276-
print("\n\033[1;31mCopying SecList Domain List \033[1;37m")
277-
print("\nSecList Domain List Installed\n")
278-
os.system(SLsublstUpgrade)
279-
subbruteUpgrade = "git clone https://github.com/TheRook/subbrute.git ./bin/subbrute"
280-
print("\n\033[1;31mInstalling Subbrute \033[1;37m")
281-
os.system(subbruteUpgrade)
282-
print("\nSubbrute Installed\n")
283-
amassUpgrade = "go get -u github.com/OWASP/Amass/..."
284-
print("\n\033[1;31mInstalling Amass \033[1;37m")
285-
os.system(amassUpgrade)
286-
subfinderUpgrade = "go get -u github.com/subfinder/subfinder"
287-
print("\n\033[1;31mInstalling Subfinder \033[1;37m")
288-
os.system(subfinderUpgrade)
289-
massdnsUpgrade = "git clone --branch v0.2 --single-branch https://github.com/blechschmidt/massdns ./bin/massdns"
290-
print("\n\033[1;31mInstalling massdns \033[1;37m")
291-
os.system(massdnsUpgrade)
292-
massdnsMake = "make -C ./bin/massdns"
293-
os.system(massdnsMake)
294-
print("\nMassdns Installed\n")
295-
os.system("cp ./bin/subbrute/resolvers.txt ./")
296-
if "kali" in unameChk:
297-
reconNGInstall = "apt-get install recon-ng"
298-
print("\n\033[1;31mInstalling Recon-ng \033[1;37m")
299-
os.system(reconNGInstall)
300-
print("\nRecon-ng Installed\n")
301-
else:
302-
print("Please install Recon-ng - https://bitbucket.org/LaNMaSteR53/")
303-
print("\n\033[1;31mAll tools installed \033[1;37m")
304-
print("Changing back to old working directory: {}".format(old_wd))
305-
os.chdir(old_wd)
306-
307229

308230
def writeFiles(name):
309231
"""Writes info of all hosts from subhosts
@@ -329,10 +251,10 @@ def writeFiles(name):
329251
f.writelines("\n\n" + name)
330252
for hosts in SubHosts:
331253
hosts = "".join(hosts)
332-
f.writelines("\n" + hosts)
333-
subdomainCounter += 1
334-
os.remove(fileName)
335-
print("\n%s Subdomains discovered by %s" % (subdomainCounter, name))
254+
f1.writelines("\n" + hosts)
255+
subdomainCounter = subdomainCounter + 1
256+
os.remove(massdnsFileName)
257+
print("\n{} Subdomains discovered by massdns".format(subdomainCounter))
336258
except:
337259
print("\nError Opening %s File!\n" % name)
338260
return subdomainCounter
@@ -453,9 +375,7 @@ def options():
453375
os.system("rm -r output")
454376
newpath = r"output"
455377
os.makedirs(newpath)
456-
if install:
457-
upgradeFiles()
458-
elif upgrade:
378+
if install or upgrade:
459379
upgradeFiles()
460380
else:
461381
if domain:

installer.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import os
2+
import time
3+
import subprocess
4+
5+
6+
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
7+
8+
9+
def upgradeFiles():
10+
"""Upgrade all the required files
11+
"""
12+
binpath = os.path.join(SCRIPT_PATH, "bin")
13+
old_wd = os.getcwd()
14+
if not os.path.exists(binpath):
15+
os.makedirs(binpath)
16+
else:
17+
print("Removing old bin directory: {}".format(binpath))
18+
os.system("rm -rf {}".format(binpath))
19+
os.makedirs(binpath)
20+
print("Changing into domained home: {}".format(SCRIPT_PATH))
21+
os.chdir(SCRIPT_PATH)
22+
unameChk = subprocess.check_output(["uname", "-am"]).decode("utf-8")
23+
24+
if "kali" not in unameChk:
25+
print("\n\033[1;31mKali Linux Recommended!\033[1;37m")
26+
time.sleep(1)
27+
28+
sublist3rUpgrade = (
29+
"git clone https://github.com/aboul3la/Sublist3r.git ./bin/Sublist3r"
30+
)
31+
print("\n\033[1;31mInstalling Sublist3r \033[1;37m")
32+
os.system(sublist3rUpgrade)
33+
subInstallReq = "pip install -r bin/Sublist3r/requirements.txt"
34+
os.system(subInstallReq)
35+
print("Sublist3r Installed\n")
36+
37+
eyeWitnessUpgrade = "git clone https://github.com/FortyNorthSecurity/EyeWitness.git ./bin/EyeWitness"
38+
print("\n\033[1;31mInstalling EyeWitness \033[1;37m" + eyeWitnessUpgrade)
39+
os.system(eyeWitnessUpgrade)
40+
eyeInstallReq = "bash bin/EyeWitness/setup/setup.sh"
41+
print("\n\033[1;31mRunning Command: \033[1;37m")
42+
os.system(eyeInstallReq)
43+
cpphantomjs = "cp phantomjs ./bin/EyeWitness/bin/"
44+
os.system(cpphantomjs)
45+
movephantomjs = "mv phantomjs bin/"
46+
os.system(movephantomjs)
47+
print("\nEyeWitness Installed\n")
48+
49+
enumallUpgrade = "git clone https://github.com/jhaddix/domain.git ./bin/domain"
50+
print("\n\033[1;31mInstalling Enumall \033[1;37m")
51+
print("\nenumall Installed\n")
52+
os.system(enumallUpgrade)
53+
54+
knockpyUpgrade = "git clone https://github.com/guelfoweb/knock.git ./bin/knockpy"
55+
print("\n\033[1;31mInstalling Knock \033[1;37m")
56+
os.system(knockpyUpgrade)
57+
print("\nKnockpy Installed\n")
58+
59+
sublstUpgrade = "git clone https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056 ./bin/sublst"
60+
print("\n\033[1;31mCopying JHaddix All Domain List: \033[1;37m")
61+
print("\nJHaddix All Domain List Installed\n")
62+
os.system(sublstUpgrade)
63+
SLsublstUpgrade = "wget -O ./bin/sublst/sl-domains.txt https://raw.githubusercontent.com/\
64+
danielmiessler/SecLists/master/Discovery/DNS/sortedcombied-knock-dnsrecon-fierce-reconng.txt"
65+
print("\n\033[1;31mCopying SecList Domain List \033[1;37m")
66+
print("\nSecList Domain List Installed\n")
67+
os.system(SLsublstUpgrade)
68+
69+
subbruteUpgrade = "git clone https://github.com/TheRook/subbrute.git ./bin/subbrute"
70+
print("\n\033[1;31mInstalling Subbrute \033[1;37m")
71+
os.system(subbruteUpgrade)
72+
print("\nSubbrute Installed\n")
73+
74+
amassUpgrade = "go get -u github.com/OWASP/Amass/..."
75+
print("\n\033[1;31mInstalling Amass \033[1;37m")
76+
os.system(amassUpgrade)
77+
subfinderUpgrade = "go get -u github.com/subfinder/subfinder"
78+
print("\n\033[1;31mInstalling Subfinder \033[1;37m")
79+
os.system(subfinderUpgrade)
80+
massdnsUpgrade = "git clone --branch v0.2 --single-branch https://github.com/blechschmidt/massdns ./bin/massdns"
81+
print("\n\033[1;31mInstalling massdns \033[1;37m")
82+
os.system(massdnsUpgrade)
83+
massdnsMake = "make -C ./bin/massdns"
84+
os.system(massdnsMake)
85+
print("\nMassdns Installed\n")
86+
os.system("cp ./bin/subbrute/resolvers.txt ./")
87+
88+
if "kali" in unameChk:
89+
reconNGInstall = "apt-get install recon-ng"
90+
print("\n\033[1;31mInstalling Recon-ng \033[1;37m")
91+
os.system(reconNGInstall)
92+
print("\nRecon-ng Installed\n")
93+
else:
94+
print("Please install Recon-ng - https://bitbucket.org/LaNMaSteR53/")
95+
96+
print("\n\033[1;31mAll tools installed \033[1;37m")
97+
print("Changing back to old working directory: {}".format(old_wd))
98+
os.chdir(old_wd)

0 commit comments

Comments
 (0)