sudo apt-get install python3
sudo apt-get install python3-pip
echo print ("hello world!") > hello.py
In [63]:
print ("hello world!")
In [7]:
port = 22
In [8]:
message = "SSH Server v2"
In [9]:
print ("Search for {} in port {}".format(message,port))
In [ ]:
message = "SSH Server v2"
type(message)
In [ ]:
port = 22
type(port)
In [ ]:
portlist = [22,21,80,5000]
type(portlist)
In [ ]:
portOpen = True
type(portOpen)
In [1]:
message= "SSH Server v2"
In [ ]:
print (message.upper())
print (message.lower())
In [ ]:
print (message.split('r'))
In [ ]:
print(message.replace('Server','Client'))
In [ ]:
print (message.find('SSH'))
In [34]:
portList = []
portList.append(22)
portList.append(80)
portList.append(5000)
portList.append(25)
print (portList)
In [ ]:
portList.sort()
print (portList)
In [ ]:
print ("{} portas ativas encontradas!".format(len(portList)))
In [52]:
services = {'ftp':21, 'ssh':22, 'smtp': 25, 'http':80, 'https':443}
In [ ]:
services.keys()
In [ ]:
services.items()
In [ ]:
services.get('ssh')
In [ ]:
services['ssh']
In [ ]:
print (" Falha encontrada no SSH na porta {}".format(services['ssh']))
In [ ]:
del services['ftp']
if EXPRESSÃO BOOLEANA:
COMANDOS_1 # executados se condição tem valor True
else:
COMANDOS_2 # executados se condição tem valor False
for VARIAVEL in LISTA: #o comando for processa cada Item em uma Lista
COMANDO
In [ ]:
Falar do range
while CONDICAO_BOOLEANA: #enquanto a CONDICAO_BOOLEANA for verdadeira,
# o COMANDO será executado
COMANDO
In [ ]:
Falar do break e do continue
def NOME( PARÂMETROS ):
COMANDOS
In [56]:
def ip_example(ip,port):
return 'IP : {} and PORT {}'.format(ip,port)
In [ ]:
print (ip_example('192.168.0.1',80))
In [ ]:
print (2/0)
try: #caso o comando nao seja executado corretamente,
COMANDO # a excecao sera tratada
except EXCECAO:
COMANDO
In [ ]:
try:
print (2/0)
except ZeroDivisionError:
print ("Divisao por zero, -100 de xp")