elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Script
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Script  (Leído 2,181 veces)
Geruis

Desconectado Desconectado

Mensajes: 1


Ver Perfil
Script
« en: 29 Marzo 2018, 06:24 am »

Como realizar Script en python que llene automaticamente con datos diferentes los campos e una base de datos


En línea

engel lex
Moderador Global
***
Desconectado Desconectado

Mensajes: 15.514



Ver Perfil
Re: Script
« Respuesta #1 en: 29 Marzo 2018, 08:05 am »

hay casi muchas formas diferentes de hacer esto según el caso... es como preguntar "como se escribe un libro lleno de palabras en paginas" primero investiga sobre que manejadores hay de linux para tu  base de datos y luego que tengas algo formulado y un código, has una pregunta más clara y punstual


En línea

El problema con la sociedad actualmente radica en que todos creen que tienen el derecho de tener una opinión, y que esa opinión sea validada por todos, cuando lo correcto es que todos tengan derecho a una opinión, siempre y cuando esa opinión pueda ser ignorada, cuestionada, e incluso ser sujeta a burla, particularmente cuando no tiene sentido alguno.
Sentex

Desconectado Desconectado

Mensajes: 87


Programador


Ver Perfil WWW
Re: Script
« Respuesta #2 en: 31 Marzo 2018, 12:55 pm »

Hola!. Aqui tienes un ejemplo de manejo de base de datos con python. La base de datos es personalizada osea no es sqlite ni nada de eso. Necesitaras crear un fichero en la misma carpeta del script que se llame spotify.db y ya funcionaria el script. Claro este script sirve para lo que sirve que es para almacenar cuentas de spotify y tal.

