当前位置: 首页>>代码示例>>Python>>正文


Python Utils.is_readable方法代码示例

本文整理汇总了Python中core.utils.Utils.is_readable方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.is_readable方法的具体用法?Python Utils.is_readable怎么用?Python Utils.is_readable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.utils.Utils的用法示例。


在下文中一共展示了Utils.is_readable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_config

# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import is_readable [as 别名]
    def load_config(self):
        # does config file exist?
        if (self.config["config_filename"] is not None):
            temp1 = self.config
            temp2 = Utils.loadConfig(self.config["config_filename"])
            self.config = dict(temp2.items() + temp1.items())
        else:
            # guess not..   so try to load the default one
            if Utils.is_readable("default.cfg"):
                self.display.error("a CONFIG FILE was not specified...  defaulting to [default.cfg]")
                print
                temp1 = self.config
                temp2 = Utils.loadConfig("default.cfg")
                self.config = dict(temp2.items() + temp1.items())
            else:
                # someone must have removed it!
                self.display.error("a CONFIG FILE was not specified...")
                print
                sys.exit(1)

        # set verbosity/debug level
        if (self.config['verbose'] >= 1):
            self.display.enableVerbose()
        if (self.config['verbose'] > 1):
            self.display.enableDebug()
开发者ID:psuedoelastic,项目名称:MailPillage,代码行数:27,代码来源:mailpillager.py

示例2: loadSites

# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import is_readable [as 别名]
    def loadSites(self):

        templates = self.getTemplates()
        print

        # loop over each web template
        for f in templates:
            template_file = f + "/CONFIG"
            if Utils.is_readable(template_file) and os.path.isfile(template_file):
                print "Found the following web sites: [%s]" % template_file
                # read in the VHOST, LOGFILE, and REDIRECTURL
                VHOST = ""
                LOGFILE = ""
                REDIRECTURL = ""
                #PATH = self.config["web_template_path"] + f + "/"
                PATH = f + "/"
                with open (template_file, "r") as myfile:
                    for line in myfile.readlines():
                        match=re.search("VHOST=", line)
                        if match:
                            VHOST=line.replace('"', "")
                            VHOST=VHOST.split("=")
                            VHOST=VHOST[1].lower().strip()
                        match2=re.search("LOGFILE=", line)
                        if match2:
                            LOGFILE=line.replace('"', "")
                            LOGFILE=LOGFILE.split("=")
                            LOGFILE=LOGFILE[1].strip()
                        match3=re.search("REDIRECTURL=", line)
                        if match3:
                            REDIRECTURL=line.replace('"', "")
                            REDIRECTURL=REDIRECTURL.replace(r'\n', "\n")
                            REDIRECTURL=REDIRECTURL.split("=")
                            REDIRECTURL=REDIRECTURL[1].strip()
                self.websites[VHOST] = {'path':PATH, 'port':8000, 'logfile':LOGFILE, 'redirecturl':REDIRECTURL}
开发者ID:firebitsbr,项目名称:SPF,代码行数:37,代码来源:web.py

示例3: process_email_template

# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import is_readable [as 别名]
 def process_email_template(self, campaign):
     if (Utils.is_readable(self.directory + "email_template_" + campaign  +".txt")):
         data = ""
         with open (self.directory + "email_template_" + campaign  +".txt" , "r") as myfile:
             data = myfile.read()
         parts = data.split("----------------------------------------------")
         self.campaigns[campaign]["email_template"] = parts[1].strip()
         parts = parts[2].split("--------")
         emails = parts[1].strip().splitlines()
         self.campaigns[campaign]["email_targets"] = emails
     return
开发者ID:BahtiyarB,项目名称:SPF,代码行数:13,代码来源:report.py

示例4: getTemplates

# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import is_readable [as 别名]
 def getTemplates(self):
     templates = []
     db_static_templates = self.db.getWebTemplates(ttype="static")
     db_dynamic_templates = self.db.getWebTemplates(ttype="dynamic")
     if (db_static_templates or db_dynamic_templates):
         for template in db_static_templates:
             parts = template.split("[-]")
             template_file = parts[0] + "/CONFIG"
             if Utils.is_readable(template_file) and os.path.isfile(template_file):
                 templates.append(parts[0])
                 print "STATIC = [%s]" % (parts[0])
         for template in db_dynamic_templates:
             parts = template.split("[-]")
             template_file = parts[0] + "/CONFIG"
             if Utils.is_readable(template_file) and os.path.isfile(template_file):
                 templates.append(parts[0])
                 print "DYNAMIC = [%s]" % (parts[0])
     else:
         for f in os.listdir(self.config["web_template_path"]):
             template_file = os.path.join(self.config["web_template_path"], f) + "/CONFIG"
             if Utils.is_readable(template_file) and os.path.isfile(template_file):
                 templates.append(os.path.join(self.config["web_template_path"], f))
                 print "FIXED = [%s]" % (os.path.join(self.config["web_template_path"], f))
     return templates
开发者ID:firebitsbr,项目名称:SPF,代码行数:26,代码来源:web.py

示例5: load_config

# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import is_readable [as 别名]
    def load_config(self):
        filename = self.directory + "INFO.txt"
        if not Utils.is_readable(filename):
            raise ReportGenException("Filename: [%s] is NOT readable." % (filename))

        a=open(filename,'rb')
        lines = a.readlines()
        for line in lines:
            parts = line.split("=")
            if (parts[0] == "STARTTIME"):
                self.config["start_ts"] = parts[1]
            if (parts[0] == "ENDTIME"):
                self.config["end_ts"] = parts[1]
            if (parts[0] == "TARGETDOMAIN"):
                self.config["domain"] = parts[1]
            if (parts[0] == "PHISHINGDOMAIN"):
                self.config["phishing_domain"] = parts[1]
开发者ID:BahtiyarB,项目名称:SPF,代码行数:19,代码来源:report.py

示例6: int

# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import is_readable [as 别名]
            if (self.phishingsites):
                root.addHost(self.config["ip"], proxy.ReverseProxyResource('localhost', int(self.websites[self.phishingsites.keys()[0]]['port']), ''))
                try:
                    site = Site(root, logPath=self.logpath + "logs/root.log.access")
#                    site.logRequest = True
                    reactor.listenTCP(int(self.config["default_web_port"]), site)
                except twisted.internet.error.CannotListenError, ex:
                    print "ERROR: Could not start web service listener on port [80]!"
                    print "ERROR: Host Based Virtual Hosting will not function!"
            else:
                print "ERROR: Could not start web service listener on port [80]!"
                print "ERROR: Host Based Virtual Hosting will not function!"

        print
        print "Websites loaded and launched."
        sys.stdout.flush()
        reactor.run()

if __name__ == "__main__":
    def usage():
        print "web.py <config file>"

    if len(sys.argv) != 2:
        usage()
        sys.exit(0)

    if Utils.is_readable(sys.argv[1]):
        PhishingWebServer(Utils.load_config(sys.argv[1])).start()
    else:
        PhishingWebServer(Utils.decompressDict(sys.argv[1])).start()
开发者ID:firebitsbr,项目名称:SPF,代码行数:32,代码来源:web.py

示例7: print_file

# 需要导入模块: from core.utils import Utils [as 别名]
# 或者: from core.utils.Utils import is_readable [as 别名]
    def print_file(self, line):
        fullfilename = self.directory + self.filename
        
        if not os.path.exists(os.path.dirname(fullfilename)):
            os.makedirs(os.path.dirname(fullfilename))

        if not Utils.is_writeable(fullfilename):
            raise ReportGenException("Filename: [%s] is NOT writeable." % (fullfilename))

        fp = open(fullfilename, "a")
        fp.write(line)
        fp.close()

        return

if __name__ == "__main__":
    def usage():
        print "report.py <report directory>"

    if len(sys.argv) != 2:
        usage()
        exit(0)

    if Utils.is_readable(sys.argv[1] + "INFO.txt"):
        try:
            print ReportGen(sys.argv[1]).start()
        except ReportGenException as e:
            print e
    else:
        print "[" + sys.argv[1] + "] does not appear to be a valid report directory."
开发者ID:BahtiyarB,项目名称:SPF,代码行数:32,代码来源:report.py


注:本文中的core.utils.Utils.is_readable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。