mirror of https://github.com/CIRCL/Circlean
partial implementation of unpacking (archives)
parent
a2d1ec8e63
commit
016c0a681b
|
@ -1,4 +1,4 @@
|
||||||
# Paths to the commands used to convert the files
|
# Paths to the commands used to convert the files
|
||||||
PDF="/usr/local/bin/pdf2htmlEX"
|
PDF="/usr/bin/pdf2htmlEX"
|
||||||
LO="/usr/bin/libreoffice"
|
LO="/usr/bin/libreoffice"
|
||||||
|
UNPACKER="/usr/bin/7z"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
source ./constraint.sh
|
source ./constraint.sh
|
||||||
source ./constraint_conv.sh
|
source ./constraint_conv.sh
|
||||||
|
|
||||||
|
@ -17,36 +20,44 @@ copy(){
|
||||||
text(){
|
text(){
|
||||||
echo Text file ${1}
|
echo Text file ${1}
|
||||||
# XXX: append .txt ?
|
# XXX: append .txt ?
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Multimedia
|
# Multimedia
|
||||||
## WARNING: They are assumed safe.
|
## WARNING: They are assumed safe.
|
||||||
audio(){
|
audio(){
|
||||||
echo Audio file ${1}
|
echo Audio file ${1}
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
image(){
|
image(){
|
||||||
echo Image file ${1}
|
echo Image file ${1}
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
video(){
|
video(){
|
||||||
echo Video file ${1}
|
echo Video file ${1}
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Random - Used
|
# Random - Used
|
||||||
|
|
||||||
archive(){
|
archive(){
|
||||||
|
echo Archive file ${1}
|
||||||
|
src_file=${1}
|
||||||
|
dst_dir=${2}
|
||||||
|
temp_extract_dir=${dst_dir}_temp
|
||||||
|
mkdir -p ${temp_extract_dir}
|
||||||
|
${UNPACKER} x ${src_file} -o${temp_extract_dir} -bd
|
||||||
|
main ${dst_dir} ${RECURSIVE_ARCHIVE_CURRENT} ${temp_extract_dir}
|
||||||
|
rm -rf ${temp_extract_dir}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
application(){
|
application(){
|
||||||
echo App file ${1}
|
echo App file ${1}
|
||||||
src_file=${1}
|
src_file=${1}
|
||||||
dst_file=${2}${1##$SRC}
|
dst_file=${2}${1##$CURRENT_SRC}
|
||||||
mime_details=${3}
|
mime_details=${3}
|
||||||
case ${mime_details} in
|
case ${mime_details} in
|
||||||
pdf)
|
pdf)
|
||||||
|
@ -71,6 +82,10 @@ application(){
|
||||||
echo "Win executable"
|
echo "Win executable"
|
||||||
copy ${src_file} ${dst_file}_DANGEROUS
|
copy ${src_file} ${dst_file}_DANGEROUS
|
||||||
;;
|
;;
|
||||||
|
x-gzip|x-7z-compressed)
|
||||||
|
echo "Compressed file"
|
||||||
|
archive ${src_file} ${dst_file}
|
||||||
|
;;
|
||||||
octet-stream)
|
octet-stream)
|
||||||
echo "Unknown type."
|
echo "Unknown type."
|
||||||
copy ${src_file} ${dst_file}.bin
|
copy ${src_file} ${dst_file}.bin
|
||||||
|
@ -88,22 +103,22 @@ application(){
|
||||||
|
|
||||||
example(){
|
example(){
|
||||||
echo Example file ${1}
|
echo Example file ${1}
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
message(){
|
message(){
|
||||||
echo Message file ${1}
|
echo Message file ${1}
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
model(){
|
model(){
|
||||||
echo Model file ${1}
|
echo Model file ${1}
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
multipart(){
|
multipart(){
|
||||||
echo Multipart file ${1}
|
echo Multipart file ${1}
|
||||||
copy ${1} ${2}${1##$SRC}
|
copy ${1} ${2}${1##$CURRENT_SRC}
|
||||||
}
|
}
|
||||||
|
|
||||||
main(){
|
main(){
|
||||||
|
@ -114,21 +129,29 @@ main(){
|
||||||
# first param is the destination dir
|
# first param is the destination dir
|
||||||
dest=${1}
|
dest=${1}
|
||||||
|
|
||||||
|
if [ -z ${2} ]; then
|
||||||
|
CURRENT_SRC=${SRC}
|
||||||
|
else
|
||||||
|
CURRENT_SRC=${2}
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ${2} ]; then
|
|
||||||
RECURSIVE_ARCHIVE_CURRENT=${RECURSIVE_ARCHIVE_CURRENT}+1
|
if [ -z ${2} ]; then
|
||||||
SRC=${3}
|
RECURSIVE_ARCHIVE_CURRENT=0
|
||||||
|
else
|
||||||
|
RECURSIVE_ARCHIVE_CURRENT=${2}
|
||||||
|
CURRENT_SRC=${3}
|
||||||
if [ ${RECURSIVE_ARCHIVE_CURRENT} -gt ${RECURSIVE_ARCHIVE_MAX} ]; then
|
if [ ${RECURSIVE_ARCHIVE_CURRENT} -gt ${RECURSIVE_ARCHIVE_MAX} ]; then
|
||||||
echo Archive bomb.
|
echo Archive bomb.
|
||||||
rm -rf ${SRC}
|
rm -rf ${CURRENT_SRC}
|
||||||
exit
|
return
|
||||||
|
else
|
||||||
|
RECURSIVE_ARCHIVE_CURRENT=`expr ${RECURSIVE_ARCHIVE_CURRENT} + 1`
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
RECURSIVE_ARCHIVE_CURRENT=0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FILE_COMMAND='file -b --mime-type'
|
FILE_COMMAND='file -b --mime-type'
|
||||||
FILE_LIST=`find ${SRC} -type f`
|
FILE_LIST=`find ${CURRENT_SRC} -type f`
|
||||||
for file in ${FILE_LIST}; do
|
for file in ${FILE_LIST}; do
|
||||||
mime=`$FILE_COMMAND ${file}`
|
mime=`$FILE_COMMAND ${file}`
|
||||||
echo ${mime}
|
echo ${mime}
|
||||||
|
|
Loading…
Reference in New Issue