Script
Código
  1. # -*- coding: utf-8 -*-
  2.  
  3. import sys, os
  4. from tabulate import tabulate
  5. from random import SystemRandom
  6. from base64 import b64encode as encode
  7. from base64 import b64decode as decode
  8.  
  9. def deca():
  10.  
  11.    global fathers
  12.    global pfathers
  13.    global user
  14.    global passwd
  15.    global name
  16.  
  17.    fathers = []
  18.    pfathers = []
  19.    user = []
  20.    passwd = []
  21.    name = []
  22.  
  23. def clearf():
  24.    for father in fathers:
  25.        fathers.remove(father)
  26.    for pfather in pfathers:
  27.        pfathers.remove(pfather)
  28.    for usr in user:
  29.        user.remove(usr)
  30.    for passw in passwd:
  31.        passwd.remove(passw)
  32.    for na in name:
  33.        name.remove(na)
  34.  
  35.  
  36. class more:
  37.    INFO = "[#] "
  38.    CORRECT = "[*] "
  39.    ERROR = "[!ERROR] "
  40.  
  41. SPOTIFY = ('''
  42.   _____             __  _ ____    
  43.  / ___/____  ____  / /_(_) __/_  __
  44.  \__ \/ __ \/ __ \/ __/ / /_/ / / /
  45. ___/ / /_/ / /_/ / /_/ / __/ /_/ /
  46. /____/ .___/\____/\__/_/_/  \__, /  
  47.    /_/                    /____/  
  48. ''')
  49.  
  50. def clear():
  51.    syst = sys.platform
  52.    if str(syst) == 'win32':
  53.        os.system('cls')
  54.    else:
  55.        os.system('clear')
  56.  
  57. def deconfuse(data):
  58.    data = str(data).replace('β', '=').replace('≡', '?').replace('∑', "W").replace("∂", "c").replace("◊", "H").replace("€", "T").replace("•", "5")
  59.    return data
  60.  
  61. def confuse(data):
  62.    data = str(data).replace('=', 'β').replace('?', '≡').replace('W', "∑").replace("c", "∂").replace("H", "◊").replace("T", "€").replace("5", "•")
  63.    return data
  64.  
  65. def decryptdb(db):
  66.    reader = open(db, "r")
  67.    data = reader.read()
  68.    if str(data).find("DaRpa") == -1:
  69.        print more.ERROR + "The db is not encrypted"
  70.        main()
  71.    data = str(data).replace("DaRpa", "").rstrip(" ")
  72.    data = deconfuse(data)
  73.    data = decode(data)
  74.    reader.close()
  75.    writer = open(db, "w")
  76.    writer.write(data)
  77.    writer.close()
  78.  
  79. def encryptdb(db):
  80.    reader = open(db, "r")
  81.    data = encode(reader.read())
  82.    data = "DaRpa" + confuse(data)
  83.    reader.close()
  84.    writer = open(db, "w")
  85.    writer.write(data)
  86.    writer.close()
  87.  
  88. def edit_account(db, email, password, nombre, nemail, npassword, nnombre, father, pfather, nfather, npfather):
  89.    reader = open(db, "r")
  90.    data = reader.read()
  91.    data = str(data).replace(email+":"+password+":"+nombre+":"+father+":"+pfather, nemail+":"+npassword+":"+nnombre+":"+nfather+":"+npfather)
  92.    reader.close()
  93.    writer = open(db, "w")
  94.    writer.write(data)
  95.    writer.close()
  96.  
  97. def delete_account(db, email, password, nombre, father, pfather):
  98.    reader = open(db, "r")
  99.    data = reader.read()
  100.    data = str(data).replace("{0}:{1}:{2}:{3}:{4}", "").rstrip("\n").format(email,password, nombre, father, pfather)
  101.    reader.close()
  102.    writer = open(db, "w")
  103.    writer.write(data)
  104.    writer.close()
  105.  
  106. def add_account(db, email, password, nombre, father, pfather):
  107.    reader = open(db, "r")
  108.    data = reader.read()
  109.    data = str(data)+"\n{0}:{1}:{2}:{3}:{4}\n".rstrip("\n").format(email, password, nombre, father, pfather)
  110.    reader.close()
  111.    writer = open(db, "w")
  112.    writer.write(data)
  113.    writer.close()
  114.  
  115. def random(long, opt):
  116.    if opt == "Mm1":
  117.        abc = "a0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  118.    elif opt == "Mm":
  119.        abc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  120.    elif opt == "m":
  121.        abc = "abcdefghijklmnopqrstuvwxyz"
  122.  
  123.    gen = SystemRandom()
  124.    rand = ""
  125.    while long > 0:
  126.        rand = rand + gen.choice(abc)
  127.        long -= 1
  128.    return rand
  129.  
  130. def generate():
  131.    print more.INFO + "Generating an account..."
  132.    mail = random(7, "m")
  133.    password = random(5, "Mm1")
  134.    print "YopMail: "+mail+"@yopmail.com"
  135.    print "PassWord: "+password
  136.    print "Name: Not Set"
  137.    print "Father: Not Set"
  138.    print "PassWord: Not Set"
  139.    print ""
  140.    raw_input("Press enter to continue")
  141.    add_account("spotify.db", mail+"@yopmail.com", password, "unset", "unset", "unset")
  142.    print more.CORRECT + "Account Created"
  143.    main()
  144.  
  145. def opendb(db):
  146.    clearf()
  147.    file = open(db, "r")
  148.    data = file.readlines()
  149.    for lines in data:
  150.        if not lines == "":
  151.            info = str(lines).split(":")
  152.            user.append(info[0])
  153.            passwd.append(info[1])
  154.            name.append(info[2])
  155.            fathers.append(info[3])
  156.            pfathers.append(info[4])
  157.    file.close()
  158.  
  159. def statusdb(db):
  160.    file = open(db, "r")
  161.    data = file.read()
  162.    if not str(data).find("DaRpa") == -1:
  163.        print "DB Status: Encrypted!"
  164.    else:
  165.        print "DB Status: Decrypted!"
  166.  
  167. def make_table():
  168.    if len(user) > 1:
  169.  
  170.        datau = ""
  171.        datap = ""
  172.        datae = ""
  173.        dataf = ""
  174.        datapf = ""
  175.  
  176.        for usr in user:
  177.            datau += "\n" + usr + "\n".rstrip("\n")
  178.        for passw in passwd:
  179.            datap += "\n" + passw + "\n".rstrip("\n")
  180.        for na in name:
  181.            datae += "\n" + na + "\n".rstrip("\n")
  182.        for father in fathers:
  183.            dataf += "\n" + father + "\n".rstrip("\n")
  184.        for passw in pfathers:
  185.            datapf += passw + "\n".rstrip("\n")
  186.  
  187.        table = [['Email', 'Password', 'Father', 'Password', 'Name'],
  188.                  [datau, datap, dataf, datapf, datae]]
  189.        print(tabulate(table, headers='firstrow'))
  190.        print ""
  191.        raw_input("Press enter to continue")
  192.        clearf()
  193.        del datau
  194.        del datap
  195.        del datae
  196.        del dataf
  197.        del datapf
  198.        main()
  199.    else:
  200.        main()
  201.  
  202. def main():
  203.    print ""
  204.    statusdb("spotify.db")
  205.    print "Spotify Manager By Sentex"
  206.    print "--Select Option--------------------"
  207.    print " 1._ Open DB"
  208.    print " 2._ Delete account"
  209.    print " 3._ Add account"
  210.    print " 4._ Edit account"
  211.    print " 5._ Encrypt DB"
  212.    print " 6._ Decrypt DB"
  213.    print " 7._ Show DB"
  214.    print " 8._ Generate"
  215.    print " 9._ Exit"
  216.    opt = raw_input(">")
  217.    if opt == "":
  218.        print more.ERROR + "Wrong command"
  219.        main()
  220.    if int(opt) == 1:
  221.        print more.INFO + "Loading DB..."
  222.        opendb("spotify.db")
  223.        print more.CORRECT + "DB Loaded!"
  224.        main()
  225.    elif int(opt) == 2:
  226.        print "Email"
  227.        email = raw_input(">")
  228.        print "Password"
  229.        password = raw_input(">")
  230.        print "Name"
  231.        nombre = raw_input(">")
  232.        print "Father"
  233.        father = raw_input(">")
  234.        print "Password"
  235.        pfather = raw_input(">")
  236.        print more.INFO + "Removing Account..."
  237.        delete_account("spotify.db", email,password, nombre, father, pfather)
  238.        print more.CORRECT + "Account Deleted!"
  239.        main()
  240.    elif int(opt) == 3:
  241.        print "Email"
  242.        email = raw_input(">")
  243.        print "Password"
  244.        password = raw_input(">")
  245.        print "Name"
  246.        nombre = raw_input(">")
  247.        print "Father"
  248.        father = raw_input(">")
  249.        print "Password"
  250.        pfather = raw_input(">")
  251.        print more.INFO + "Creating new account..."
  252.        add_account("spotify.db", email, password, nombre, father, pfather)
  253.        print more.CORRECT + "Account Created!"
  254.        main()
  255.    elif int(opt) == 4:
  256.        print "Email"
  257.        email = raw_input(">")
  258.        print "Password"
  259.        password = raw_input(">")
  260.        print "Name"
  261.        nombre = raw_input(">")
  262.        print "Father"
  263.        father = raw_input(">")
  264.        print "Password"
  265.        pfather = raw_input(">")
  266.        print "New Email"
  267.        nemail = raw_input(">")
  268.        print "New Password"
  269.        npassword = raw_input(">")
  270.        print "New Name"
  271.        nnombre = raw_input(">")
  272.        print "New Father"
  273.        nfather = raw_input(">")
  274.        print "New Password"
  275.        npfather = raw_input(">")
  276.        print more.INFO + "Editing Account"
  277.        if nemail == "":
  278.            nemail = str(email)
  279.        elif npassword == "":
  280.            npassword = str(password)
  281.        elif nnombre == "":
  282.            nnombre = str(nombre)
  283.        if nfather == "":
  284.            nfather = str(father)
  285.        if npfather == "":
  286.            npfather = str(pfather)
  287.        edit_account("spotify.db", email, password, nombre, nemail, npassword, nnombre, father, pfather, nfather, npfather)
  288.        print more.CORRECT + "Account Edited"
  289.        main()
  290.    elif int(opt) == 5:
  291.        print more.INFO + "Encrypting DB..."
  292.        encryptdb("spotify.db")
  293.        print more.CORRECT + "DB Encrypted!"
  294.        main()
  295.    elif int(opt) == 6:
  296.        print more.INFO + "Decrypting DB..."
  297.        decryptdb("spotify.db")
  298.        print more.CORRECT + "DB Decrypted!"
  299.        main()
  300.    elif int(opt) == 7:
  301.        make_table()
  302.    elif int(opt) == 8:
  303.        generate()
  304.    elif int(opt) == 9:
  305.        print more.INFO + "Encrypting the db"
  306.        f = open("spotify.db", "r")
  307.        data = f.read()
  308.        if str(data).find("DaRpa") == -1:
  309.            encryptdb("spotify.db")
  310.        print more.CORRECT + "Encrypted!"
  311.        print "Bye!"
  312.        sys.exit()
  313.    else:
  314.        print more.ERROR + "Wrong command"
  315.        main()
  316.  
  317. deca()
  318. clear()
  319. print SPOTIFY
  320. main()
  321.  

Si sacas fragmentos del código te puede ayudar.
En línea

Preguntas o peticiones en twitter o discord:

Discord: MrSentex#1227
Twitter: @fbi_sentex
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines