|
#! C:/perl/bin/perl.exe
Use strict;
Use warnings;
Use Digest: MD5;
Use dBi;
Use DBD: MySQL;
My $ filepath = "D: // malware // ixigua.exe ";
My $ filelen =-S $ filepath;
My $ MD5 = Digest: MD5-> New ();
Open (hfile, "<$ filepath") or die ("can't open: $! ");
Binmode (hfile );
$ MD5-> AddFile (* hfile );
My $ strmd5 = $ MD5-> hexdigest (); # Calculate the MD5 Value
Seek (hfile, 0, 0); # adjust the file pointer to the file header. required steps
My $ data; # store file content
My $ Len = read (hfile, $ data, $ filelen );
Close (hfile );
My $ DBH = DBI-> connect ("DBI: mysql: db_aaa; host = 192.168.22.252; user = ixigua; Password = aaa123", {raiseerror => 1 });
My $ insertstr = "insert into 'simple _ body' (simple_size, simple_body) values (?,?); "; # Reserved parameter location
My $…… = $ DBH-> prepare ($ insertstr) or die ("cannot prepare statement:", $ DBH-> errstr (), "/N ");
My $ rc = $ something-> execute ($ Filelen, $ data) Or die ("cannot execute statement:", $ something-> errstr (), "/N ");
My $ id = $ DBH->Last_insert_id(UNDEF, UNDEF, "'simple _ body'", "simple_body_key ");
# Ignore the first two parameters. 3rd are data table names and 4th are column names with auto-increment attributes.
Print 'insert _ id = ', $ id, "/N ";
Warn ($ DBI: errstr) If $ DBI: Err;
$ DBH-> disconnect (); ========================================================== ========== Note: If the database insert statement does not require parameter reservation,The operation fails.Why not found?
My $ insertstr = "insert into 'simple _ body' (simple_size, simple_body) values ($ Filelen, $ data); "; # Fill directly without reserved Parameters
My $…… = $ DBH-> prepare ($ insertstr) or die ("cannot prepare statement:", $ DBH-> errstr (), "/N ");
My $ rc = $ something-> execute () or die ("cannot execute statement:", $ something-> errstr (), "/N ");
|