Monday, 8 June 2020

51 . Bruteforce attack

#On Monday you created a password : this is the code:

print ('Hello, Its Monday')
print ('create a number-password')
NEWPASS = int(input())
print ('Thank you, bye')
print('')

#On Tuesday hackers entered the system.
#THE AUTOMATIC BRUTEFORCE STARTS HERE.
#Hackers cannot see the above code (The monday password)

import time
print ('Hello, Its Tuesday')

a=0
while NEWPASS != a:
  print ('To enter the system please introduce your password')
  a=a+1
  print (a)
   
print ('Welcome to MI6')

50 One-word encryption (permutation code) hacked (+ grammar attack)

#One-word encryption (permutation code) hacked (+ grammar attack)
#Think of the name of a common animal.
#Encrypt it: change its letters of order cat---> act


# HACKED
while True:
    print ('')
    print ('Paste the encrypted text here:')
    ET = str(input())

    import itertools

    l = itertools.permutations(str(ET))
    output= ([str(''.join(x)) for x in l])
    print (output)

    #for elem in ET:
     #   print ((elem, end = '') )                #  , end = ''
     
    #elem = elem.lower()

###########################################################
#DICC is the dictionary of
    while True: 
        DICC = ["cat", "bat", "rat", "elephant", "dog"]

        for x in DICC:
            if x in output:
                print (x)
            else:
                print ('...')
        break

     
 


 

 


49 #Caesar code Encrypt / Decrypt with password

#Caesar code Encrypt / Decrypt with password

#List of characters:
#import string
#print (string.printable)

L1 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@[\]^_`{|}~' *999999 #This multiplies the extension of L1
           #L1 must contain all possible keyboard symbols
           #Randomeness in L1 increases layer of unpredictivity

while True:
    print ('')
    print ('')
    print ('Encript=E /Decrypt=D')
    EorD = input()
    EorD = EorD.lower()
    if EorD == 'e':
       
        #Message
        print('')
        print ('Introduce text to encrypt.')
        MESS = input()
       
        #Password (number of translations)
        print ('6-digit Numerical Password')
        PASS = int(input())
       
        #Item by item translation
        for LETTER in MESS:
            NEWPOS = L1.find(LETTER)+ PASS
            if NEWPOS == 0 :
                print ('fuc')
                break
            elif NEWPOS >= len(L1):
                print ('try again with a smaller password')
            print (L1[NEWPOS], end = '')
           
    elif EorD == 'd':
        #Message
        print('')
        print ('Paste text to decrypt.')
        MESS = input()
       
        #Password (number of translations)
        print ('6-digit Numerical Password')
        PASS = int(input())
       
        #Item by item translation
        for LETTER in MESS:
            NEWPOS = L1.find(LETTER)- PASS
            if NEWPOS < 0:
                print ( end = '')
           
            print (L1[NEWPOS], end = '')

     
       
 

48 Decryption: Caesar

#Caesar code DECRYPT -1

#L1 = ['a','e'] # + swap 'find' for 'index'
L1 = 'aeiou'
print (' introdu')
MESS = input ()

for LETTER in MESS:
    NEWPOS = L1.find(LETTER)-1 # Decrypt +1 ---> -1
    if NEWPOS == -2 :
        print ('\nthe letter ' + LETTER+ ' is not included')
        break
    elif NEWPOS <0:  # >= len (L1) -----> < 0
        NEWPOS = len(L1) -1 # 0 ----> len(L1) -1       
    print (L1[NEWPOS], end = '')

47 Encryption: Caesar

#Caesar code

#L1 = ['a','e'] # + swap 'find' for 'index'
L1 = 'aeiou'
print (' introdu')
MESS = input ()

for LETTER in MESS:
    NEWPOS = L1.find(LETTER)+1 #find the position in L1, +1
    if NEWPOS == 0 :
        print ('\nthe letter ' + LETTER+ ' is not included so i stop')
        break #quit() if you want to kill it
    elif NEWPOS >= len(L1):
        NEWPOS = 0    #solving last item +1 error
    #print (L1.find(LETTER))  #Finds the position of the item in a list
    print (L1[NEWPOS], end = '') #cancels the default print-newline

Tuesday, 2 June 2020

39. Upeercase / Lowercase

print ('Do you believe in God?')
a = input ( ) 
a = a.lower() #All goes lowercase. Try capitals and see

if a == ('yes'):
    print ('You are a believer')
elif a == ('no'):
    print ('You are either an agnostic or an atheist')
else:
    print ('No wanna talk with me? Bye!')

38. itertools.permutations(str(myInt))

import itertools
myInt = 123
l = itertools.permutations(str(myInt))
for x in l:
  print (x)