SHARE
TWEET

Untitled

mage_1868 Jul 19th, 2014 (edited) 157 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # coding:utf8
  2.  
  3. import os
  4. import sys
  5. import pexpect
  6.  
  7. def new_solve(ans):
  8.     c = pexpect.spawn("./amida")
  9.  
  10.     if len(ans) == 0:
  11.         return c
  12.  
  13.     for a in ans:
  14.         c.expect('\?')
  15.         c.send(a+"\n")
  16.  
  17.     return c
  18.  
  19. if __name__ == '__main__':
  20.     ans = []
  21.  
  22.     for count in range(1000):
  23.         c = new_solve(ans)
  24.  
  25.         for i in range(1, 9):
  26.             c.expect('\?')
  27.  
  28.             test = str(i)
  29.             c.send(test + "\n")
  30.             c.expect('\?|Wrong|FLAG\{.*?\}')
  31.             response = c.after
  32.  
  33.             if response != 'Wrong':
  34.                 ans.append(test)
  35.                 print "collect " + test + ' ' + str(count)
  36.                 print response
  37.                 break
  38.             else:
  39.                 print "wrong " + test + ' ' + str(count)
  40.                 c = new_solve(ans)
RAW Paste Data
Top