def checkGRID(self): dd = """( other.GlueCEUniqueID == "deimos.htc.biggrid.nl:2119/jobmanager-pbs-medium" || other.GlueCEUniqueID == "pbs-enmr.cerm.unifi.it:8443/cream-pbs-verylong");""" if os.path.exists("/opt/checkGRID/pickle.pck"): file_pickle = open("/opt/checkGRID/pickle.pck", "r") # read mode job = pickle.load(file_pickle) else: print "NO JOBS INFORMATIONS " return dd #pprint(job) queue_time = 1441 ce_sub = [] for check_ce in job.keys(): if job[check_ce].has_key("status"): if job[check_ce]["status"] == "OK": if job[check_ce].has_key("VOMaxCPUTime"): time = job[check_ce]["VOMaxCPUTime"] if time.isdigit(): if int(job[check_ce] ["VOMaxCPUTime"]) > queue_time and int( job[check_ce] ["VOMaxCPUTime"]) < 9999999999: ce_sub.append(check_ce) #print ce_sub if len(ce_sub) > 0: list_cet = "(" for i in ce_sub: list_cet = list_cet + ' other.GlueCEUniqueID == "%s" ||' % i list_ce = list_cet[:-2] + ")" else: list_ce = dd return list_ce
def checkToStart(self, time) -> bool: # upload data data = json.load(open('./options/options.json', 'r')) # Learn the number of elements in DataBase DBlength = ManageDataBase().check_length_db() # number check isdigitTime = time.isdigit() if isdigitTime: if int(time) > 0: if data['Work'] == 0: if DBlength: if data['Mode'] == 0: return True else: messagebox.showerror( 'Error', f'Чтоб снова запустить режим подождите {time} секунд.' ) return False else: messagebox.showerror( 'Error', 'В базе данных нет ни единого слова.') return False else: messagebox.showerror('Error', 'Режим уже был запущен.') return False else: messagebox.showerror('Error', 'Некоректное количество секунд.') return False else: messagebox.showerror('Error', 'Вы указали вместо секунд буквы.') return False
async def slowmode(self, ctx, time): """Puts the current channel in slowmode. Usage: ;slowmode [time/"off"] time = time of the cooldown between messages a user has. off = turns off slowmode for this channel""" if time == "off" and self.slow_mode: # Turn Slow Mode off self.slow_mode = False self.slow_mode_channels.pop(ctx.channel.id) self.users.pop(ctx.channel.id) return await ctx.send("Slowmode off") elif time.isdigit() and not self.slow_mode: # Turn Slow Mode On self.users[ctx.channel.id] = {} self.slow_mode_channels[ctx.channel.id] = int(time) self.slow_mode = True return await ctx.send( "Slowmode on :snail: ({} seconds)".format(time)) elif time.isdigit and self.slow_mode: # Change value of Slow Mode timer self.slow_mode_channels[ctx.channel.id] = int(time) return await ctx.send( "Slowmode set to :snail: ({} seconds)".format(time)) else: pass
def ValidateListTimes(self, time): if (not time.isdigit() or int(time) >= 1440): self.SendNotice( 'second option must be an integer between 1 and 1440 (24 hours)' ) else: return True
def parseTime(time): if time.isdigit(): return int(time) table = { 's': 1, 'sec': 1, 'secs': 1, 'second': 1, 'seconds': 1, 'm': 60, 'min': 60, 'mins': 60, 'minute': 60, 'minutes': 60, 'h': 60 * 60, 'hour': 60 * 60, 'hours': 60 * 60 } for expr in table: if time.endswith(expr): firstPart = time[:-(len(expr))] if firstPart.isdigit(): return int(firstPart) * table[expr] return 3 * 60
def ask_time_limit(puzzle): """ Allow the user to choose a time limit for the program """ time = input("\nChoose a time limit (in seconds) : ") while time.isdigit() == 0: time = input( "\nChoose a time limit (in seconds and in digit plz -_-) : ") puzzle.time_limit = int(time)
def _parse_time(time): if any(u in time for u in UNIT_TABLE.keys()): delim = '([0-9.]*[{}])'.format(''.join(UNIT_TABLE.keys())) time = re.split(delim, time) time = sum([_timespec_sec(t) for t in time if t != '']) elif not time.isdigit(): raise BadTimeExpr("invalid expression '%s'" % time) return int(time)
def main(time, localTime=True): # convert 64bit timestamp to time string if time.isdigit(): time = long(time) return timeStamptoDate(time, localTime) # convert time string to 64bit timestamp else: return packFromString(time, localTime)
def Format(self, time=0, tformat='%s', read_format='%S'): if time in [0, '0', None]: return datetime.now().strftime(tformat) elif isinstance(time, int) or (isinstance(time, str) and time.isdigit()): if read_format == '%S': return datetime.fromtimestamp(int(time)).strftime(tformat) else: return datetime.strptime(str(time), read_format).strftime(tformat)
def setup(): global timeLimit board = [["-"] * 8 for i in range(8)] print "4 in a Line Game!" print "Would you like to go first (y/n)? : ", first = raw_input() print "How much time will the AI run for? (in seconds) : ", time = raw_input() if time.isdigit(): timeLimit = int(time) return [board, first]
def print_text(link): page = requests.get(link) soup = BeautifulSoup(page.text) for row in soup.findAll('li', {'class':'g'}): titles = row.find('h3') summarys = row.find('div',{'class':'st'}) date = row.find('span', {'class':'f'}) title = titles.text.encode('utf-8') + '\n' #title_test= titles.text.encode('utf-8') Summary_test = summarys.text.encode('utf-8') + '\n' cleanCom = r'à|ä|í|ç|õ|ô|é|è|ó|ü|ă|â|ç|õ|' text_clean = re.sub(cleanCom,'',title) Summary = re.sub(cleanCom,'',Summary_test) print title print Summary titless = text_clean.replace(' ','') titlesss = titless.decode('utf-8') if titlesss >= u'\u4e00' and titlesss <= u'\u9fa5': print '中文排除' break times = date.text time = times.title()[-4:] if time.isdigit(): a = times.split("-")[-1:] b = ''.join(a) c = datetime.strptime(b, " %b %d, %Y") dates = c.strftime("%Y%m%d") print dates data_insert(dates,title,Summary) else : time = times.title()[-9:-4] if time == "nutes": number = re.search(r"(\d+)", times).group() time = datetime.now() - timedelta(minutes= int(number)) dates = time.strftime('%Y%m%d') print dates data_insert(dates,title,Summary) elif time == "Hours": number = re.search(r"(\d+)", times).group() time = datetime.now()-timedelta(hours = int(number)) dates = time.strftime('%Y%m%d') print dates data_insert(dates,title,Summary) else : number = re.search(r"(\d+)", times).group() time = datetime.now() - timedelta(days= int(number)+1) dates = time.strftime('%Y%m%d') print dates data_insert(dates,title,Summary) get_Next(link)
def setBlockTime(self,time): if not time.isdigit() or float(time) < 0: return "This is not a valid entry." if float(time) > MAX_BLOCK_LIMIT: return "are you sure you want to block your password the long?" if self.blockerNotSet(): newTime = timeram.getCurrentTime() + ( int(time) * 60 ) timeram.updateStopTime(newTime) return "Temporary block time has begun." else: return "Block Time: " + self.getTimeLeftInMinutes() + "."
def vaildate(self): back = self.backupPathT.GetValue() target = self.targetPathT.GetValue() time: str = self.timePathT.GetValue() if len(back) == 0 or len(target) == 0 or len(time) == 0: msg = wx.MessageDialog(None, u'填写信息不全,请重新填写!', u'警告', wx.OK) msg.ShowModal() return False if not time.isdigit(): msg = wx.MessageDialog(None, u'时间格式不正确,请重新填写', u'警告', wx.OK) msg.ShowModal() return False return True
def get_time(requestMsg, errorMsg): """ requestMsg: String, prompt user to input time limit for players errorMsg: String, prompt user the input time is in wrong format return: Float, the time limit for players """ inputOK = False time = "" while not inputOK: time = raw_input(requestMsg) if time.isdigit(): inputOK = True return float(time)
async def mute(self, ctx, user: discord.Member = None, time=None): perms = ctx.message.author.permissions_in(ctx.channel) if not perms.manage_messages: em = discord.Embed( title=":x: Error!", description="You have insufficient permissions!", colour=discord.Colour.red()) msg = await ctx.send(embed=em) await asyncio.sleep(3) await msg.delete() else: if user == None: em = discord.Embed( title=":x: Error!", description="Enter a member's name to mute!", colour=discord.Colour.red()) msg = await ctx.send(embed=em) await asyncio.sleep(3) await msg.delete() else: if time == None: await ctx.channel.set_permissions(user, send_messages=False) em = discord.Embed( title="Muted", description= "Finally peace and quiet, we don't get much of that in hell.", colour=discord.Colour.green()) await ctx.send(embed=em) else: if not time.isdigit(): em = discord.Embed( title=":x: Error!", description="Enter the time in seconds", colour=discord.Colour.red()) msg = await ctx.send(embed=em) await asyncio.sleep(3) await msg.delete() else: time = int(time) await ctx.channel.set_permissions(user, send_messages=False) em = discord.Embed( title="Muted for {} seconds".format(time), description= "Finally peace and quiet, we don't get much of that in hell.", colour=discord.Colour.green()) await ctx.send(embed=em) await asyncio.sleep(time) await ctx.channel.set_permissions(user, send_messages=True)
def sessionPeriod(self, session, *args, **kwargs): span = kwargs.get('span', 'hour') time = kwargs.get('time', '') upto = kwargs.get('upto', '') for k in ('time', 'span', 'upto', 'end'): if 'phedex.period.' + k in session: del session['phedex.period.' + k] if time.isdigit(): session['phedex.period.time'] = int(time) if span in ('hour', 'day', 'week', 'month', 'year'): session['phedex.period.span'] = span if upto != '': if session.get('phedex.period.span', 'hour') == 'week': if re.match(r'^\d{6}$', upto): # January 4th is always in (ISO) week one, so find out what # day of week that is, then go back to Monday of that week, # and advance specified number of weeks plus one. jan4 = time2gm(year=int(upto[0:4]), month=1, day=4, hour=23, minute=59, second=59) session['phedex.period.upto'] = upto session['phedex.period.end'] = \ jan4 + (-gmtime(jan4).tm_wday + 7*(int(upto[4:6])-1))*86400 else: if re.match(r'^\d{6}$', upto): session['phedex.period.upto'] = upto session['phedex.period.end'] = \ time2gm(year=int(upto[0:4]), month=int(upto[4:6])+1, day=1, hour=23, minute=59, second=59) - 86400 elif re.match(r'^\d{8}$', upto): session['phedex.period.upto'] = upto session['phedex.period.end'] = \ time2gm(year=int(upto[0:4]), month=int(upto[4:6]), day=int(upto[6:8]), hour=23, minute=59, second=59) elif re.match(r'^\d{8}[Z ]\d{4}$', upto): session['phedex.period.upto'] = upto session['phedex.period.end'] = \ time2gm(year=int(upto[0:4]), month=int(upto[4:6]), day=int(upto[6:8]), hour=int(upto[9:11]), minute=59, second=59) self.gui._saveSession(session) return self._state(session)
def from_timestamp(cls, source, time): filename = ytdl.prepare_filename(source.data) options = ffmpeg_options.copy() options['before_options'] = '-nostdin -ss {}'.format(time) if not time.isdigit(): time = time.split(':') seconds = int(time[-1]) if len(time) > 1: seconds += int(time[-2]) * 60 if len(time) > 2: seconds += int(time[-3]) * 3600 else: seconds = int(time) source.data['modified_duration'] = source.data['duration'] - seconds return cls(discord.FFmpegPCMAudio(filename, **options), data=source.data)
def sessionPeriod(self, session, *args, **kwargs): span = kwargs.get('span', 'hour') time = kwargs.get('time', '') upto = kwargs.get('upto', '') for k in ('time', 'span', 'upto', 'end'): if 'phedex.period.' + k in session: del session['phedex.period.' + k] if time.isdigit(): session['phedex.period.time'] = int(time) if span in ('hour', 'day', 'week', 'month', 'year'): session['phedex.period.span'] = span if upto != '': if session.get('phedex.period.span', 'hour') == 'week': if re.match(r'^\d{6}$', upto): # January 4th is always in (ISO) week one, so find out what # day of week that is, then go back to Monday of that week, # and advance specified number of weeks plus one. jan4 = time2gm(year=int(upto[0:4]), month=1, day=4, hour=23, minute=59, second=59) session['phedex.period.upto'] = upto session['phedex.period.end'] = \ jan4 + (-gmtime(jan4).tm_wday + 7*(int(upto[4:6])-1))*86400; else: if re.match(r'^\d{6}$', upto): session['phedex.period.upto'] = upto session['phedex.period.end'] = \ time2gm(year=int(upto[0:4]), month=int(upto[4:6])+1, day=1, hour=23, minute=59, second=59) - 86400 elif re.match(r'^\d{8}$', upto): session['phedex.period.upto'] = upto session['phedex.period.end'] = \ time2gm(year=int(upto[0:4]), month=int(upto[4:6]), day=int(upto[6:8]), hour=23, minute=59, second=59) elif re.match(r'^\d{8}[Z ]\d{4}$', upto): session['phedex.period.upto'] = upto session['phedex.period.end'] = \ time2gm(year=int(upto[0:4]), month=int(upto[4:6]), day=int(upto[6:8]), hour=int(upto[9:11]), minute=59, second=59) self.gui._saveSession(session) return self._state(session)
def get_duration(time): seconds = 0 #check the format time = time.split(" ") str_len = len(time) if (str_len == 2): #print ("minutes and seconds") if(time[0][-1] != 'm' or time[1][-1] != 's'): print ("wrong format") return -1 else: if(time[0][:-1].isdigit() == False or time[1][:-1].isdigit() == False): #print ("wrong format") return -1 seconds = 60*int(time[0][:-1]) + int(time[1][:-1]) elif(str_len == 1): time = str(time[0]) #print ("minutes or seconds only") if(time[-1] != 'm' and time[-1] != 's'): if(time.isdigit() == False): print ("wrong format") return -1 if(time[-1] == 'm'): if(time[:-1].isdigit() == False): print ("wrong format") return -1 else: seconds = 60*int(time[:-1]) elif(time[-1] == 's'): if(time[:-1].isdigit() == False): print ("wrong format") return -1 else: seconds = int(time[:-1]) else: seconds = int(time) else: print ("wrong format") return -1 return seconds
def setKeyStop(request, username, group): response = {'code': '0', 'errormsg': ''} if request.method == 'POST': reqInfo = json.loads(str(request.body, encoding='utf-8')) keyList = reqInfo.get('keyList', None) time = reqInfo.get('time', None) if type(time) == str and time.isdigit(): time = int(time) if keyList != None and time != None and type(time) == int: keyword = ','.join(keyList) obj = KeyStop.objects.filter(group=group) if obj.exists(): obj.update(keyword=keyword, time=time) else: KeyStop.objects.create(group=group, keyword=keyword, time=time) else: response['code'] = '-2' response['errormsg'] = '传入数据有误' return HttpResponse(json.dumps(response))
def time_selected(time): if time.lower() == 'c': self.update_status_text() return True if not time.isdigit(): return False seconds = int(time) if seconds > 300: self.print('Max time is 300 seconds') return False self._obs_data['commands'][new_command] = { 'action': action, 'filter': filter, 'source': source, 'time': seconds } self.save_module_data(self._obs_data) self.update_status_text() self.print(f'Command !{new_command} successfully added') return True
def _parse_iso_8601(value): """ Parses an ISO8601:2004 date time string. """ # remove trailing 'Z' value = value.replace('Z', '') # split between date and time try: (date, time) = value.split("T") except: date = value time = "" # remove all hyphens in date date = date.replace('-', '') # remove colons in time time = time.replace(':', '') # guess date pattern length_date = len(date) if date.count('W') == 1 and length_date == 8: # we got a week date: YYYYWwwD # remove week indicator 'W' date = date.replace('W', '') date_pattern = "%Y%W%w" year = int(date[0:4]) # [Www] is the week number prefixed by the letter 'W', from W01 # through W53. # strpftime %W == Week number of the year (Monday as the first day # of the week) as a decimal number [00,53]. All days in a new year # preceding the first Monday are considered to be in week 0. week = int(date[4:6]) - 1 # [D] is the weekday number, from 1 through 7, beginning with # Monday and ending with Sunday. # strpftime %w == Weekday as a decimal number [0(Sunday),6] day = int(date[6]) if day == 7: day = 0 date = "%04d%02d%1d" % (year, week, day) elif length_date == 7 and date.isdigit() and value.count('-') != 2: # we got a ordinal date: YYYYDDD date_pattern = "%Y%j" elif length_date == 8 and date.isdigit(): # we got a calendar date: YYYYMMDD date_pattern = "%Y%m%d" else: raise ValueError("Wrong or incomplete ISO8601:2004 date format") # check for time zone information # note that the zone designator is the actual offset from UTC and # does not include any information on daylight saving time if time.count('+') == 1 and '+' in time[-6:]: (time, tz) = time.rsplit('+') delta = -1 elif time.count('-') == 1 and '-' in time[-6:]: (time, tz) = time.rsplit('-') delta = 1 else: delta = 0 if delta: while len(tz) < 3: tz += '0' delta = delta * (int(tz[0:2]) * 60 * 60 + int(tz[2:]) * 60) # split microseconds ms = 0 if '.' in time: (time, ms) = time.split(".") ms = float('0.' + ms.strip()) # guess time pattern length_time = len(time) if length_time == 6 and time.isdigit(): time_pattern = "%H%M%S" elif length_time == 4 and time.isdigit(): time_pattern = "%H%M" elif length_time == 2 and time.isdigit(): time_pattern = "%H" elif length_time == 0: time_pattern = "" else: raise ValueError("Wrong or incomplete ISO8601:2004 time format") # parse patterns dt = datetime.datetime.strptime(date + 'T' + time, date_pattern + 'T' + time_pattern) # add microseconds and eventually correct time zone return UTCDateTime(dt) + (float(delta) + ms)
def TimeAddSign( time ): sign=':' if( len( time ) == 6 and time.isdigit( ) ): return time[0:2]+sign+time[2:4]+sign+time[4:6] else: return time
def _parse_time(time): time = time.lower() if not time.isdigit(): time = re.split(r'\s*([\d.]+\s*[^\d\s,;]*)(?:[,;\s]|and)*', time) time = sum(map(_timespec_sec, filter(None, time))) return int(time)
def Execute(data): if data.IsChatMessage(): command = data.GetParam(0) if command == ScriptSettings.TTSCommand and IsFromValidSource( data, ScriptSettings.TTSCommandUsage, ScriptSettings.TTSCommandUsageReply, ScriptSettings.TTSCommandUsageReplyMessage): if HasPermission(data, ScriptSettings.TTSCommandPermission, ScriptSettings.TTSCommandPermissionInfo): if not IsOnCooldown(data, ScriptSettings.TTSCommand, ScriptSettings.TTSCasterCD, ScriptSettings.TTSUseCD, ScriptSettings.TTSOnCooldown, ScriptSettings.TTSOnUserCooldown): if HasCurrency(data, ScriptSettings.TTSCommandCost): commandOffset = len(ScriptSettings.TTSCommand) + 1 text = data.Message[commandOffset:] message = ScriptSettings.TTSCommandMessage.format( user=data.UserName, message=text) messageThread = threading.Thread( target=SendTTSMessage, args=(spk, message, False, data.UserName.lower(), text, data.UserName)) messageThread.daemon = True messageThread.start() Parent.AddUserCooldown(ScriptName, ScriptSettings.TTSCommand, data.User, ScriptSettings.TTSUserCooldown) Parent.AddCooldown(ScriptName, ScriptSettings.TTSCommand, ScriptSettings.TTSCooldown) elif command == ScriptSettings.BanWordCommand and HasPermission( data, ScriptSettings.BanWordCommandPermission, ScriptSettings. BanWordCommandPermissionInfo) and data.GetParamCount() > 1: message = data.GetParam(1) i = 2 while i < data.GetParamCount(): message = message + ' ' + data.GetParam(i) i = i + 1 if message: global bannedWords isPhrase = (' ' in message) if message in bannedWords: bannedWords.remove(message) if isPhrase: Parent.SendStreamMessage( ScriptSettings.BanWordRemoveResponse.format( user=data.UserName, word=message)) else: Parent.SendStreamMessage( ScriptSettings.BanWordRemoveResponse.format( user=data.UserName, word=message)) else: bannedWords.append(message) if isPhrase: Parent.SendStreamMessage( ScriptSettings.BanWordAddResponse.format( user=data.UserName, word=message)) else: Parent.SendStreamMessage( ScriptSettings.BanWordAddResponse.format( user=data.UserName, word=message)) writeArrayToFile(bannedWords, BannedWordFile) updateBannedSettings() elif command == ScriptSettings.BanUserCommand and HasPermission( data, ScriptSettings.BanUserCommandPermission, ScriptSettings. BanUserCommandPermissionInfo) and data.GetParamCount() > 1: user = data.GetParam(1).lower() if user: handleBanUser(data, user) if data.GetParamCount() > 2: time = data.GetParam(2) if time.isdigit(): banThread = threading.Timer(int(time), handleBanUser, args=(data, user)) banThread.daemon = True banThread.start() if ScriptSettings.TTSAllChat and IsFromValidSource( data, ScriptSettings.TTSAllChatUsage, ScriptSettings.TTSAllChatUsageReply, ScriptSettings.TTSAllChatUsageReplyMessage): if not ScriptSettings.TTSAllChatExcludeCommands or command[ 0] != '!': if "msg-id=highlighted-message" in data.RawData: message = ScriptSettings.TTSAllChatMessage.format( user=data.UserName, message=data.Message) messageThread = threading.Thread( target=SendTTSMessage, args=(spk, message, False, data.UserName.lower(), data.Message, data.UserName)) messageThread.daemon = True messageThread.start() # End of execute return
def _parseISO8601(value): """ Parses an ISO8601:2004 date time string. """ # remove trailing 'Z' value = value.replace('Z', '') # split between date and time try: (date, time) = value.split("T") except: date = value time = "" # remove all hyphens in date date = date.replace('-', '') # remove colons in time time = time.replace(':', '') # guess date pattern length_date = len(date) if date.count('W') == 1 and length_date == 8: # we got a week date: YYYYWwwD # remove week indicator 'W' date = date.replace('W', '') date_pattern = "%Y%W%w" year = int(date[0:4]) # [Www] is the week number prefixed by the letter 'W', from W01 # through W53. # strpftime %W == Week number of the year (Monday as the first day # of the week) as a decimal number [00,53]. All days in a new year # preceding the first Monday are considered to be in week 0. week = int(date[4:6]) - 1 # [D] is the weekday number, from 1 through 7, beginning with # Monday and ending with Sunday. # strpftime %w == Weekday as a decimal number [0(Sunday),6] day = int(date[6]) if day == 7: day = 0 date = "%04d%02d%1d" % (year, week, day) elif length_date == 7 and date.isdigit() and value.count('-') != 2: # we got a ordinal date: YYYYDDD date_pattern = "%Y%j" elif length_date == 8 and date.isdigit(): # we got a calendar date: YYYYMMDD date_pattern = "%Y%m%d" else: raise ValueError("Wrong or incomplete ISO8601:2004 date format") # check for time zone information # note that the zone designator is the actual offset from UTC and # does not include any information on daylight saving time if time.count('+') == 1 and '+' in time[-6:]: (time, tz) = time.rsplit('+') delta = -1 elif time.count('-') == 1 and '-' in time[-6:]: (time, tz) = time.rsplit('-') delta = 1 else: delta = 0 if delta: tz = tz.replace(':', '') # XXX: not needed while len(tz) < 3: tz += '0' delta = delta * (int(tz[0:2]) * 60 * 60 + int(tz[2:]) * 60) # split microseconds ms = 0 if '.' in time: (time, ms) = time.split(".") ms = float('0.' + ms.strip()) # guess time pattern length_time = len(time) if length_time == 6 and time.isdigit(): time_pattern = "%H%M%S" elif length_time == 4 and time.isdigit(): time_pattern = "%H%M" elif length_time == 2 and time.isdigit(): time_pattern = "%H" elif length_time == 0: time_pattern = "" else: raise ValueError("Wrong or incomplete ISO8601:2004 time format") # parse patterns dt = datetime.datetime.strptime(date + 'T' + time, date_pattern + 'T' + time_pattern) # add microseconds and eventually correct time zone return UTCDateTime(dt) + (float(delta) + ms)
def ping(): p=1 os.system("touch hackfiles/config") while p!=0: try: os.system("dialog --ascii-lines --backtitle 'ThE PaNtHeR' --title 'PING an IP/Website' --menu 'Select an Option' 25 70 7 1 'Increase or Decrease the Time Interval Between Packets' 2 'Send N packets and stop' 3 'Flood the network' 4 'Audible ping: Give beep when the peer is reachable' 5 'Change Ping Packet Size' 2> hackfiles/temp") fh=open("hackfiles/temp", "r") ch=fh.read() fh.close() if ch=="": break elif int(ch)==1: inputbox("Enter the IP/Website Name:-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") ip=fh.read().strip() fh.close() inputbox("Enter the time interval b/w the packets (in sec):-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") time=fh.read().strip() fh.close() if ip!="" and time.isdigit(): os.system("ping -i "+time+" "+ip) wait() elif int (ch)==2: inputbox("Enter the IP/Website Name:-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") ip=fh.read().strip() fh.close() inputbox("Enter the No. of Packets which you want to send:-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") N=fh.read().strip() fh.close() if ip!="" and N.isdigit(): os.system("ping -c "+N+" "+ip) wait() elif int (ch)==3: inputbox("Enter the IP/Website Name:-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") ip=fh.read().strip() fh.close() if ip!="": os.system("ping -f "+ip) wait() elif int (ch)==4: inputbox("Enter the IP/Website Name which you want to flood:-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") ip=fh.read().strip() fh.close() if ip!="": os.system("ping -a "+ip) wait() elif int(ch)==5: inputbox("Enter the IP/Website Name:-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") ip=fh.read().strip() fh.close() inputbox("Enter the size of packet data:-","15","60","hackfiles/temp") fh=open("hackfiles/temp", "r") size=fh.read().strip() fh.close() if ip!="" and size.isdigit(): os.system("ping -s "+size+" "+ip) wait() else: pass except: error() pass #main_network_info()
def draw_map(event, x, y, flags, param): # print(flags,event) # mode=cv2.getTrackbarPos('mode','maplaner') fontbig = 2 Scalexy = 600 / 821 global preimg global nowimg global inputing global raiseerror if raiseerror == 0: if flags == 1 and event == cv2.EVENT_LBUTTONDBLCLK: # 左键双击go if ls != [] and ls[len(ls) - 1][0] != 4 and inputing != True: prelist.append(nowimg.copy()) if xyi != []: # 修正坐标为实际坐标 posx = (x - xyi[0]) * Scalexy posy = (-y + xyi[1]) * Scalexy posz = getInput('输入', 'go高度厘米整数数默认110') if not posz.isdigit(): posz = 110 else: posz = int(posz) print(posz, type(posz)) cv2.circle(nowimg, (x, y), 15, (255, 255, 255), 2) cv2.circle(nowimg, (x, y), 5, (0, 255, 255), -1) cv2.putText(nowimg, 'go', (x + 20, y - 20), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) cv2.rectangle(nowimg, (x + 20, y - 10), (x + 60, y - 40), (255, 255, 255), 1) ls.append([2, x, y, 0]) lscom.append([2, posx, posy, posz]) i = len(ls) - 2 if ls[i + 1][0] != 4 and ls[i + 1][0] != 1: cv2.arrowedLine(nowimg, (ls[i][1], ls[i][2]), ((ls[i + 1][1] + ls[i][1]) // 2, (ls[i + 1][2] + ls[i][2]) // 2), (0, 255, 255), 2, 1, 0, 0.05) cv2.line(nowimg, ((ls[i + 1][1] + ls[i][1]) // 2, (ls[i + 1][2] + ls[i][2]) // 2), (ls[i + 1][1], ls[i + 1][2]), (0, 255, 255), 2, 4) elif flags == 33 and event == cv2.EVENT_LBUTTONDBLCLK: # alt+左键双击不旋转go if ls != [] and ls[len(ls) - 1][0] != 4 and inputing != True: prelist.append(nowimg.copy()) if xyi != []: # 修正坐标为实际坐标 posx = (x - xyi[0]) * Scalexy posy = (-y + xyi[1]) * Scalexy posz = getInput('输入', 'closeon高度厘米整数数默认110') if not posz.isdigit(): posz = 110 else: posz = int(posz) print(posz, type(posz)) cv2.circle(nowimg, (x, y), 15, (255, 255, 255), 2) cv2.circle(nowimg, (x, y), 5, (0, 255, 255), -1) cv2.putText(nowimg, 'CN', (x + 20, y - 20), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) cv2.rectangle(nowimg, (x + 20, y - 18), (x + 60, y - 45), (255, 255, 255), 1) ls.append([8, x, y, 0]) lscom.append([8, posx, posy, posz]) i = len(ls) - 2 if ls[i + 1][0] != 4 and ls[i + 1][0] != 1: cv2.arrowedLine(nowimg, (ls[i][1], ls[i][2]), ((ls[i + 1][1] + ls[i][1]) // 2, (ls[i + 1][2] + ls[i][2]) // 2), (0, 255, 255), 2, 1, 0, 0.05) cv2.line(nowimg, ((ls[i + 1][1] + ls[i][1]) // 2, (ls[i + 1][2] + ls[i][2]) // 2), (ls[i + 1][1], ls[i + 1][2]), (0, 255, 255), 2, 4) elif event == cv2.EVENT_RBUTTONDBLCLK: # 右键双击起飞 if ls == [] and inputing != True: # prelist.append(nowimg.copy()) xyi.append(x) xyi.append(y) # 建立坐标系 # nowimg[:, :, 0] = np.zeros([900,1600]) + 255 # nowimg[:, :, 1] = np.ones([900,1600]) + 254 # nowimg[:, :, 2] = np.ones([900,1600]) * 255 nowimg = bgimg cv2.arrowedLine(nowimg, (0, xyi[1]), (1600, xyi[1]), (0, 0, 0), 1, 8, 0, 0.02) # x轴 cv2.arrowedLine(nowimg, (xyi[0], 900), (xyi[0], 0), (0, 0, 0), 1, 8, 0, 0.03) # y轴 cv2.putText(nowimg, 'x', (1600 - 30, xyi[1]), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) cv2.putText(nowimg, 'y', (xyi[0], 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) # 标尺 for i in [-6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6]: sx = str(i) + 'm' sy = str(-i) + 'm' cv2.circle(nowimg, (int(xyi[0] + 100 * i / Scalexy), xyi[1]), 2, (0, 0, 0), -1) cv2.putText(nowimg, sx, (int(xyi[0] + 100 * i / Scalexy), xyi[1] + 25), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 1) cv2.circle(nowimg, (xyi[0], int(xyi[1] + 100 * i / Scalexy)), 2, (0, 0, 0), -1) cv2.putText(nowimg, sy, (xyi[0], int(xyi[1] + 100 * i / Scalexy)), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 1) height = getInput('输入', '起飞高度分米整数默认10') if not height.isdigit(): height = 10 else: height = int(height) print(height, type(height)) cv2.circle(nowimg, (x, y), 20, (160, 160, 160), 2) cv2.putText(nowimg, 'home', (x + 20, y + 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) cv2.rectangle(nowimg, (x + 20, y + 15), (x + 110, y + 45), (255, 255, 255), 1) ls.append([0, x, y, 0]) lscom.append([0, height, 0, 0]) elif flags == 4 and event == cv2.EVENT_MBUTTONDBLCLK: # 中间键双击降落 if ls != [] and ls[len(ls) - 1][0] != 4 and inputing != True: prelist.append(nowimg.copy()) cv2.circle(nowimg, (ls[len(ls) - 1][1], ls[len(ls) - 1][2]), 10, (0, 0, 255), -1) cv2.putText(nowimg, 'land', (ls[len(ls) - 1][1] - 30, ls[len(ls) - 1][2] + 73), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) cv2.rectangle( nowimg, (ls[len(ls) - 1][1] - 30, ls[len(ls) - 1][2] + 50), (ls[len(ls) - 1][1] + 37, ls[len(ls) - 1][2] + 75), (255, 255, 255), 1) cv2.line(nowimg, (ls[-1][1], ls[-1][2]), (ls[-1][1], ls[-1][2] + 50), (0, 0, 0), 2, 4) ls.append([4, ls[len(ls) - 1][1], ls[len(ls) - 1][2]]) lscom.append([4, 0, 0, 0]) elif flags == 10 and event == 2: # ctrl+右键单击holdon if ls != [] and ls[len(ls) - 1][0] != 4 and inputing != True: prelist.append(nowimg.copy()) time = getInput('输入', '悬停时间秒整数默认2') if not time.isdigit(): time = 2 else: time = int(time) cv2.line(nowimg, (ls[-1][1] - 15, ls[-1][2] - 15), (ls[-1][1] + 15, ls[-1][2] + 15), (0, 0, 0), 2, 4) cv2.line(nowimg, (ls[-1][1] - 15, ls[-1][2] + 15), (ls[-1][1] + 15, ls[-1][2] - 15), (0, 0, 0), 2, 4) cv2.putText( nowimg, 'holdon', (ls[len(ls) - 1][1] - 118, ls[len(ls) - 1][2] - 15), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) cv2.rectangle( nowimg, (ls[-1][1] - 118, ls[-1][2] - 40), (ls[len(ls) - 1][1] - 16, ls[len(ls) - 1][2] - 12), (255, 255, 255), 1) ls.append([1, ls[len(ls) - 1][1], ls[len(ls) - 1][2], 0]) lscom.append([1, time, 0, 0]) elif flags == 9 and event == 1: # ctrl+左键返航 if ls != [] and ls[len(ls) - 1][0] != 4 and ls[ len(ls) - 1][0] != 3 and ls[len(ls) - 1][0] != 0 and ls[ -1][1] != 0 and ls[-1][2] != 0 and inputing != True: prelist.append(nowimg.copy()) x = ls[0][1] y = ls[0][2] posx = 0 posy = 0 posz = getInput('输入', '返航高度厘米整数默认110') if not posz.isdigit(): posz = 110 else: posz = int(posz) print(posz) cv2.rectangle(nowimg, (x + 10, y + 10), (x - 10, y - 10), (200, 0, 200), 1) ls.append([3, x, y, 0]) lscom.append([3, posx, posy, posz]) # 画箭头 i = len(ls) - 2 if ls[i + 1][0] != 4 and ls[i + 1][0] != 1: cv2.rectangle(nowimg, (ls[i][1] + 10, ls[i][2] + 10), (ls[i][1] - 10, ls[i][2] - 10), (200, 0, 200), 1) cv2.putText(nowimg, 'gohome', (ls[i][1] - 145, ls[i][2] + 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), fontbig) cv2.rectangle(nowimg, (ls[i][1] - 145, ls[i][2] + 4), (ls[i][1] - 20, ls[i][2] + 39), (255, 255, 255), 1) cv2.arrowedLine(nowimg, (ls[i][1], ls[i][2]), ((ls[i + 1][1] + ls[i][1]) // 2, (ls[i + 1][2] + ls[i][2]) // 2), (0, 255, 255), 2, 1, 0, 0.05) cv2.line(nowimg, ((ls[i + 1][1] + ls[i][1]) // 2, (ls[i + 1][2] + ls[i][2]) // 2), (ls[i + 1][1], ls[i + 1][2]), (0, 255, 255), 2, 4) elif flags == 1 and event == 1: if ls != [] and inputing != True: preimg = nowimg.copy() # cv2.rectangle(img,(5,0),(120,80),(255,255,255),-1) if xyi != []: # 修正坐标为实际坐标 posx = (x - xyi[0]) * Scalexy posy = (-y + xyi[1]) * Scalexy pointxy.clear() pointxy.append(posx) pointxy.append(posy) pointxydrawer.clear() pointxydrawer.append(x) pointxydrawer.append(y) sx = 'x:' + str(int(pointxy[0])) + 'cm' sy = 'y:' + str(int(pointxy[1])) + 'cm' cv2.putText(nowimg, sx, (x + 10, y + 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2) cv2.putText(nowimg, sy, (x + 10, y + 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2) cv2.circle(nowimg, (x, y), 5, (255, 0, 0), -1) print(pointxydrawer, end="") print(pointxy) pointxydrawer.clear() pointxy.clear() elif flags == 0 and event == cv2.EVENT_LBUTTONUP: if ls != [] and inputing != True: nowimg = preimg.copy() elif event == cv2.EVENT_RBUTTONDOWN: # 右键撤销上一步 if ls != [] and ls[len(ls) - 1][0] != 0 and inputing != True: ls.pop() lscom.pop() nowimg = prelist.pop()
def vulScan(): try: right_choice = [False, False, False, False] port_is_range = bool() banner_array = [] port_array = [] while not right_choice[0]: targets = str(input('\n[+] Enter Target/s To Scan(split multiple targets with ,): ')).strip(' ') for ip_add in targets.split(','): if vul.check_ip(ip_add)[1] == False: right_choice[0] = False print(colored(ip_add, on_color='on_red', attrs=['underline']) + colored(' not an ipaddress', color='red')) break else: right_choice[0] = True while not right_choice[1]: ports = input( '\n[+] Enter Port/s To Scan(multiple ports with - for range or , for specific ports): ').strip(' ') if '-' not in ports: # if it not a range i.e specific port(s) port_is_range = False for port in ports.split(','): if port.isdigit(): # check if each port theyve entered is an whole number port_array.append(int(port)) # add it it to the array right_choice[1] = True else: # if a input isn't a number, ask the the question again right_choice[1] = False print( colored(port, on_color='on_red', attrs=['underline']) + colored(' not a valid port number', color='red')) break else: # if its a range port_is_range = True for port in ports.split('-'): if port.isdigit(): # check if each ports they've entered is an whole number port_array.append(int(port)) right_choice[1] = True else: right_choice[1] = False print(colored(port, color='grey', attrs=['underline']) + colored(' not a valid port number', color='red')) break # makes sure the range is in order # in case they input higher port first port_array.sort() while not right_choice[2]: time = input('\n[+] Enter timeout time in seconds ').strip(' ') if time.isdigit(): right_choice[2] = True else: right_choice[2] = False while not right_choice[3]: vul_File = input('\n[+] Input file with banners to search for') if not path.isfile(vul_File): print(colored('File Not Found !', color='red')) else: right_choice[3] = True for ip_add in targets.split(','): if port_is_range: banner_port = vul.scan(ip_add, port_array[0], port_array[1], int(time)) if None in banner_port: pass else: banner_array.append(banner_port[0].lower()) port_array.append(banner_port[1]) else: banner_port = vul.scan1(ip_add, port_array, int(time)) if None in banner_port: pass else: banner_array.append(banner_port[0]) port_array.append(banner_port[1]) if len(banner_array) != 0: with open(vul_File, 'r') as file: once = count = 0 for line in file.readlines(): if line.lower() in banner_array: once = 1 print( colored('[!!] VULNERABLE BANNER: ', 'green') + colored(line, 'cyan', attrs=['bold', 'underline', 'reverse']) + colored('" ON PORT: ', 'green') + colored(str(vul.open_ports[banner_array.index(line.lower())]), color='cyan', attrs=['bold', 'underline', 'reverse']) ) view_all = input(colored('Would you like it see all banners found ?', 'yellow')).strip() if 'y' in view_all: for x in range(len(banner_array)): print(colored('Banner: ', on_color='on_green') + colored(banner_array[x], 'yellow', attrs=['underline', 'bold']) + colored('on Port: ', on_color='on_green') + colored(port_array[x], 'yellow', attrs=['underline', 'bold'])) else: exit(0) except KeyboardInterrupt: print('bye.') exit(0)
def portScannerf(): print('_____PORTSCANNER____') try: pr, tr, tmr = False, False, False time, ports, targets = str(), str(), str() while not tr: # Keep repeating the question until user inputs are valid targets = input('[+] Enter Target/s To Scan(split multiple targets with): ').strip(' ') for ip_add in targets.split(','): # for every ip address in the inputted targets target if portScanner.check_ip(ip_add.strip(' '))[1]: # check if its a valid ip tr = True else: # if not print the error and ask the question again, by breaking the loop print(ip_add + ' not an ip address') tr = False break while not pr: # port is not right i.e pr ports = input('[+] Enter Port/s To Scan(multiple ports with - for range or , for specific ports): ').strip( ' ') if ',' in ports: for port in ports.split(','): if port.isdigit(): pr = True else: pr = False print('invalid port number\nTry Again') break # ends the iteration once an error is found elif '-' in ports: for port in ports.split('-'): if port.isdigit(): pr = True else: pr = False print('invalid port number specified\nTry Again') break # break from teh for loop else: if ports.isdigit(): pr = True else: pr = False print('invalid port number\n\nTry Again') while not tmr: time = input('[+] Enter timeout time in seconds i.e 5 = fives seconds ').strip(' ') if time.isdigit(): tmr = True else: print('invalid time \nTry Again') tmr = False value = 0 portsArray = list() # if a range if '-' in ports: for port in ports.split('-'): portsArray.append(int(port)) # makes sure the range is in order portsArray.sort() else: for port in ports.split(','): print(port) portsArray.append(int(port.strip(' '))) value = 1 print("The value is: " + str(value)) if ',' in targets: print('There are multiple targets: "," detected') for ip_add in targets.split(','): if value != 1: portScanner.scanRange(ip_add, portsArray[0], portsArray[1], time) else: portScanner.scan1(ip_add, portsArray, time) else: print('There is a single target: no "," detected') if value != 1: print('Range') portScanner.scanRange(targets.strip(' '), portsArray[0], portsArray[1], time) else: print('Single') print(targets, portsArray, time) portScanner.scan1(targets, portsArray, time) except KeyboardInterrupt: print('\n\nbye.') exit(0)
def validate_time(time): """ validate attack duration """ return time.isdigit() and int(time) >= 10 and int(time) <= 1300