Пример #1
0
    def run(self, ctx):
        # retrieve the primary unit (first unit of first artifact, assume it exists)
        prj = ctx.getMainProject()
        assert prj, 'Need a project'

        unit = prj.getLiveArtifact(0).getUnits().get(0)
        if unit.getFormatType() != WellKnownUnitTypes.typePdf:
            raise Exception('Expected a PDF file')

        # [OPTIONAL] refer to https://github.com/pnfsoftware/jeb2-plugin-pdf/tree/master/src/main/java/com/pnf/plugin/pdf
        # the unit retrieved is of the IPdfUnit type, and has additional methods, eg getStatistics() provide a PdfSTatistics object
        print 'Encrypted:', unit.getStatistics().isEncrypted()

        # process all PDF Stream units
        for unit in UnitUtil.findDescendantsByFormatType(unit, 'Stream'):
            # the pdf plugin is lazy, make sure to process sub-units before retrieving data
            if not unit.isProcessed():
                unit.process()

            # retrieve the 'Decoded Stream' text document
            for pres in unit.getFormatter().getDocumentPresentations():
                if pres.getLabel() == 'Decoded Stream':
                    doc = pres.getDocument()
                    text = TextDocumentUtil.getText(doc)
                    print '%s: %s' % (unit.getName(), text[:50] + '...'
                                      )  # TODO: eg, dump text to file(s)
                    doc.dispose()
Пример #2
0
  def run(self, ctx):
    # current IRuntimeProject
    prj = ctx.getMainProject()
    # find the first IApkUnit in the project
    apk = prj.findUnit(IApkUnit)
    # retrieve the IXmlUnit representing the Android Manifest
    man = apk.getManifest()

    # 1) print the manifest (first presentation offered by the unit)
    doc = man.getFormatter().getPresentation(0).getDocument()
    print(TextDocumentUtil.getText(doc))

    # 2) retrieve the org.w3c.dom.Document
    doc = man.getDocument()
    # ...
Пример #3
0
  def exportSourceUnit(self, srcUnit, outdir):
    ext = srcUnit.getFileExtension()
    if isinstance(srcUnit, INativeSourceUnit):
      filename = srcUnit.getName() + '.' + ext
      dirpath = outdir
    else:
      csig = srcUnit.getFullyQualifiedName()
      filename = csig[1:len(csig)-1] + '.' + ext
      dirpath = os.path.join(outdir, filename[:filename.rfind('/') + 1])

    if not os.path.exists(dirpath):
      os.makedirs(dirpath)

    doc = srcUnit.getSourceDocument()
    text = TextDocumentUtil.getText(doc)

    filepath = os.path.join(outdir, filename)
    with open(filepath, 'wb') as f:
      f.write('// Decompiled by JEB v%s\n\n' % self.ctx.getSoftwareVersion())
      f.write(text.encode('utf-8'))
Пример #4
0
  def exportSourceUnit(self, srcUnit, outdir):
    ext = srcUnit.getFileExtension()

    csig = srcUnit.getFullyQualifiedName()
    subpath = csig[1:len(csig)-1] + '.java'
    dirname = subpath[:subpath.rfind('/') + 1]

    dirpath = os.path.join(outdir, dirname)
    if not os.path.exists(dirpath):
      os.makedirs(dirpath)

    # source document (interactive text)
    doc = srcUnit.getSourceDocument()

    # convert it to a string
    text = TextDocumentUtil.getText(doc)

    filepath = os.path.join(outdir, subpath)
    with open(filepath, 'wb') as f:
      f.write('// Decompiled by JEB v%s\n\n' % self.ctx.getSoftwareVersion())
      f.write(text.encode('utf-8'))
Пример #5
0
    def run(self, ctx):
        # current IRuntimeProject
        prj = ctx.getMainProject()
        assert prj, 'Need a project'

        # find the first IApkUnit in the project
        apk = prj.findUnit(IApkUnit)
        assert apk, 'Need an apk unit'

        # retrieve the IXmlUnit representing the Android Manifest
        man = apk.getManifest()
        assert man, 'The Manifest was not found'

        # 1) print the manifest (first presentation offered by the unit)
        doc = man.getFormatter().getPresentation(0).getDocument()
        print(TextDocumentUtil.getText(doc))

        # 2) retrieve the org.w3c.dom.Document
        doc = man.getDocument()
        # ...

        doc.dispose()