Exemple #1
0
 def takeUserInput():
     name = user_input.get()
     letters = string.ascii_letters
     result_str = ''.join(random.choice(letters) for i in range(16))
     print(result_str)
     Password.add_password(name, result_str)
     thePassword.set(result_str)
Exemple #2
0
    def testSetHashedPassword(self):
        clear_pw = TEST_PW.encode('utf-8')
        u1 = User()
        p1 = Password(clear_pw)
        u1.set_password(p1)

        self.assertEquals(p1, u1.pw)
    def bruteforce(self, encrypted_path, bruteforced_path=None):
        encrypted_file = open(encrypted_path, "rb")
        if bruteforced_path is None:
            bruteforced_path = encrypted_path + ".bruteforced"
        bruteforced_file = open(bruteforced_path, "wb")

        bruteforced = {}
        bruteforced_entropies = {}

        salt = encrypted_file.readline().strip()
        encrypted = encrypted_file.read()

        passwords = []
        for first in string.ascii_lowercase:
            for second in string.ascii_lowercase:
                passwords.append(first + second)
        # print 'debug: generated passwords'

        for password in passwords:
            # print 'debug: going over password \'{}\''.format(password)
            aes = AES.new(Password.new(password, salt).generate_key())
            decrypted = aes.decrypt(encrypted)
            bruteforced[password] = decrypted
            bruteforced_entropies[password] = self.__entropy(decrypted[0:30])
        # print 'debug: bruteforced file for all passwords'

        best_password = min(bruteforced_entropies, key=bruteforced_entropies.get)
        # print 'debug: found best password'
        print "log: best password is '{}'".format(best_password)
        bruteforced_file.write(bruteforced[best_password])

        for opened_file in [encrypted_file, bruteforced_file]:
            opened_file.close()
Exemple #4
0
def get_password_hashes(*inputs):
    """Returns password hashes for all inputs (calculated using the same salt)"""
    all_hashes = []

    salt = bcrypt.gensalt()

    for ip in inputs:
        p = Password(TEST_PW.encode('utf-8'))  # use complex password to not fail here

        p.salt = salt
        p.hashed_password = p.hash_password(ip.encode('utf-8'))
        hash_ = p.hashed_password

        all_hashes.append(hash_)

    return all_hashes
Exemple #5
0
 def __init__(self, master):
     self.master = master
     self.colour_bg = "Grey"
     self.colour_err = "Red"
     self.draw_widgets()
     self.random_password_size = 15
     self.dbcon = sql.SQLCon()
     self.password = p.Password()
def NewPasswordGenerator(numOfPasswords=1):

    U1 = UserInput('What\'s the minimum length?', string.ascii_letters)
    U2 = UserInput('How many special characters?', '!@#$%^&*)-')
    U3 = UserInput('How many numbers?', '0123456789')
    User_Input_List = [U1, U2, U3]

    for x in User_Input_List:
        x.poll_user_input()

    for y in range(numOfPasswords):
        password_final = Password()

        for x in User_Input_List:
            x.generate_random_string()
            password_final.generate_simple_password(x)

        print(password_final.generate_random_password())

    return
    def encrypt(self, password, plain_path, encrypted_path=None):
        plain_file = open(plain_path, "rb")
        if encrypted_path is None:
            encrypted_path = plain_path + ".encrypted"
        encrypted_file = open(encrypted_path, "wb")

        password = Password.new(password)
        aes = AES.new(password.generate_key())

        plain_data = self.__fill_plain_data(plain_file.read(), aes.block_size)
        encrypted_file.write(password.salt + "\n")
        encrypted_file.write(aes.encrypt(plain_data))

        for opened_file in [encrypted_file, plain_file]:
            opened_file.close()
    def decrypt(self, password, encrypted_path, plain_path=None):
        encrypted_file = open(encrypted_path, "rb")
        if plain_path is None:
            plain_path = encrypted_path + ".plain"
        plain_file = open(plain_path, "wb")

        salt = encrypted_file.readline().strip()
        password = Password.new(password, salt)
        aes = AES.new(password.generate_key())

        encrypted_data = encrypted_file.read()
        plain_file.write(aes.decrypt(encrypted_data))

        for opened_file in [encrypted_file, plain_file]:
            opened_file.close()
