Why does it make a difference to insert an ELF into a SQLite3 database via console or python

126 views Asked by At

When I insert an ELF into a SQLite database via the command:

$ sqlite3 insert into TABLE values('name', readfile('executable'));

I can execute the extracted pendant to it. But when I insert the blob file via the following python command:

>>> cursor.execute('''INSERT INTO table(Name,Executable) VALUES(?,?)''',('name',sqlite3.Binary(file)))

I get the error message

cannot execute binary file: Fehler im Format der Programmdatei

So it seems that sql.Binary() changes the file. The ELF extracted after the second method is way smaller than the other one.

Whan am I doing wrong? Actually both methods should do the same, right?

1

There are 1 answers

0
Maximilian On BEST ANSWER

io.open() is doing the job. It doesn't convert the file to octet-stream