Advertisement
SERBIANHACKERS

SRBTOOL | Host details scanner

Apr 18th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.35 KB | None | 0 0
  1. #SRBHACKERS
  2. #SRBHACKERS
  3. #SRBHACKERS
  4.  
  5. #!/usr/bin/env python
  6.  
  7.  
  8.  
  9. import os
  10. import socket
  11. import subprocess
  12. import shutil
  13. import errno
  14. if os.name != "nt":
  15.     import fcntl
  16. import urllib2
  17. import struct
  18. import uuid
  19.  
  20. def get_ip(inter):
  21.     s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  22.     ip_addr = socket.inet_ntoa(fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', inter[:15]))[20:24])
  23.     return ip_addr
  24.  
  25. def get_mac_address(inter):
  26.     s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  27.     info = fcntl.ioctl(s.fileno(), 0x8927,  struct.pack('256s', inter[:15]))
  28.     mac_address = ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
  29.     return mac_address
  30.  
  31. def get_localhost_details(interfaces_eth, interfaces_wlan):
  32.     hostdata = "None"
  33.     hostname = "None"
  34.     windows_ip = "None"
  35.     eth_ip = "None"
  36.     wlan_ip = "None"
  37.     host_fqdn = "None"
  38.     eth_mac = "None"
  39.     wlan_mac = "None"
  40.     windows_mac = "None"
  41.     hostname = socket.gethostbyname(socket.gethostname())
  42.     if hostname.startswith("127.") and os.name != "nt":
  43.         hostdata = socket.gethostbyaddr(socket.gethostname())
  44.         hostname = str(hostdata[1]).strip('[]')
  45.         host_fqdn = socket.getfqdn()
  46.         for interface in interfaces_eth:
  47.             try:
  48.                 eth_ip = get_ip(interface)
  49.                 if not "None" in eth_ip:
  50.                     eth_mac = get_mac_address(interface)
  51.                 break
  52.             except IOError:
  53.                 pass
  54.         for interface in interfaces_wlan:
  55.             try:
  56.                 wlan_ip = get_ip(interface)
  57.                 if not "None" in wlan_ip:
  58.                     wlan_mac = get_mac_address(interface)
  59.                 break
  60.             except IOError:
  61.                 pass
  62.     else:
  63.         windows_ip = socket.gethostbyname(socket.gethostname())
  64.         windows_mac = uuid.getnode()
  65.         windows_mac = ':'.join(("%012X" % windows_mac)[i:i+2] for i in range(0, 12, 2))
  66.         hostdata = socket.gethostbyaddr(socket.gethostname())
  67.         hostname = str(socket.gethostname())
  68.         host_fqdn = socket.getfqdn()
  69.     return hostdata, hostname, windows_ip, eth_ip, wlan_ip, host_fqdn, eth_mac, wlan_mac, windows_mac
  70.  
  71. def get_public_ip(request_target):
  72.     grabber = urllib2.build_opener()
  73.     grabber.addheaders = [('User-agent','Mozilla/5.0')]
  74.     try:
  75.         public_ip_address = grabber.open(target_url).read()
  76.     except urllib2.HTTPError, error:
  77.         print("There was an error trying to get your Public IP: %s") % (error)
  78.     except urllib2.URLError, error:
  79.         print("There was an error trying to get your Public IP: %s") % (error)
  80.     return public_ip_address
  81.  
  82. wireless_ip = "None"
  83. windows_ip = "None"
  84. ethernet_ip = "None"
  85. public_ip = "None"
  86. host_fqdn = "None"
  87. hostname = "None"
  88. fqdn = "None"
  89. ethernet_mac = "None"
  90. wireless_mac = "None"
  91. windows_mac = "None"
  92. target_url = "http://ip.42.pl/raw"
  93. inter_eth = ["eth0", "eth1", "eth2", "eth3"]
  94. inter_wlan = ["wlan0", "wlan1", "wlan2", "wlan3", "wifi0", "wifi1", "wifi2", "wifi3", "ath0", "ath1", "ath2", "ath3"]
  95.  
  96.  
  97. public_ip = get_public_ip(target_url)
  98. hostdata, hostname, windows_ip, ethernet_ip, wireless_ip, host_fqdn, ethernet_mac, wireless_mac, windows_mac = get_localhost_details(inter_eth, inter_wlan)
  99.  
  100. if not "None" in public_ip:
  101.     print("Your Public IP address is: %s") % (str(public_ip))
  102. else:
  103.     print("Your Public IP address was not found")
  104.  
  105. if not "None" in ethernet_ip:
  106.     print("Your Ethernet IP address is: %s") % (str(ethernet_ip))
  107.     print("Your Ethernet MAC address is: %s") % (str(ethernet_mac))
  108. elif os.name != "nt":
  109.     print("No active Ethernet Device was found")
  110.  
  111. if not "None" in wireless_ip:
  112.     print("Your Wireless IP address is: %s") % (str(wireless_ip))
  113.     print("Your Wireless Devices MAC Address is: %s") % (str(wireless_mac))
  114. elif os.name != "nt":
  115.     print("No active Wireless Device was found")
  116.  
  117. if not "None" in windows_ip:
  118.     print("Your Windows Host IP address is: %s") % (str(windows_ip))
  119.     print("Your Windows Mac address is: %s") % (str(windows_mac))
  120. else:
  121.     print("You are not running Windows")
  122.  
  123. if not "None" in hostname:
  124.     print("Your System's hostname is: %s") % (hostname)
  125.  
  126. if host_fqdn == 'localhost':
  127.     print("Your System is not Registered to a Domain")
  128. else:
  129.     print("Your System's Fully Qualifed Domain Name is: %s") % (host_fqdn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement