Python log.Log() Examples

The following are 5 code examples of log.Log(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module log , or try the search function .
Example #1
Source File: sploit.py    From CVE-2016-6366 with MIT License 5 votes vote down vote up
def __init__(self, tool_name, tool_version):
        self.tool_name    = tool_name
        self.tool_version = tool_version

        self.terminateFlingOnException = False

        self.env      = argparse.Namespace()
        self.params   = argparse.Namespace()
        self.key_data = None
        self.vinfo    = None
        
        self.log = Log(self.tool_name, self.tool_version)
        self.log.open()
        
        self._init_parser() 
Example #2
Source File: server.py    From esp8266 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, config = {'host': '0.0.0.0', 'port': 44403}) :
        self._host = config['host']
        self._port = config['port']
        self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._state = 'stopped'
        #self._logger = log.Log() 
Example #3
Source File: util.py    From lethean-vpn with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def commonArgs(p):
    p.add_argument('-l', '--log-level',               dest='d', metavar='LEVEL', help='Log level', default='WARNING')
    p.add_argument(      '--syslog',                  dest='syslog', const='syslog', action='store_const', help='Use syslog', default=None)
    p.add_argument('-v', '--verbose',                 metavar='VERBOSITY', action='store_const', dest='v', const='v', help='Be more verbose')
    p.add_argument('-h', '--help',                    metavar='HELP', required=None, action='store_const', dest='h', const='h', help='Help')
    p.add_argument('-f', '--config',                  metavar='CONFIGFILE', required=None, is_config_file=True, default=config.Config.CONFIGFILE, help='Config file')    
    p.add_argument('-s', '--sdp',                     metavar='SDPFILE', required=None, default=config.Config.SDPFILE, help='SDP file')
    p.add_argument('-p', '--pid',                     dest='p', metavar='PIDFILE', required=None, default=config.Config.PIDFILE, help='PID file')
    p.add_argument('-A', '--authids',                 dest='A', metavar='FILE', help='Authids db file.', default="none")
    p.add_argument('-a', '--audit-log',               dest='a', metavar='FILE', help='Audit log file', default=config.CONFIG.PREFIX + '/var/log/audit.log')        
    p.add_argument(      '--audit-log-json',          dest='aj', action='store_const', const='aj', metavar='Bool', help='Audit log to JSON', default=None)
    p.add_argument('-lc' ,'--logging-conf',           dest='lc', metavar='FILE', help='Logging config file')
    p.add_argument(       '--service-conf-dir',       dest='serviceDir', metavar='DIR', required=None, default=None, help='Use this directory to save config files for service. Use only for config generation per one service!')
    p.add_argument(       '--haproxy-bin',            dest='haproxyBin', metavar='Binary', required=None, help='Haproxy binary', default=config.Config.HAPROXY_BIN)
    p.add_argument(       '--openvpn-bin',            dest='openvpnBin', metavar='Binary', required=None, help='OpenVPN binary', default=config.Config.OPENVPN_BIN)
    p.add_argument(       '--stunnel-bin',            dest='stunnelBin', metavar='Binary', required=None, help='Stunnel binary', default=config.Config.STUNNEL_BIN)    
    p.add_argument(       '--sdp-server-uri',         dest='sdpUri', metavar='URL', required=None, help='SDP server(s)', default='https://sdp.lethean.io')
    p.add_argument(       '--sdp-wallet-address',     dest='sdpWallet', metavar='ADDRESS', required=None, help='SDP server wallet address', default='iz4xKrEdzsF5dP7rWaxEUT4sdaDVFbXTnD3Y9vXK5EniBFujLVp6fiAMMLEpoRno3VUccxJPnHWyRctmsPiX5Xcd3B61aDeas')
    p.add_argument(       '--sdp-service-endpoint',   dest='serviceFqdn', metavar='FQDN', required=None, help='Service FQDN or IP')
    p.add_argument(       '--sdp-service-port',       dest='servicePort', metavar='NUMBER', required=None, help='Service port')
    p.add_argument(       '--sdp-service-proto',      dest='serviceProto', metavar='PROTOCOL', required=None, default=None, help='Service protocol')
    p.add_argument(       '--sdp-service-id',         dest='serviceId', metavar='NUMBER', required=None, help='Service ID')
    p.add_argument(       '--provider-id',            dest='providerid', metavar='PROVIDERID', required=None, default='<NOID>', help='ProviderID (public ed25519 key)')
    p.add_argument(       '--ca',                     dest='providerCa', metavar="ca.crt", required=None, default='<NOCA>', help='Set certificate authority file')
    p.add_argument(       '--wallet-address',         dest='walletAddr', metavar='ADDRESS', required=None, default='<NOADDR>', help='Provider wallet address')
    p.add_argument(       '--sdp-cache-dir',          dest='sdpCacheDir', metavar='DIR', required=None, default=config.CONFIG.PREFIX + '/var/', help='SDP cache dir')
    p.add_argument(       '--sdp-cache-expiry',       dest='sdpCacheExpiry', metavar='SECONDS', required=None, default=300, help='SDP cache expiry in seconds')
    p.add_argument(       '--compatibility',          dest='comp', metavar='Level', required=None, default="v3", choices=["v3.1", "v3"], help='Compatibility level for remote node. Use v3.1 or v3')
    p.add_argument(       '--vpnd-dns',               dest='vpndDns', metavar='IP', required=None, default=None, help='Use and offer local DNS server for VPN clients')
    p.add_argument(       '--vpnd-more-user-sessions',dest='duplicateCN', metavar='bool', action='store_const', const='duplicateCN', required=None, default=None, help='If true, user can connect multiple sessions with one paymentid.')
    p.add_argument(       '--vpnd-iprange',           dest='vpndIPRange', metavar='IP', required=None, default="10.11.0.0", help='IP Range for client IPs. Client will get /30 subnet from this range.')
    p.add_argument(       '--vpnd-ipmask',            dest='vpndIPMask', metavar='MASK', required=None, default="255.255.0.0", help='IP mask for client IPs')
    p.add_argument(       '--vpnd-ip6range',          dest='vpndIP6Range', metavar='IP6', required=None, default=None, help='IP6 Range for client IPs. Client will get /30 subnet from this range.')
    p.add_argument(       '--vpnd-reneg',             dest='vpndReneg', metavar='S', required=None, default=600, help='Client has to renegotiate after this number of seconds to check if paymentid is still active')
    p.add_argument(       '--vpnd-tun',               dest='vpndTun', metavar='IF', required=None, default="tun0", help='Use specific tun device for server')
    p.add_argument(       '--vpnd-mgmt-port',         dest='vpndMgmtPort', metavar='PORT', required=None, default="11192", help='Use specific port for local mgmt')
    p.add_argument(       '--vpnc-standalone',        dest='vpncStandalone', action='store_const', const='vpncStandalone', metavar='Bool', required=None, help='Create standalone openvn config that can be run outside of dispatcher.')
    p.add_argument(       '--proxyc-standalone',      dest='proxycStandalone',  action='store_const', const='proxycStandalone', metavar='Bool', required=None, help='Create standalone haproxy config that can be run outside of dispatcher.')
    p.add_argument(       '--no-run',                 dest='noRun', action='store_const', const='vpncStandalone', metavar='Bool', required=None, help='Do not run openvpn or haproxy, just prepare configs') 
