Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do I use the _generate_html function? #323

Open
z1r00 opened this issue Dec 4, 2024 · 1 comment
Open

how do I use the _generate_html function? #323

z1r00 opened this issue Dec 4, 2024 · 1 comment

Comments

@z1r00
Copy link

z1r00 commented Dec 4, 2024

Hello, how do I use the _generate_html function?
I set the corresponding global variables, but it did not execute successfully.
The error is as follows

[Diaphora: Wed Dec 4 10:19:25 2024] Sorry, there is no pseudo-code available for either the first or the second database.
[Diaphora: Wed Dec 4 10:19:25 2024] Sorry, there is no assembly available for either the first or the second database.

It will go through the following function

def generate_pseudo_diff(self, ea1, ea2, html=True, error_func=log):
    cur = self.db_cursor()
    try:
      sql = """select *
        from (
        select prototype, pseudocode, name, 1
         from functions
        where address = ?
          and pseudocode is not null
    union
       select prototype, pseudocode, name, 2
         from diff.functions
        where address = ?
          and pseudocode is not null)
        order by 4 asc"""
      ea1 = str(int(ea1, 16))
      ea2 = str(int(ea2, 16))
      cur.execute(sql, (ea1, ea2))
      print("[*] sql = " + sql)
      rows = cur.fetchall()
      res = None
      if len(rows) != 2:
        error_func(
          "Sorry, there is no pseudo-code available for either the first or the second database."
        )
      else:
        row1 = rows[0]
        row2 = rows[1]

        html_diff = CHtmlDiff()
        proto1 = self.decompile_and_get(int(ea1))
        if proto1:
          buf1 = proto1 + "\n" + "\n".join(self.pseudo[int(ea1)])
        else:
......

There is no diff.functions in the sqlite generated in DIAPHORA_DB1

sqlite> .tables
basic_blocks                function_bblocks
bb_instructions             functions
bb_relations                instructions
callgraph                   program
compilation_unit_functions  program_data
compilation_units           version
constants

At the same time, the output.sqlite generated by me according to the operation document does not have it, only the following tables

sqlite> .tables
config     results    unmatched

My ultimate goal is to get the comparison results through diaphora and save them in html, or save them in a diff file

@joxeankoret
Copy link
Owner

Hey!

There is no diff.functions in the sqlite generated in DIAPHORA_DB1

There is no diff.XXX table as diff is how I name the attached SQLite database, the schema, if you prefer. To read the diff.functions table you need to query the functions table in the 2nd database (DIAPHORA_DB2).

My ultimate goal is to get the comparison results through diaphora and save them in html, or save them in a diff file

For this you will need to do the following:

  1. Get the diffing results from, in your case, output.sqlite.
  2. Read the appropriate function from the functions table in DIAPHORA_DB1 (which is usually referenced by Diaphora internally as main.functions or as functions, because by default it tries to find tables in the main schema) to get the assembly or pseudo-code for the function to diff.
  3. Read the appropriate function from the functionstable in DIAPHORA_DB2 (which is referenced by Diaphora internally as diff.functions) to get the assembly or pseudo-code for the function to diff against.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants