displays hostnames

This commit is contained in:
R3DDY97 2017-07-19 07:53:24 +05:30 committed by GitHub
parent 644bd81473
commit 14cb61370c

View File

@ -11,7 +11,7 @@ See License at nikolaskama.me (https://nikolaskama.me/kickthemoutproject)
import time, os, sys, logging, math
from time import sleep
import urllib2 as urllib
import traceback
import traceback, socket
BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[94m', '\033[91m', '\33[97m', '\33[93m', '\033[1;35m', '\033[1;32m', '\033[0m'
notRoot = False
@ -163,8 +163,9 @@ def kickoneoff():
for host in hostsList:
if host[0] == onlineIPs[i]:
mac = host[1]
hostname = socket.gethostbyaddr(onlineIPs[i])[0]
vendor = resolveMac(mac)
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t"+ vendor + "{4}").format(YELLOW, WHITE, RED, GREEN, END)
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t"+ vendor + " (" + hostname + ")""{4}").format(YELLOW, WHITE, RED, GREEN, END)
canBreak = False
while not canBreak:
@ -227,8 +228,9 @@ def kicksomeoff():
for host in hostsList:
if host[0] == onlineIPs[i]:
mac = host[1]
hostname = socket.gethostbyaddr(onlineIPs[i])[0]
vendor = resolveMac(mac)
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + "{4}").format(YELLOW, WHITE, RED, GREEN, END)
print(" [{0}" + str(i) + "{1}] {2}" + str(onlineIPs[i]) + "{3}\t" + vendor + " (" + hostname + ")" "{4}").format(YELLOW, WHITE, RED, GREEN, END)
canBreak = False
while not canBreak:
@ -424,7 +426,7 @@ def main():
print(
"\n{0}Using interface '{1}" + defaultInterface + "{2}' with mac address '{3}" + defaultInterfaceMac + "{4}'.\nGateway IP: '{5}"
+ defaultGatewayIP + "{6}' --> {7}" + str(len(hostsList)) + "{8} hosts are up.{9}").format(GREEN, RED, GREEN, RED, GREEN,
+ defaultGatewayIP + "{6}' --> {7}" + str(len(hostsList)) + "{8} hosts are up.{9}").format(GREEN, RED, GREEN, RED, GREEN,
RED, GREEN, RED, GREEN, END)
# display warning in case of no active hosts
if len(hostsList) == 0 or len(hostsList) == 1:
@ -484,4 +486,4 @@ if __name__ == '__main__':
# commence scanning process
scanNetwork()
main()
main()