コード例 #1
0
ファイル: views.py プロジェクト: saintdrug/pentester
def iface_detail(request, iface):
    """
    Display detailed information about particular network interface in the
    system.
    """
    
    interfaces = IFConfig.get_ifaces_up()
    
    if iface in interfaces: #check if interface is on the system and is up
        ip = IFConfig.get_ip_address(iface)
        mask = IFConfig.get_netmask(iface)
        return HttpResponse("Interface %s, <br>%s/%s" % (iface, ip, mask))
    else:
        return HttpResponse("error")
コード例 #2
0
ファイル: views.py プロジェクト: saintdrug/pentester
def ifaces(request):
    """
    Displays names of all network interfaces in the system.
    """
    ipiface = []                             #initialize interface list
    interfaces = IFConfig.get_ifaces_up()    #get list from IFConfig module
    
    # for every interface in a list create a string representing
    # interface with its settings (IP address and network mask)
    for iface in interfaces:                
        ipiface.append("%s (%s / %s)" % (iface, IFConfig.get_ip_address(iface), IFConfig.get_netmask(iface)))
    # join the list, separating interfaces with newline characters 
    output = '<br>\n'.join(ipiface)
    return HttpResponse("<b>Interfaces:</b><br> %s"% output)
コード例 #3
0
ファイル: views.py プロジェクト: saintdrug/pentester
def ifaceslist():
    """
    Gets list of network interfaces on the system and returns a list of 
    dictionaries with 'name', 'ip' and 'mask' keys. Works with conjunction
    on IFConfig module.
    """
    # initialize list of interfaces
    ipiface = []
    # fill it with entries from IFConfig module
    for iface in IFConfig.get_ifaces_up():
        ipiface.append({'name' : iface, 'ip' : IFConfig.get_ip_address(iface), 'mask' : IFConfig.get_netmask(iface)})
    return ipiface