Last active
November 19, 2018 14:55
-
-
Save YasserGersy/ed8b4c31bbaac115dafe623725e624d9 to your computer and use it in GitHub Desktop.
HackthisSite realistic 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def most_common(lst): | |
return max(set(lst), key=lst.count) | |
def stripme(d): | |
z='' | |
for c in d: | |
if c in '0123456789': | |
z=z+c | |
return z | |
def IsInt(s): | |
try: | |
int(s) | |
return True | |
except ValueError: | |
return False | |
data=open('v.txt','r').read().strip() | |
dots=data.split('.') | |
nums=[] | |
obj=[] | |
for d in dots: | |
d=stripme(d) | |
if len(d)<1: | |
continue | |
if IsInt(d.strip()): | |
n=int(d) | |
if len(obj)>2: | |
nums.append(obj[0]+obj[1]+obj[2]) | |
obj=[] | |
obj.append(n) | |
master=most_common(nums) | |
key=master-32 | |
msg='' | |
print '-----------------------' | |
print 'we suppose the most duplicate charater in our writings is the space char' | |
print 'The most duplicate element in this message has ascciii code = '+str(master) | |
print 'We can guess that the key used to encrypt the message is equal to ELEMENT-32 = '+str(master-32) | |
print 'Let`s decrypt using '+str(master-32) | |
print '-----------------------' | |
for zv in nums: | |
g=int(zv-key) | |
c=chr(g) | |
msg=msg+str(c) | |
print '----------------------- Message------------------' | |
print msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment