python类RESET的实例源码

xmlrpc-bruteforcer.py 文件源码 项目:xmlrpc-bruteforcer 作者: AresS31 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def copyright():

    copyright = """
       =[ {0}smali-code-injector v1.1-dev{1}       ]
+ -- --=[ Alexandre Teyar @Ares              ]
+ -- --=[ Pentester at Ambersail Ltd.        ]
+ -- --=[ GitHub: https://github.com/AresS31 ]
""".format(Fore.YELLOW, Fore.RESET)
    print("{}".format(copyright))
plugin_handler.py 文件源码 项目:MusicBot 作者: BjoernPetersen 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def load_plugins(self):
        logger = logging.getLogger(__name__)
        if not os.path.isdir(plugin_dir):
            return
        possible_plugins = os.listdir(plugin_dir)
        for filename in possible_plugins:
            if not os.path.isfile(os.path.join(plugin_dir, filename)):
                continue
            split = filename.split('.')
            if not (len(split) > 1 and split[-1] == "py"):
                continue
            name = "".join(split[:-1])
            module_info = imp.find_module(name, [plugin_dir])
            try:
                module = imp.load_module(name, *module_info)
                dir_list = dir(module)
                if ("get_label" in dir_list) and ("run_command" in dir_list):
                    self.plugins.append(module)
                else:
                    logger.error(Fore.RED + "'%s' is not a valid plugin!" + Fore.RESET, filename)
            except Exception as e:
                logger.error(Fore.RED + "%s error while loading plugin '%s': \n %s" + Fore.RESET,
                             type(e).__name__, filename, e)
            finally:
                module_info[0].close()

    # Return a list of loaded plugins
status_media-gateways.py 文件源码 项目:python-ossi 作者: iskhomutov 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def print_major_alarms(mj):
    """
    Args:
        mj (int): Counts of major alarms

    Returns:
        str: Colorized information by using colorama
    """
    if mj > 0:
        return Back.RED + Fore.WHITE + str(mj) + Fore.RESET + Back.RESET
    else:
        return Fore.GREEN + str(mj) + Fore.RESET
status_media-gateways.py 文件源码 项目:python-ossi 作者: iskhomutov 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def print_minor_alarms(mn):
    """
    Args:
        mn (int): Counts of minor alarms

    Returns:
        str: Colorized information by using colorama
    """
    if mn > 0:
        return Fore.RED + str(mn) + Fore.RESET
    else:
        return Fore.GREEN + str(mn) + Fore.RESET
status_media-gateways.py 文件源码 项目:python-ossi 作者: iskhomutov 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def print_warnings(wn):
    """
    Args:
        wn (int): Counts of warnings

    Returns:
        str: Colorized information by using colorama
    """
    if wn > 0:
        return Fore.YELLOW + str(wn) + Fore.RESET
    else:
        return Fore.GREEN + str(wn) + Fore.RESET
ARPySnitch.py 文件源码 项目:ARPySnitch 作者: securecurebt5 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run(self):
        try:
            arp_header = struct.unpack('!2s2s1s1s2s6s4s6s4s', self.arpdata[14:42])
            if hexlify(arp_header[4]) == "0002" and hexlify(arp_header[5]) != self.GW_MAC.replace(":","") and socket.inet_ntoa(arp_header[6]) == self.GW_IP:
                try:
                   if hexlify(arp_header[5]) not in Attacker:
                    Attacker.append(hexlify(arp_header[5]))
                    print "="*50 
                    print foreground.RED + "ARP Poison Detected" + foreground.RESET
                    print "="*50 
                    print "******************_ARP_HEADER_******************"
                    print "Hardware Type: ", hexlify(arp_header[0])
                    print "Protocol Type: ", hexlify(arp_header[1])
                    print "Hardware Size: ", hexlify(arp_header[2])
                    print "Protocol Size: ", hexlify(arp_header[3])
                    print "Opcode: ", opcodes[hexlify(arp_header[4])]
                    print "Attacker's MAC : ", foreground.RED + hexlify(arp_header[5]) + foreground.RESET
                    print "Source IP : ", socket.inet_ntoa(arp_header[6])
                    print "Destination MAC : ", hexlify(arp_header[7])
                    print "Destination IP : ", socket.inet_ntoa(arp_header[8])
                   else:
                    pass
                except:
                    pass
        except:
                pass
tylogger.py 文件源码 项目:TyStrings 作者: luckytianyiyan 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def success(self, msg, *args, **kwargs):
        self._log(SUCCESS, BEERS_EMOJI + ' ' + Fore.LIGHTWHITE_EX + msg + Fore.RESET, args, **kwargs)
tylogger.py 文件源码 项目:TyStrings 作者: luckytianyiyan 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def addition(self, msg, *args, **kwargs):
        self._log(ADDITION, BEERS_EMOJI + ' ' + Fore.LIGHTWHITE_EX + msg + Fore.RESET, args, **kwargs)
CmdInterpreter.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def do_match(self, s):
        """Matches patterns in a string by using regex."""
        if six.PY2:
            file_name = raw_input(Fore.RED + "Enter file name?:\n" + Fore.RESET)
            pattern = raw_input(Fore.GREEN + "Enter string:\n" + Fore.RESET)
        else:
            file_name = input(Fore.RED + "Enter file name?:\n" + Fore.RESET)
            pattern = input(Fore.GREEN + "Enter string:\n" + Fore.RESET)
        file_name = file_name.strip()
        if file_name == "":
            print("Invalid Filename")
        else:
            system("grep '" + pattern + "' " + file_name)
