#NEWLINE# def on_response( self , context , response ) : #NEWLINE# #INDENT# response . send_response ( 200 ) #NEWLINE# response . end_headers ( ) #NEWLINE# length = int ( response . headers . getheader ( 'content-length' ) ) #NEWLINE# data = response . rfile . read ( length ) #NEWLINE# response . stop_tracking_host ( ) #NEWLINE# if ( len ( data ) > 0 ) : #NEWLINE# #INDENT# def print_post_data( data ) : #NEWLINE# #INDENT# buf = StringIO ( data . strip ( ) ) . readlines ( ) #NEWLINE# for line in buf : #NEWLINE# #INDENT# context . log . highlight ( line . strip ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# context . log . success ( 'Enumerated available tokens' ) #NEWLINE# if self . user : #NEWLINE# #INDENT# if ( data . find ( self . user ) != ( - 1 ) ) : #NEWLINE# #INDENT# context . log . success ( 'Found token for user {}!' . format ( self . user ) ) #NEWLINE# print_post_data ( data ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if self . userfile : #NEWLINE# #INDENT# with open ( self . userfile , 'r' ) as userfile : #NEWLINE# #INDENT# for user in userfile : #NEWLINE# #INDENT# user = user . strip ( ) #NEWLINE# if ( data . find ( user ) != ( - 1 ) ) : #NEWLINE# #INDENT# context . log . success ( 'Found token for user {}!' . format ( self ) ) #NEWLINE# print_post_data ( data ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# print_post_data ( data ) #NEWLINE# #UNINDENT# #UNINDENT# log_name = 'Tokens-{}-{}.log' . format ( response . client_address [ 0 ] , datetime . now ( ) . strftime ( '%Y-%m-%d_%H%M%S' ) ) #NEWLINE# with open ( ( 'logs/' + log_name ) , 'w' ) as tokens_output : #NEWLINE# #INDENT# tokens_output . write ( data ) #NEWLINE# #UNINDENT# context . log . info ( 'Saved output to {}' . format ( log_name ) )