随机字符组合.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import os
  2. import subprocess
  3. # import time
  4. # start = time.clock()
  5. numb = ['0','1','2','3','4','5','6','7','8','9',
  6. 'a','b','c','d','e','f','g','h',
  7. 'i','j','k','l','m','n','o','p',
  8. 'q','r','s','t','u','v','w','x','y','z']
  9. shuzi = ['0','1','2','3','4','5','6','7','8','9']
  10. # passwd = []
  11. f = open('./password.txt','w')
  12. for fi in numb:
  13. #passwd.append(fi)
  14. for s in numb:
  15. #passwd.append(fi+s)
  16. for t in numb:
  17. #passwd.append(fi+s+t)
  18. for four in shuzi:
  19. f.write(fi+s+t+four+ '\n')
  20. # passwd.append(fi+s+t+four)
  21. # f = open('./password.txt','w')
  22. # # passwd1 = passwd[0:200000]
  23. # for i in passwd:
  24. # f.write(i + '\n')
  25. f.close()
  26. f = open('./password.txt','w')
  27. passwd = f.readlines
  28. nu = 0
  29. for s in passwd:
  30. while nu<100:
  31. nu += 1
  32. print(s)
  33. #x = subprocess.getstatusoutput('/root/dd' + ' ' + s)
  34. #if "WRONG PASSWORD!" in x[1]:
  35. # print(x[0])
  36. #if 'CORRECT PASSWORD' in x:
  37. # print(x)
  38. """
  39. outputss = os.popen(['/root/dd' + ' ' + s "&& grep WRONG PASSWORD"])
  40. x = outputss.read()
  41. if x == "WRONG PASSWORD!":
  42. pass
  43. x.close()
  44. """
  45. #os.system('/root/dd' + ' ' + s)
  46. #subprocess.Popen('/root/dd' + ' ' + s, shell=True, cwd="/home")
  47. #print(passwd)
  48. # for four in numb:
  49. # print(first+second+thrid+four)
  50. # elapsed = (time.clock() - start)
  51. # print("Time used:",elapsed)
  52. import os
  53. import time
  54. import subprocess
  55. # import _thread
  56. import threading
  57. def runa(one,two):
  58. f = open('./passwd.txt','r')
  59. for s in f.readlines()[one:two]:
  60. x = subprocess.getstatusoutput('/root/cstor_server/challenge/q2/server -g 8 -u 87 -p' + ' ' + s)
  61. if "WRONG PASSWORD!" in x:
  62. pass
  63. elif "Get User ID!" in x:
  64. pass
  65. else:
  66. print(x,s)
  67. f.close()
  68. if __name__ == '__main__':
  69. threading.Thread(target=runa,args=(1,10000)).start()
  70. threading.Thread(target=runa,args=(10000,20000)).start()
  71. threading.Thread(target=runa,args=(20000,30000)).start()
  72. threading.Thread(target=runa,args=(30000,40000)).start()
  73. threading.Thread(target=runa,args=(40000,50000)).start()
  74. import os
  75. import threading
  76. numb = ['0','1','2','3','4','5','6','7','8','9',
  77. 'a','b','c','d','e','f','g','h',
  78. 'i','j','k','l','m','n','o','p',
  79. 'q','r','s','t','u','v','w','x','y','z']
  80. shuzi = ['0','1','2','3','4','5','6','7','8','9']
  81. # passwd = []
  82. #for fi in numb:
  83. #passwd.append(fi)
  84. # for s in numb:
  85. #passwd.append(fi+s)
  86. # for t in numb:
  87. #passwd.append(fi+s+t)
  88. # for four in shuzi:
  89. # if os.popen('./server -u 1 -g 1 -p '+fi+s+t+four).readline()!='WRONG PASSWORD!\n':
  90. # print(fi+s+t+four)
  91. def calc_pass(first='0',laster=0):
  92. print('thread start :'+first)
  93. for s in numb:
  94. #passwd.append(fi+s)
  95. for t in numb:
  96. #passwd.append(fi+s+t)
  97. for four in shuzi:
  98. if os.popen('./server -u 11 -g 10 -p '+first+s+t+four).readline()!='WRONG PASSWORD!\n':
  99. print(first+s+t+four)
  100. break
  101. if __name__ == '__main__':
  102. map(lambda first:threading.Thread(target=calc_pass, args=(first,"0")).start(),numb)