How to find out which services are running on a python port?

Asked

Viewed 297 times

1

I would like to add my question to that code:

#!/usr/bin python3
# coding: utf-8

import argparse
import socket
import os
import sys

def Logo():
    print ('''
______  ____  __________
___  / / /_ \/ /__  ___/
__  /_/ / __  / _____ \ 
_  __  /  _  /  ____/ / 
/_/ /_/   /_/   /____/1.0

''')

def main():
    Sis()
    Logo()
    Argumentos()
    Conectar()

def Sis():
    if sys.platform != "linux2":
        os.system("cls")
    else:
        os.system("clear")

def Argumentos():
    global args
    print ("\n[+] Scanner de Portas \n")
    print ("[+] Digite hys.py --help para checar o manual\n")
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", dest="host", action="store", help="Use -s para definir o site.Ex: hys.py -s www.google.com")
    parser.add_argument("-p", dest="port", action="store", help="Use -p para escanear uma porta expercifica Ex: -p 80")
    parser.add_argument('-v', dest="version", action='version', version='%(prog)s 1.0 ')
    args = parser.parse_args()

def Conectar():
    if (args.host and args.port):
        print ("Host Alvo: ",args.host)
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(2)
        c = s.connect_ex((str(args.host),int(args.port)))
        if c == 0:
            print ("\nPorta\n"+args.port+"\nAberta")
        else:
                print ("\nPorta\n"+args.port+"\nFechada")
    else:
        quit()

main()

The result I imagine would be: "Mysql Open port 3306" "Door 80 Open Apache"

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.