-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathIP_Lookup.py
55 lines (47 loc) · 2.29 KB
/
IP_Lookup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#################################################################################
# #
# IP_Lookup.py #
# #
# The software is licensed Creative Commons CC-BY-NC-SA. Under this agreement #
# you are authorized to use, share on the same rights or edit this software #
# for personnal purpose only. You are not allow to sell this software. #
# #
# Official Website : https://coinpaign.com #
# Contact : romain.guihot@gmail.com #
# #
# This module is installed in Remote Administrator' computer. #
# This is used in RemoteAdminTool.py. #
# Function: #
# 1. Get IP address from domain address #
# 2. Get some information of target IP' computer #
# information: country, city, region, location #
# #
#################################################################################
import socket
import sys
import json
import requests
def func_getservip(target):
try:
s = socket.gethostbyname(target)
getResult = "IP: " + str(s) + " | " + target
except:
getResult = " Unknown Domain "
return getResult
def func_whois(target):
getResult = []
output = requests.get('https://ipinfo.io/'+target+'/geo')
content = output.text
obj = json.loads(content)
ss = str(obj).split(",")
dd = ss[1].split("'")
if dd[1] == "city":
getResult.append(obj['ip'])
getResult.append(obj['city'])
getResult.append(obj['region'])
getResult.append(obj['country'])
getResult.append(obj['loc'])
getResult.append(obj['readme'])
else:
getResult = []
return getResult