예제 #1
0
    def run(self):
        # https://stackoverflow.com/questions/49978705/access-ip-camera-in-python-opencv/51166331
        try:
            uri = int(self.args["uri"])
        except:
            uri = self.args["uri"]
        print_info("Trying to connect...")
        cam = cv2.VideoCapture(uri)
        if cam:
            while (True):
                try:
                    success, frame = cam.read()
                    if success:
                        print_ok("Connected")
                        print_info("Use q in the frame to close it")
                        # Show frame
                        cv2.imshow('frame', frame)
                        # To close
                        if cv2.waitKey(1) & 0xFF == ord('q'):
                            cv2.destroyAllWindows()
                            break
                    else:
                        print_error("No connection")
                        break
                except KeyboardInterrupt:
                    break
                except:
                    pass

        else:
            print_error("No connection")
예제 #2
0
 def _load_theme(self, theme):
     theme = colors_terminal.get(theme[0], None)
     if theme is not None:
         ColorSelected(theme)
         print_ok("Theme changed!")
     else:
         print_error("Theme not available")
예제 #3
0
파일: atr.py 프로젝트: wanggh1021/KITT
    def update(self, observable, actions):
        try:
            readers = self._list()
            self.reader_name = readers[0]
        except:
            print_error("Error retreiving the reader")
        try:
            (addedcards, removedcards) = actions
            for card in addedcards:
                print_info(f"Reader 0: {self.reader_name}")
                print_ok_raw(f"Card State: Card inserted")
                print("ATR: ", toHexString(card.atr))

                atr = ATR(card.atr)
                if (self.verbose):
                    atr.dump()

                print()
                print_info(
                    "Possible identified card (using _smartcard_list.txt)")
                self.search_in_txt('utildata/_smartcard_list.txt',
                                   toHexString(card.atr))
            for card in removedcards:
                print_info(f"Reader 0: {self.reader_name}")
                print_error_raw(f"Card State: Card removed")
                print("ATR: ", toHexString(card.atr))
        except Exception as e:
            pass
예제 #4
0
    def run(self):
        try:
            shodan_api = shodan.Shodan(self.args["apishodan"])
            # Lookup the host
            host = shodan_api.host(self.args["rhost"])
        except Exception as e:
            print_error(e)
            print_error("Module has not been launched")
            return
        if host:
            # Print general info
            print_info(f"""
IP: {host['ip_str']}
Organization: {host.get('org', 'n/a')}
Operating System: {host.get('os', 'n/a')}
            """)

            # Print all banners
            for item in host['data']:
                print_info(f"""
Port: {item['port']}
Banner: {item['data']}
                    """)
        else:
            print_info("No data recollected")
예제 #5
0
    def run(self):
        """Creates the wifi advertisement with the given ssid, and phone or email
        """
        ssid = self.args.get("ssid", 'none')
        phone = self.args.get("phone", 'none')
        email = self.args.get("email", 'none')
        appleid = self.args.get("appleid", 'none')
        interval = int(self.args.get("interval", 200))
        dev_id = int(self.args.get("ble_iface", 0))

        toggle_device(dev_id, True)

        header = (0x02, 0x01, 0x1a, 0x1a, 0xff, 0x4c, 0x00)
        const1 = (0x0f, 0x11, 0xc0, 0x08)
        id1 = (0xff, 0xff, 0xff)
        contact_id_mail = self.get_hash(email)
        contact_id_tel = self.get_hash(phone)
        contact_id_appleid = self.get_hash(appleid)
        id_wifi = self.get_hash(ssid)
        const2 = (0x10, 0x02, 0x0b, 0x0c,)
        try:
            sock = bluez.hci_open_dev(dev_id)
        except:
            print_error(f"Cannot open bluetooth device {dev_id}")
            return

        try:
            print_info("Start advertising press ctrl + c to quit...")
            start_le_advertising(sock, adv_type=0x00, min_interval=interval, max_interval=interval, data=(
                        header + const1 + id1 + contact_id_appleid + contact_id_tel + contact_id_mail + id_wifi + const2))
            while True:
                sleep(2)    
        except:
            stop_le_advertising(sock)
예제 #6
0
    def run(self):
        ble_device = BLE(self.args["bmac"], self.args["type"])

        attempt = 1
        success = False
        while attempt <= 5 and not success:
            print_info(
                f"Trying to connect {self.args['bmac']}. (Attempt: {attempt})")
            try:
                ble_device.connect()
                success = True
            except KeyboardInterrupt:
                print_info("Interrupted... exit run")
                return
            except:
                attempt += 1

        if not success:
            print_error("Failed to connect")
            return

        uuid = self.args["uuid"]
        if uuid:
            ble_device.read_specific_characteristic(uuid)
        else:
            ble_device.read_all_characteristics()

        ble_device.disconnect()
