import os
import time
import subprocess

nu = 0
nu2 = 0
start = time.clock()
f = open('./password.txt','r')
# passwd1 = passwd[0:200000]
#for i in passwd:
    #f.write(i + '\n')
while nu2<100:
    nu2 += 1
    passwd = f.readline()
    for s in passwd:
        while nu<100:
            nu += 1
            x = subprocess.getstatusoutput('/root/cstor_server/challenge/q2/server' + ' ' + s)
            if "WRONG PASSWORD!" in x[1]:
                pass
            else:
                print(x,s) 
                #print(x[0])

# f1=file('XXX.txt','r')
# for line in f1.readlines()[N:]:

    #if 'CORRECT PASSWORD' in x:
    #    print(x)

    """
    outputss = os.popen(['/root/dd' + ' ' + s "&& grep WRONG PASSWORD"])
    x = outputss.read()
    if x == "WRONG PASSWORD!":
        pass
    x.close()
    """

    #os.system('/root/dd' + ' ' + s)
    #subprocess.Popen('/root/dd' + ' ' + s, shell=True, cwd="/home")


#print(passwd)
    #         for four in numb:

    #             print(first+second+thrid+four)
f.close()   
elapsed = (time.clock() - start)
print("Time used:",elapsed)

import os
import time
import subprocess

nu = 0
nu2 = 0
start = time.clock()
f = open('./passwd.txt','r')
#f = file('passwd.txt','r')
while True:
    for s in f.readlines()[100:110]:
            # print(s)
            x = subprocess.getstatusoutput('/root/cstor_server/challenge/q2/server' + ' ' + s)
            if "WRONG PASSWORD!" in x:
                pass
            else:
                print(x,s)

f.close()
elapsed = (time.clock() - start)
print("Time used:",elapsed)
