Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Dockerfile.processor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ipeddocker/iped:dependencies

ARG SNAPSHOT=true IPED_RELEASE_VERSION=4.2 SNAPSHOT_WORKFLOW_ID=12279329706 PKGTMPDIR=/tmp/pkgs
ARG SNAPSHOT=false IPED_RELEASE_VERSION=4.2.0 SNAPSHOT_WORKFLOW_ID=12279329706 PKGTMPDIR=/tmp/pkgs


RUN --mount=type=secret,id=ACTION_GH_TOKEN export ACTION_GH_TOKEN=$(cat /run/secrets/ACTION_GH_TOKEN) \
Expand Down Expand Up @@ -91,6 +91,24 @@ RUN --mount=type=secret,id=ACTION_GH_TOKEN export ACTION_GH_TOKEN=$(cat /run/sec
&& echo "#####################################" \
&& cp /usr/local/lib/python3.9/dist-packages/jep/jep-4.2.0.jar /opt/IPED/iped/lib/jep-4.0.3.jar \
&& echo "#####################################" \
&& echo "Configure TaskBridge-Scripts" \
&& echo "#####################################" \
&& sed -i -e 's/<task class="iped.engine.task.ParsingTask"><\/task>/<task class="iped.engine.task.ParsingTask"><\/task>\n <task script="VirusScanningTask.py"><\/task>/' /opt/IPED/iped/conf/TaskInstaller.xml \
&& sed -i -e 's/<task script="SearchHardwareWallets.py"><\/task>/<task script="SearchHardwareWallets.py"><\/task>\n <task script="AudioTranslateTask.py"><\/task>\n <task script="ImageClassificationTask.py"><\/task>/' /opt/IPED/iped/conf/TaskInstaller.xml \
&& git clone https://github.com/hilderonny/iped-audiotranslatetask.git \
&& git clone https://github.com/hilderonny/iped-virusscantask.git \
&& git clone https://github.com/hilderonny/iped-imageclassificationtask.git \
&& cp iped-audiotranslatetask/conf/AudioTranslation.txt /opt/IPED/iped/conf/AudioTranslation.txt \
&& cp iped-audiotranslatetask/scripts/tasks/AudioTranslateTask.py /opt/IPED/iped/scripts/tasks/AudioTranslateTask.py \
&& cp iped-imageclassificationtask/conf/ImageClassification.txt /opt/IPED/iped/conf/ImageClassification.txt \
&& cp iped-imageclassificationtask/scripts/tasks/ImageClassificationTask.py /opt/IPED/iped/scripts/tasks/ImageClassificationTask.py \
&& cp iped-virusscantask/conf/VirusScanning.txt /opt/IPED/iped/conf/VirusScanning.txt \
&& cp iped-virusscantask/scripts/tasks/VirusScanningTask.py /opt/IPED/iped/scripts/tasks/VirusScanningTask.py \
&& echo "\nenableAudioTranslation = false" >> /opt/IPED/iped/IPEDConfig.txt \
&& echo "\nenableVirusScanning = false" >> /opt/IPED/iped/IPEDConfig.txt \
&& echo "\nenableImageClassification = false" >> /opt/IPED/iped/IPEDConfig.txt \
&& pip install --no-cache-dir requests \
&& echo "#####################################" \
&& echo "Cleaning UP the container " \
&& echo "#####################################" \
&& rm -rfv ${PKGTMPDIR}/* && apt-get clean && rm -rfv /var/lib/apt/lists/*
Expand Down
137 changes: 66 additions & 71 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,46 @@ PHOTODNA=false
HASHESDB=false
COUNTRY='BR'



echo -n Populating IPED plugins directory with extra plugins...
if [ -d /mnt/plugins ] && [ ! -z "$(ls /mnt/plugins)" ]
then
ORIGDIR=${PWD}
cd /opt/IPED/plugins/ && find /mnt/plugins -type f \
| xargs -I% sh -c 'ln -s "$@" > /dev/null 2>&1 && echo -n $@[OK]...|| echo -n $@[FAILED]...' _ %
if [ -d /mnt/plugins ] && [ ! -z "$(ls /mnt/plugins)" ]; then
ORIGDIR=${PWD}
cd /opt/IPED/plugins/ && find /mnt/plugins -type f |
xargs -I% sh -c 'ln -s "$@" > /dev/null 2>&1 && echo -n $@[OK]...|| echo -n $@[FAILED]...' _ %
cd ${ORIGDIR}
echo "Done."
fi

if [ ! -z "$(ls /opt/IPED/plugins/ | grep -i photodna | grep -i '\.jar$' )" ]
then
if [ ! -z "$(ls /opt/IPED/plugins/ | grep -i photodna | grep -i '\.jar$')" ]; then
PHOTODNA=true

echo -n Setting PhotoDNA related flags to $PHOTODNA... && \
sed -i -e "s/enablePhotoDNA =.*/enablePhotoDNA = $PHOTODNA/" /opt/IPED/iped/IPEDConfig.txt && \
sed -i -e "s/enablePhotoDNALookup =.*/enablePhotoDNALookup = $PHOTODNA/" /opt/IPED/iped/IPEDConfig.txt && \
echo Done. || echo Failed.
echo -n Setting PhotoDNA related flags to $PHOTODNA... &&
sed -i -e "s/enablePhotoDNA =.*/enablePhotoDNA = $PHOTODNA/" /opt/IPED/iped/IPEDConfig.txt &&
sed -i -e "s/enablePhotoDNALookup =.*/enablePhotoDNALookup = $PHOTODNA/" /opt/IPED/iped/IPEDConfig.txt &&
echo Done. || echo Failed.
fi

if [ -f /mnt/hashesdb/iped-hashes.db ]; then
HASHESDB=true

if [ -f /mnt/hashesdb/iped-hashes.db ]
then
HASHESDB=true

echo -n Setting HASHDB related flags to $HASHESDB... && \
sed -i -e "s/enableHashDBLookup =.*/enableHashDBLookup = $HASHESDB/" /opt/IPED/iped/IPEDConfig.txt && \
sed -i -e "s/enableLedCarving =.*/enableLedCarving = $HASHESDB/" /opt/IPED/iped/IPEDConfig.txt && \
echo Done. || echo Failed.
echo -n Setting HASHDB related flags to $HASHESDB... &&
sed -i -e "s/enableHashDBLookup =.*/enableHashDBLookup = $HASHESDB/" /opt/IPED/iped/IPEDConfig.txt &&
sed -i -e "s/enableLedCarving =.*/enableLedCarving = $HASHESDB/" /opt/IPED/iped/IPEDConfig.txt &&
echo Done. || echo Failed.

# check if HASHESDBONTMP is setted, if it is, copy it to tmp dir
# can be used in cases that hashesdb in on the network and the only way
# to accelerate things is to put it on tmpdir, that is mandatory to be local
if [ "$HASHESDBONTMP" == "true" ]
then
echo -n "Copying iped-hashes.db to /mnt/ipedtmp..." && \
cp -p --update /mnt/hashesdb/iped-hashes.db /mnt/ipedtmp/ && echo -n OK... && \
echo -n "Updating config..." && \
sed -i -e "s/hashesDB =.*/hashesDB = \/mnt\/ipedtmp\/iped-hashes.db/" /opt/IPED/iped/LocalConfig.txt && \
echo OK. || -n echo Failed.
if [ "$HASHESDBONTMP" == "true" ]; then
echo -n "Copying iped-hashes.db to /mnt/ipedtmp..." &&
cp -p --update /mnt/hashesdb/iped-hashes.db /mnt/ipedtmp/ && echo -n OK... &&
echo -n "Updating config..." &&
sed -i -e "s/hashesDB =.*/hashesDB = \/mnt\/ipedtmp\/iped-hashes.db/" /opt/IPED/iped/LocalConfig.txt &&
echo OK. || -n echo Failed.

fi

fi


# Custom flags to be used to modify configuration on runtime
# LocalConfig.txt variables (with iped_ prefix)
for v in \
Expand All @@ -64,15 +56,22 @@ for v in \
iped_tskJarPath \
iped_mplayerPath \
iped_pluginFolder \
iped_regripperFolder
do
iped_regripperFolder; do
echo ${v}=${!v}
if [ "${!v}" ]
then
if [ "${!v}" ]; then
sed -i -e "s|.*${v#iped_} =.*|${v#iped_} = ${!v}|" /opt/IPED/iped/LocalConfig.txt
fi
done

if [ $iped_taskBridgeUrl ]; then
v="iped_taskBridgeUrl"
echo "iped_taskBridgeUrl = $iped_taskBridgeUrl"
sed -i -e "s|.*${v#iped_} =.*|${v#iped_} = ${!v}|" /opt/IPED/iped/conf/AudioTranslation.txt
sed -i -e "s|.*${v#iped_} =.*|${v#iped_} = ${!v}|" /opt/IPED/iped/conf/ImageClassification.txt
sed -i -e "s|.*${v#iped_} =.*|${v#iped_} = ${!v}|" /opt/IPED/iped/conf/VirusScanning.txt

fi

# IPEDConfig.txt variables (with iped_ prefix)
for v in \
iped_enableHash \
Expand Down Expand Up @@ -108,65 +107,61 @@ for v in \
iped_enableVideoThumbs \
iped_enableDocThumbs \
iped_enableHTMLReport \
iped_enableOCR
do
iped_enableOCR \
iped_enableVirusScanning \
iped_enableAudioTranslation \
iped_enableImageClassification; do
echo ${v}=${!v}
if [ "${!v}" ]
then
if [ "${!v}" ]; then
sed -i -e "s|.*${v#iped_} =.*|${v#iped_} = ${!v}|" /opt/IPED/iped/IPEDConfig.txt
fi
done

# IPED variables setting on the config dir (with iped_ prefix).
# supportedMimes, host and port are repeatedly used on configs
# so they were removed. IPED Variables with dots cannot be used
# so they were removed. IPED Variables with dots cannot be used
# as environment variables, removed also
for v in $( for file in $( find /opt/IPED/iped/conf/ -type f | grep Config.txt \
| grep -v -i regex); do grep "=" $file | grep -v "^host =" \
| grep -v "^port = " | cut -d "=" -f 1 \
| grep -v "\." | grep -v "^#" | grep -v supportedMimes \
| awk '{ if ($0 != "\r" ) {print "iped_"$0;} }';\
done )
do
for v in $(for file in $(find /opt/IPED/iped/conf/ -type f | grep Config.txt |
grep -v -i regex); do
grep "=" $file | grep -v "^host =" |
grep -v "^port = " | cut -d "=" -f 1 |
grep -v "\." | grep -v "^#" | grep -v supportedMimes |
awk '{ if ($0 != "\r" ) {print "iped_"$0;} }'
done); do
echo ${v}=${!v}
if [ "${!v}" ]
then
find /opt/IPED/iped/conf/ -type f | grep Config.txt | grep -v -i regex | xargs sed -i -e "s|${v#iped_} =.*|${v#iped_} = ${!v}|"
if [ "${!v}" ]; then
find /opt/IPED/iped/conf/ -type f | grep Config.txt | grep -v -i regex | xargs sed -i -e "s|${v#iped_} =.*|${v#iped_} = ${!v}|"
fi
done

echo Setting GraphConfig...
for v in \
iped_phone_region
do
iped_phone_region; do
echo ${v}=${!v}
if [ "${!v}" ]
then
sed -i -e "s|.*\"$(echo ${v#iped_}| sed 's/_/-/g')\":.*|\"$(echo ${v#iped_}| sed 's/_/-/g')\":\"${!v}\",|" /opt/IPED/iped/conf/GraphConfig.json
else
sed -i -e "s|.*\"$(echo ${v#iped_}| sed 's/_/-/g')\":.*|\"$(echo ${v#iped_}| sed 's/_/-/g')\":\"${COUNTRY}\",|" /opt/IPED/iped/conf/GraphConfig.json
if [ "${!v}" ]; then
sed -i -e "s|.*\"$(echo ${v#iped_} | sed 's/_/-/g')\":.*|\"$(echo ${v#iped_} | sed 's/_/-/g')\":\"${!v}\",|" /opt/IPED/iped/conf/GraphConfig.json
else
sed -i -e "s|.*\"$(echo ${v#iped_} | sed 's/_/-/g')\":.*|\"$(echo ${v#iped_} | sed 's/_/-/g')\":\"${COUNTRY}\",|" /opt/IPED/iped/conf/GraphConfig.json
fi

done


#
# Test for UID presence and, if exist, change the execution for this user id
#
if [ "${USERID}" ]
then
echo -n "Adding user for command execution..." && \
useradd --uid ${USERID} -U tmpuser -m && echo "user added with UID ${USERID}." && \
echo -n "Creating mplayer config on user environment..." && \
sudo -u tmpuser mplayer >/dev/null 2>&1 && echo "OK" && \
echo -n "Configuring cache of tmpuser ..." && \
ln -fs /root/.cache /home/tmpuser/.cache && \
chown -RL tmpuser:tmpuser /root/.cache && chmod +x /root && \
echo "Executing command as UID $USERID..." && \
sudo -u tmpuser --chdir=${PWD} --preserve-env=SAL_USE_VCLPLUGIN,JAVA_HOME,LD_LIBRARY_PATH,IPED_VERSION $@ || \
echo "Running as UID $USERID Failed."

else
#
if [ "${USERID}" ]; then
echo -n "Adding user for command execution..." &&
useradd --uid ${USERID} -U tmpuser -m && echo "user added with UID ${USERID}." &&
echo -n "Creating mplayer config on user environment..." &&
sudo -u tmpuser mplayer >/dev/null 2>&1 && echo "OK" &&
echo -n "Configuring cache of tmpuser ..." &&
ln -fs /root/.cache /home/tmpuser/.cache &&
chown -RL tmpuser:tmpuser /root/.cache && chmod +x /root &&
echo "Executing command as UID $USERID..." &&
sudo -u tmpuser --chdir=${PWD} --preserve-env=SAL_USE_VCLPLUGIN,JAVA_HOME,LD_LIBRARY_PATH,IPED_VERSION $@ ||
echo "Running as UID $USERID Failed."

else
# no arguments = bash, otherwise exec then
echo "Executing command as ROOT..."
exec "$@"
Expand Down