def load(proj_n): # function to load a project global current c = conn.cursor() c.execute("SELECT * FROM project;") rows = c.fetchall() current = rows[int(proj_n)] print_logo() print("load project") print("------------------------------------------") print("project: " + current[1] + " loaded") print("") print("options: ") print("") print("0 : scan all") print("1 : resume") print("2 : nmap only") print("3 : create report") print("------------------------------------------") i_nr = input("option: ") # choose one option if i_nr == "0": # scan all nmap_hack.run_nmap() scan.scan() ########### elif i_nr == "1": # resume scan.scan() elif i_nr == "2": # nmap only nmap_hack.run_nmap() elif i_nr == "3": # create report report.create(current[1]) elif (i_nr != "0" or "1" or "2" or "3"): print("enter a valid value!")
def mm_createProj(): #This is horrible practice you should create a submenu for this instead and this dialogue should be a project menu or whatever i_abfrage = "c" # so that the program can enter the while loop once. while (i_abfrage.lower() == "c"): # to create another project print_logo() print("create project") print("------------------------------------------") i_proj = input("project name: ") i_hosts = input("hosts (ip): ") i_prot = input("TCP (0) or UDP (1): ") i_port = input("ports: ") i_http_s = input("http (0) or https (1): ") print("") project.create(i_proj, i_hosts, i_port, i_prot, i_http_s) print_logo() print("create a project") print("------------------------------------------") print("project: " + i_proj + " successfully create") print("") print("press 'r' to return menu:") # open the complete py script print("press 'l' to load the project:") print("press 'c' to create another project:") # while i_abfrage = c i_abfrage = input() if (i_abfrage.lower() == "r" ): # after creating a project, the py script starts against return elif (i_abfrage.lower() == "l"): c = conn.cursor() c.execute("SELECT COUNT(*) FROM project;") project.load(str(int(c.fetchone()[0]) - 1)) # load project created above
def start(args): # Takes args from the bridge to select which tasks are need to be executed if args.index_search == 0: if args.mode == '0': if args.search_str is not None: inp = args.search_str str_search(inp, args) else: print('Missing arguments') elif args.mode == '1': logo.print_logo() inp = input('Enter the search string: ') str_search(inp, args) else: print('Unknown arguments') elif args.index_search == 1: if args.mode == '0': if args.search_idx is not None: index = args.search_idx idx_search(index, args) else: print('Missing arguments') elif args.mode == '1': logo.print_logo() index = input('Enter image index: ') idx_search(index, args) else: print('Unknown argument') else: print('Unknown argument')
def start(args): if args.index_search == 0: if args.mode == '0': if args.search_str is not None: inp = args.search_str str_search(inp, args) else: print('Missing arguments') elif args.mode == '1': logo.print_logo() inp = input('Enter the search string: ') str_search(inp, args) else: print('Unknown arguments') elif args.index_search == 1: if args.mode == '0': if args.search_idx is not None: index = args.search_idx idx_search(index, args) else: print('Missing arguments') elif args.mode == '1': logo.print_logo() index = input('Enter image index: ') idx_search(index, args) else: print('Unknown argument') else: print('Unknown argument')
def mm_wipe(): print_logo() print("delete database & reload modules") print("------------------------------------------") print("") print("press 'y' to confirm deletion: ") i_load = input() if (i_load.lower() == "y"): print("Deleting") os.remove("pta.sqlite") shutil.rmtree("./projects") os.system("python3 pta.py") return print("Aborted")
def interpereter(self): print_logo(0) print("If you don't know about the options, enter----> help") while True: cmd = input("> ") if cmd == "help": print("all commands are exit help first follow display states") if cmd == "exit": break if cmd == "first": self.disp_first() if cmd == "follow": self.disp_follow() if cmd == "display": self.disp() if cmd == "states": self.disp_states()
def mm_delProj(): print_logo() print("delete project") print("------------------------------------------") print("which project would you like to delete?") print("") i = 0 c = conn.cursor() c.execute("SELECT * FROM project ORDER BY id") rows = c.fetchall() for row in rows: print(str(i) + " : " + row[1]) i = i + 1 i_nr = input("projectname: ") # choose a projekt to delete project.delete(rows[i_nr])
def mm_loadProj(): print_logo() print("load project") print("------------------------------------------") print("which project would you like to load?") print("") i = 0 c = conn.cursor() c.execute("SELECT * FROM project") rows = c.fetchall() for row in rows: print(str(i) + " : " + row[1]) i = i + 1 print("") i_proj = input("projectname: ") project.load(i_proj)
import os import sys import pygtrie as pygtrie import json import argparse as arg from PIL import Image from collections import defaultdict import logo from difflib import get_close_matches parser = arg.ArgumentParser('searchp') if sys.argv[1] == '--help' or sys.argv[1] == '-h': logo.print_logo() parser.add_argument('--mode', default=0, help='Choose from two modes: 0-Command line 1-Interactive') parser.add_argument('--search_str', type=str, default=None, help='Enter search string: ') parser.add_argument( '--index_search', type=int, default=0, help='Choose 1 to enable searching images from their indices') parser.add_argument('--search_idx', default=0, help='Enter image index: ') parser.add_argument('--result', type=int, default=0,
def start(args): ''' Generates meme with different arrangement of text and image based on arguments. # Mode - 0, 1 # Formats ''' formatObj = None if args.mode == '0': if args.format == '0': if args.random == 'True' or args.random == 'False': random_meme(args.random) else: print('Empty or invalid arguments') if args.format == '1': if args.text1 and args.text2 and args.image1: preprocessImages(args.image1) formatObj = Format1(image_path=args.image1, top_text=args.text1, bottom_text=args.text2) use(formatObj) elif args.text1 and args.image1: preprocessImages(args.image1) formatObj = Format1(image_path=args.image1, top_text=args.text1, bottom_text=None) use(formatObj) elif args.text2 and args.image1: preprocessImages(args.image1) formatObj = Format1(image_path=args.image1, top_text=None, bottom_text=args.text2) use(formatObj) else: print('Missing arguments') if args.format == '2': if args.image1 is not None and args.text1 is not None \ and args.image2 is not None and args.text2 is not None: preprocessImages(args.image1) preprocessImages(args.image2) formatObj = Format2(args.image1, args.image2, args.text1, args.text2) use(formatObj) else: print('Missing arguments') if args.format == '3': if args.image1 is not None and args.text1 is not None \ and args.image2 is not None and args.text2 is not None: text_top = args.text1.split(',') text_bottom = args.text2.split(',') if text_top.__len__() > 2 or text_bottom.__len__() > 2: print("Too many arguements") else: preprocessImages(args.image1) preprocessImages(args.image2) formatObj = Format3(image1_path=args.image1, image2_path=args.image2, top_text=text_top, bottom_text=text_bottom) use(formatObj) else: print("Missing arguements") if args.mode == '1': logo.print_logo() if args.format is not None: format = args.format else: format = input('Enter the format type :') if format == '0': show = input('Generate random image? True/False:') random_meme(show) if format == '1': img = input('Enter the image path: ') print(format1type1, format1type2, format1type3) user_res = input('Select one of the formats (default : 1): ') if user_res == '1': preprocessImages(img) top_text = input('Input the top line here: ') formatObj = Format1(image_path=img, top_text=top_text) elif user_res == '2': preprocessImages(img) bottom_text = input('Input the bottom line here: ') formatObj = Format1(image_path=img, bottom_text=bottom_text) elif user_res == '3': preprocessImages(img) top_text = input('Input the top line here: ') bottom_text = input('Input the bottom line here: ') formatObj = Format1(image_path=img, top_text=top_text, bottom_text=bottom_text) use(formatObj) if format == '2': img1 = input('Enter image 1 path: ') img2 = input('Enter image 2 path: ') top_text = input('Input the top line here: ') bottom_text = input('Input the bottom line here: ') preprocessImages(img1) preprocessImages(img2) formatObj = Format2(img1, img2, top_text, bottom_text) use(formatObj) if format == '3': img1 = input('Enter image 1 path: ') img2 = input('Enter image 2 path: ') preprocessImages(img1) preprocessImages(img2) print(format3type1, format3type2, format3type3, format3type4) type = input('Select the layout of meme (default : 1): ') top_text = list() bottom_text = list() if type == '1' or type == '': text1 = input('Input the top spreading text: ') text2 = input('Input the bottom spreading text: ') top_text.append(text1) bottom_text.append(text2) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) elif type == '2': text1 = input('Input the top spreading text: ') text2 = input('Input the line for first image: ') text3 = input('Input the line for second image: ') top_text.append(text1) bottom_text.append(text2) bottom_text.append(text3) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) elif type == '3': text1 = input('Input the line for first image: ') text2 = input('Input the line for second image: ') text3 = input('Input the bottom spreading line: ') top_text.append(text1) top_text.append(text2) bottom_text.append(text3) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) elif type == '4': text1 = input('Input the top line for first image: ') text2 = input('Input the top line for second image: ') text3 = input('Input the bottom line for first image: ') text4 = input('Input the bottom line for second image: ') top_text.append(text1) top_text.append(text2) bottom_text.append(text3) bottom_text.append(text4) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) use(formatObj) if args.mode == '2': if args.format is not None: format = args.format else: format = input('Enter the format type :') if format == '0': show = input('Generate random image? True/False:') random_meme(show) if format == '1': if args.url1 is not None: url = args.url1 else: url = input('Enter image URL: ') download(url, 'meme_img') img = 'meme_img.jpg' print(format1type1, format1type2, format1type3) user_res = input('Select one of the formats (default : 1): ') if user_res == '1' or user_res == '': preprocessImages(img) top_text = input('Input the top line here: ') formatObj = Format1(image_path=img, top_text=top_text) elif user_res == '2': preprocessImages(img) bottom_text = input('Input the bottom line here: ') formatObj = Format1(image_path=img, bottom_text=top_text) elif user_res == '3': preprocessImages(img) top_text = input('Input the top line here: ') bottom_text = input('Input the bottom line here: ') formatObj = Format1(image_path=img, top_text=top_text, bottom_text=bottom_text) use(formatobj) if format == '2': if args.url1 is not None: url1 = args.url1 else: url1 = input('Enter URL for first Image: ') if args.url2 is not None: url2 = args.url2 else: url2 = input('Enter URL for second Image: ') download(url1, 'meme_img1') download(url2, 'meme_img2') img1 = 'meme_img1.jpg' img2 = 'meme_img2.jpg' top_text = input('Input the top line here: ') bottom_text = input('Input the bottom line here: ') preprocessImages(img1) preprocessImages(img2) formatObj = Format2(img1, img2, top_text, bottom_text) use(formatobj) if format == '3': if args.url1 is not None: url1 = args.url1 else: url1 = input('Enter URL for first Image: ') if args.url2 is not None: url2 = args.url2 else: url2 = input('Enter URL for second Image: ') download(url1, 'meme_img1') download(url2, 'meme_img2') img1 = 'meme_img1.jpg' img2 = 'meme_img2.jpg' print(format3type1, format3type2, format3type3, format3type4) type = input('Select the layout of meme (default : 1): ') top_text = list() bottom_text = list() if type == '1' or type == '': text1 = input('Input the top spreading text: ') text2 = input('Input the bottom spreading text: ') top_text.append(text1) bottom_text.append(text2) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) elif type == '2': text1 = input('Input the top spreading text: ') text2 = input('Input the line for first image: ') text3 = input('Input the line for second image: ') top_text.append(text1) bottom_text.append(text2) bottom_text.append(text3) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) elif type == '3': text1 = input('Input the line for first image: ') text2 = input('Input the line for second image: ') text3 = input('Input the bottom spreading line: ') top_text.append(text1) top_text.append(text2) bottom_text.append(text3) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) elif type == '4': text1 = input('Input the top line for first image: ') text2 = input('Input the top line for second image: ') text3 = input('Input the bottom line for first image: ') text4 = input('Input the bottom line for second image: ') top_text.append(text1) top_text.append(text2) bottom_text.append(text3) bottom_text.append(text4) formatObj = Format3(image1_path=img1, image2_path=img2, top_text=top_text, bottom_text=bottom_text) use(formatobj)
def main(): print_logo() BOARDS = {} LOGGER = new_logger("joerg") async def new_game(websocket, payload): board = init_game() board_id = random.randint(0, 100) BOARDS[board_id] = board LOGGER.info(f"Board {board_id} created!") await websocket.send( json.dumps({ "type": "board", "board_id": board_id, "board": board }, cls=MyEncoder)) async def hello(websocket, path): LOGGER.info(f"{websocket._host}: Connected!") while True: try: raw_payload = await websocket.recv() except websockets.exceptions.ConnectionClosedOK: LOGGER.info(f"{websocket._host}: left") break except websockets.exceptions.ConnectionClosedError: LOGGER.info(f"{websocket._host}: left") break try: payload = json.loads(raw_payload) except json.decoder.JSONDecodeError as jde: msg = f"! Malformed request: {jde}" LOGGER.info(msg) await websocket.send(error(msg)) continue if not isinstance(payload, dict): msg = "! Malformed request, payload must be json object" LOGGER.info(msg) await websocket.send(error(msg)) continue if "type" not in payload: msg = "! Missing key `type` in JSON payload" await websocket.send(error(msg)) continue LOGGER.info(f"< {payload}") payload_type = payload["type"] LOGGER.info(f"New incoming payload: {payload_type}") if payload_type == NEW_GAME_ACTION: LOGGER.info("Here!") await new_game(websocket, payload) continue await websocket.send( json.dumps({"message": "type queried not yet implemented."})) start_server = websockets.serve(hello, "192.168.1.109", 8000) asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_forever()
def cs(): print('\nData file for core-shell type potential.\n') CF = input('Chemical Formula: ') first_line = 'Coreshell: '+CF+'\n\n' cs_nat = int(input('Number of CS atoms type?: ')) cs_symb=[] cs_mass=[] cs_charge=[] cs_n=[] cs_m=[] cs_fn=[] for i in range(0,int(cs_nat)): s = input('Symbol for '+str(i+1)+'-CS atom: ') cs_symb.append(s) m1 = input('Mass for core of '+s+' atom: ') m2 = input('Mass for shell of '+s+' atom: ') c1 = input('Charge for core of '+s+' atom: ') c2 = input('Charge for shell of '+s+' atom: ') cs_mass.append([m1,m2]) cs_charge.append([c1,c2]) cn = input('Atom number for core of '+s+': ') sn = input('Atom number for shell of '+s+': ') cs_n.append([cn,sn]) n = input('Molecule number of '+s+': ') cs_m.append(n) n = input('Number of atoms for '+s+' in complete formula: ') cs_fn.append(int(n)) ncs_nat = int(input('Number of non-CS atoms type?: ')) ncs_symb=[] ncs_mass=[] ncs_charge=[] ncs_n=[] ncs_m=[] ncs_fn=[] for i in range(0,int(ncs_nat)): s = input('Symbol for '+str(i+1)+'-non-CS atom: ') ncs_symb.append(s) m1 = input('Mass of '+s+' atom: ') c1 = input('Charge of '+s+' atom: ') ncs_mass.append(m1) ncs_charge.append(c1) n = input('Atom number of '+s+': ') ncs_n.append(n) n = input('Molecule number of '+s+': ') ncs_m.append(n) n = input('Number of atoms for '+s+' in complete formula: ') ncs_fn.append(int(n)) nr = int(input('Number of replecation of base formula: ')) num_str = str(int(nr)*(2*sum(cs_fn)+sum(ncs_fn)))+' atoms\n'+str(int(nr)*sum(cs_fn))+' bonds\n0 angles\n0 dihedrals\n\n' typ_str = str(2*cs_nat+ncs_nat)+' atoms types\n'+str(cs_nat)+' bonds types \n0 angles types\n0 dihedrals types\n\n' #add_masses ad_mass = 'Masses\n\n' str4='' for ind,i in enumerate(cs_n): str4 += i[0]+'\t'+cs_mass[ind][0]+'\n' str4 += i[1]+'\t'+cs_mass[ind][1]+'\n' for ind,i in enumerate(ncs_n): str4 += i+'\t'+ncs_mass[ind]+'\n' #add_atoms ad_atoms = '\nAtoms\n\n' total_cs_atoms = nr*cs_fn total_ncs_atoms = nr*ncs_fn total = sum(total_cs_atoms) + sum(total_ncs_atoms) exp_bl = 1.6 side = int(math.pow(total,1/3)+1) coords=[] for i in range(side): for j in range(side): for k in range(side): coords.append([str(exp_bl*k),str(exp_bl*j),str(exp_bl*i)]) xyz=[float(min(coords[:][0]))-0.1,float(max(coords[:][0]))+0.1, float(min(coords[:][1]))-0.1,float(max(coords[:][1]))+0.1, float(min(coords[:][2]))-0.1,float(max(coords[:][2]))+0.1] s=['xlo','xhi','ylo','yhi','zlo','zhi'] dim_str = str(xyz[0])+' '+str(xyz[1])+' '+'xlo xhi\n'+str(xyz[2])+' '+str(xyz[3])+' '+'ylo yhi\n'+str(xyz[4])+' '+str(xyz[5])+' '+'zlo zhi\n\n' ind1 = [i for i in range(total)] shuffle(ind1) shift=0 bshift=1 str5='' str3='' str1='' for i in range(nr): for ind,atoms in enumerate(cs_fn): for j in range(atoms): str1 += (str(2*shift+1)+'\t'+cs_m[ind]+'\t'+cs_n[ind][0]+'\t'+cs_charge[ind][0]+'\t'+coords[ind1[shift]][0]+'\t'+coords[ind1[shift]][1]+'\t'+coords[ind1[shift]][2]+'\n') str1 += (str(2*shift+2)+'\t'+cs_m[ind]+'\t'+cs_n[ind][1]+'\t'+cs_charge[ind][1]+'\t'+coords[ind1[shift]][0]+'\t'+coords[ind1[shift]][1]+'\t'+coords[ind1[shift]][2]+'\n') str3 += (str(bshift)+'\t'+str(ind+1)+'\t'+str(2*shift+1)+'\t'+str(2*shift+2)+'\n') str5 += (str(2*shift+1)+'\t'+str(shift+1)+'\n'+ str(2*shift+2)+'\t'+str(shift+1)+'\n') shift += 1 bshift += 1 str2='' nshift = 1*shift for i in range(nr): for ind,atoms in enumerate(ncs_fn): for j in range(atoms): str2 += (str(nshift+shift+1)+'\t'+ncs_m[ind]+'\t'+ncs_n[ind]+'\t'+ncs_charge[ind]+'\t'+coords[ind1[shift]][0]+'\t'+coords[ind1[shift]][1]+'\t'+coords[ind1[shift]][2]+'\n') shift += 1 #add_bond ad_bonds = '\nBonds\n\n' #str3 #add_info ad_info = '\nCS-info\n\n' #str5 all_data = first_line+num_str+typ_str+dim_str+ad_mass+str4+ad_atoms+str1+str2+ad_bonds+str3+ad_info+str5 f = open('./CS_datafile','w+') f.write(all_data) f.close() print('\n\n'+'\033[91m'+'\033[1m'+'Data stored in CS_datafile.'+'\033[0m'+'\n\n') logo.print_logo()
except KeyboardInterrupt: s.close() print '\n[*] NoSQLInjector is shutting down' sys.exit(1) s.close() def print_options_list(): print '[*] proxy port: %i' % listening_port print '[*] proxy host: %s' % host print '[*] inject payload into query parameters: %s' % inject_query_params # main try: print_logo() parser = argparse.ArgumentParser( description='Perform NoSQL injection scan') parser.add_argument( '-qs', '--injectqs', help='inject malicious payload into query string parameters', type=bool, default=False) parser.add_argument('-p', '--port', help='proxy port', type=int, default=8080) parser.add_argument('-host', '--proxyhost',
def main(): lg.print_logo() ct.create_table() run_program()
import snap7 import subprocess import time as t import db import threading import logo city = 1 logo.print_logo() # ~PRINT LOGO def database(): # global city # cnxn = pyodbc.connect(driver = "{FreeTDS}", server = "192.168.2.82", port = 1433, database="prototypedb", user="******", password="******") # cursor = cnxn.cursor() t.sleep(2) # query = f"SELECT * FROM [BarcodesTBL] where how = {0}" # cursor.execute(query) # barcode = cursor.fetchall()[0] # city+=1 # cursor.execute(f"insert into ParcelsTBL values( '{barcode.barcode}','{city}',{counter})") # cnxn.commit() plc = snap7.client.Client() plc.connect('192.168.2.100', 0, 1) me = 0 last = 0 lastsub = 0
def cmd_line(): """Usr inputs option among -a(add todo), -l(list todo), -m(modify todo), -d(delete todo), -c(show category)""" usage = "Usage: %prog [options]" parser = OptionParser(usage=usage, version="%prog 0.0.5") parser.add_option("-a", dest="add", action='store', type=str, default=False, help="add a new todo", metavar="[what] [due(yyyy-mm-dd hh:mm:ss)] [importance(0~5)] [category]") parser.add_option("-l", dest="list", action='store', type=str, default=False, help="list todos by option", metavar="what || due || importance || category [category]") parser.add_option("-m", dest="modify", action='store', type=str, default=False, help="modify the todo", metavar="[org_what] [what] [due(yyyy-mm-dd hh:mm:ss)] [importance(0~5)] [category] [finished(y/n)]") parser.add_option("-d", dest="delete", action='store', type=str, default=False, help="delete the todo", metavar="[what]") parser.add_option("-c", dest="category", action='store_true', default=False, help="show categories") options, args = parser.parse_args() # no option if len(args) == 0 and not (options.add or options.list or options.modify or options.delete or options.category): lg.print_logo() run_program() if options.add: sql = "insert into todo (what, due, importance, category, finished) values (?, ?, ?, ?, ?)" what, due, importance, category = options.add, args[0]+" "+args[1], args[2], args[3] if not dc.isdue(due): print('Invaild input! Please check your input(yyyy-mm-dd hh:mm:ss)') exit() data = [what, due, importance, category, "n"] cur.execute(sql, data) print("ADDED") conn.commit() if options.list: op = options.list if op == 'what': li.list_todo_what() elif op == 'due': li.list_todo_due() elif op == 'importance': li.list_todo_importance() elif op == 'category': # check whether category is exsited in todo table c = args[0] cmp_data = "select distinct category from todo" cur.execute(cmp_data) cmp_records = cur.fetchall() cmp_list = [] for i in range(len(cmp_records)): cmp_list.append(cmp_records[i][0]) if not c in cmp_list: print("There is not", c) li.list_todo_category(c) if options.modify: modify_data = options.modify # check whether there is the modify val in table chk_is_there(modify_data) what, due, importance, category, finished = args[0], args[1]+" "+args[2], args[3], args[4], args[5] sql = "update todo set what = ?, due = ?, importance = ?, category = ?, finished = ? where what = ?" cur.execute(sql, [what, due, int(importance), category, finished, modify_data]) print("MODIFIED") conn.commit() if options.delete: delete_data = options.delete # check whether there is the delete_data val in table chk_is_there(delete_data) del_record = "delete from todo where what = ?" cur.execute(del_record, [delete_data]) print("DELETED") conn.commit() if options.category: ctg.show_category()
def find_conflicts(indiv, n): return [hits(indiv, n, column, indiv[column]) for column in range(n)] ############################################################################### def hits(indiv, n, column, row): total = 0 for i in range(n): if i == column: continue if (indiv[i] == row) or (math.fabs(i - column) == math.fabs(indiv[i] - row)): total += 1 return total ############################################################################### if __name__ == '__main__': print_logo(self=0) print("Starting N-Queen solver with min-conflict algoritm:") boardsize = int(input("please set the board size : ")) print(" board size : ", boardsize) print(" iteration size : ", 10000) print("==================================================================") nqueens(boardsize)
def main(): lg.print_logo() ct.create_table() cmd_line()