<s> try : <EOL> import re <EOL> import shlex <EOL> import datetime <EOL> import subprocess <EOL> from lib . core . core import Core <EOL> from lib . screen . webscan import WebScan <EOL> from lib . core . threadpool import Worker , ThreadPool <EOL> except ImportError , err : <EOL> from lib . core . core import Core <EOL> Core . print_error ( err ) <EOL> class ScreenScan ( WebScan ) : <EOL> def __init__ ( self , args ) : <EOL> self . __urls = [ ] <EOL> self . __args = args <EOL> WebScan . __init__ ( self , self . __args ) <EOL> def _run ( self , logger ) : <EOL> cmd = "<STR_LIT>" . format ( Core . _commands_path [ "<STR_LIT>" ] , self . _nmap_options ) <EOL> logger . _logging ( "<STR_LIT>" . format ( cmd ) ) <EOL> cmd_list = shlex . split ( cmd ) <EOL> proc = subprocess . Popen ( cmd_list , stdout = subprocess . PIPE , stderr = subprocess . PIPE , ) . communicate ( ) <EOL> logger . _logging ( "<STR_LIT>" ) <EOL> self . __parse_nmap_scan ( logger ) <EOL> def __parse_nmap_scan ( self , logger ) : <EOL> self . _result_file . seek ( <NUM_LIT:0> ) <EOL> for line in self . _result_file : <EOL> for port in self . _scan_options . split ( "<STR_LIT:U+002C>" ) : <EOL> if re . search ( "<STR_LIT>" . format ( port ) , line ) : <EOL> ip = line . split ( ) [ <NUM_LIT:1> ] <EOL> if port != "<STR_LIT>" : <EOL> self . __urls . append ( "<STR_LIT>" . format ( ip , port ) ) <EOL> else : <EOL> self . __urls . append ( "<STR_LIT>" . format ( ip ) ) <EOL> self . _result_file . close ( ) <EOL> if self . __urls : <EOL> self . __take_screenshot ( logger ) <EOL> def __take_screenshot ( self , logger ) : <EOL> logger . _logging ( "<STR_LIT>" . format ( self . __args . thread ) ) <EOL> pool = ThreadPool ( self . __args . thread ) <EOL> for url in self . __urls : <EOL> output_file = "<STR_LIT>" . format ( self . _output_dir , url . split ( "<STR_LIT:/>" ) [ <NUM_LIT:2> ] , datetime . datetime . now ( ) . strftime ( "<STR_LIT>" ) ) <EOL> phantomjs_cmd = "<STR_LIT>" . format ( Core . _commands_path [ "<STR_LIT>" ] , self . __args . rasterize , url , output_file ) <EOL> logger . _logging ( "<STR_LIT>" . format ( url . split ( "<STR_LIT:/>" ) [ <NUM_LIT:2> ] ) ) <EOL> pool . add_task ( self . __run_phantomjs , phantomjs_cmd ) <EOL> pool . wait_completion ( ) <EOL> logger . _logging ( "<STR_LIT>" . format ( self . _output_dir ) ) <EOL> def __run_phantomjs ( self , cmd ) : <EOL> cmd_list = shlex . split ( cmd ) <EOL> proc = subprocess . Popen ( cmd_list , stdout = subprocess . PIPE , stderr = subprocess . PIPE , ) . communicate ( ) </s>
