| skipped 22 lines |
23 | 23 | | output = [] |
24 | 24 | | for data in iter(self.rfile.readline, ''): |
25 | 25 | | term = data.decode().strip() |
26 | | - | if re.search("^[\w\s:\-\+\._]+$", term): |
| 26 | + | if not re.search("^[\w\s:\-\+\.~_]+$", term): |
27 | 27 | | print("[-] recieved search term with invalid characters: {}".format(term)) |
28 | 28 | | continue |
29 | 29 | | |
30 | 30 | | print('[ ] Searching for: ' + term) |
31 | | - | splitTerms = term.split(" ") |
32 | | - | splitTerms[-1] = splitTerms[-1][:3] #cut down on the last item which should be the version number |
33 | 31 | | proc = subprocess.Popen([_searchsploit, *splitTerms], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
34 | 32 | | self.wfile.write('{}\n'.format(proc.stdout.read()).encode()) |
35 | 33 | | print('[$] Closing connection from {}\n'.format(self.client_address[0])) |
36 | 34 | | except Exception as e: |
37 | 35 | | print("[-] Caught exception {}. Closing this connection.".format(e)) |
38 | | - | self.wfile.write("[-] Server caught {}. Closing Connection".format(e).encode()) |
| 36 | + | self.wfile.write("[-] Server caught {}. Closing Connection\n".format(e).encode()) |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
| skipped 33 lines |