CmdInterpreter.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def do_movies(self, s):
        """Jarvis will find a good movie for you."""
        if six.PY2:
            movie_name = raw_input(
                Fore.RED + "What do you want to watch?\n" + Fore.RESET)
        else:
            movie_name = input(
                Fore.RED + "What do you want to watch?\n" + Fore.RESET)
        system("ims " + movie_name)
Jarvis.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def postcmd(self, stop, line):
        """Hook that executes after every command."""
        if self.first_reaction:
            self.prompt = (
                Fore.RED +
                "{} What can i do for you?\n".format(PROMPT_CHAR) + Fore.RESET
            )
            self.first_reaction = False
        if self.enable_voice:
            self.speech.text_to_speech("What can i do for you?\n")
test_evaluator.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_calc(self):
        # Test a basic calculation
        calc("2 powER 7 PLUS (6.7 Minus 3) diVided BY 0.45 bY 3", self.jarvis)
        sys.stdout.seek(0)
        output = sys.stdout.read().strip()
        result = Fore.BLUE + str(2 ** 7 + (6.7 - 3) / 0.45 / 3) + Fore.RESET
        self.assertEqual(output, result)

        # And now for something a little more _complex_
        sys.stdout = StringIO()
        calc("(1 pluS 9.1j)^3.14129 mINUS 2.712", self.jarvis)
        sys.stdout.seek(0)
        output = sys.stdout.read().strip()
        result = Fore.BLUE + str((1 + 9.1j)**3.14129 - 2.712) + Fore.RESET
        self.assertEqual(output, result)
fileHandler.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def read_file(name, default=None):
    if os.path.exists(name):
        try:
            with open(name, "r+") as f:
                return json.load(f)
        except ValueError:
            print(
                Fore.RED + "Storage file not in right format. Backup stored as {0}.bak".format(name) + Fore.RESET)
            os.rename(name, name + ".bak")
    return default
file_organise.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def print_after(path):
    print(Fore.LIGHTBLUE_EX + "\nFolders after cleaning\n" + Fore.RESET)

    for files in os.listdir(path):
        print(files, sep=',\t')

    print(Fore.LIGHTMAGENTA_EX + "\nCLEANED\n" + Fore.RESET)
cricket.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def commentary(desc):
    mid = match_id(desc)
    data = c.commentary(mid)
    comm = {}
    comm['matchinfo'] = "{}, {}".format(data['matchinfo']['mnum'], data['matchinfo']['mchdesc'])
    comm['status'] = "{}, {}".format(data['matchinfo']['mchstate'].title(), data['matchinfo']['status'])
    comm['commentary'] = data['commentary']
    text = ''
    text += Fore.LIGHTYELLOW_EX + comm['matchinfo'] + '\n' + comm['status'] + '\n\n' + Fore.RESET
    for com in comm['commentary']:
        text += "{}\n\n".format(com)

    return text
mapps.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def locate_me():
    hcity = get_location()['city']
    print(Fore.BLUE + "You are at " + hcity + Fore.RESET)
mapps.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def weather(city=None):
    if not city:
        city = get_location()['city']

    # Checks country
    country = get_location()['country_name']

    # If country is US, shows weather in Fahrenheit
    if country == 'United States':
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=imperial".format(
                city)
        )
        unit = ' ºF in '

    # If country is not US, shows weather in Celsius
    else:
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=metric".format(
                city)
        )
        unit = ' ºC in '
    r = requests.get(send_url)
    j = json.loads(r.text)

    # check if the city entered is not found
    if 'message' in j and j['message'] == 'city not found':
        print(Fore.BLUE + "City Not Found" + Fore.RESET)
        return False

    else:
        temperature = j['main']['temp']
        description = j['weather'][0]['main']
        print(Fore.BLUE + "It's " + str(temperature) + unit +
              str(city) + " (" + str(description) + ")" + Fore.RESET)

    return True
mapps.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def search_near(things, city=0):
    if city:
        print(Fore.GREEN + "Hold on!, I'll show " + things +
              " near " + city + Fore.RESET)
        url = "https://www.google.com/maps/search/{0}+{1}".format(things, city)
    else:
        print(Fore.GREEN + "Hold on!, I'll show " +
              things + " near you" + Fore.RESET)
        url = "https://www.google.com/maps/search/{0}/@{1},{2}".format(
            things, get_location()['latitude'], get_location()['longitude'])
    webbrowser.open(url)
weatherIn.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def main(self, s):
    # Trim input command to get only the location
    loc = s.replace('weather', '').replace('in ', '').strip()

    # Checks country
    country = mapps.get_location()['country_name']

    # If country is US, shows weather in Fahrenheit
    if country == 'United States':
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=imperial".format(
                loc)
        )
        unit = ' ºF in '

    # If country is not US, shows weather in Celsius
    else:
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=metric".format(loc)
        )
        unit = ' ºC in '
    r = requests.get(send_url)
    j = json.loads(r.text)

    if 'message' in list(j.keys()) and ('city not found' in j['message'] or 'Nothing to geocode' in j['message']):
        return pinpoint.main(Memory(), self, s)

    temperature = j['main']['temp']
    description = j['weather'][0]['main']
    location = j['name']
    print(Fore.BLUE + "It's " + str(temperature) + unit +
          str(location.title()) + " (" + str(description) + ")" + Fore.RESET)
GeneralUtilities.py 文件源码 项目:Jarvis 作者: sukeesh 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def critical(string):
    print(Fore.RED + string + Fore.RESET)


问题


面经


文章

微信
公众号

扫码关注公众号