class Deobfuscator: def deobLink(self, url, jscommentname, jsname, chunkoutdir, beautifydir): chromeDeob.chromeDeobLink(url, jscommentname) # rmcomment.rmCommentFile(jscommentname, jsname) chunkJS.chunkJSFile(jscommentname, chunkoutdir) jsbeautify.jsdeobfuscatedir(chunkoutdir, beautifydir) def deobTestLink(self, url): paras = utils.genTestName(url) self.deobLink(paras[0], paras[1], paras[2], paras[3], paras[4]) def deobSpecificURL(self, url, filename): thefile = open(filename, 'r') for line in thefile: paras = utils.genTempnameLine(line) if paras[0] == url: self.deobLink(paras[0], paras[1], paras[2], paras[3], paras[4]) def deobFile(self, filename): log = utils.LOG() progress = log.STATUS(filename) thefile = open(filename, 'r') count = 0 for line in thefile: count = count + 1 if count <= progress: continue print line paras = utils.genTempnameLine(line) self.deobLink(paras[0], paras[1], paras[2], paras[3], paras[4]) log.UPDATE(filename, count) def deobFiles(self, regex, order = -1): # deobfuscate files that match regex and generate output to ../../data/JSAdd2Tree files = utils.lsresult(regex) num_files = len(files) if order == -1: for i in range(num_files-1, -1, -1): print 'Processing file: ' + files[i] self.deobFile(files[i]) elif order == 1: for i in range(0, num_files): print 'Processing file: ' + files[i] self.deobFile(files[i]) def deobLabel(self, label): self.con = PsqlCon() res = self.con.psqlSelectOneLabel('TEST') for url, url_hash, label in res: paras = utils.genTempnameTuple(url, url_hash, label) self.deobLink(paras[0], paras[1], paras[2], paras[3], paras[4]) def deobTerry(self): malurl.formatFile('../../data/JSTerry/javascript_20131018/terryurl', '../../data/TempData/URLs/terryurl', '../../data/JSTerry/javascript_20131018/') self.deobFile('../../data/TempData/URLs/terryurl')
def deobLabel(self, label): self.con = PsqlCon() res = self.con.psqlSelectOneLabel('TEST') for url, url_hash, label in res: paras = utils.genTempnameTuple(url, url_hash, label) self.deobLink(paras[0], paras[1], paras[2], paras[3], paras[4])