| skipped 21 lines |
22 | 22 | | def handle(self): |
23 | 23 | | try: |
24 | 24 | | print('[+] Connection from '+ self.client_address[0]) |
25 | | - | self.pool = multiprocessing.Pool(5) |
26 | | - | for output in self.pool.imap_unordered(self.search, iter(str(self.rfile.readline), '\n')): |
| 25 | + | self.pool = multiprocessing.Pool(10) |
| 26 | + | for output in self.pool.imap(SearchHandler.search, iter(self.rfile.readline, b'\n'), 5): |
27 | 27 | | if not output[0]: |
28 | 28 | | #error'd out. print the results, but don't send them on? |
29 | 29 | | print(output[1]) |
30 | 30 | | continue |
31 | | - | if json.loads(output[1]).get("results", False): |
32 | | - | print('[+] Found results for: {}'.format(' '.join(term))) |
| 31 | + | jsonOutput = json.loads(output[1]) |
| 32 | + | if jsonOutput.get("results", False): |
| 33 | + | print('[+] Found results for: {}'.format(jsonOutput.get("SEARCH", output))) |
33 | 34 | | self.wfile.write(output.encode()) |
34 | 35 | | else: |
35 | | - | print('[-] No results for: {}'.format(' '.join(term))) |
| 36 | + | print('[-] No results for: {}'.format(jsonOutput.get("SEARCH", output))) |
36 | 37 | | |
37 | 38 | | self.pool.close() |
38 | 39 | | self.pool.join() |
| skipped 4 lines |
43 | 44 | | print("[-] Exception Caught: {}".format(e)) |
44 | 45 | | self.pool.join() |
45 | 46 | | |
46 | | - | def search(data): |
| 47 | + | @classmethod |
| 48 | + | def search(cls, data): |
47 | 49 | | try: |
48 | 50 | | term = data.decode().strip().split(" ") |
49 | 51 | | term[-1] = term[-1][:3] #cut down on the last item which should be the version number |
| skipped 7 lines |
57 | 59 | | |
58 | 60 | | except Exception as e: |
59 | 61 | | return [False, "[-] ".format(e)] |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | class ExploitServer(socketserver.ThreadingMixIn, socketserver.TCPServer): |
| skipped 32 lines |