IP๋ก ์๋น์ค๋ฅผ ์ ๊ทผํ์์๋ ์ ๊ทผ ๊ฐ๋ฅํ ๊ฒ์ ์ทจ์ฝ์ผ๋ก ํ๋จํ๋ ๋ถ๋ฅ ์์ค์ฝ๋์ด๋ค.
์ ๊ฒ ๊ฒฐ๊ณผ๋ Excel๋ก ํ์ธ ๊ฐ๋ฅํ๋ค ์ฌ์ดํธ์ ์ง์ ์ ๊ทผํ์ฌ ํ์ธํด์ผํ๋ ์๋์ ๊ฒ ํญ๋ชฉ์ด ์๋ค.
์ฝ์&์์ ๋ฒ์
import requests
from openpyxl import Workbook
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
class bcolors:
HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKCYAN = "\033[96m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
write_wb = Workbook()
write_ws = write_wb.active
write_ws.cell(1,1,"๋ฒํธ")
write_ws.cell(1,2,"IP")
write_ws.cell(1,3,"๊ฒฐ๊ณผ")
write_ws.cell(1,4,"๋น๊ณ ")
f = open("./list.txt", 'r')
no = 0
print("================์ง๋จ ์ค================")
while True :
try:
#IP ๋ชฉ๋ก
line = f.readline().rstrip()
if not line: break
no+=1
#Request ์์ฒญ
response = requests.get(url=line, timeout=3, verify=False)
#IF ๊ตฌ๋ฌธ์์ฑ์ ์ํ ํน์ ์ฌ์ดํธ ๋ด์ฉ ํ์ธ
# if no==22:
# print(line+response.url)
#๋ถ๋ฅ ๋ฐ ์์ธ์ฒ๋ฆฌ if ๋ฌธ
if "Please enable JavaScript" in response.text:
print(str(no) + " " + bcolors.WARNING + line + ": ์๋์ ๊ฒ - Enable JS" + bcolors.ENDC)
# warningSite.append = no
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์๋์ ๊ฒ")
write_ws.cell(no + 1, 4, "Enable JS")
elif "๋ฆฌ๋ค์ด๋ ์
๋๋ URL ๋ฃ์ด์ฃผ์ธ์" in response.url:
print(str(no)+" "+bcolors.FAIL+line+": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ(๋ฆฌ๋ค์ด๋ ์
)"+bcolors.ENDC)
# warningSite.append = no
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ(๋ฆฌ๋ค์ด๋ ์
)")
elif "๋ณด์์ ์ฑ
์ ๋ฐ๋ผ ์ฐจ๋จ" in response.text:
print(str(no)+" "+bcolors.OKGREEN+line+": ์ํธ - ๋ณด์์ ์ฑ
ํ์ด์ง"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "๋ณด์์ ์ฑ
ํ์ด์ง๋ก ์ ๊ทผ์ ์ด")
elif "invalid page fault" in response.text:
print(str(no)+" "+bcolors.OKGREEN+line+": ์ํธ - ๊ธฐํ ์น ์๋ฌ ํ์ด์ง"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "๊ธฐํ ์น ์๋ฌํ์ด์ง")
elif "error page test" in response.text :
print(str(no)+" "+bcolors.OKGREEN+line + ": ์ํธ - ๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง")
elif "Error 404" in response.text:
print(str(no)+" "+bcolors.FAIL+line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ(WEB ์๋ฒ 404 ํ์ด์ง)"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ(WAS 404 ํ์ด์ง)")
elif "Wrong approach path" in response.text:
print(str(no)+" "+bcolors.OKGREEN+line + ": ์ํธ - ๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง")
elif "/error/error_img" in response.text:
print(str(no)+" "+bcolors.OKGREEN+line + ": ์ํธ - ๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง")
elif "Error 403</h2>" in response.text:
print(str(no)+" "+bcolors.FAIL+line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ(IIS 403 ํ์ด์ง)"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ(IIS 403 ํ์ด์ง)")
elif "<h2>404 -" in response.text:
print(str(no)+" "+bcolors.FAIL+line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ(IIS 404 ํ์ด์ง)"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ(IIS 404 ํ์ด์ง)")
elif "Invalid" in response.text:
print(str(no)+" "+bcolors.OKGREEN+line + ": ์ํธ - ๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "๋ณ๋์ ์ ๊ทผ์ ์ด ํ์ด์ง")
elif "You are unauthorized to access this page." in response.text:
print(str(no)+" "+bcolors.OKGREEN+line + ": ์ํธ - WAS 403 ์ ๊ทผ์ ์ด ํ์ด์ง"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "WAS 403 ์ ๊ทผ์ ์ด ํ์ด์ง")
elif "you've successfully installed Tomcat" in response.text:
print(str(no) + " " + bcolors.FAIL+line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ(Apache ๊ธฐ๋ณธ ํ์ด์ง)"+bcolors.ENDC)
# warningSite.append = no
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ(Apache ๊ธฐ๋ณธ ํ์ด์ง)")
elif "IIS Windows Server" in response.text:
print(str(no) + " " + bcolors.FAIL+line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ(IIS ๊ธฐ๋ณธ ํ์ด์ง)"+bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ(IIS ๊ธฐ๋ณธ ํ์ด์ง)")
else:
if "์์ด๋" in response.text or "password" in response.text or "login" in response.text:
if "https" in response.url:
print(str(no) + " " + bcolors.FAIL + line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ" + bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ")
else:
print(str(no) + " " +bcolors.FAIL + line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ(๋ก๊ทธ์ธ http)" + bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ(๋ก๊ทธ์ธ http)")
else:
print(str(no) + " " +bcolors.FAIL + line + ": ์ทจ์ฝ - ํ์ด์ง ๋
ธ์ถ" + bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ทจ์ฝ")
write_ws.cell(no + 1, 4, "ํ์ด์ง ๋
ธ์ถ")
#์ฐ๊ฒฐ ์๊ฐ์ด๊ณผ ์์ธ์ฒ๋ฆฌ
except requests.exceptions.Timeout:
print(str(no) + " " + bcolors.OKCYAN + line + ": ์ํธ - ์์ธ์ฒ๋ฆฌ(์๋ต์์)" + bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "์์ธ์ฒ๋ฆฌ(ํ์์์)")
pass
#SSL ์ธ์ฆ์ ์๋ฌ ๋ฐ์ ๋ฐฉ์ง
except requests.exceptions.SSLError:
print(str(no) + " " + bcolors.OKCYAN + line + ": ์ํธ - ์์ธ์ฒ๋ฆฌ(SSLError)" + bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "์์ธ์ฒ๋ฆฌ(SSLError)")
pass
#์ฐ๊ฒฐ ์คํจ(์๋ต ์์) ์์ธ์ฒ๋ฆฌ
except requests.exceptions.ConnectionError:
print(str(no) + " " + bcolors.OKCYAN + line + ": ์ํธ - ์์ธ์ฒ๋ฆฌ(์๋ต์์)" + bcolors.ENDC)
write_ws.cell(no + 1, 1, str(no))
write_ws.cell(no + 1, 2, line)
write_ws.cell(no + 1, 3, "์ํธ")
write_ws.cell(no + 1, 4, "์์ธ์ฒ๋ฆฌ(์๋ต์์)")
pass
f.close()
write_wb.save('./result.xlsx')
'๐ค์ ๋ณด๋ณด์ > ๐๋ธ๋ฃจํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ ๋ณด] ์น ๋ฐฉํ๋ฒฝ ip ์ฐจ๋จ ์ ์ฃผ์ ์ฌํญ (0) | 2023.02.15 |
---|---|
[์ ๋ณด] ๋์งํธ ํฌ๋ ์์ด๋ (0) | 2023.02.15 |
XDR EDR ์ฐจ์ด(CrowdStrike์ ํ์ฌ ๋น๊ต ๋ฉํธ) (0) | 2023.01.12 |
[ํ์ด์ฌ] ๋์ธ ์๋น์ค ์คํ ์ ๋ฌด ์ฒดํฌ ํ๋ก๊ทธ๋จ(๋ฉ์ผ๋ณด๊ณ ๊ธฐ๋ฅ) (0) | 2021.04.26 |
[ํ์ด์ฌ3.x] nslookup ์๋ํ ํด (0) | 2020.05.21 |