mirror of https://github.com/CIRCL/PyCIRCLean
Open file and magic.read_buffer in helpers.py
parent
cc5d1e5117
commit
4bc113cefa
20
.travis.yml
20
.travis.yml
|
@ -41,11 +41,11 @@ install:
|
||||||
- sudo apt-get install rar
|
- sudo apt-get install rar
|
||||||
# Prepare tests
|
# Prepare tests
|
||||||
# Malware from theZoo
|
# Malware from theZoo
|
||||||
- git clone https://github.com/Rafiot/theZoo.git
|
# - git clone https://github.com/Rafiot/theZoo.git
|
||||||
- pushd theZoo/malwares/Binaries
|
# - pushd theZoo/malwares/Binaries
|
||||||
- python unpackall.py
|
# - python unpackall.py
|
||||||
- popd
|
# - popd
|
||||||
- mv theZoo/malwares/Binaries/out tests/uncategorized/
|
# - mv theZoo/malwares/Binaries/out tests/uncategorized/the_zoo/
|
||||||
# Path traversal attacks
|
# Path traversal attacks
|
||||||
- git clone https://github.com/jwilk/path-traversal-samples
|
- git clone https://github.com/jwilk/path-traversal-samples
|
||||||
- pushd path-traversal-samples
|
- pushd path-traversal-samples
|
||||||
|
@ -56,17 +56,21 @@ install:
|
||||||
- make
|
- make
|
||||||
- popd
|
- popd
|
||||||
- popd
|
- popd
|
||||||
- mv path-traversal-samples/zip/*.zip tests/uncategorized/
|
- mv path-traversal-samples/zip/*.zip tests/uncategorized/path_traversal_zip
|
||||||
- mv path-traversal-samples/rar/*.rar tests/uncategorized/
|
- mv path-traversal-samples/rar/*.rar tests/uncategorized/path_traversal_rar
|
||||||
# Office docs
|
# Office docs
|
||||||
- git clone https://github.com/eea/odfpy.git
|
- git clone https://github.com/eea/odfpy.git
|
||||||
- mv odfpy/tests/examples/* tests/uncategorized/
|
- mv odfpy/tests/examples/* tests/uncategorized/odfpy
|
||||||
- pushd tests/uncategorized/
|
- pushd tests/uncategorized/
|
||||||
|
- mkdir olefile && pushd olefile
|
||||||
- wget https://bitbucket.org/decalage/olefileio_pl/raw/3073963b640935134ed0da34906fea8e506460be/Tests/images/test-ole-file.doc
|
- wget https://bitbucket.org/decalage/olefileio_pl/raw/3073963b640935134ed0da34906fea8e506460be/Tests/images/test-ole-file.doc
|
||||||
|
- popd
|
||||||
|
- mkdir fraunhofer && pushd fraunhofer
|
||||||
- wget --no-check-certificate https://www.officedissector.com/corpus/fraunhoferlibrary.zip
|
- wget --no-check-certificate https://www.officedissector.com/corpus/fraunhoferlibrary.zip
|
||||||
- unzip -o fraunhoferlibrary.zip
|
- unzip -o fraunhoferlibrary.zip
|
||||||
- rm fraunhoferlibrary.zip
|
- rm fraunhoferlibrary.zip
|
||||||
- popd
|
- popd
|
||||||
|
- popd
|
||||||
# - pushd tests/dangerous/
|
# - pushd tests/dangerous/
|
||||||
# - 7z x -p42 42.zip
|
# - 7z x -p42 42.zip
|
||||||
# - popd
|
# - popd
|
||||||
|
|
|
@ -240,7 +240,8 @@ class FileBase(object):
|
||||||
self.set_property('symlink_path', os.readlink(file_path))
|
self.set_property('symlink_path', os.readlink(file_path))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
mt = magic.from_file(file_path, mime=True)
|
with open(file_path, 'rb') as file:
|
||||||
|
mt = magic.from_buffer(file, mime=True)
|
||||||
# libmagic will always return something, even if it's just 'data'
|
# libmagic will always return something, even if it's just 'data'
|
||||||
except UnicodeEncodeError as e:
|
except UnicodeEncodeError as e:
|
||||||
raise UnicodeEncodeError(e)
|
raise UnicodeEncodeError(e)
|
||||||
|
|
Loading…
Reference in New Issue