[Python] IPTools 1.0

Iniciado por Subzer, Septiembre 12, 2016, 12:45:14 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Bueno como tenia mas de 2 o 3 años sin programar y estoy volviendo a esto, trabajé en un par de librerias y he llegado a hacer esto.
Tuve un par de complicaciones pero las logre resolver.
Apartando todo eso, veamos el programa:



You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
Le coloque el nombre de IP Tools debido a que las herramientas que se encuentran en el programa utilizan la IP [target] que el usuario le indique.
El programa tiene 2 herramientas sencillas que son las siguientes: IP Geo Localization e IP - Port Scanner

IP GeoLocalization:
+ Localizar de donde proviene la IP que se indique
   { País, ciudad, region, zona, zona horaria, zip code, etc.}
   { Crear un log llamado 'ip_log.txt' en el cual queda grabado toda la informacion que se consiga}
   { El log que se crea siempre va a estar actualizandose al final del archivo, manteniendo un formato y colocando la hora en que se escriba}
+ Consigue datos como latitud y longitud del IP proveniente
+ Puede abrirse google maps con el default browser y colocar la ubicacion exacta del IP proveniente, según el usuario lo indique

IP - Port Scanner:
+ Escanear puertos de una IP según un rango establecido por el usuario: {start} {end}
+ Escanear puertos vulnerables de una IP
   { Como puertos vulnerables incluye: Telnet, FTP, SMTP relay, HTTP, Netbios, VPN (PPTP), Firewall, etc.}

Bueno sin más que decir les dejo mi codigo y unas imagenes para que vean el funcionamiento.

Aqui coloque la IP de una proxy de Argentina pero como ven igual indica todos los datos.


Código: python
#!/usr/bin/env python
# -*- coding utf-8 -*-
# IPTools ver. 1.0
#Coded by Subzer
#For Underc0de.org forum!
#Free use - don't forget to give credits!
import urllib, json
import socket, sys
from datetime import datetime
import os, time

def port_scan():
print '1. Scan ports in range [start]:[end]'
print '2. Scan vulnerability ports from an IP'
print '[*] Port Scanner executed, now enter 1 or 2 depending on your choice'
choice = raw_input('Select option:  ')

if choice == '1':
IP = raw_input('{+} Target IP: ')
start = input ('{+} Port start range: ')
end = input ('{+} Port end range: ')
print '\n'+'Connecting to: '+(IP)+' from: '+str(start)+' to: '+str(end)+'\n'
s = socket.socket()
for p in range (start, end+1):
try:
s.connect((IP, p))
print 'Port: '+str(p)+' is [OPEN]'
except:
print 'Port: '+str(p)+' is [CLOSED]'
s.close()
elif choice == '2':
IP = raw_input('{+} Target IP: ')
vulns = {'FTP/File server':21, 'SMTP relay':25, 'HTTP/Web server':80, 'NETBIOS susceptibility':139, 'Microsoft Remote desktop':3389, 'VPN (PPTP) service':1723, 'ORACLE Database':1521, 'Telnet service':23, 'POP3 / Email':110, 'Windows file sharing susceptibility':445, 'Firewall remote login':8080, 'VNC Remote desktop':5900, 'Microsoft SQL server':1433, 'MySQL database':3306}
s = socket.socket()
for k, v in vulns.items():
try:
s.connect((IP, v))
print '\n *** %s' % str(k) + ' on Port: %s is [OPEN] ***' % str(v) + '\n'
except:
print '%s' % str(k) + ' on Port: %s is [CLOSED]' % str(v)
s.close()

def ip_scan():
url = 'http://freegeoip.net/json/'
print '\n' + '{+} if IP or Host name value = N/A {Default: localhost}' + '\n'
button = raw_input('{+}IP or Host name: ')
r = urllib.urlopen(url+str(button)).read()
location = json.loads(r)
location_ip = location['ip']
print 'Scanning data for: '+str(location_ip)+'\n'
location_CN = location['country_name']
print 'Country name: '+str(location_CN)
location_CC = location['country_code']
print 'Country code: '+str(location_CC)
location_city = location['city']
print 'City: '+str(location_city)
location_rc = location['region_code']
print 'Region code: '+location_rc
location_rn = location['region_name']
print 'Region name: '+str(location_rn)
location_tz = location ['time_zone']
print 'Time zone: '+str(location_tz)
global location_long
global location_lati
location_long = location['longitude']
print 'Longitude: '+str(location_long)
location_lati = location['latitude']
print 'Latitude: '+str(location_lati)
location_zip = location['zip_code']
print 'Zip code: '+str(location_zip)

