humb3rtolun4

Script_aws_conf.py

Apr 19th, 2021 (edited)
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import os
  4. import sys
  5. from art import *
  6. from colorama import init, Fore, Back, Style
  7. import time
  8.  
  9.  
  10. def root_user():
  11.     if os.geteuid() != 0:
  12.         init()
  13.         print (Fore.YELLOW + "Este Script solo lo puedes ejecutar con usuario root")
  14.         init(autoreset=True)
  15.         sys.exit(1)
  16.     else:
  17.         print("Starting")
  18.  
  19. def show_ip():
  20.     time.sleep(1)
  21.     print(Fore.GREEN + "Mostrando Lineas donde esta la anterior IP")
  22.     time.sleep(1)
  23.     print("..............................................")
  24.     ipprint = os.system("cat client.ovpn | grep remote ")
  25.     print("..............................................")
  26.     init(autoreset=True)
  27. def Cambia_IP():
  28.     time.sleep(1)
  29.     print("Copia la IP mostra arriba")
  30.     ip_old = raw_input("Introduce la antigua direccion ip: ")
  31.     time.sleep(1)
  32.     ip = raw_input("Introduce la nueva direccion ip: ")
  33.     time.sleep(1)
  34.     print ("Comando SET ejecutado...")
  35.     comando = os.system("sed -i 's/{0}/{1}/g' client.ovpn".format(ip_old, ip))
  36.  
  37. def conexion():
  38.     time.sleep(1)
  39.     print(Fore.RED + "Conectando a AWS Openvpn")
  40.     time.sleep(1)
  41.     print("..............................................\n\n")
  42.     connect = os.system("openvpn --config client.ovpn")
  43.  
  44. root_user()
  45. show_ip()
  46. Cambia_IP()
  47. conexion()
  48.  
Add Comment
Please, Sign In to add comment