Exemple #9
0
def test_password():
    pwd = Password(context.hash("test_password"), context)

    assert pwd == "test_password", "Comparing against plaintext should work"
    assert pwd != "wrong_password", "not equals should work"
import socket

import sys
sys.path.append("C:/Users/Moon/Desktop/Python/소스코드")

import Password

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('',8888))
s.listen(1)
print('Socket Listen Start')

connector, addr = s.accept()

while 1 :
    
    data = connector.recv(1024)
    if not data : break

    key='123'
    
    Password.string_xor('data', 'key')
    
    
    print("Received Message : ", data.decode('utf-8'))

    data = input("Message : ")
    connector.send(data.encode('utf-8'))

s.close()
Exemple #11
0
    def testHashCheck(self):
        pwd = TEST_PW.encode('utf-8')
        p = Password(pwd)

        self.assertTrue(p.hash_check(pwd))
Exemple #12
0
        sleep(5)

    def likeTweet(self, searchfor):
        driver = self.driver
        search_box = driver.find_element_by_xpath(
            '//*[@id="react-root"]/div/div/div[2]/main/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/form/div[1]/div/div/div[2]/input'
        )
        search_box.send_keys(searchfor)
        search_box.send_keys(Keys.RETURN)
        sleep(8)
        for i in range(1, 3):
            #try:
            driver.find_element_by_xpath("//div[@data-testid='like']").click()
            """#except exceptions.NoSuchElementException:
                sleep(3)
                driver.execute_script('window.scrollTo(0,document.body.scrollHeight/2)') 
                sleep(3)
                driver.find_element_by_xpath("//div[@data-testid='like']").click()

            sleep(1)
            driver.execute_script('window.scrollTo(0,document.body.scrollHeight/2)')"""
            sleep(5)


pass_word = Password.Password()
username = Password.user_name()

find = twitter_bot(username, pass_word)
find.login()
find.likeTweet("selenium")
Exemple #13
0
def takeUserInput():
    name = user_input.get()
    password = Password.find_password(name.lower())
    thePassword.set(password)
# ---------------------- Database Call ----------------------------------

try:
    conn = pyodbc.connect('Driver={SQL Server Native Client 11.0};'
                          'Server=174.101.154.93;'
                          'Database=PasswordManager;'
                          'uid=bruceba;'
                          'pwd=password')

    # Store return value of a database query in a Panda Data Frame
    value = pd.read_sql_query('select * from tEntries', conn)
    print(value.count())

    # Foreach row value, create a Password Class and store it in a list of Password Classes
    DatabasePasswords = [
        (Password.Password(row.EntryID, row.UserID, row.WebsiteDomainID,
                           row.WebsitePasswordID, row.CategoryID))
        for index, row in value.iterrows()
    ]

    # Foreach Password Class in list of Passwords, print out the EntryID an int
    for x in DatabasePasswords:
        print(int(x.EntryID))

    # print out the length of the array not the count in this instance
    print('Count of Database Passwords: ' + str(len(DatabasePasswords)))

except Exception:
    print('Database Error!!!')

# ------------------------ API Post Call ---------------------------------------
 def test_hash_password_hash_check(self):
     hashed_pwd = Password.hash_password(self.password)
     self.assertTrue(Password.hash_check(self.password, hashed_pwd), (True))
 def setUp(self):
     self.pw_hasher = Password.Password()
from User import User
from Password import *

#Example to trigger a sonar vulnerability
#import socket
#ip = '127.0.0.1'
#sock = socket.socket()
#sock.bind((ip, 9090))

#typical bandit findings
#>>> bandit -r <folder>
#deprecated md5 will not be found by sonar...
password = input("Please provide a password:"******"Bert")

p = Password()

if p.pwd_complex(password) == True:
    hashed_password = p.hash_password(password.encode())

    user1.set_password(hashed_password)
    hashed_password = user1.get_password()

    p.hash_check(password.encode(), hashed_password)
