Matasano CryptoPals Problem 8: Detecting ECB encryption
Assuming your algorithm is correct:


Follow the pep8 style guide.
You should use range(0, len(data), block_size) so you don't have to do all the multiplication over and over.
You can use itertools.combinations to reduce it to only one loop.
You don't close the file.  You should use with to open and close the file.
You can use zip (or for python2 itertools.izip) to get both the first and second index at the same time.
You can simplify the whole thing using any and a generator expressions.
You can use str.join to simplify the printing.


Since iterators and generator expressions are lazy evaluated, it won't create any intermediate arrays.  This makes it very fast but also very readable.

from binascii import a2b_hex
from itertools import combinations, izip

def is_ecb_encoded(data, block_size):
   myrange = range(0, len(data), block_size)
   inds = combinations(zip(myrange, myrange[1:])), 2)
   return any(data[i1:i2] == data[j1:j2] for (i1, i2), (j1, j2) in inds)

filename = '8.txt'
with open(filename) as fobj:
   lines = (line.rstrip() for line in fobj)
   lines = (a2b_hex(line) for line in lines)
   lines = (line for line in lines if is_ecb_encoded(line, 16))
   print '\n'.join(lines)