google / binexport

Export disassemblies into Protocol Buffers
Apache License 2.0
1.03k stars 197 forks source link

Error while diffing: Export of the secondary database failed #81

Open romanholidaypancakes opened 3 years ago

romanholidaypancakes commented 3 years ago

log:

Error while diffing: Export of the secondary database failed: Error executing: '"E:\tools\reverse\IDA PRO 7.5\ida64.exe" "-A" "-OBinExportAutoAction:BinExportBinary" "-OBinExportModule:C:\Users\USER~3\AppData\Local\Temp\BinDiff\secondary\test.sys1.BinExport" "-OBinExportAlsoLogToStdErr:FALSE" "-OBinExportX86NoReturnHeuristic:FALSE" "E:\testbin\test.sys1.i64"'

maybe related :https://github.com/google/binexport/issues/71

I noticed that the path contains the user USER~3. Now my computer does not contain this user, so the path does not exist. Is it a better solution not to use the path of a specific user?

cblichmann commented 3 years ago

Hi there,

BinDiff uses BinExport's GetOrCreateTempDirectory() and then invokes the IdbExporter:

  auto temp_dir = GetOrCreateTempDirectory("BinDiff");
  // ...
  const std::string secondary_temp_dir = JoinPath(*temp_dir, "secondary");
  // ...
  const auto& config = config::Proto();
    auto options =
        IdbExporter::Options()
            .set_export_dir(secondary_temp_dir)
            .set_ida_dir(idadir(/*subdir=*/nullptr))
            .set_alsologtostderr(Plugin::instance()->alsologtostderr());
    // ...
    IdbExporter exporter(options);
    exporter.AddDatabase(secondary_idb_path);

    absl::Status status;
    std::thread export_thread(
        [&status, &exporter]() { status = exporter.Export(); });

Under the hood, on Windows, this calls into GetTempPathA(). This will likely return a per-user path, which may contain a shortened path based on the value of %USERPROFILE%.

I'm not sure what goes wrong here, but you can try to set the TEMP environment variable to, say, C:\TEMP (and create this dir). If the MSDN documentation for GetTempPathA() is correct, it should pick up this path first.

Are you running the new BinDiff 7? And which version of Windows?

romanholidaypancakes commented 3 years ago

win10 and bindiff7.

cblichmann commented 3 years ago

Did my suggestion to set the TEMP environment variable help at all?

Another thing to check: Are you using a non-US locale or non US-English settings for the user interface language?

romanholidaypancakes commented 3 years ago

I still get an error after trying,(i forgot to reply...

cblichmann commented 3 years ago

(back from vacation)

I still get an error after trying,(i forgot to reply...

Does that mean you set TEMP to a different value and it didn't help? Also (see above), this is sensitive to local and user interface settings. Are you on a non-US locale or non US-English interface language?

As is, I cannot reproduce (and hence fix) this issue, unfortunately.

romanholidaypancakes commented 3 years ago

steps: ida(load primary idb file) - file - bindiff - load secondary idb file

There is a correct path in the option BinExportModule now, but the binfile.BinExport file is not generated, here is the error log:

Error while diffing: Export of the secondary database failed: Error executing: '"E:\tools\reverse\IDA PRO 7.5\ida64.exe" "-A" "-OBinExportAutoAction:BinExportBinary" "-OBinExportModule:C:\temp\BinDiff\secondary\binfile.BinExport" "-OBinExportAlsoLogToStdErr:FALSE" "-OBinExportX86NoReturnHeuristic:FALSE" "C:\Users\user1\Desktop\test\filedir\binfile.i64"'

I'm using a non-English windows system.

SiOuz commented 3 years ago

Same error here on windows version

cblichmann commented 3 years ago

@SiOuz, what is your language locale? I'm guessing non-US also?

babrath commented 2 years ago

I get the same issue on Kali Linux (2021.3), for IDA Free 7.6 and BinDiff 7.

cblichmann commented 2 years ago

@babrath, what happens if you manually execute the command that is printed (try setting -OBinExportAlsoLogToStdErr:TRUE, though)?

babrath commented 2 years ago

@cblichmann So the command was printed nowhere, but I found it using an strace. So I executed:

/home/kali/tools/idafree-7.6/ida64 -A -OBinExportAutoAction:BinExportBinary -OBinExportModule:/tmp/bindiff/secondary/patched.BinExport -OBinExportAlsoLogToStdErr:TRUE -OBinExportX86NoReturnHeuristic:FALSE /home/kali/repos/task2/patched.i64

And got the following output:

Gtk-Message: 11:09:48.254: Failed to load module "gail"

** (ida64:1638): WARNING **: 11:09:48.261: (../atk-adaptor/bridge.c:1018):atk_bridge_adaptor_init: runtime check failed: (root)
/usr/share/themes/Kali-Dark/gtk-2.0/gtkrc:39: Unable to find include file: "apps.rc"
/usr/share/themes/Kali-Dark/gtk-2.0/gtkrc:40: Unable to find include file: "hacks.rc"
/usr/share/themes/Kali-Dark/gtk-2.0/gtkrc:41: Unable to find include file: "hacks-dark.rc"
I1021 11:09:48.507509    1638 main_plugin.cc:353] BinExport 12 (@377499286, Jun  4 2021), (c)2004-2011 zynamics GmbH, (c)2011-2021 Google LLC.

None of which seem relevant? No new files appeared in /tmp/bindiff/secondary/, and the exit code is 1.

shmily-ou commented 1 year ago

Thanks