I wanted to integrate my question with this 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 envisioned would be: "MySQL Open Port 3306" "Open 80 Apache Port"