<s> '''<STR_LIT>''' <EOL> import cgi <EOL> import codecs <EOL> from tornado . template import Template , Loader <EOL> from framework . dependency_management . dependency_resolver import BaseComponent <EOL> from framework . dependency_management . interfaces import ReporterInterface <EOL> from framework . lib . general import * <EOL> from framework . interface . html . filter import sanitiser <EOL> class Reporter ( BaseComponent , ReporterInterface ) : <EOL> COMPONENT_NAME = "<STR_LIT>" <EOL> def __init__ ( self ) : <EOL> self . register_in_service_locator ( ) <EOL> self . config = self . get_component ( "<STR_LIT>" ) <EOL> self . resource = self . get_component ( "<STR_LIT>" ) <EOL> self . transaction = self . get_component ( "<STR_LIT>" ) <EOL> self . plugin_handler = self . get_component ( "<STR_LIT>" ) <EOL> self . requester = None <EOL> self . Init = False <EOL> self . Sanitiser = sanitiser . HTMLSanitiser ( ) <EOL> self . Loader = Loader ( self . config . FrameworkConfigGet ( '<STR_LIT>' ) ) <EOL> self . mNumLinesToShow = <NUM_LIT:15> <EOL> self . CounterList = [ ] <EOL> def init ( self ) : <EOL> self . requester = self . get_component ( "<STR_LIT>" ) <EOL> def TransactionTableFromIDs ( self , TransactionIDs , NumLinesReq = <NUM_LIT:15> , NumLinesRes = <NUM_LIT:15> ) : <EOL> """<STR_LIT>""" <EOL> transactions = self . transaction . GetByIDs ( TransactionIDs ) <EOL> return self . TransactionTableForTransactions ( transactions ) <EOL> def TransactionTableForURL ( self , UseCache , URL , Method = None , Data = None ) : <EOL> transaction = self . requester . GetTransaction ( <EOL> UseCache , URL , method = Method , data = Data ) <EOL> return self . TransactionTableForTransactions ( [ transaction ] ) <EOL> def TransactionTableForURLList ( <EOL> self , <EOL> UseCache , <EOL> URLList , <EOL> Method = None , <EOL> Data = None ) : <EOL> transactions = self . requester . GetTransactions ( <EOL> UseCache , <EOL> URLList , <EOL> method = Method , <EOL> data = Data ) <EOL> return self . TransactionTableForTransactions ( transactions ) <EOL> def TransactionTableForTransactions ( self , Transactions ) : <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( TransactionList = Transactions ) <EOL> def unicode ( self , * args ) : <EOL> try : <EOL> return unicode ( * args ) <EOL> except TypeError : <EOL> return args [ <NUM_LIT:0> ] <EOL> def sanitize_html ( self , RawHTML ) : <EOL> return self . Sanitiser . CleanThirdPartyHTML ( RawHTML ) <EOL> def reset_loader ( self ) : <EOL> return self . Loader . reset ( ) <EOL> def CommandTable ( self , Command ) : <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( Command = Command ) <EOL> def LinkList ( self , LinkListName , Links ) : <EOL> """<STR_LIT>""" <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> LinkListName = LinkListName , <EOL> Links = Links ) <EOL> def ResourceLinkList ( self , ResourceListName , ResourceList ) : <EOL> """<STR_LIT>""" <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> ResourceListName = ResourceListName , <EOL> ResourceList = ResourceList ) <EOL> def TabbedResourceLinkList ( self , ResourcesList ) : <EOL> """<STR_LIT>""" <EOL> TabData = [ ] <EOL> Resources = [ ] <EOL> for ResourceListName , ResourceList in ResourcesList : <EOL> TabID = ResourceListName . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' ) <EOL> TabData . append ( [ ResourceListName , TabID ] ) <EOL> Resources . append ( [ TabID , ResourceList ] ) <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> TabData = TabData , <EOL> Resources = Resources ) <EOL> def ListPostProcessing ( self , ResourceListName , LinkList , HTMLLinkList ) : <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> ResourceListName = ResourceListName , <EOL> LinkList = LinkList , <EOL> HTMLLinkList = HTMLLinkList ) <EOL> def RequestLinkList ( self , ResourceListName , LinkList ) : <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> ResourceListName = ResourceListName , <EOL> LinkList = LinkList ) <EOL> def VulnerabilitySearchBox ( self , SearchStr ) : <EOL> """<STR_LIT>""" <EOL> VulnSearchResources = self . resource . GetResources ( '<STR_LIT>' ) <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> SearchStr = SearchStr , <EOL> VulnSearchResources = VulnSearchResources ) <EOL> def SuggestedCommandBox ( <EOL> self , <EOL> PluginOutputDir , <EOL> CommandCategoryList , <EOL> Header = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> TitleList = [ ] <EOL> CommandList = [ ] <EOL> for item in CommandCategoryList : <EOL> TitleList . append ( item [ <NUM_LIT:0> ] ) <EOL> CommandList . append ( self . resource . GetResources ( item [ <NUM_LIT:1> ] ) ) <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> Header = Header , <EOL> TitleList = TitleList , <EOL> CommandList = CommandList ) <EOL> def CommandDump ( <EOL> self , <EOL> Name , <EOL> CommandIntro , <EOL> ModifiedCommand , <EOL> RelativeFilePath , <EOL> OutputIntro , <EOL> TimeStr ) : <EOL> AbsPath = self . plugin_handler . RetrieveAbsPath ( RelativeFilePath ) <EOL> OutputLines = open ( AbsPath , "<STR_LIT:r>" ) . readlines ( ) <EOL> longOutput = ( len ( OutputLines ) > self . mNumLinesToShow ) <EOL> if ( len ( OutputLines ) > self . mNumLinesToShow ) : <EOL> OutputLines = '<STR_LIT>' . join ( OutputLines [ <NUM_LIT:0> : self . mNumLinesToShow ] ) <EOL> else : <EOL> OutputLines = '<STR_LIT>' . join ( OutputLines ) <EOL> table_vars = { <EOL> "<STR_LIT:Name>" : Name , <EOL> "<STR_LIT>" : CommandIntro , <EOL> "<STR_LIT>" : ModifiedCommand , <EOL> "<STR_LIT>" : RelativeFilePath , <EOL> "<STR_LIT>" : OutputIntro , <EOL> "<STR_LIT>" : OutputLines , <EOL> "<STR_LIT>" : TimeStr , <EOL> "<STR_LIT>" : self . mNumLinesToShow , <EOL> "<STR_LIT>" : longOutput <EOL> } <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( ** table_vars ) <EOL> def URLsFromStr ( self , TimeStr , VisitURLs , URLList , NumFound ) : <EOL> html_content = self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> TimeStr = TimeStr , <EOL> VisitURLs = VisitURLs , <EOL> NumURLs = len ( URLList ) , <EOL> NumFound = NumFound ) <EOL> if URLList : <EOL> html_content += self . LinkList ( "<STR_LIT>" , URLList ) <EOL> return html_content <EOL> def Robots ( <EOL> self , <EOL> NotStr , <EOL> NumLines , <EOL> NumAllow , <EOL> NumDisallow , <EOL> NumSitemap , <EOL> SavePath , <EOL> EntriesList , <EOL> NumAddedURLs ) : <EOL> vars = { <EOL> "<STR_LIT>" : NotStr , <EOL> "<STR_LIT>" : NumLines , <EOL> "<STR_LIT>" : NumAllow , <EOL> "<STR_LIT>" : NumDisallow , <EOL> "<STR_LIT>" : NumSitemap , <EOL> "<STR_LIT>" : SavePath , <EOL> } <EOL> TestResult = self . Loader . load ( "<STR_LIT>" ) . generate ( ** vars ) <EOL> if NumDisallow > <NUM_LIT:0> or NumAllow > <NUM_LIT:0> or NumSitemap > <NUM_LIT:0> : <EOL> for Display , Links in EntriesList : <EOL> if Links : <EOL> TestResult += self . ResourceLinkList ( Display , Links ) <EOL> return TestResult <EOL> def HtmlString ( self , String ) : <EOL> return ( String ) <EOL> def ResponseBodyMatches ( self , ResponseRegexpName ) : <EOL> RegexpName , GrepOutputs , TransactionIDS , match_percent = self . transaction . SearchByRegexName ( ResponseRegexpName , stats = True ) <EOL> variables = { <EOL> "<STR_LIT:name>" : RegexpName . replace ( "<STR_LIT>" , "<STR_LIT>" ) . replace ( <EOL> '<STR_LIT:_>' , '<STR_LIT:U+0020>' ) , <EOL> "<STR_LIT>" : GrepOutputs , <EOL> "<STR_LIT>" : TransactionIDS , <EOL> "<STR_LIT>" : match_percent <EOL> } <EOL> return self . Loader . load ( "<STR_LIT>" ) . generate ( ** variables ) <EOL> def ResponseHeaderMatches ( self , HeaderRegexpName ) : <EOL> return self . ResearchHeaders ( HeaderRegexpName ) [ <NUM_LIT:0> ] <EOL> def ResearchHeaders ( self , RegexName ) : <EOL> regex_name , grep_outputs , transaction_ids , match_percent = self . transaction . SearchByRegexName ( RegexName , stats = True ) <EOL> return [ self . Loader . load ( "<STR_LIT>" ) . generate ( <EOL> match_percent = match_percent , <EOL> matches = grep_outputs , <EOL> transaction_ids = transaction_ids ) , grep_outputs ] <EOL> def FingerprintData ( self ) : <EOL> HeaderTable , matches = self . ResearchHeaders ( '<STR_LIT>' ) <EOL> for item in matches : <EOL> HeaderTable += self . VulnerabilitySearchBox ( item [ <NUM_LIT:1> ] ) <EOL> return HeaderTable <EOL> def TopTransactionsBySpeed ( self , Order ) : <EOL> transactions = self . transaction . GetTopTransactionsBySpeed ( Order ) <EOL> return self . TransactionTableForTransactions ( transactions ) <EOL> def CookieAttributeAnalysis ( self , CookieValueList , Header2TransacDict ) : <EOL> vars = { <EOL> "<STR_LIT>" : [ { <EOL> "<STR_LIT:Name>" : Cookie . split ( '<STR_LIT:=>' ) [ <NUM_LIT:0> ] , <EOL> "<STR_LIT>" : Header2TransacDict [ self . config . Get ( '<STR_LIT>' ) . lower ( ) + Cookie ] , <EOL> "<STR_LIT>" : Cookie . replace ( Cookie . split ( '<STR_LIT:=>' ) [ <NUM_LIT:0> ] + "<STR_LIT:=>" , "<STR_LIT>" ) . replace ( "<STR_LIT>" , "<STR_LIT:;>" ) . split ( "<STR_LIT:;>" ) , <EOL> } for Cookie in CookieValueList ] , <EOL> } <EOL> Table = self . Render . CreateTable ( { '<STR_LIT:class>' : '<STR_LIT>' } ) <EOL> SetCookie = self . config . Get ( '<STR_LIT>' ) . lower ( ) <EOL> PossibleCookieAttributes = self . config . Get ( <EOL> '<STR_LIT>' ) . split ( '<STR_LIT:U+002C>' ) <EOL> for Cookie in CookieValueList : <EOL> CookieName = Cookie . split ( '<STR_LIT:=>' ) [ <NUM_LIT:0> ] <EOL> CookieLink = self . Render . DrawButtonLink ( cgi . escape ( CookieName ) , Header2TransacDict [ SetCookie + Cookie ] ) <EOL> CookieAttribs = Cookie . replace ( CookieName + "<STR_LIT:=>" , "<STR_LIT>" ) . replace ( "<STR_LIT>" , "<STR_LIT:;>" ) . split ( "<STR_LIT:;>" ) <EOL> Table . CreateCustomRow ( '<STR_LIT>' + "<STR_LIT>" + CookieLink + '<STR_LIT>' ) <EOL> Table . CreateRow ( [ '<STR_LIT>' , '<STR_LIT>' ] , True ) <EOL> NotFoundStr = "<STR_LIT>" <EOL> if CookieAttribs [ <NUM_LIT:0> ] : <EOL> CookieValue = CookieAttribs [ <NUM_LIT:0> ] <EOL> else : <EOL> CookieValue = NotFoundStr <EOL> Table . CreateRow ( [ '<STR_LIT>' , CookieValue ] ) <EOL> for Attrib in PossibleCookieAttributes : <EOL> DisplayAttribute = NotFoundStr <EOL> for PresentAttrib in CookieAttribs : <EOL> if PresentAttrib . lower ( ) . startswith ( Attrib . lower ( ) ) : <EOL> DisplayAttribute = PresentAttrib <EOL> break <EOL> Table . CreateRow ( [ Attrib , DisplayAttribute ] ) <EOL> if Table . GetNumRows ( ) == <NUM_LIT:0> : <EOL> return "<STR_LIT>" <EOL> return "<STR_LIT>" + Table . Render ( ) </s>
