diff --git a/T2/Parte2/.gitignore b/T2/Parte2/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..723ef36f4e4f32c4560383aa5987c575a30c6535 --- /dev/null +++ b/T2/Parte2/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/T2/Parte2/Programas/NETSTAT.EXE b/T2/Parte2/Programas/NETSTAT.EXE new file mode 100644 index 0000000000000000000000000000000000000000..755790a6606606e0510e036dc1838a212db98c6e Binary files /dev/null and b/T2/Parte2/Programas/NETSTAT.EXE differ diff --git a/T2/Parte2/Programas/PING.EXE b/T2/Parte2/Programas/PING.EXE new file mode 100644 index 0000000000000000000000000000000000000000..3c369bd5a4a7a2e351f2839575289d3866bed151 Binary files /dev/null and b/T2/Parte2/Programas/PING.EXE differ diff --git a/T2/Parte2/Programas/calc.exe b/T2/Parte2/Programas/calc.exe new file mode 100644 index 0000000000000000000000000000000000000000..2c6fdf1b5b8c57e676cff18d16f9d8be0bf6d38c Binary files /dev/null and b/T2/Parte2/Programas/calc.exe differ diff --git a/T2/Parte2/Programas/cmd.exe b/T2/Parte2/Programas/cmd.exe new file mode 100644 index 0000000000000000000000000000000000000000..5f39586567aa29c0cbcd5270513082f74a7654db Binary files /dev/null and b/T2/Parte2/Programas/cmd.exe differ diff --git a/T2/Parte2/Programas/ssh.exe b/T2/Parte2/Programas/ssh.exe new file mode 100644 index 0000000000000000000000000000000000000000..19ead86b11ec847dc0bea80f92c058c1e9e6ea73 Binary files /dev/null and b/T2/Parte2/Programas/ssh.exe differ diff --git a/T2/Parte2/printSections.py b/T2/Parte2/printSections.py new file mode 100644 index 0000000000000000000000000000000000000000..25516eb88722053a6d64c397c2b1a72d7c6c6f1c --- /dev/null +++ b/T2/Parte2/printSections.py @@ -0,0 +1,37 @@ +import pefile +import sys +import os + +files = [] + + +# Trata o input do usuário +def handle_input(): + try: + if os.path.isdir(sys.argv[1]): + for file in os.listdir(sys.argv[1]): + files.append(os.path.join(sys.argv[1], file)) + elif os.path.isfile(sys.argv[1]): + files.append(sys.argv[1]) + except IndexError: + print("ERROR") + except FileNotFoundError: + print("ERROR") + + +# Encontra as seções executáveis e imprime na saida padrão +def print_executable_sections(): + objeto = {} + for file in files: + pe = pefile.PE(file) + executable = [] + for section in pe.sections: + if section.IMAGE_SCN_MEM_EXECUTE: + executable.append(section.Name.decode('utf-8').rstrip('\x00')) + objeto[os.path.basename(file)] = executable + print(objeto) + + +if __name__ == '__main__': + handle_input() + print_executable_sections()