else:
    print("Doesn't make complexity requirements")
import Usuario
import Password

correcto=False
while correcto==False:
        nombre=input("Ingrese nombre de usuario: ")
        if Usuario.nickname(nombre) == True:
            print("Usuario creado exitosamente")
            correcto=True

while correcto==True:
    contrasena=input("Ingrese su Password: "******"Contraseña creada exitosamente")
        correcto=False
Exemple #19
0
            text = text.replace('sequins ', '').replace('sequence ', '')
            WireSequence.sequence(text)

        elif 'reset sequence' in text:
            WireSequence.resetsequence()
            speak('Sequence Reset')

        elif 'maze' in text or 'maize' in text or "may's" in text:  #
            # 1 Indicator, start, finish sep by 'next' ie(44 next 43 next 55)
            text = text.replace('maze ', '').replace('maize ',
                                                     '').replace("may's ", '')
            Maze.maze(text)

        elif 'password' in text:  # Nato alphabet for each letter sep by 'next' ie(lima next alpha)
            text = text.replace('password ', '').replace('hilo', 'kilo')
            Password.password(text)

        elif 'knobs' in text:  # column of LEDs with top and bottom lit ie(135)
            text = text.replace('knobs ', '')
            Knobs.knobs(text)

        # Setup
        elif 'batteries' in text:
            text = text.replace('batteries ', '')
            BombSetup.batteries(text)

        elif 'serial' in text or 'cereal' in text:
            text = text.replace('serial ', '')
            BombSetup.serial(text)

        elif 'parallel port' in text:
