import os
import socket
from urllib.parse import urlparse
def nslookup(DOMAIN):
try:
ip_list = []
ais = socket.getaddrinfo(DOMAIN, 0, 0, 0, 0)
for result in ais:
ip_list.append(result[-1][0])
ip_list = list(set(ip_list))
return (',').join(ip_list)
except:
return "N/A"
def getDomain(PATH, FNAME):
# print PATH + '\\' + FNAME
with open(PATH + '\\' + FNAME, 'r') as f:
maldomain = f.readlines()
if len(maldomain) > 0:
for i in range(0, len(maldomain)):
# print i
if maldomain[i][:4] != "http":
maldomain[i] = "http://" + maldomain[i].rstrip()
# print urlparse(maldomain[i]).hostname
#maldomain[i] = "%-15s / %s" % (nslookup(urlparse(maldomain[i]).hostname), "hxxp" + maldomain[i][4:])
maldomain[i] = nslookup(urlparse(maldomain[i]).hostname)
print
maldomain[i]
else:
maldomain = "No URL in File"
## ๊ฒฐ๊ณผ ์ถ๋ ฅ
# print maldomain
return maldomain
print
"Loading...."
result = open('result.txt', 'w')
for item in getDomain(os.getcwd(), "list.txt"):
result.write("%s\n" % item)
print
"Done. Thank you!"
list.txt ํ์ผ์ ์ฝ์ด result.txt ํ์ผ์ ๊ฒฐ๊ณผ๋ฌผ์ ์์ฑํ๋ค.
URL์ ํ์ค์ ํ๋์ฉ ์ฝ๋๋ค
list.txt
www.naver.com
www.daum.net
result.txt
111.111.111.111 / hxxp://www.naver.com
222.111.111.122 / hxxp://www.daum.com
'๐ค์ ๋ณด๋ณด์ > ๐๋ธ๋ฃจํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ ๋ณด] ์น ๋ฐฉํ๋ฒฝ ip ์ฐจ๋จ ์ ์ฃผ์ ์ฌํญ (0) | 2023.02.15 |
---|---|
[์ ๋ณด] ๋์งํธ ํฌ๋ ์์ด๋ (0) | 2023.02.15 |
XDR EDR ์ฐจ์ด(CrowdStrike์ ํ์ฌ ๋น๊ต ๋ฉํธ) (0) | 2023.01.12 |
[ํ์ด์ฌ] ๋์ธ ์๋น์ค ์คํ ์ ๋ฌด ์ฒดํฌ ํ๋ก๊ทธ๋จ(๋ฉ์ผ๋ณด๊ณ ๊ธฐ๋ฅ) (0) | 2021.04.26 |
[ํ์ด์ฌ] ์น์๋น์ค IP ์ ๊ทผ ๋ ธ์ถ ํ์ธ ์์ค์ฝ๋(๋ณด์์ ์ฑ ) (0) | 2021.04.20 |