def create_device_user(redis, request): _uuid = request.get("uuid") if not _uuid: logging.error("no uuid provided. %s" % request) return None _is_service_user = bool(request.get("is_service_user")) _is_anonymous_user = bool(request.get("is_anonymous_user")) _is_owner_user = bool(request.get("is_owner_user")) _user_email = request.get("user_email") if not _user_email: import strgen _user_email = strgen.StringGenerator("[\d\w]{10}").render( ) + "@" + strgen.StringGenerator("[\d\w]{10}").render() _user_icon = request.get("user_icon") if not _user_icon: _user_icon = random_identicon(_user_email) _user_name = request.get("user_name") _user_mobile = request.get("user_mobile") _user_fullname = request.get("user_fullname") _user_password = request.get("user_password") _user_language = request.get("user_language") or "cn" _ent_user_uuid = request.get("ent_user_uuid") _ent_user_createtime = request.get("ent_user_createtime") import pypinyin if not isinstance(_user_fullname, unicode): _user_fullname = _user_fullname.decode("utf-8") _user_pinyin = "".join(pypinyin.lazy_pinyin(_user_fullname)) _user_py = "".join( pypinyin.lazy_pinyin(_user_fullname, style=pypinyin.FIRST_LETTER)) _values = { "uuid": _uuid, "is_service_user": _is_service_user, "is_owner_user": _is_owner_user, "is_ppmessage_user": _is_ppmessage_user, "is_anonymous_user": _is_anonymous_user, "user_name": _user_name, "user_mobile": _user_mobile, "user_email": _user_email, "user_icon": _user_icon, "user_fullname": _user_fullname, "user_password": _user_password, "user_pinyin": _user_pinyin, "user_py": _user_py, "ent_user_uuid": _ent_user_uuid, "ent_user_createtime": _ent_user_createtime } _row = DeviceUser(**_values) _row.async_add(redis) _row.create_redis_keys(redis) return _values
def generate_user(len_user=6, len_pass=6, russian_username=False, russian_email=False, mask=True): username = strgen.StringGenerator('[a-z]{%d}' % len_user if not russian_username else '[а-я]{%d}' % len_user).render() if mask: email = strgen.StringGenerator('[a-z]{3:5}@[\c]{3:4}.(com|net|ru)').render() elif russian_email: email = strgen.StringGenerator('[а-я]{3:5}@[\c]{3:4}.(com|net|ru)').render() else: email = strgen.StringGenerator('[a-z]{10}').render() password = strgen.StringGenerator('[a-zZ-A0-9]{%d}' % len_pass).render() return username, email, password
async def password(self, ctx, character_length): if int(character_length) > int("120"): embed = discord.Embed( color=self.bot.embed_color, title="→ Password Error!", description= "• Please put in a value equal to or less than 120 characters." ) await ctx.send(embed=embed) elif int(character_length) < int("9"): embed = discord.Embed( color=self.bot.embed_color, title="→ Password Error!", description="• Password length must be at least 10 characters." ) await ctx.send(embed=embed) elif int(character_length) <= int("120"): password = strgen.StringGenerator( f"[\w\d\p]{{{int(character_length)}}}").render() embed = discord.Embed( color=self.bot.embed_color, title="→ Password Sent!", description=f"• The {character_length} " f"character length password has been generated and sent in your Direct Messages!" ) await ctx.send(embed=embed) embed2 = discord.Embed(color=self.bot.embed_color, title="→ Generated Password:"******"• Password: ```{password}```") await ctx.author.send(embed=embed2) logger.info(f"Utility | Sent Password: {ctx.author}")
def generate(self): discordToken = strgen.StringGenerator(self.regularExpression).render() discordToken = discordToken.replace("..", ".") print(discordToken) self.generated += 1 self.write(discordToken) self.title()
def sign_up_now(): error=None first_name=str(request.form['first_name']).strip().title() middle_name=str(request.form['middle_name']).strip().title() last_name=str(request.form['last_name']).strip().title() phone=str(request.form['phone']).strip() email=str(request.form['email']).strip() health_code=str(request.form['health_code']).strip() option=str(request.form['option']) organisation=str(request.form['organisation']) try: password=strgen.StringGenerator("[\d\w]{10}").render() password_hash=str(generate_password_hash(password, 10)) users=Users(First_Name=first_name, Middle_Name=middle_name, Last_Name=last_name, Phone=phone, Email=email, Health_Code=health_code, Organisation=organisation, Level=option, Password_Hash=password_hash, Created_By="*****@*****.**", Status="Amber") db.session.add(users) db.session.commit() except Exception as e: flash("Account already exist!", 'error') return redirect(url_for('signup')) else: try: msg = Message('Preskriber', sender = '*****@*****.**', recipients = [email]) msg.body = "Your account has been created, please wait while we verify your account." mail.send(msg) flash("ACCOUNT CREATED!", 'info') return redirect(url_for('signup')) except: flash("Error B612!", 'error') return redirect(url_for('signup'))
def step_impl(context): context.browser.implicitly_wait(10) context.browser.find_element(By.XPATH, locator.button_register1).click() sleep(1) context.browser.implicitly_wait(10) context.browser.find_element(By.XPATH, locator.form_register) sleep(1) #generate random string for uniq username and email username = strgen.StringGenerator("[\w\d]{5}").render() email = "@email.automation" context.browser.implicitly_wait(10) context.browser.find_element(By.XPATH, locator.input_email).send_keys( "%s%s" % (username, email)) sleep(1) context.browser.implicitly_wait(10) context.browser.find_element(By.XPATH, locator.input_username).send_keys( "%s" % (username)) sleep(1) context.browser.implicitly_wait(10) context.browser.find_element( By.XPATH, locator.input_password1).send_keys("12345678wasd") sleep(1) context.browser.implicitly_wait(10) context.browser.find_element( By.XPATH, locator.input_password2).send_keys("12345678wasd") sleep(1) context.browser.implicitly_wait(10) context.browser.find_element(By.XPATH, locator.button_register2).click() sleep(3)
def get_obj_arr(num_records, avro=False): res_arr = [] a = AvroConvertor() id_start = random.randint(1, 1000000) for i in range(0, num_records): o = {} itms = [] num = random.randint(1, 5) for x in range(0, num): itm = {} itm_id = random.randint(1, 5) qty = random.randint(1, 20) itm['id'] = itm_id itm['name'] = str(strgen.StringGenerator(r'[\d\w]{10}').render()) itm['price'] = random.uniform(1, 100) itms.append(itm) o['items'] = itms o['id'] = id_start id_start += 1 o['timestamp'] = int(round(time.time() * 1000)) days = (datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).days o['dt'] = days if avro: res_arr.append(a.convert(o)) else: obj_str = json.dumps(o) res_arr.append(json.dumps(o).encode('utf-8')) return res_arr
def add_official(): error=None details=(session.get('username')).split("|") if details[1]!="admin": return redirect(url_for('home')) else: first_name=str(request.form['first_name']).strip() middle_name=str(request.form['middle_name']).strip() last_name=str(request.form['last_name']).strip() phone=str(request.form['phone']).strip() email=str(request.form['email']).strip() option=str(request.form['option']) time=str(datetime.datetime.now()) password=strgen.StringGenerator("[\d\w]{10}").render() password_hash=str(generate_password_hash(password, 10)) try: add_official=Users(First_Name=first_name, Middle_Name=middle_name, Last_Name=last_name, Phone=phone, Email=email, Level="official", Organisation=option, Password_Hash=password_hash, Status="Green", Created_By=details[3]) db.session.add(add_official) db.session.commit() except: flash("USER ALREADY EXIST ON PRESKRIBER!", 'error') return redirect(url_for('admin')) else: try: msg=Message('Preskriber-Welcome', sender='*****@*****.**', recipients=email) msg.body="Hello "+first_name+"! "+"Please use this code("+password+") to log into Preskriber. Please remember to change it immediately." mail.send(msg) except: flash("EMAIL ERROR!", 'error') return redirect(url_for('admin')) else: flash("ACCOUNT WAS CREATED SUCCESSFULLY!", 'info') return redirect(url_for('admin'))
def decorator(*args, **kwargs): if not base_config.options.server('secure_frontend_requests'): return func(*args, **kwargs) # Asynchronously delete the incoming SPA token (assigned from a prior request) existing_spa_token = request.cookies.get(COOKIE_SPA_TOKEN) async_delete_token(existing_spa_token) # Generate a new, replacement SPA token new_spa_token = strgen.StringGenerator("[\d\p\w]{50}").render() # Transparently generate a response from the decorated API endpoint and attach the newly # created SPA token as a cookie resp = make_response(*func(*args, **kwargs)) resp.set_cookie(COOKIE_SPA_TOKEN, new_spa_token) # To retain server-side state of this assigned token, synchronously add its value to the # local cache cache.set( name=util.cache.format_key(util.cache.TAG_SPA_TOKEN, new_spa_token), value=True, ex=6 * 60 * 60, # Automated TTL of 6 hours ) return resp
def main(): #version check print(' _ __') print(' /\ /\/_\ / _\ /\ /\ ') print(' / /_/ //_|\ \ \ / /_/ /') print('/ __ / _ \_\ \/ __ / ') print('\/ /_/\_/ \_/\__/\/ /_/ ') #print(requests.__version__) #print(requests.__copyright__) print('url mega bruteforce written by hanihmk#') print( 'requirement: python module StringGenerator install using cmd \'pip install StringGenerator\' ' ) #input url print('Enter $ to bruteforcing area') url = input("Enter the url for bruteforcing random string patterns : ") print('Entered url:', url) url = str(url) if (url.find('$') == -1): print('bruteforcing point not specified ($) will not work !!!') #url = 'https://anonfile.com/' #concatenate pattern+/ #pattern = 'K2wbm2t6nc' n = 0 template = input( 'Enter template of string pattern (find more about template at https://pypi.org/project/StringGenerator/ ): ' ) template = str(template) #template = '[A-Z]{1}[\d]{1}[\c]{3}[0-9]{1}[a-z]{1}[0-9]{1}[\c]{2}' while (1): pattern = strgen.StringGenerator(template).render() #pattern = 'K2wbm2t6nc' url2 = url.replace("$", pattern) #url2 = "%s%s/"%(url,pattern) print('Checking ------ ', url2) #finding status code try: req = urllib.request.Request(url2, headers={'User-Agent': 'Mozilla/5.0'}) connection = urllib.request.urlopen(req) #connection = urllib.request.urlopen(url2) statuscode = connection.getcode() #statuscode = urllib.urlopen(url2).getcode() print(type(statuscode), statuscode) if (statuscode == 200 or 301 or 300): n = n + 1 print(statuscode, '-- got ', n, ' urls') foundedurls = open('output.txt', 'a') foundedurls.write(url2) foundedurls.write('\n') foundedurls.close() connection.close() #except urllib.request.HTTPError or urllib.error.URLError as e: except urllib.error.URLError as e: print(e.reason)
def createalert(self): createalert = [] alert = {} self.name = strgen.StringGenerator("[\d\w\p]{30}").render() print(self.name) alert.update("") pass
def GenerateFilename(formfilesdatafilename): # Quiero el nombre del archivo para obtener la extensión, # pero no voy a usar el nombre del archivo para identificarlo filename = secure_filename(formfilesdatafilename) extension = filename.split('.').pop() # Voy a guardar el archivo con un nombre random. filename = strgen.StringGenerator("[\\d\\w]{20}").render() filename += '.' + extension return {'name': filename, 'ext': extension}
def revise_up(email): error=None details=(session.get('username')).split("|") user=Users.query.filter_by(Email=email).first() if details[1]=="admin": try: password=strgen.StringGenerator("[\d\w]{10}").render() password_hash=str(generate_password_hash(password, 10)) user.Password_Hash=password_hash user.Status="Green" organisation=user.Organisation db.session.commit() talk="Your account has been approved, please use this to log in to preskriber:"+password msg = Message('Preskriber', sender = '*****@*****.**', recipients = [email]) msg.body = talk mail.send(msg) except: flash("Check Email Settings!", 'error') return redirect(url_for('admin')) else: flash("ACCOUNT HAS BEEN APPROVED!", 'info') return redirect(url_for('admin')) elif details[1]=="official" and details[2]==user.Organisation: try: password=strgen.StringGenerator("[\d\w]{10}").render() password_hash=str(generate_password_hash(password, 10)) user.Password_Hash=password_hash user.Status="Green" db.session.commit() talk="Your account has been approved, please use this to log in to preskriber:"+password msg = Message('Preskriber', sender = '*****@*****.**', recipients = [email]) msg.body = talk mail.send(msg) except: flash("Check Email Settings!", 'error') return redirect(url_for('official')) else: flash("ACCOUNT HAS BEEN APPROVED!", 'info') return redirect(url_for('official')) else: flash("PERMISSION ERROR!", 'error') return redirect(url_for('home'))
def misc(): lista_categorias = CategoryList.query.all() password = session.get('password', None) if not password: session['password'] = strgen.StringGenerator("[\\d\\w]{50}").render() print(lista_categorias) return render_template('misc.html', lista_categorias=lista_categorias, nbar='categories')
def a () : randomString1 = strgen.StringGenerator("[\w\c]{5}").render() randomString2 = strgen.StringGenerator("[\w\c]{5}").render() randomString3 = strgen.StringGenerator("[\w\c]{5}").render() randomString4 = strgen.StringGenerator("[\w\c]{6}").render() randomString5 = strgen.StringGenerator("[\w\c]{6}").render() randomString6 = strgen.StringGenerator("[\w\c]{6}").render() randomString7 = strgen.StringGenerator("[\w\c]{6}").render() randomString8 = strgen.StringGenerator("[\w\c]{6}").render() randomString9 = strgen.StringGenerator("[\w\c]{6}").render() randomString10 = strgen.StringGenerator("[\w\c]{6}").render() page = requests.get(Xbeta + randomString1) print (Xbeta + randomString1 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString2) print (Xbeta + randomString2 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString3) print (Xbeta + randomString3 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString4) print (Xbeta + randomString4 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString5) print (Xbeta + randomString5 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString5) print (Xbeta + randomString6 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString2) print (Xbeta + randomString7 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString3) print (Xbeta + randomString8 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString4) print (Xbeta + randomString9 , page.status_code ) time.sleep(1) page = requests.get(Xbeta + randomString5) print (Xbeta + randomString10 , page.status_code )
def configuration(self): """ Configuration property Create a copy of the Chassis dictionary, then fix it up. """ config = self.config.copy() # Change to random string - 3 letters and 10 digits config['SerialNumber'] = strgen.StringGenerator( '[A-Z]{3}[0-9]{10}').render() return config
def index(): if request.method == 'POST' : olink = request.form['olink'] slink = strgen.StringGenerator("[\d\w]{7}").render() check = Link.query.filter_by(slink=slink).first() if not check : new_link = Link(olink,slink,0) db.session.add(new_link) db.session.commit() return render_template('link.html',link=new_link) else : return render_template('index.html') return render_template('index.html')
def get_random_inputs(input_number=10, length=13, mode=None): """ generate random inpust if mode is training, generates minimum 5 images per class otherwise can generate one image per class """ list_for_return = [] str_patt = "[a-z]{" + str(length) + "}" dig_patt = "[0-9]{" + str(length) + "}" if mode == 'train': default_string = 'abcdefghijklmnopqrstuvwxyz' + 'abcdefghijklmnopqrstuvwxyz'.upper( ) + '0123456789' list_for_return = [] div = int(len(default_string) / length) for i in range(div): list_for_return.append(default_string[i * length:(i + 1) * length]) passed = length * div list_for_return.append(default_string[passed:]) input_number = int(input_number) input_number -= len(list_for_return) for i in range(1, int(input_number) + 1): if i % 3 == 0: list_for_return.append( strgen.StringGenerator(str_patt).render().upper()) elif i % 9 == 0: list_for_return.append( strgen.StringGenerator(dig_patt).render().upper()) else: list_for_return.append( strgen.StringGenerator(str_patt).render().lower()) return list_for_return
def store_credentials_to_file(user_name, password): website = raw_input( "\nEnter the name of the websites you want to store credentials for:\n" ) strong_password = strgen.StringGenerator("[\d\w]{24}").render() text = str(strong_password) + "aaaaaaaa" key = password encryption_suite = AES.new(key, AES.MODE_CBC, 'This is an IV456') cipher_text = encryption_suite.encrypt(text) saved_cipher = repr(cipher_text) f = open("user_%s" % user_name, 'a+') f.write(website + "and" + saved_cipher) f.write("\n") f.close()
def get_EgResource_instance(wildcards): """ Creates an instance of TEMPLATE and replaces wildcards as specfied. Also sets any unique values. Arguments: wildcard - A dictionary of wildcards strings and their replacement values """ c = copy.deepcopy(_TEMPLATE) replace_recurse(c, wildcards) # print ("fini c: ", c) c['SerialNumber'] = strgen.StringGenerator('[A-Z]{3}[0-9]{10}').render() return c
def createTmpTable(db, sts, point: coordinates.point): tablename = strgen.StringGenerator("[a-z]{15}").render() cursor = db.cursor() cursor.execute( "create table {tname} (id bigint, distance integer);".format( tname=tablename)) basequerystr = 'insert into {tname} (id, distance) values '.format( tname=tablename) arglist = [] for o in sts: distance = coordinates.calculateDistance(point, o.coordinates) stringa = cursor.mogrify("(%s,%s)", (int(o.companyID), distance)) arglist.append(stringa.decode("utf-8")) args = ",".join(arglist) cursor.execute(basequerystr + args) db.commit() cursor.close() return tablename
def password_generate(length=8): """ Generate random password with minimum 2 digits, 2 uppercase and 2 lowercase chars Exclude symbols: I,l,1,O,0 """ if length < 6: length = 6 accepted_symbols_lower = 'abcdefghijkmnopqrstuvwxyz' accepted_symbols_upper = 'ABCDEFGHJKLMNPQRSTUVWXYZ' accepted_digits = '23456789' accepted_chars = accepted_symbols_upper + accepted_symbols_lower + accepted_digits password_mask = '[{chars}]{{{length}}}&[{digits}]{{2}}&[{upper}]{{2}}&[{lower}]{{2}}'.format( length=length - 6, lower=accepted_symbols_lower, upper=accepted_symbols_upper, digits=accepted_digits, chars=accepted_chars) return strgen.StringGenerator(password_mask).render()
def get_Chassis_template(rest_base, ident): """ Formats the template Arguments: rest_base - Base URL for the RESTful interface indent - ID of the chassis """ c = copy.deepcopy(_CHASSIS_TEMPLATE) c['@odata.context'] = c['@odata.context'].format(rb=rest_base) c['@odata.id'] = c['@odata.id'].format(rb=rest_base, id=ident) c['Id'] = c['Id'].format(id=ident) c['Thermal']['@odata.id'] = c['Thermal']['@odata.id'].format(rb=rest_base, id=ident) c['Power']['@odata.id'] = c['Power']['@odata.id'].format(rb=rest_base, id=ident) c['Links']['ManagedBy'][0]['@odata.id'] = c['Links']['ManagedBy'][0]['@odata.id'].format(rb=rest_base, id=ident) c['Links']['ComputerSystems'][0]['@odata.id']=c['Links']['ComputerSystems'][0]['@odata.id'].format(rb=rest_base) c['SerialNumber'] = strgen.StringGenerator('[A-Z]{3}[0-9]{10}').render() return c
def gpsapi(): """(re)Generate and/or present API key.""" form = ApiForm(request.form) hasapi = ApiKey.query.filter_by(user_id=current_user.get_id()).all() # Handle regeneration of API key if request.method == "POST": if form.validate_on_submit(): apikey = strgen.StringGenerator("[\w\d]{10}").render() ApiKey.create(user_id=current_user.get_id(), apikey=apikey) db.session.commit() current_app.logger.info("API key has been added.") flash("API key {} has been added.".format(apikey), "info") return redirect(url_for("gpsdb.gpsapi")) else: flash_errors(form) # No regeneration request apikey = [] if hasapi: for x in hasapi: apikey.append(x.apikey) db.session.close() return render_template("gpsdb/apikey.html", form=form, apikeys=apikey)
def generateString(): hostname = strgen.StringGenerator("[\w\d]{10}").render() num = random.random() sap_id = int(num * 100) def ipAdd(n): ip_add = '' for i in range(n): num1 = random.random() num1 *= 1000 ip_add += str(int(num1)) + '.' return ip_add[:-1] data = { 'sap_id': sap_id, 'hostname': hostname, 'ip_address': ipAdd(4), 'mac_address': ipAdd(5) } return data
def reset_account(): error=None email=str(request.form['email']).strip().lower() try: email=Users.query.filter_by(Email=email).first() except: flash("ACCOUNT DOESN'T EXIST!", 'info') return redirect(url_for('reset')) else: try: name_0=email.First_Name password=strgen.StringGenerator("[\d\w]{10}").render() msg=Message('Preskriber', sender='*****@*****.**', recipients=email) msg.body="Hello "+name_0+", please use this code to access Preskriber." mail.send(msg) except: flash("EMAIL ERROR!", 'info') return redirect(url_for('reset')) else: password_hash=str(generate_password_hash(password, 10)) user.Password_Hash=password_hash db.session.commit()
def add_affliate(): error=None details=(session.get('username')).split("|") username=details[0] level=details[1] if level not in ['pharmacist']: return redirect(url_for('home')) else: first_name=str(request.form['first_name']).strip() middle_name=str(request.form['middle_name']).strip() last_name=str(request.form['last_name']).strip() email=str(request.form['email']).strip() phone=str(request.form['last_name']).strip() store_name=str(request.form['store_name']).strip() store_address=str(request.form['last_name']).strip() address=store_name+"- "+store_address user=Users.query.filter_by(Email=details[3]).first() code=user.Health_Code password=strgen.StringGenerator("[\d\w]{10}").render() password_hash=str(generate_password_hash(password, 10)) try: msg=Message('Preskriber-Affliate', sender='*****@*****.**', recipients=email) msg.body="Hello "+first_name+"! "+"Please use this code("+password+") to log into Preskriber. Please remember to change it immediately." mail.send(msg) except: flash("EMAIL ERROR!", 'error') return redirect(url_for('home')) else: try: add_affliate=Users(First_Name=first_name, Middle_Name=middle_name, Last_Name=last_name, Phone=phone, Email=email, Address=address, Level='affliate', Organisation=details[2], Health_Code=code, Password_Hash=password_hash, Status="Green", Created_By=details[3]) db.session.add(add_affliate) db.session.commit() except: flash("EMAIL ERROR!", 'error') return redirect(url_for('home')) else: flash("SUCCESSFULLY ADDED AFFLIATE INTO CIRCLE!", 'info') return redirect(url_for('home'))
def random_slug(name): randstr=strgen.StringGenerator("[\d\w]{4}").render() sl = "{name}-{randstr}".format( name=name , randstr = randstr ) return sl
def generate_email() -> str: """Generates a random mail address starts with 'locustn11tester'""" email = "locustn11tester" + strgen.StringGenerator( "[a-z]{5}[0-9]{5}").render() + "@mailinator.com" return email
import strgen f = open("data.txt", "a") f.write(strgen.StringGenerator("[\d\w]{3}").render()) f.close() print("hi") import os os.system("git init") print(1) os.system("git remote add origin https://github.com/globefire/Goals.git") print(2) os.system("git add .") print(3) os.system('git commit -m "a new commit"') print(4) os.system('git push origin master') print(5)