Skip to content

Commit

Permalink
adds all the projects from the information security course
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiocp committed Jul 5, 2021
0 parents commit 73f2af1
Show file tree
Hide file tree
Showing 19 changed files with 193 additions and 0 deletions.
29 changes: 29 additions & 0 deletions TCP/clientetcp.py
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()
20 changes: 20 additions & 0 deletions UDP/clienteudp.py
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()
19 changes: 19 additions & 0 deletions UDP/servidorudp.py
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)

1 change: 1 addition & 0 deletions comparadordehashes/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Este é o curso de Python para segurança
1 change: 1 addition & 0 deletions comparadordehashes/b.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Este é o curso de Python para segurança
24 changes: 24 additions & 0 deletions comparadordehashes/ch.py
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())


10 changes: 10 additions & 0 deletions geradordesenhas/gs.py
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)))
3 changes: 3 additions & 0 deletions ping/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ping/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions ping/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ping/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions ping/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions ping/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions ping/.idea/ping.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions ping/hosts.txt
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
10 changes: 10 additions & 0 deletions ping/pingmultiplo.py
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))

9 changes: 9 additions & 0 deletions ping/pingsimples.py
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)

8 changes: 8 additions & 0 deletions threads-e-ips/ips.py
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)
18 changes: 18 additions & 0 deletions threads-e-ips/threads.py
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()

0 comments on commit 73f2af1

Please sign in to comment.