def get_host_info(htype='1', netint='1', netmac='1'):
    "Populate the host info caches"

    if htype == '1':
        get_type_cached(env.host_string)
    if netint == '1':
        get_netint_cached(env.host_string, int_no=-1)
        get_netint_windump_cached(env.host_string, int_no=-1)
        get_netint_cached(env.host_string, int_no=-1, internal_int='0')
        get_netint_windump_cached(env.host_string, int_no=-1, internal_int='0')
    if netmac == '1':
        get_netmac_cached(env.host_string)
Example #2
0
def get_host_info(htype='1', netint='1', netmac='1'):
    "Populate the host info caches"

    if htype == '1':
        get_type_cached(env.host_string)
    if netint == '1':
        get_netint_cached(env.host_string, int_no=-1)
        get_netint_windump_cached(env.host_string, int_no=-1)
	get_netint_cached(env.host_string, int_no=-1, internal_int='0')
        get_netint_windump_cached(env.host_string, int_no=-1, 
                                  internal_int='0')
    if netmac == '1':
        get_netmac_cached(env.host_string)
Example #3
0
def start_tcpdump(
        file_prefix='', remote_dir='', local_dir='.', snap_len='80',
        tcpdump_filter='', internal_int='1'):
    "Start tcpdump instance on host"

    # get host type
    htype = get_type_cached(env.host_string)

    if env.host_string in config.TPCONF_router:
        interfaces = get_netint_cached(env.host_string, int_no=-1,
                                       internal_int=internal_int)
    else:
        if htype == 'CYGWIN':
            interfaces = get_netint_windump_cached(env.host_string,
                                                    int_no=0,
                                                    internal_int=internal_int)
        else:
            interfaces = get_netint_cached(env.host_string,
                                            int_no=0,
                                            internal_int=internal_int)

    if len(interfaces) < 1:
        abort('Internal interface not specified')

    if remote_dir != '' and remote_dir[-1] != '/':
        remote_dir += '/'

    for interface in interfaces:

        if env.host_string in config.TPCONF_router:
	    if internal_int == '1':
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + \
                    '_' + interface + '_router.dmp'
            else:
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + '_ctl.dmp' 
        else:
            if internal_int == '1':
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + '.dmp'
            else:
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + '_ctl.dmp'

        if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
            tcpdump_cmd = 'tcpdump -n -s %s -i %s -w %s \'%s\'' % (
                snap_len, interface, file_name, tcpdump_filter)
        else:
            # CYGWIN
            tcpdump_cmd = 'WinDump -n -s %s -i %s -w ' \
                '"$(cygpath -aw "%s")" \'%s\'' % (
                    snap_len, interface, file_name, tcpdump_filter)
        pid = runbg(tcpdump_cmd)

        name = 'tcpdump-' + interface
        #bgproc.register_proc(env.host_string, name, '0', pid, file_name)
        bgproc.register_proc_later(
            env.host_string,
            local_dir,
            name,
            '0',
            pid,
            file_name)
Example #4
0
def start_tcpdump(
        file_prefix='', remote_dir='', local_dir='.', snap_len='80',
        tcpdump_filter='', internal_int='1'):
    "Start tcpdump instance on host"

    # get host type
    htype = get_type_cached(env.host_string)

    if env.host_string in config.TPCONF_router:
        interfaces = get_netint_cached(env.host_string, int_no=-1,
                                       internal_int=internal_int)
    else:
        if htype == 'CYGWIN':
            interfaces = get_netint_windump_cached(env.host_string,
                                                    int_no=0,
                                                    internal_int=internal_int)
        else:
            interfaces = get_netint_cached(env.host_string,
                                            int_no=0,
                                            internal_int=internal_int)

    if len(interfaces) < 1:
        abort('Internal interface not specified')

    if remote_dir != '' and remote_dir[-1] != '/':
        remote_dir += '/'

    for interface in interfaces:

        if env.host_string in config.TPCONF_router:
	    if internal_int == '1':
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + \
                    '_' + interface + '_router.dmp'
            else:
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + '_ctl.dmp' 
        else:
            if internal_int == '1':
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + '.dmp'
            else:
                file_name = remote_dir + file_prefix + '_' + \
                    env.host_string.replace(':', '_') + '_ctl.dmp'

        if htype == 'FreeBSD' or htype == 'Linux' or htype == 'Darwin':
            tcpdump_cmd = 'tcpdump -n -s %s -i %s -w %s \'%s\'' % (
                snap_len, interface, file_name, tcpdump_filter)
        else:
            # CYGWIN
            tcpdump_cmd = 'WinDump -n -s %s -i %s -w ' \
                '"$(cygpath -aw "%s")" \'%s\'' % (
                    snap_len, interface, file_name, tcpdump_filter)
        pid = runbg(tcpdump_cmd)

        name = 'tcpdump-' + interface
        #bgproc.register_proc(env.host_string, name, '0', pid, file_name)
        bgproc.register_proc_later(
            env.host_string,
            local_dir,
            name,
            '0',
            pid,
            file_name)