def test_ascii_to_hex_template( self, n = 1000 ) : pkt = urandom( n ) pkt = pkt.replace(pkt[-1], '~') pkt = pkt.replace(pkt[-2], '~') pkt = pkt.replace(pkt[-3], '~') templ = asciiToHexTemplate( pkt ) config = ''' X:_data_: data1="""%s""" ''' % templ psi = StegoInjector( config ) cap = psi.getCapacity( 'data1' ) inj = psi.inject(cap*'~', 'data1' ) print( "Changed %d bytes" % cap ) self.assertTrue( inj == pkt )
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p> </body> <!-- Reference Code: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> </html> ''' resp_templ = asciiToHexTemplate(resp_ascii) req_ascii = '''GET /search.php?q=~~~~~~~~?userid=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HTTP/1.1 Host: {0} Cookie: SESSIOID=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ eTag: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' # 2 new lines terminate the HTTP Request req_templ = asciiToHexTemplate(req_ascii) # Create the StegoOrchestrator configuration string stego_config = ''' X:_data_:\n\n resp = """%s""" req = """%s"""