예제 #7
0
    def run(self):
        if not has_nmap:
            print_error("To launch this module install nmap (sudo apt install nmap)")
            return
        print("Scanning...")
        nm = nmap.PortScanner()
        try:
            timeout = int(self.args["timeout"])
        except:
            timeout = 6

        result = nm.scan(self.args["rhost"], self.args["rports"], arguments=f"-s{self.args['scan']} --host-timeout {timeout}")
        try:
            state = result["scan"][self.args["rhost"]]["status"]["state"]
        except:
            state = "down"
        hs = "Host state"
        print("")
        print(hs)
        print("-"*len(hs))
        print_info(state)
        if state == "down":
            return
        ports = result["scan"][self.args["rhost"]]["tcp"]
        msg = "Services found"
        print(msg)
        print("-"*len(msg))
        found = False
        for key, value in ports.items():
            if value["state"] == "open":
                found = True
                print_info(f"{key}  -  {value['name']}")
        if not found:
            print_info("No open ports")
예제 #8
0
    def run(self):
        bmac = self.args["bmac"]
        try:
            iface = int(self.args["iface"])
        except:
            iface = 0
        data = self._transform_data(self.args["encode"], self.args["data"])
        if not data:
            return

        attempt = 1
        success = False
        ble_device = BLE(bmac, self.args["type"], iface)
        while attempt <= 5 and not success:
            print_info(f"Trying to connect {bmac}. (Attempt: {attempt})")
            try:
                ble_device.connect()
                success = True
            except KeyboardInterrupt:
                print_info("Interrupted... exit run")
                return 
            except:
                attempt += 1
        if not success:
            print_error("Failed to connect")
            return
        ble_device.write_data(data, self.args["uuid"])
        try:
            sleep(int(self.args["wait"]))
        except:
            sleep(2)
            
        ble_device.disconnect()
예제 #9
0
    def get_iface(self, interfaces):
        scanned_aps = []
        if len(interfaces) < 1:
            print_error(
                'No wireless interfaces found, bring one up and try again')
            self.exit = True
            return None
        if len(interfaces) == 1:
            for interface in interfaces:
                return interface

        # Find most powerful interface
        for iface in interfaces:
            count = 0
            proc = Popen(['iwlist', iface, 'scan'],
                         stdout=PIPE,
                         stderr=self.DN)
            for line in proc.communicate()[0].decode().split('\n'):
                if ' - Address:' in line:  # first line in iwlist scan for a new AP
                    count += 1
            scanned_aps.append((count, iface))
            print_ok(f'Networks discovered by {iface}: {count}')
        try:
            interface = max(scanned_aps)[1]
            return interface
        except Exception as e:
            print_error(f'Minor error: {e}')
            iface = interfaces[0]
            print_info(f'    Starting monitor mode on {iface}')
            return iface
예제 #10
0
    def run(self):
        if not has_nmap:
            print_error(
                "To launch this module install nmap (sudo apt install nmap)")
            return
        print("Trying to get OS")
        nm = nmap.PortScanner()
        try:
            timeout = int(self.args["timeout"])
        except:
            timeout = 6
        result = nm.scan(self.args["rhost"],
                         arguments=f"-O --host-timeout {timeout}")
        try:
            state = result["scan"][self.args["rhost"]]["status"]["state"]
        except:
            state = "down"
        print_info(f"Host state: <b>{state}</b>")

        try:
            print_info(
                f'OS: <b>{result["scan"][self.args["rhost"]]["osmatch"][0]["name"]}</b>'
            )
        except:
            print_info("OS not found")
예제 #11
0
 def stop(self, event, frame):
     self.exit = True
     if not self.monitor_on:
         self.remove_mon_iface(self.mon_iface)
         os.system('service network-manager restart')
     print("")
     print_error('Closing')
예제 #12
0
 def dump_tag(self, tag, path):
     if not tag.ndef:
         print_error("Some proble ocurred")
         return
     data = tag.ndef.octets
     with open(path, 'wb') as f:
         f.write(data)
         print("File generated")
예제 #13
0
 def run(self):
     client = mqtt.Client(client_id="MqttClient")
     client.on_connect = self.__on_connect
     try:
         client.connect(self.args["rhost"], 1883, 60)
         client.publish(self.args["sensor"], self.args["data"])
     except Exception as e:
         print_error(e)
예제 #14
0
 def setup_ap(self):
     ssid = self.devices.get(self.args["device"], None)
     if ssid:
         launch_ap(self.args.get("ap_iface"), self.args.get("net_iface"),
                   "6", True, False, "12345678", False, ssid, False,
                   self.args.get("tshark", False), False, [], "no")
     else:
         print_error("No valid device")
예제 #15
0
 def run(self):
     print_info("Launching Service")
     res = start_dirtytooth(self.args["bmac"], self.args["path"])
     if res == 1:
         print_ok("Done")
     elif res == 0:
         print_error(
             'Process dirtyagent doesn´t exist (use module launch-service first)'
         )
예제 #16
0
def get_shodan_search_matches(apikey, to_search):
    try:
        shodan_api = shodan.Shodan(apikey)
        print_info(f"Making request to Shodan. Search: {to_search}")
        result = shodan_api.search(to_search)
        return result["matches"]
    except Exception as e:
        print_error(e)
        return None
예제 #17
0
 def run(self):
     proc = Popen(f"hciconfig {self.args['iface']} reset".split(" "),
                  stdout=PIPE,
                  stderr=PIPE)
     data = proc.communicate()
     if len(data[1]) > 0:
         print_error(data[1].decode().strip())
     else:
         print_ok(f"{self.args['iface']} has been reset")
예제 #18
0
 def start_mon_mode(self, interface):
     print_ok(f'Starting monitor mode: {interface}')
     try:
         os.system('ifconfig %s down' % interface)
         os.system('iwconfig %s mode monitor' % interface)
         os.system('ifconfig %s up' % interface)
         return interface
     except Exception:
         print_error('Could not start monitor mode')
         self.exit = True
예제 #19
0
 def _transform_data(self, encode, data):
     if encode == "hex":
         try:
             data = bytes.fromhex(data.replace("0x",""))
         except:
             print_error("Bad Hexadecimal value check it")
             data = None 
     else:
         data = data.encode()
     return data
예제 #20
0
 def run(self):
     ascii_text = self.args["ascii"]
     try:
         binary_text = self.text_to_bits(ascii_text)
         hext_text = ascii_text.encode("utf-8").hex()
         print_info(f"Input -> {ascii_text}")
         print_info(f"|_ Hex: {hext_text}")
         print_info(f"|_ Bin: {binary_text}")
     except:
         print_error("Error processing input")
예제 #21
0
 def run(self):
     command = "nmcli dev wifi list"
     try:
         aux = check_call("nmcli", stdout=PIPE)
         data = Popen(command, shell=True, stdout=PIPE).stdout.read()
         i = 1
         for line in data.decode().split("\n"):
             print_info(line)
     except:
         print_error("nimcli not found")
예제 #22
0
 def upload(self, data):
     file_path = "./utildata/ble/"+data[0]
     try:
         with open(file_path, 'r') as file_read:
             for line in file_read.readlines():
                 data = line.split(":")
                 data[1] = data[1].strip()
                 self.set_value(data)
     except:
         print_error("Error reading file")
예제 #23
0
 def save(self, data):
     
     file_path = "./utildata/ble/"+data[0]
     data = [f"uuid:{self.args['uuid']}", f"type:{self.args['type']}", f"data:{self.args['data']}", 
             f"encode:{self.args['encode']}", f"wait:{self.args['wait']}"]
     try:
         with open(file_path, 'w') as file_save:
             for line in data:
                 file_save.write(line + "\n")
     except:
         print_error("Error writing file")
예제 #24
0
 def run(self):
     binary_text = self.args["binary"]
     try:
         ascii_text = self.text_from_bits(binary_text)
         hext_text = ascii_text.encode("utf-8").hex()
         print_info(f"Input -> {binary_text}")
         print_info(f"|_ Hex: {hext_text}")
         print_info(f"|_ Ascii: {ascii_text}")
     except Exception as e:
         print(e)
         print_error("Error processing input")
예제 #25
0
 def run(self):
     hex_text = self.args["hex"]
     try:
         ascii_text = binascii.unhexlify(hex_text).decode()
         binary_text = self.text_to_bits(ascii_text)
         hext_text = ascii_text.encode("utf-8").hex()
         print_info(f"Input -> {hext_text}")
         print_info(f"|_ Ascii: {ascii_text}")
         print_info(f"|_ Bin: {binary_text}")
     except:
         print_error("Error processing input")
예제 #26
0
파일: ble.py 프로젝트: lucianmaxx/HomePWN
 def subscribe(self):
     while True:
         try:
             self.device.waitForNotifications(1.0)
         except KeyboardInterrupt:
             print("Module Interrupted")
             return True
         except BTLEDisconnectError:
             print_error("Device disconnected...")
         except:
             self.disconnect()
예제 #27
0
 def wrapper(*args, **kwargs):
     logger = Logger.get_instance().get_logger()
     try:
         return func(*args, **kwargs)
     except KeyboardInterrupt:
         print_error("Interrupted...")
         return
     except:
         error = f"There was an exception in  {func.__name__}"
         logger.exception(error)
     if msg:
         print_error(msg)
예제 #28
0
 def run(self):
     url = f"http://{self.args['target']}/web/cgi-bin/hi3510/param.cgi?cmd=getuser"
     headers = {
         'User-Agent':
         'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0'
     }
     response = requests.get(url, headers=headers)
     if response.status_code == 200:
         for line in response.text.split("\n"):
             print_info(line)
     else:
         print_error(f"Response code: {response.status_code}")
예제 #29
0
 def read_qr(self, verbose, path):
     """Reads the QR code to get the attributes
     
     Args:
         verbose (Boolean): Set to True to verbose mode
         path (str): Path to store the image
     """
     try:
         read = decode(Image.open(path))
     except:
         print_error("Error, file not found or not readable")
         return
     display_qr(read, verbose)
예제 #30
0
 def run(self):
     try:
         self.file_to_save = open(self.args["file"], "w+")
     except Exception as e:
         print_error(e)
         print_error("Module has not been launched")
         return
     print_info(
         f'Trying to get information from {self.args["rhost"]}. The data is saved in {self.args["file"]}d'
     )
     new_process_function(self.__start,
                          name="mqtt_subscribe",
                          seconds_to_wait=1)