(self, args)
| 11 | |
| 12 | #:todo: make this more efficient |
| 13 | def sort(self, args): |
| 14 | self.hits = {} |
| 15 | self.query = None |
| 16 | self.param = None |
| 17 | self.prequery = "SELECT ID, TYPE, LANGUAGE, ARCHITECTURE, PLATFORM, NAME FROM MALWARES WHERE " |
| 18 | self.ar = [] |
| 19 | args = [x.lower() for x in args] |
| 20 | |
| 21 | for arg in args: |
| 22 | for optname, values in globals.vars.opts: |
| 23 | for value in values: |
| 24 | if arg in value: |
| 25 | self.hits.update({optname: value}) |
| 26 | # Malware name checking has its own iterations to avoid false matches |
| 27 | if not self.hits: |
| 28 | for arg in args: |
| 29 | for name in self.names: |
| 30 | if arg in name: |
| 31 | self.query = "NAME LIKE ?" |
| 32 | self.param = name |
| 33 | |
| 34 | if len(self.hits) > 0: |
| 35 | self.query = self.build_query(self.hits) |
| 36 | self.ar = self.db.query(self.prequery + self.query) |
| 37 | self.print_payloads(self.ar) |
| 38 | elif self.param is not None: |
| 39 | self.ar = self.db.query(self.prequery + self.query, [self.param]) |
| 40 | self.print_payloads(self.ar) |
| 41 | else: |
| 42 | print "Error: filter did not match any malware :(" |
| 43 | exit() |
| 44 | |
| 45 | return self.hits |
| 46 | |
| 47 | # Build the dynamic query |
| 48 | def build_query(self, dic): |
no test coverage detected