Example #4
Source File: util.py    From lethean-vpn with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def parseCommonArgs(parser, cfg, name):
    if (cfg.lc):
        logging.config.fileConfig(cfg.lc)
        log.L = log.Log(level=cfg.d, name=name)
        log.A = log.Audit(level=logging.WARNING)
    elif (cfg.syslog):
        h = logging.handlers.SysLogHandler(address="/dev/log")
        log.L = log.Log(level=cfg.d, name=name, handler=h)
        log.A = log.Audit(handler=h)
    else:
        ah = logging.FileHandler(cfg.a)
        log.L = log.Log(level=cfg.d, name=name)
        log.A = log.Audit(handler=ah)
    config.Config.VERBOSE = cfg.v
    config.Config.CONFIGFILE = cfg.config
    config.Config.SDPFILE = cfg.sdp
    config.Config.d = cfg.d
    config.Config.a = cfg.a
    config.Config.SDPURI = cfg.sdpUri
    config.CONFIG.PIDFILE = cfg.p
    if (config.Config.AUTHIDSFILE == "none"):
        config.Config.T_SAVE = 0
        config.Config.AUTHIDSFILE = ''
    if (cfg.comp=="v3"):
        cfg.mgmtHeader="X-ITNS-MgmtID"
        cfg.authidHeader="X-ITNS-PaymentID"
    elif (cfg.comp=="v3.1"):
        cfg.mgmtHeader="X-LTHN-MgmtID"
        cfg.authidHeader="X-LTHN-PaymentID"
    else:
        log.L.error("Bad compatibility level.")
        sys.exit(2)
    if cfg.sdpUri.endswith('/'):
        cfg.sdpUri = cfg.sdpUri[:-1]
    if not cfg.sdpUri.endswith('/v1'):
        cfg.sdpUri = cfg.sdpUri + '/v1'
    cfg.sdpUri = {'sdp': cfg.sdpUri}
    if cfg.noRun:
        cfg.vpncStandalone = True
        cfg.proxycStandalone = True
    
    # Initialise services
    services.SERVICES = services.Services()

    if (cfg.h):
        helpmsg(parser)
        sys.exit() 
