chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Maya Networking Tool filter_list
Author
Message
Maya Networking Tool #1
I got bored, learned about sockets and JSON tricks, and made this. I'm too tired to outline everything, so there's tips and everything in the help command.

Running (since this apparently confuses people):
Code:
#from parent directory
$ python maya
#from source directory
$ python .

Files:

__main__.py:
Code:
from subprocess import call
import portscanner
import geoip

header=''' __  __   ___ __   __ ___  
|  \/  | / _ \\\\ \ / // _ \
| .  . |/ /_\ \\\\ V // /_\ \\
| |\/| ||  _  | \ / |  _  |
| |  | || | | | | | | | | |
\_|  |_/\_| |_/ \_/ \_| |_/
'''+'*'*27
services={'notes': ['leave ip/host field blank for current host','hit enter after service to return to menu'],'port scanner': ['id           : 2','desc         : scans specified host for open ports in range','instructions : follow prompts','source       : portscanner.py'],'ip locator': ['id           : 1','desc         : geolocates IPs using https://freegeoips.net/','instructions : follow prompts','source       : geoip.py']}

def main():
    call('clear',shell=True)
    print header
    i=raw_input('Enter service ID (0 for service help): ')
    try: title=['help','port scanner','ip locator'][int(i)]
    except: main()
    print title+'\n'+'-'*len(title)
    if int(i)==0:
        for (k,v) in services.iteritems():
            print k
            for x in v: print '    '+x
    elif int(i)==1: portscanner.scanner()
    elif int(i)==2: geoip.getgeo()
    raw_input()
    main()

main()

geoip.py:
Code:
from requests import get

def getgeo():
    ip=raw_input('Enter ip or hostname to locate: ')
    if ip=='': ip=get('https://api.ipify.org').content
    for (k,v) in eval(get('https://freegeoip.net/json/'+ip).content).iteritems():
        print '{:<13}: {}'.format(k.replace('_',' ').title(),v)

portscanner.py:
Code:
from datetime import datetime
from threading import Thread
from requests import get
import socket

def scanner():
    serv=socket.gethostbyname(raw_input('Enter host to scan: '))
    if serv=='': serv='0.0.0.0'
    r=map(int,raw_input('Enter port range: ').split(' '))
    r=range(r[0],r[-1]+1)
    grps=[r[i:i+3] for i in range(0,r[-1],3)]
    def scan(serv,g):
        try:
            for port in g:
                sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
                s=sock.connect_ex((serv,port))
                if s==0: print "Port ["+str(port)+"]: "+"Open"
                sock.close()
        except socket.gaierror:
            print 'Hostname could not be resolved. Exiting'
            exit()
        except socket.error:
            print "Couldn't connect to server"
            exit()
        except KeyboardInterrupt:
            exit()
    time=datetime.now()
    for g in grps:
        if g!=[]:
            t=Thread(target=scan,args=(serv,g))
            t.start()
            t.join()
    print "finished scanning",serv,"in",str(datetime.now()-time)[:-4]

[+] 1 user Likes Inori's post
Reply




Messages In This Thread
Maya Networking Tool - by Inori - 12-31-2015, 07:48 AM
RE: Maya Networking Tool - by zorrophreak - 12-31-2015, 08:39 AM
RE: Maya Networking Tool - by Inori - 12-31-2015, 09:03 PM
RE: Maya Networking Tool - by Nil - 01-01-2016, 02:43 AM



Users browsing this thread: 1 Guest(s)