<s> try : <EOL> import sys <EOL> import time <EOL> import subprocess <EOL> from lib . core . core import Core <EOL> from lib . passive . passive import Passive <EOL> except ImportError , err : <EOL> from lib . core . core import Core <EOL> Core . print_error ( err ) <EOL> class PassiveScan ( Passive ) : <EOL> def __init__ ( self , args ) : <EOL> self . __args = args <EOL> Passive . __init__ ( self , self . __args ) <EOL> self . __proc_ip_forward = "<STR_LIT>" <EOL> self . __cmd = "<STR_LIT>" . format ( Core . _commands_path [ "<STR_LIT>" ] , self . __args . interface , self . _output_file ) <EOL> def __show_progress ( self ) : <EOL> counter = <NUM_LIT:0> <EOL> time_wait = <NUM_LIT:2> <EOL> progress = <NUM_LIT:100> / ( self . __args . passive_timeout / time_wait ) <EOL> start_time = time . time ( ) <EOL> while ( ( time . time ( ) - start_time ) < self . __args . passive_timeout ) : <EOL> sys . stdout . write ( '<STR_LIT:\r>' ) <EOL> if ( progress < ( <NUM_LIT:100> - ( progress * counter ) ) ) : <EOL> sys . stdout . write ( "<STR_LIT>" % ( '<STR_LIT:=>' * ( counter * progress ) , progress * counter ) ) <EOL> else : <EOL> sys . stdout . write ( "<STR_LIT>" % ( '<STR_LIT:=>' * ( counter * progress ) , <NUM_LIT:100> ) ) <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> sys . stdout . flush ( ) <EOL> counter = counter + <NUM_LIT:1> <EOL> time . sleep ( time_wait ) <EOL> def __run_tcpdump ( self ) : <EOL> tcpdump_proc = subprocess . Popen ( [ self . __cmd ] , shell = True , stdout = subprocess . PIPE , stderr = subprocess . PIPE , ) <EOL> self . __show_progress ( ) <EOL> tcpdump_proc . kill ( ) <EOL> def __enable_forwarding ( self ) : <EOL> with open ( self . __proc_ip_forward , '<STR_LIT:w>' ) as ip_forward : <EOL> ip_forward . write ( '<STR_LIT>' ) <EOL> def _run ( self , logger ) : <EOL> arpspoof_proc = None <EOL> if self . __args . mim : <EOL> logger . _logging ( "<STR_LIT>" ) <EOL> self . __enable_forwarding ( ) <EOL> if self . _default_gw : <EOL> logger . _logging ( "<STR_LIT>" . format ( self . _default_gw ) ) <EOL> logger . _logging ( "<STR_LIT>" ) <EOL> arpspoof_proc = subprocess . Popen ( [ Core . _commands_path [ "<STR_LIT>" ] , "<STR_LIT>" , self . __args . interface , self . _default_gw ] , shell = False , stdout = subprocess . PIPE , ) <EOL> logger . _logging ( "<STR_LIT>" ) <EOL> self . __run_tcpdump ( ) <EOL> logger . _logging ( "<STR_LIT>" ) <EOL> if arpspoof_proc : <EOL> logger . _logging ( "<STR_LIT>" ) <EOL> arpspoof_proc . kill ( ) <EOL> logger . _logging ( "<STR_LIT>" . format ( self . _output_dir ) ) </s>
