-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import socket | ||
import sys | ||
|
||
|
||
def main(): | ||
try: | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) | ||
except socket.error as e: | ||
print("A conexão falhou") | ||
print("Erro: {}".format(e)) | ||
sys.exit() | ||
|
||
print("Socket criado com sucesso") | ||
|
||
HostAlvo = input("Digite o Host ou IP a ser conectado: ") | ||
PortaAlvo = input("Digite a porta a ser conectada: ") | ||
|
||
try: | ||
s.connect((HostAlvo, int(PortaAlvo))) | ||
print("Cliente TCP conectado com sucesso Host: " + HostAlvo + " e na porta: " + PortaAlvo) | ||
s.shutdown(2) | ||
except socket.error as e: | ||
print("Não foi possível conectar no Host: " + HostAlvo + " - Porta: " + PortaAlvo) | ||
print("Erro: {}".formtat(e)) | ||
sys.exit() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import socket | ||
|
||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
|
||
print("Cliente Socket criado com sucesso!") | ||
|
||
host = 'localhost' | ||
porta = 5433 | ||
mensagem = "Olá, servidor. Firmeza?\n" | ||
|
||
try: | ||
print("Cliente: " + mensagem) | ||
s.sendto(mensagem.encode(), (host, 5432)) | ||
|
||
dados, servidor = s.recvfrom(4096) | ||
dados = dados.decode() | ||
print("Cliente: " + dados) | ||
finally: | ||
print("Cliente: Fechando a conexão") | ||
s.close() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import socket | ||
|
||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
|
||
print("Socket criado com sucesso!") | ||
|
||
host = 'localhost' | ||
port = 5432 | ||
|
||
s.bind((host, port)) | ||
mensagem = '\nServidor: Olá, cliente! Tudo certinho?' | ||
|
||
while 1: | ||
dados, end = s.recvfrom(4096) | ||
|
||
if dados: | ||
print("Servidor enviando mensagem...") | ||
s.sendto(dados + (mensagem.encode()), end) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Este é o curso de Python para segurança |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Este é o curso de Python para segurança |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import hashlib | ||
|
||
arquivo1 = 'a.txt' | ||
arquivo2 = 'b.txt' | ||
|
||
hash1 = hashlib.new('ripemd160') | ||
|
||
hash1.update(open(arquivo1, 'rb').read()) | ||
|
||
hash2 = hashlib.new('ripemd160') | ||
|
||
hash2.update(open(arquivo2, 'rb'). read()) | ||
|
||
if hash1.digest() != hash2.digest(): | ||
print(f"O arquivo: {arquivo1} é diferente do arquivo: {arquivo2}") | ||
print("O hash do arquivo a.txt é: ", hash1.hexdigest()) | ||
print("O hash do arquivo b.txt é: ", hash2.hexdigest()) | ||
|
||
else: | ||
print(f"O arquivo: {arquivo1} é igual ao arquivo: {arquivo2}") | ||
print("O hash do arquivo a.txt é: ", hash1.hexdigest()) | ||
print("O hash do arquivo b.txt é: ", hash2.hexdigest()) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import random | ||
import string | ||
|
||
tamanho = 16 | ||
|
||
chars = string.ascii_letters + string.digits + 'ç!@#$%&*()-=+,.;:/?' | ||
|
||
rnd = random.SystemRandom() | ||
|
||
print("".join(rnd.choice(chars) for i in range(tamanho))) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
www.google.com | ||
8.8.8.8 | ||
www.pudim.com.br | ||
4.4.4.4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os | ||
|
||
with open('hosts.txt') as file: | ||
dump = file.read() | ||
dump = dump.splitlines() | ||
|
||
for ip in dump: | ||
p | ||
os.system('ping -m 2 {}'.format(ip)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import os | ||
|
||
print("#" * 60) | ||
ip_ou_host = input("Digite o IP ou Host a ser verificado: ") | ||
print("-" * 60) | ||
|
||
os.system('ping -n 6 {}'.format(ip_ou_host)) | ||
print("-" * 60) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import ipaddress | ||
|
||
ip = '192.168.0.100/0' | ||
|
||
rede = ipaddress.ip_network(ip, strict=False) | ||
|
||
for ip in rede: | ||
print(ip) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from threading import Thread | ||
import time | ||
|
||
|
||
def carro(velocidade, piloto): | ||
trajeto = 0 | ||
while trajeto <= 100: | ||
trajeto += velocidade | ||
time.sleep(0.5) | ||
print('Piloto: {} Km: {} \n'.format(piloto, trajeto)) | ||
|
||
|
||
t_carro1 = Thread(target=carro, args=[50, "Kaio"]) | ||
t_carro2 = Thread(target=carro, args=[25, "Diego"]) | ||
|
||
t_carro1.start() | ||
t_carro2.start() | ||
|