mal_s3_upload_3.py 525 B

1234567891011121314
  1. def upload_s3(filename, md5, sha256, filetype):
  2. try:
  3. # Connect and upload to S3 bucket
  4. conn = boto.connect_s3()
  5. bucket = conn.create_bucket(unique_string.lower() + '_malware')
  6. k = Key(bucket)
  7. # Set unique_id
  8. k.key = sha256
  9. k.set_metadata('md5_hash', md5)
  10. k.set_metadata('file_type', filetype)
  11. k.set_contents_from_filename(filename)
  12. return 'success'
  13. except:
  14. return 'upload to s3 failed, make sure your aws keys are set in ~/.boto'