def Go():
    #auxiliares del save
    auxi=0
    auxj=0
    deactivate=False
    first=False
    #termino de variables auxiliares del save
    pygame.init()
    #Variables para la panalla y seeo de esa
    x = 1024
    y = 768
    size = (x,y)
    black = (135,206,235)
    screen = pygame.display.set_mode(size)
    #Imagenes
    menu = pygame.image.load("Imagenes/menu.png")
    fondo = pygame.image.load("Imagenes/fondo.png")
    fondo_pass = pygame.image.load("Imagenes/fondo_pass.png")
    gameover = pygame.image.load("Imagenes/gameover.png")
    #Musica
    pygame.mixer.music.load("Music/music1.mp3")
    pygame.mixer.music.play(-1)
    #Clock
    clock = pygame.time.Clock()
    #Variables de Novatin
    s = 0
    cabeza = Clases.Extremidad(0,0,"cabeza")
    brazo_i = Clases.Extremidad(0,0,"brazo_i")
    brazo_d = Clases.Extremidad(0,0,"brazo_d")
    saven = 0
    xi = 40
    yi = y-40
    di = 0
    mi = False
    jefe = False
    jefe2 = False
    Novatin = Clases.Novatin(xi,yi,di,mi)
    Vidas = 10
    Creditos = 1
    cb = True
    firstchange = True
    secondchange = True
    thirdchange = True
    fourthchange = True
    #Portada
    main = 1
    seleccion = 0
    #Mapas
    construir = 0
    cambiar = False
    Mapa = []
    #Inicio etapas
    for i in(range(15)):
        Mapa.append(Maps.Mapa(x,y,"Levels/level"+str(i+1)+".txt",i+1))
    #Fin etapas
    for mapa in Mapa:
        mapa.cambia(Mapa)

    while 1:
        if construir == 4 and jefe2==False:
            jefe = True
            jefe2 = True
        if jefe == True:
            #pygame.mixer.music.load("Music/music2.mp3")
            #pygame.mixer.music.play()
            jefe = False
        if construir in range(len(Mapa)) and cambiar == True:
            Novatin.rect.centerx = xi
            Novatin.rect.centery = yi
            cambiar = False
        if construir < 9 and construir >4 and firstchange == True:
            pygame.mixer.music.load("Music/music3.mp3")
            pygame.mixer.music.play(-1)
            firstchange = False
        if construir == 9 and secondchange == True:
            pygame.mixer.music.load("Music/music4.mp3")
            pygame.mixer.music.play(-1)
            secondchange = False
        if construir < 13 and construir >9 and thirdchange == True:
            pygame.mixer.music.load("Music/music5.mp3")
            pygame.mixer.music.play(-1)
            thirdchange = False
        if construir == 14 and fourthchange == True:
            pygame.mixer.music.load("Music/music6.mp3")
            pygame.mixer.music.play(-1)
            fourthchange = False
        clock.tick(30)
        if main == 1:
            for event in pygame.event.get():
                if hasattr(event, 'key')==False:
                    continue
                down = event.type == KEYDOWN
                if event.key == K_ESCAPE:
                    pygame.quit()
                    sys.exit(0)
                if event.key == K_SPACE:
                    if seleccion == 0:
                        main = 0
                    else:
                        main = 2
                    s = 1
            key = pygame.key.get_pressed()
            if key[K_UP] == True:
                seleccion = 0
            if key[K_DOWN] == True:
                seleccion = 1
            screen.blit(menu, (0,0))
            if seleccion == 0:
                screen.blit(cabeza.image, (450,540))
            else:
                screen.blit(cabeza.image, (450,640))
            pygame.display.flip()
        elif main == 2:
            for event in pygame.event.get():
                if hasattr(event, 'key')==False:
                    continue
                down = event.type == KEYDOWN
                if event.key == K_ESCAPE:
                    pygame.quit()
                    sys.exit(0)
                if event.key == K_SPACE:
                    if Password.no_repetir:
                        Password.no_repetir = False
                        if Password.seleccion == 37:
                            Password.clave = Password.borra_espacio(Password.clave)
                        elif Password.seleccion == 38:
                            main, construir, Novatin.rect.centerx, Novatin.rect.centery, Novatin.metralleta, Novatin.contador_m = Password.clavea()
                        #################SAVE/CHEATS################### 
                        else:
                            Password.clave += Password.caracteres[(Password.seleccion-1)]
                    else:
                        Password.no_repetir = True
                if event.key == K_UP:
                    Password.seleccion, Password.movil = Password.mover_arriba(Password.seleccion, Password.movil)
                if event.key == K_DOWN:
                    Password.seleccion, Password.movil = Password.mover_abajo(Password.seleccion, Password.movil)
                if event.key == K_RIGHT:
                    Password.seleccion, Password.movil = Password.mover_derecha(Password.seleccion, Password.movil)
                if event.key == K_LEFT:
                    Password.seleccion, Password.movil = Password.mover_izquierda(Password.seleccion, Password.movil)
            screen.blit(fondo_pass, (0,0))
            for j in range(len(Password.caracteres)):
                pos = (Password.posicion_teclado(j))
                text, text_rect = texto(Password.caracteres[j], pos[0], pos[1], 40)
                screen.blit(text, text_rect)
            pos = Password.posicion_cursor(Password.seleccion)
            screen.blit(cabeza.image, pos)
            for i in range(len(Password.clave)):
                pos = (Password.posicion_clave(i))
                password, password_rect = texto(Password.clave[i], pos[0], pos[1], 40)
                screen.blit(password, password_rect)
            pygame.display.flip()
        elif main == 3:
            for event in pygame.event.get():
                if hasattr(event, 'key')==False:
                    continue
                down = event.type == KEYDOWN
                if event.key == K_ESCAPE:
                    pygame.quit()
                    sys.exit(0)
                if event.key == K_SPACE:
                    if Password.no_repetir:
                        Password.no_repetir = False
                        if Password.seleccion == 37:
                            Password.clave = Password.borra_espacio(Password.clave)
                        elif Password.seleccion == 38:
                            main, construir, Novatin.rect.centerx, Novatin.rect.centery, Novatin.metralleta, Novatin.contador_m = Password.clavea()
                        #################SAVE/CHEATS################### 
                        else:
                            Password.clave += Password.caracteres[(Password.seleccion-1)]
                    else:
                        Password.no_repetir = True
                if event.key == K_UP:
                    Password.seleccion, Password.movil = Password.mover_arriba(Password.seleccion, Password.movil)
                if event.key == K_DOWN:
                    Password.seleccion, Password.movil = Password.mover_abajo(Password.seleccion, Password.movil)
                if event.key == K_RIGHT:
                    Password.seleccion, Password.movil = Password.mover_derecha(Password.seleccion, Password.movil)
                if event.key == K_LEFT:
                    Password.seleccion, Password.movil = Password.mover_izquierda(Password.seleccion, Password.movil)
            screen.blit(fondo_pass, (0,0))
            for j in range(len(Password.caracteres)):
                pos = (Password.posicion_teclado(j))
                text, text_rect = texto(Password.caracteres[j], pos[0], pos[1], 40)
                screen.blit(text, text_rect)
            pos = Password.posicion_cursor(Password.seleccion)
            screen.blit(cabeza.image, pos)
            for i in range(len(Password.clave)):
                pos = (Password.posicion_clave(i))
                password, password_rect = texto(Password.clave[i], pos[0], pos[1], 40)
                screen.blit(password, password_rect)
            pygame.display.flip()
        else:
            Novatin.shoot = False
            for event in pygame.event.get():
                if hasattr(event, 'key')==False:
                    continue
                down = event.type == KEYDOWN
                if event.key == K_s:
                    if cb == True:
                        Vidas += 10
                        Creditos += 1
                        cb = False
                    elif cb == False:
                        cb == True
                if event.key == K_RIGHT:
                    Novatin.direccionx = 0
                    Novatin.speed = down*15
                elif event.key == K_r:
                    if Novatin.alive == False:
                        Novatin.restart = True
                elif event.key == K_LEFT:
                    Novatin.direccionx = 1
                    Novatin.speed = down*15
                elif event.key==K_ESCAPE:
                    pygame.quit()
                    sys.exit(0)
                if event.key == K_SPACE:
                    if s==0 and Novatin.metralleta == False:
                        Novatin.shoot=True
                        s=1
                    elif s==1 and Novatin.metralleta == False:
                        Novatin.shoot=False
                        s=0
            key = pygame.key.get_pressed()
            if key[K_UP] == True:
                Novatin.jump = True
            elif key[K_UP] == False:
                Novatin.jump = False
            if key[K_SPACE] == True and Novatin.metralleta == True:
                Novatin.shoot = True
            elif key[K_SPACE] == False and Novatin.metralleta == True:
                Novatin.shoot = False
            #############################################################################
            screen.fill(black) #si se pone dentro del if entonces se vuelve negra una vez
            #############################################################################
            if Novatin.alive==True:
                Novatin.move(Mapa[construir].plataformas,x)
                Novatin.saltar(y,Mapa[construir].plataformas)
                Novatin.disparar(Mapa[construir].plataformas,Mapa[construir].save,Mapa[construir].enemigos,x, Mapa[construir].jefes)
                Novatin.ambiente(Mapa[construir].espinas,cabeza,brazo_d,brazo_i, Mapa[construir].manzanas,Mapa[construir].camaespinas,Mapa[construir].enemigos,Mapa[construir].powerups, Mapa[construir].jefes)
                for change in Mapa[construir].changes:
                    if ((Novatin.rect.right> change[0] and Novatin.rect.left <= change[0]) or (Novatin.rect.left<change[0] and Novatin.rect.right >= change[0])) and Novatin.rect.centery-16<change[1] and Novatin.rect.centery+16>change[1]:
                        xi = change[3]
                        yi = change[4]
                        construir = change[2]
                        cambiar = True
            else:
                Novatin.shoot = False
                Novatin.disparar(Mapa[construir].plataformas,Mapa[construir].save,Mapa[construir].enemigos,x, Mapa[construir].jefes)
                if Novatin.play == True:
                    pygame.mixer.music.load("Music/gameover.mp3")
                    pygame.mixer.music.play()
                    Novatin.play = False
                    Vidas -=1
                    if (Vidas==0):
                        main = 3
                Novatin.revivir += 1
                if Novatin.revivir == 300 or Novatin.restart == True:
                    if construir !=4:
                        pygame.mixer.music.load("Music/music1.mp3")
                        pygame.mixer.music.play(-1)
                    elif construir == 4:
                        pygame.mixer.music.load("Music/music2.mp3")
                        pygame.mixer.music.play()
                    elif construir>4 and construir<9:
                        pygame.mixer.music.load("Music/music3.mp3")
                        pygame.mixer.music.play(-1)
                    elif construir == 9:
                        pygame.mixer.music.load("Music/music4.mp3")
                        pygame.mixer.music.play(-1)
                    elif construir>9 and construir<13:
                        pygame.mixer.music.load("Music/music5.mp3")
                        pygame.mixer.music.play(-1)
                    elif construir == 14:
                        pygame.mixer.music.load("Music/music6.mp3")
                        pygame.mixer.music.play(-1)
                    Novatin.revivir = 0
                    Novatin.alive = True
                    Novatin.play = True
                    Novatin.restart = False
                    for i in range(len(Mapa)):
                        for jefe in Mapa[i].jefes:
                            jefe.reppos()
                    for i in range(len(Mapa)):
                        for j in range(len(Mapa[i].save)):
                            if Mapa[i].save[j].deactivate==True:
                                auxi=i
                                auxj=j
                                deactivate=True
                    if deactivate==True:
                        for i in range(len(Mapa)):
                            for j in range(len(Mapa[i].save)):
                                if i!=auxi and j!=auxj:
                                    Mapa[i].save[j].active=False
                        Mapa[auxi].save[auxj].deactivate=False
                        deactivate=False
                        auxi=0
                        auxj=0
                    for i in range(len(Mapa)):
                        for j in range(len(Mapa[i].save)):
                            if Mapa[i].save[j].active==True:
                                Novatin.rect.centerx = Mapa[i].save[j].savex
                                Novatin.rect.centery = Mapa[i].save[j].savey
                                construir = i
                                first=True
                    if first==False:
                        Novatin.rect.centerx = 48
                        Novatin.rect.centery = y-48
                        construir=0
                    cabeza.alive = False
                    cabeza.roce = random.randint(-15,15)
                    cabeza.jumpspeed = random.randint(10, 25)
                    brazo_d.alive = False
                    brazo_d.roce = random.randint(-15,15)
                    brazo_d.jumpspeed = random.randint(10,25)
                    brazo_i.alive = False
                    brazo_i.roce = random.randint(-15,15)
                    brazo_i.jumpspeed = random.randint(10,25)
                    Mapa[construir].Restaurar()
            muertes, muertes_rect = texto(str(Novatin.muertes), x-100, 20, 20)
            creditos, creditos_rect = texto(str(Creditos), x-150, 20, 20)
            if Novatin.contador_m < 300:
                bonus, bonus_rect = texto(str(Novatin.contador_m//30+1), x-100, 40, 20)
            if cabeza.alive:
                cabeza.jump(y)
            if brazo_i.alive:
                brazo_i.jump(y)
                brazo_i.mover(y)
            if brazo_d.alive:
                brazo_d.mover(y)
                brazo_d.jump(y)
            screen.blit(fondo, (0,0))
            Mapa[construir].Imprimir(Novatin, Clases.PowerUp)
            for clave in Mapa[construir].claves:
                password, password_rect = texto(clave.password, clave.posx, clave.posy, 40)
                screen.blit(password, password_rect)
            if Novatin.alive==True:
                screen.blit(Novatin.image, Novatin.rect)
            if cabeza.alive:
                screen.blit(cabeza.image, cabeza.rect)
            if brazo_d.alive:
                screen.blit(brazo_d.image, brazo_d.rect)
            if brazo_i.alive:
                screen.blit(brazo_i.image, brazo_i.rect)
            screen.blit(muertes, muertes_rect)
            screen.blit(creditos, creditos_rect)
            if Novatin.contador_m < 300:
                screen.blit(bonus, bonus_rect)
            for bullet in Novatin.bullets:
                if bullet.alive==True:
                    screen.blit(bullet.image, bullet.rect)
            if Novatin.alive == False:
                screen.blit(gameover,(x/2-400,(y-191)/2))
            pygame.display.flip()