viper-framework / viper

Binary analysis and management framework
Other
1.54k stars 351 forks source link

"copy -d" exception #670

Closed xme closed 6 years ago

xme commented 6 years ago

I was facing a strange issue when moving files between projects. The first 'copy -d' was always successful but the next ones always raised an exception. Today, I took time to investigate deeper and found the reason.

In viper/core/ui/commands.py, files to be deleted are processed in a loop:

for item_id, item_sha256 in db.copied_id_sha256:

But db.copied_id_sha256 is not initialized before each 'copy -d' command and still contains all the SHA256 of files to be deleted, which causes the exception starting from the 2nd 'copy -d'. I just added the following line:

db.copied_id_sha256 = []

before the call to db.copy()...

botherder commented 6 years ago

I can't seem to be able to replicate this. Would you have a full traceback?

xme commented 6 years ago

Removed my patch and here we go:

default viper d.exe > copy -d Archived [+] Copied: xxxxxxxxx (xxxxxx.exe) [!] The opened file doesn't appear to be in the database, have you stored it yet? [!] The command copy raised an exception: Traceback (most recent call last): File "/home/viper/viper/viper/core/ui/console.py", line 312, in start self.cmd.commands[root]'obj' File "/home/viper/viper/viper/core/ui/commands.py", line 285, in run os.remove(get_sample_path(item_sha256)) TypeError: unlink: can't specify None for path argument

botherder commented 6 years ago

Is this for a stored file from an existing project or just an opened file?

xme commented 6 years ago

Just an imported file and already stored in the 'default' project.

botherder commented 6 years ago

This should be fixed now, let me know if it works.