Example #1
0
 def __init__(self, device_id, threads_num=20):
     threading.Thread.__init__(self)
     self.processes = []
     self._adb = AndroidDebuggingBridge(device_id)
     self._processes_queue = Queue.Queue()
     self._THREADS_NUM = threads_num
     self._create_threads()
Example #2
0
def main(args):
    processes = []
    try:
        console_writer_q, log_file_q, metadata_file_q = set_up_writers(args)
        print("[!] Set up plugins. it may take a few seconds ..")
        sleep(2.5)
        acm = Acf(device_id=args.device_id, threads_num=args.threads)
        acm.setDaemon(True)
        acm.start()

        adb = AndroidDebuggingBridge(args.device_id)

        while True:
            running_processes = get_running_processes(adb, args.package_filter,
                                                      args.user_filter)
            for process in running_processes:
                if process not in processes:
                    p = Process(process, console_writer_q, log_file_q,
                                metadata_file_q)
                    processes.append(process)
                    acm.processes.append(p)
            sleep(1.2)

    except KeyboardInterrupt:
        print("Bye Bye")
        exit(0)
Example #3
0
 def __init__(self, device_id, threads_num=20):
     threading.Thread.__init__(self)
     self.processes = []
     self._device_id = device_id
     self._command = "shell cat /proc/{pid}/net/icmp /proc/{pid}/net/tcp /proc/{pid}/net/udp /proc/{pid}/net/raw"
     self._adb = AndroidDebuggingBridge(device_id)
     self._processes_queue = queue.Queue()
     self._THREADS_NUM = threads_num
     self._create_threads()
Example #4
0
    def _acm_worker(self):
        while True:
            process = self._processes_queue.get()
            output = AndroidDebuggingBridge.shell(self._command.format(pid=process.pid), self._device_id)
            if DIRECTORY_NOT_FOUND in output:
                self._processes_queue.task_done()
                continue
            conns = output.split("\r\r\n")
            process.updateConnections(conns)

            self._processes_queue.task_done()
Example #5
0
    def _acm_worker(self):
        while True:
            process = self._processes_queue.get()
            output = AndroidDebuggingBridge.shell(
                self._command.format(pid=process.pid), self._device_id)
            if DIRECTORY_NOT_FOUND in output:
                self._processes_queue.task_done()
                continue
            conns = output.split("\r\n")
            process.updateConnections(conns)

            self._processes_queue.task_done()
Example #6
0
class Acf(threading.Thread):
    def __init__(self, device_id, threads_num=20):
        threading.Thread.__init__(self)
        self.processes = []
        self._adb = AndroidDebuggingBridge(device_id)
        self._processes_queue = Queue.Queue()
        self._THREADS_NUM = threads_num
        self._create_threads()

    def run(self):
        while True:
            if self._processes_queue.empty():
                self._populate_processes_queue()
            sleep(0.8)

    def _populate_processes_queue(self):
        for p in self.processes:
            self._processes_queue.put(p)

    def _acm_worker(self):
        while True:
            process = self._processes_queue.get()
            self._adb.execute("shell cat /proc/%s/net/tcp" % process.pid)
            tcp_conns = self._adb.output.split("\r\r\n")
            process.updateTcp(tcp_conns)

            self._adb.execute("shell cat /proc/%s/net/udp" % process.pid)
            udp_conns = self._adb.output.split("\r\r\n")
            process.updateUdp(udp_conns)
            self._processes_queue.task_done()

    def _create_threads(self):
        for i in xrange(self._THREADS_NUM):
            t = threading.Thread(target=self._acm_worker)
            t.daemon = True
            t.start()