Example #5
Source File: main.py    From redis-sniffer with MIT License 4 votes vote down vote up
def main():
    parser = argparse.ArgumentParser()
    source_group = parser.add_mutually_exclusive_group(required=True)
    source_group.add_argument('-i', '--interface', help="the interface to bind to")
    source_group.add_argument('-F', '--file', help="pcap file containing captured traffic to analyze")
    parser.add_argument('-p', '--port', type=int, help="the port to grab packets from.  Default: 6379", default=6379)
    parser.add_argument('--out', default='.', help="the location to generate the full or event logs, defaults to the \
                        directory the application is executed from")
    parser.add_argument('-l', choices=['debug', 'event', 'full'], default='full', help="the type of log(s) you want to \
                        create. Default: full")
    parser.add_argument('-el', '--event-log', default="event", help="the name of the event outout file. \
                        Default: event_sniff")
    parser.add_argument('-fl', '--full-log', default="full", help="the name of the full sniff output file. \
                        Default: full_sniff")
    parser.add_argument('-f', '--filter', default="", help="comma separated list of events to log(ex: setex,delete)"
                        )
    parser.add_argument('--append', default="_sniff", help="the suffix to append to command logs")
    parser.add_argument('--extra', help="log non-redis traffic")
    args = parser.parse_args()
    fmt_full = '%.6f %-21s %8d %8d %s\n'
    fmt = '%s\n'
    event_filters = args.filter.split(',') if args.filter else []

    logger = Log(args.l, args.out, {'event': args.event_log, 'full': args.full_log}, event_filters, args.append)

    log_level = logging.INFO
    if args.l == 'debug':
        log_level = logging.DEBUG

    logging.basicConfig(filename=os.path.join(args.out, 'sniffer.log'), level=log_level)

    source = args.interface if args.interface else args.file
    sniffer = Sniffer(source, args.port)

    for session in sniffer.sniff():
        ptime, client, req_size, resp_size, command = session
        comm_parts = command.split()
        if comm_parts[0].lower() in event_filters:
            logger.write_command(comm_parts[0].lower(), command)
        if logger.event_log:
            logger.write_event(fmt % command)
        if logger.full_log:
            logger.write_log(fmt_full % (ptime, client, req_size, resp_size, command))