Advertisement
phieulang1993

crypt6

Sep 7th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from selenium import webdriver
  4.  
  5. profile=webdriver.FirefoxProfile()
  6. driver=webdriver.Firefox(profile)
  7.  
  8. charsets = "abcdef0123456789}"
  9. cipher = "62 a9 6c 28 0e 33 31 c6 68 cd 66 66 59 46 cc 53 0c 98 31 65 c6 35 c9 a9 60 4e 37 b0 33 46 0d 60 46 26 66 33 cc e6 a9 f6 6c 07 2b 23 af"
  10. flag = list("MMA{0123456789abcdef0123456789abcdef01234567}")
  11. driver.get('http://bow.chal.mmactf.link/~scs/crypt6.cgi')
  12. pos = [[] for i in xrange(0,44)]
  13. pos[0]=[3, 4, 69, 70]
  14. pos[1]=[9, 10, 69, 70]
  15. pos[2]=[9, 10, 117, 118]
  16. pos[3]=[15, 16, 117, 118]
  17. pos[4]=[15, 16, 75, 76]
  18. pos[5]=[21, 22, 75, 76]
  19. pos[6]=[21, 22, 105, 106]
  20. pos[7]=[27, 28, 105, 106]
  21. pos[8]=[27, 28, 81, 82]
  22. pos[9]=[33, 34, 81, 82]
  23. pos[10]=[33, 34, 129, 130]
  24. pos[11]=[39, 40, 129, 130]
  25. pos[12]=[39, 40, 87, 88]
  26. pos[13]=[45, 46, 87, 88]
  27. pos[14]=[45, 46, 111, 112]
  28. pos[15]=[51, 52, 111, 112]
  29. pos[16]=[51, 52, 93, 94]
  30. pos[17]=[57, 58, 93, 94]
  31. pos[18]=[57, 58, 123, 124]
  32. pos[19]=[63, 64, 123, 124]
  33. pos[20]=[63, 64, 99, 100]
  34. pos[21]=[0, 1, 99, 100]
  35. pos[22]=[0, 1, 6, 7]
  36. pos[23]=[6, 7, 12, 13]
  37. pos[24]=[12, 13, 18, 19]
  38. pos[25]=[18, 19, 24, 25]
  39. pos[26]=[24, 25, 30, 31]
  40. pos[27]=[30, 31, 36, 37]
  41. pos[28]=[36, 37, 42, 43]
  42. pos[29]=[42, 43, 48, 49]
  43. pos[30]=[48, 49, 54, 55]
  44. pos[31]=[54, 55, 60, 61]
  45. pos[32]=[60, 61, 66, 67]
  46. pos[33]=[66, 67, 72, 73]
  47. pos[34]=[72, 73, 78, 79]
  48. pos[35]=[78, 79, 84, 85]
  49. pos[36]=[84, 85, 90, 91]
  50. pos[37]=[90, 91, 96, 97]
  51. pos[38]=[96, 97, 102, 103]
  52. pos[39]=[102, 103, 108, 109]
  53. pos[40]=[108, 109, 114, 115]
  54. pos[41]=[114, 115, 120, 121]
  55. pos[42]=[120, 121, 126, 127]
  56. pos[43]=[126, 127, 132, 133]
  57. def getPos(p1,p2):
  58.     p = []
  59.     for i in p1:
  60.         if i in p2:
  61.             p.append(i)
  62.     return p
  63. def check(c1,c2,p):
  64.     for i in p:
  65.         if c1[i]!=c2[i]:
  66.             return False
  67.     return True
  68. for i in xrange(4,len(flag)-1):
  69.     p = getPos(pos[i],pos[i-1])
  70.     for c in charsets:
  71.         flag[i] = c
  72.         name = driver.find_element_by_name('s')
  73.         name.clear()
  74.         name.send_keys(flag)
  75.         name.submit()
  76.         html_source = driver.page_source
  77.         n = html_source.index("<form enctype=",353)
  78.         if check(html_source[350:n],cipher,p):
  79.             print "".join(flag)
  80.             break
  81. print "".join(flag)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement