def check_anonymous_login(hostname): try: ftp = FTP(hostname) ftp.login() Debug.CRITICAL("[+]Anonymous => [ok]") Debug.CRITICAL("[+]Username => [anonymous]") Debug.CRITICAL("[+]Pass => [anonymous]") ftp.quit() except: Debug.AVISO("[+]Anonymous off") pass
def escrever_encode16(arquivo, escrever): """ :info escrever no arquivo com base16 :param arquivo,escrever: :parameter arquivo => nome+caminho do arquivo :parameter escrever => escrever :return: arquivo + texto """ with open(arquivo, "w") as ll: encode = b16encode(bytes(escrever, 'utf-8')) decode = str(encode)[2:-1] ll.write(decode) Debug.CRITICAL("arquivo: " + arquivo) Debug.CRITICAL("escrita " + decode)
def connect_UDP(host, port, timeout): try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.settimeout(timeout) s.connect((host, port)) hp = str(host) + ":" + str(port) Debug.CRITICAL(f"conectado UDP => [{hp}]") except socket.error: hp = str(host) + ":" + str(port) Debug.AVISO(f"falha ao conectar => [{hp}]")
def escrever(arquivo, escrever): """ :info escrever no arquivo :param arquivo,escrever: :parameter arquivo => nome+caminho do arquivo :parameter escrever => escrever :return: arquivo + texto """ try: try: with open(arquivo, "w") as ll: ll.write(escrever) Debug.CRITICAL("arquivo: " + arquivo) Debug.CRITICAL("escreveu: " + escrever) except TypeError: print(TypeError) except THG_OSError: print("erro " + str(OSError))
def report(CTF_NOME, CTF_team, CTF_USER, CTF_challenges, CTF_challenges_PASTA, file_name, evento_nome, flag_pontos): Debug.CRITICAL("[+]criando relatorio") Debug.AVISO(f"CTF_NOME: {CTF_NOME} ") Debug.AVISO(f"CTF_TIME: {CTF_team} ") Debug.AVISO(f"CTF_USER: {CTF_USER} ") Debug.AVISO(f"CTF_TIPO: {CTF_challenges} ") Debug.AVISO(f"CTF_PASTA: {CTF_challenges_PASTA} ") Debug.AVISO(f"EVENTO_NOME: {evento_nome} ") Debug.AVISO(f"FLAG_PONTOS {flag_pontos} ") try: # Ele vai tentar criar a pasta brainiac_ctf_report, pasta CTF_challenges_PASTA e o nome do arquivo os.mkdir("../brainiac_ctf_report") # Cria pasta brainiac_ctf_report Debug.CRITICAL("[+] criando pasta => [brainiac_ctf_report]") os.mkdir(CTF_challenges_PASTA) # Cria pasta CTF_challenges_PASTA os.chdir(CTF_challenges_PASTA) # Entra na pasta CTF_challenges_PASTA Debug.CRITICAL(f"[+] CTF_challenges => [{CTF_challenges_PASTA}]") Debug.CRITICAL(f"[+] file_challenges => [{file_name}]") except FileExistsError: # Se a pasta brainiac_ctf_report existir ele entra na pasta os.chdir("../brainiac_ctf_report") # Entra na pasta brainiac_ctf_report try: # Tenta criar a pasta CTF_challenges_PASTA os.mkdir(CTF_challenges_PASTA) # Cria CTF_challenges_PASTA os.chdir(CTF_challenges_PASTA) # Entra CTF_challenges_PASTA Debug.CRITICAL(f"[+] CTF_challenges => [{CTF_challenges_PASTA}]") Debug.CRITICAL(f"[+] file_challenges => [{file_name}]") except FileExistsError: # Se a pasta CTF_challenges_PASTA existir os.chdir(CTF_challenges_PASTA) # Entra na pasta CTF_challenges_PASTA Debug.CRITICAL(f"[+] CTF_challenges => [{CTF_challenges_PASTA}]") Debug.CRITICAL(f"[+] file_challenges => [{file_name}]") with open(file_name, "w") as fl: ###Escreve logs no file_name fl.write("#" * 35) fl.write("\n" + "#" * 10 + "report" + "#" * 10) fl.write("\n" + "#" * 5 + "brainiac_report_info_ctf" + "#" * 6) fl.write("\n" + "#" * 35) fl.write("\n" + f"CTF_EVENTO: {evento_nome} ") fl.write("\n" + f"CTF_DATE: {today}") fl.write("\n" + f"CTF_PONTOS: {flag_pontos} ") fl.write("\n" + f"CTF_NOME: {CTF_NOME} ") fl.write("\n" + f"CTF_TIME: {CTF_team} ") fl.write("\n" + f"CTF_USER: {CTF_USER} ") fl.write("\n" + f"CTF_TIPO: {CTF_challenges} ") fl.write("\n" + f"CTF_PASTA: {CTF_challenges_PASTA} ") fl.close() os.system("nano " + file_name)