date = datetime.now()

print '\n [+] Creating a log file named {ip_log.txt} - dir: where your iptools is.'

f = open('ip_log.txt', 'a')
f.write('------ NEW LOG ------\n')
f.write('DATE: '+str(date)+'\n')
f.write('IP Log Register for: '+str(location_ip)+'\n')
f.write('Country name: '+location_CN+'\n')
f.write('Country code: '+location_CC+'\n')
f.write('City: '+location_city+'\n')
f.write('Region code: '+location_rc+'\n')
f.write('Region name: '+location_rn+'\n')
f.write('Time zone: '+location_tz+'\n')
f.write('Longitude: '+str(location_long)+'\n')
f.write('Latitude: '+str(location_lati)+'\n')
f.write('Zip code: '+location_zip+'\n')
f.close()

time.sleep(2)
print '[+] Successfully created the log file \n'

time.sleep(1)
print '--- MENU OPTIONS ---'
print '::: else will exit the program ::: type number.'
print 'This will open GOOGLE MAPS'
map = raw_input('[+] Do you want to open where the IP Host locates? Y/n ')
if map == 'Y':
maps()
elif map == 'y':
maps()
else:
sys.exit(0)

def maps():
print 'Opening {default browser}'
os.system('start https://www.google.co.ve/maps/search/googlemaps/@%s,-%s,15z' % (location_lati, location_long))



def menu():
print '''
  _____ _____ _______          _     
|_   _|  __ \__   __|        | |   
   | | | |__) | | | ___   ___ | |___
   | | |  ___/  | |/ _ \ / _ \| / __|
  _| |_| |      | | (_) | (_) | \__ \
  IP Geo Localization | Port Scanner
|_____|_|      |_|\___/ \___/|_|___/
 
by Subzer -ver. 1.0 
'''
print '''usage:
-g GEO Localization {start IP Geo Localization program}
-p PORT Scanner {start Port scanner program}

e.g | iptools.py -g / ip.tools.py -p''' + '\n'

if len(sys.argv) != 2:
print '[+] Use: {command}'
print 'eg. -g or -p'
option = raw_input('Type command: ')
if option == '-g':
ip_scan()
elif option == '-p':
port_scan()
else:
sys.exit(2)
elif sys.argv[1] == '-g':
ip_scan()
elif sys.argv[1] == '-p':
port_scan()
else:
print '\n' + '{*} Use a valid command | type -h for help'
sys.exit(1)

if __name__ == '__main__':
menu()
else:
sys.exit(0)




Avisenme que les parece y comenten si ven algun o error o algo que puedo arreglar.
Saludos, Subzer!

PABLO ESCOBAR.

Esta bien, sencillo pero util en lo que intenta hacer. Lo unico que haria como comentario es que intentes buscar una alternativa a la web de You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ya que si esa web se cae, el 50% de la funcionalidad del programa pierde sentido. Deberias tener una de backup alternativa.

Saludos.
Security Researcher
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Muy bueno, estaba queriendo hacer algo igual, gracias por compartir. Saludos.

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
Esta bien, sencillo pero util en lo que intenta hacer. Lo unico que haria como comentario es que intentes buscar una alternativa a la web de You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ya que si esa web se cae, el 50% de la funcionalidad del programa pierde sentido. Deberias tener una de backup alternativa.

Saludos.

Gracias bro, lo tengo en cuenta para la proxima version si es que la llego a hacer.
Estoy tratando de hacer diferentes cosas pero ya hay muchas herramientas que existen en python y crear una desde cero y que sea algo innovador me es dificil pero buee, ando aprendiendo y poco a poco ire haciendo cosas!
Saludos,
Subzer.

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
Muy bueno, estaba queriendo hacer algo igual, gracias por compartir. Saludos.

Gracias, me alegra que te haya gustado. Si tienes ideas o algo que podamos desarrollar estoy a la orden!
Saludos,
Subzer.

PABLO ESCOBAR.

Excelente herramienta! Muy util y sencilla.

Congratz!!