Skip to content

Commit

Permalink
Merge pull request #1 from qro/v2
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
lozza committed Jan 22, 2022
2 parents 303b5eb + 6a2a3bb commit 6ebdb71
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 143 deletions.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
![](https://img.shields.io/github/watchers/qro/ip-multi?style=social) ![](https://img.shields.io/github/stars/qro/ip-multi?style=social) ![](https://img.shields.io/github/forks/qro/ip-multi?style=social)
<p align="center">
<a href="https://www.python.org/">
<img src="https://img.shields.io/badge/python-3.10.2+-3776AB">
</a>
<a href="https://github.com/qro/ip/blob/master/LICENSE">
<img src="https://img.shields.io/badge/License-WTFPL-3776AB">
</a>
</p>

# IP Multi
An IP multi tool that has the ability to execute a ICMP Ping, check your own local IP, detailed lookup on the specified IP and look into the ports that are open in the IP.
<h1 align="center">
<img src="https://www.svgrepo.com/show/28319/magnifying-glass.svg" width="150px"><br>
🔎 ip - a IP multifunctional tool.
</h1>
<p align="center">
Simple ICMP ping, detailed lookup and local IP check.
</p>

![](https://cdn.discordapp.com/attachments/631162287968747550/852356764497608724/unknown.png)
## 🛠️ Installation
[Releases](https://github.com/qro/ip-multi/releases/tag/2.0.0) are available in this project, if you want to skip the whole installation process.

# Information
- I know the code is horrible, but I am looking to update this later on...
- If you need any support, pm my <a href="https://t.me/afqro">telegram</a>.
[Python](https://www.python.org/downloads/) must be installed on your computer; please get the most recent version.

### Windows 🪟
If you're running Windows, you can [download](https://codeload.github.com/qro/ip/zip/refs/heads/master) the .zip file directly from GitHub. In this case, you can still use [Git](https://github.com/git-for-windows/git/releases) to clone my repository.

Extract the Zip file and then open your command prompt in the same directory
```
$ py main.py
```

### Linux 🐧
If you're running Linux, clone my repository into your own directory by using this command
```
$ sudo apt install git
$ git clone https://github.com/qro/ip.git
$ cd ip
```
From there,
```
$ python3 main.py
```

## ℹ️ Information
- Removed the port scanner from `v1` because it's extremely unstable, but everything else should be cleaned up.
- Added a function to create a `.txt` file and save all your sent ip's with the date and time, pretty useless but yeah.
- If you need any support, pm my [telegram](https://t.me/afqro).
197 changes: 61 additions & 136 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,149 +1,74 @@
import os, sys, time, subprocess, json, socket
import os, subprocess, json, datetime, socket
from urllib.request import urlopen
from concurrent import futures
t = datetime.datetime.now()

def icmp():
os.system('cls & mode 70, 40')
client = input('\n [?] Enter IP address: ')
ping(client)
class IP():
def __init__(self):
self.client = client

def lookup():
os.system('cls & mode 70, 40')
client = 1
client = input(f'\n [?] Enter IP Address: ')
url1 = "http://ip-api.com/json/"
url2 = "http://extreme-ip-lookup.com/json/"
trackedip1 = urlopen(url1 + client)
trackedip2 = urlopen(url2 + client)
data1 = trackedip1.read()
data2 = trackedip2.read()
values1 = json.loads(data1)
values2 = json.loads(data2)

print(f'\n [>] IP: ' + values1['query'])
print(f' [>] City: ' + values1['city'])
print(f' [>] Country: ' + values1['country'])
print(f' [>] Name of the region: ' + values1['regionName'])
print(f' [>] Region: ' + values1['region'])
print(f' [>] ISP: ' + values1['isp'])
print(f' [>] ZIP Code: ' + values1['zip'])
print(f' [>] IP Type: ' + values2['ipType'])
print(f' [>] Organisation: ' + values2['org'])
print(f' [>] City: ' + values2['city'])
print(f' [>] Latitude: ' + values2['lat'])
print(f' [>] Longitude: ' + values2['lon'])
def valid(self):
i = 0
valid = True
for element in self.client:
if element == '.':
i += 1
else:
try:
int(element)
except:
valid = False
pass
if not i == 3:
valid = False
return valid

x = input('\n [?] x to go to menu: ')
if x == 'x':
main()
else:
print('\n [!] Invalid option')
time.sleep(0.5)
lookup()

def localip():
os.system('cls & mode 70, 12')
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)

print(f'\n [>] Hostname: {hostname}')
print(f' [>] IP Address: {ip_address}')

x = input('\n [?] x to go to menu: ')
if x == 'x':
main()
else:
print('\n [!] Invalid option')
time.sleep(0.5)
localip()
def main(self):
os.system('cls & mode 70, 12')
option = input('\n [1] ICMP Ping, [2] IP lookup, [3] Local IP\n\n [?] Option: ')
if option == '1':
IP().ping()
elif option == '2':
IP().lookup()
elif option == '3':
IP().localip()
else:
IP().main()

def portscan():
os.system('cls & mode 70, 30')
client = input('\n [?] Enter IP Address: ')
timeout = int(input(" [?] Timeout: "))
print("")
scan(client, timeout)

def validip(client): # stack
i = 0
valid = True
for element in client:
if element == '.':
i += 1
else:
try:
int(element)
except:
valid = False
pass
if not i == 3:
valid = False
return valid

def ping(client):
while not validip(client):
client = input(" [!] Invalid, please try again: ")
else:
print('\n [!] Press ctrl + c to stop')
time.sleep(1)
def ping(self):
os.system('cls & mode 70, 40')
while True:
try:
subprocess.check_call(f"PING {client} -n 1 | FIND \"TTL=\" > NUL",shell=True)
print(f' [>] {client} is online!')
subprocess.check_call(f"PING {self.client} -n 1 | FIND \"TTL=\" > NUL",shell=True)
print(f' [>] {self.client} is online!')
except subprocess.CalledProcessError:
print(f' [>] {client} is offline!')
except KeyboardInterrupt:
icmp()

def check_port(client, port, timeout):
TCPsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
TCPsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
TCPsock.settimeout(timeout)
try:
TCPsock.connect((client, port))
return(port)
except:
return

def scan(client, timeout):
threadPoolSize = 500
portsToCheck = 10000
print(f' [>] {self.client} is offline!')
except KeyboardInterrupt: # ctrl + c
IP().main()

executor = futures.ThreadPoolExecutor(max_workers=threadPoolSize)
checks = [
executor.submit(check_port, client, port, timeout)
for port in range(0, portsToCheck, 1)
]
def lookup(self):
os.system('cls & mode 70, 20')
url = 'http://ip-api.com/json/'
ip = urlopen(url + (self.client))
data = ip.read()
values = json.loads(data)
input(f'\n [>] IP: ', values['query'], '\n [>] City: ', values['city'], '\n [>] Country: ', values['country'], '\n [>] Name of the region: ', values['regionName'], '\n [>] Region: ', values['region'], '\n [>] ISP: ', values['isp'], '\n [>] ZIP Code: ', values['zip'], '\n [>] Organisation: ', values['org'], '\n')
IP().main()

for response in futures.as_completed(checks):
if (response.result()):
print(" [>] Listening on port: {} ".format(response.result()))
def localip(self):
os.system('cls & mode 70, 12')
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)
input(f'\n [>] Hostname: {hostname}\n [>] Local IP: {ip_address}\n')
IP().main()


def main():
if len(sys.argv) < 2:
os.system('cls & mode 70, 12 & title ip multi tool │ by lozza (github.com/qro)')
sys.stdout.write('''
[1] ICMP Ping
[2] IP lookup
[3] What is my local ip?
[4] Portscan
''')

choice = input("[?] Option: ")
if choice == '1':
icmp()
elif choice == '2':
lookup()
elif choice == '3':
localip()
elif choice == '4':
portscan()
if __name__ == '__main__':
os.system('cls & mode 70, 12 & title ip │ by lozza (github.com/qro)')
client = input(f'\n [?] Enter an IP address: ')
while not IP().valid():
exit()
else:
print('\n[!] Invalid option')
time.sleep(0.5)
main()

main()
f = open("ip.txt", "a")
f.write(t.strftime("%H:%M:%S %d/%m/%Y : ") + '"' + client + '"' + '\n')
f.close()
IP().main()

0 comments on commit 6ebdb71

Please sign in to comment.