It’s possible to store a EXE file inside a MySQL database. You can try this out. For demonstration purposes I’m running MySQL in my localhost. I will be creating a simple database and a table big enough to store the exe file. Since we convert the exe to a hex file the content would be larger than the original exe file. I will be using ‘putty.exe’ as the binary.
CREATE DATABASE testupload;
CREATE TABLE uploads (
id INT(3) NOT NULL AUTO_INCREMENT,
name VARCHAR(1000000) NOT NULL,
PRIMARY KEY (id)
First we convert the exe in hex format. For this we can use MySQL’s hex() function.
select hex(load_file(‘C:/tmp/putty.exe’)) into dumpfile ‘C:/tmp/putty.dmp’;
Next let’s store the dumped hex file inside our table.
load data infile ‘C:/tmp/putty.dmp’ into table uploads fields
terminated by ‘@OsandaMalith’ lines terminated by ‘@OsandaMalith’ (name);
Now we can dump the file from our table and see nothing has changed. We use the unhex() function in MySQL to convert back to a exe.
select unhex(name) from uploads into dumpfile ‘C:/tmp/new.exe’;
Let’s check the SHA-256 checksum of both the original and the new exe file and you can see no change has been occurred during this process.
One thought on “Storing a EXE inside MySQL”
The MySQL has a blob fields types.