mirror of
https://github.com/e-m-b-a/emba.git
synced 2026-10-12 02:13:21 +00:00
Merge branch 'master' into master
This commit is contained in:
@@ -27,5 +27,5 @@ jobs:
|
||||
- name: ShellCheck EMBA
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
env:
|
||||
SHELLCHECK_OPTS: -x
|
||||
SHELLCHECK_OPTS: -x -o require-variable-braces
|
||||
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ check() {
|
||||
echo -e "\\n""${GREEN}""Run shellcheck and semgrep:""${NC}""\\n"
|
||||
for SOURCE in "${SOURCES[@]}"; do
|
||||
echo -e "\\n""${GREEN}""Run ${ORANGE}shellcheck${GREEN} on ${ORANGE}${SOURCE}""${NC}""\\n"
|
||||
if shellcheck -x -P "${INSTALLER_DIR}":"${HELP_DIR}":"${MOD_DIR}":"${MOD_DIR_LOCAL}" "${SOURCE}" || [[ $? -ne 1 && $? -ne 2 ]]; then
|
||||
if shellcheck -x -o require-variable-braces -P "${INSTALLER_DIR}":"${HELP_DIR}":"${MOD_DIR}":"${MOD_DIR_LOCAL}" "${SOURCE}" || [[ $? -ne 1 && $? -ne 2 ]]; then
|
||||
echo -e "${GREEN}""${BOLD}""==> SUCCESS""${NC}""\\n"
|
||||
else
|
||||
echo -e "\\n""${ORANGE}""${BOLD}""==> FIX ERRORS""${NC}""\\n"
|
||||
|
||||
+76
-20
@@ -1,11 +1,13 @@
|
||||
CVE;advisory name;advisory URL;unknown PoC;Github PoC;Curl PoC;XML PoC;
|
||||
CVE-2019-11253;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGAPISERVER-1050876;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGAPISERVER-1050876;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNETHOST-5971045;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNETHOST-5971045;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-GOLANG-5971067;https://security.snyk.io/vuln/SNYK-AMZN2023-GOLANG-5971067;yes;no;no;no;
|
||||
CVE-2021-23772;SNYK-GOLANG-GITHUBCOMKATARASIRISV12-2325170;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKATARASIRISV12-2325170;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE315-LIGHTTPD-6042944;https://security.snyk.io/vuln/SNYK-ALPINE315-LIGHTTPD-6042944;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE315-NGHTTP2-5964211;https://security.snyk.io/vuln/SNYK-ALPINE315-NGHTTP2-5964211;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE315-NGINX-6012604;https://security.snyk.io/vuln/SNYK-ALPINE315-NGINX-6012604;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE316-LIGHTTPD-6042949;https://security.snyk.io/vuln/SNYK-ALPINE316-LIGHTTPD-6042949;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE316-NGHTTP2-6043732;https://security.snyk.io/vuln/SNYK-ALPINE316-NGHTTP2-6043732;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE316-NGINX-5969471;https://security.snyk.io/vuln/SNYK-ALPINE316-NGINX-5969471;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE317-JETTYRUNNER-5969477;https://security.snyk.io/vuln/SNYK-ALPINE317-JETTYRUNNER-5969477;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE317-LIGHTTPD-6042947;https://security.snyk.io/vuln/SNYK-ALPINE317-LIGHTTPD-6042947;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE317-NGHTTP2-5954769;https://security.snyk.io/vuln/SNYK-ALPINE317-NGHTTP2-5954769;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE317-NGINX-5969473;https://security.snyk.io/vuln/SNYK-ALPINE317-NGINX-5969473;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-ALPINE318-DOTNET6BUILD-5960913;https://security.snyk.io/vuln/SNYK-ALPINE318-DOTNET6BUILD-5960913;yes;no;no;no;
|
||||
@@ -76,6 +78,7 @@ CVE-2023-44487;SNYK-AMZN2023-DOTNET60DEBUGINFO-5971031;https://security.snyk.io/
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNET60DEBUGSOURCE-5971048;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNET60DEBUGSOURCE-5971048;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNETAPPHOSTPACK60-5971040;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNETAPPHOSTPACK60-5971040;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNETAPPHOSTPACK60DEBUGINFO-5971046;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNETAPPHOSTPACK60DEBUGINFO-5971046;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNETHOST-5971045;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNETHOST-5971045;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNETHOSTDEBUGINFO-5971030;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNETHOSTDEBUGINFO-5971030;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNETHOSTFXR60-5971027;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNETHOSTFXR60-5971027;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-DOTNETHOSTFXR60DEBUGINFO-5971029;https://security.snyk.io/vuln/SNYK-AMZN2023-DOTNETHOSTFXR60DEBUGINFO-5971029;yes;no;no;no;
|
||||
@@ -95,7 +98,7 @@ CVE-2021-46829;SNYK-AMZN2023-GDKPIXBUF2MODULES-5912315;https://security.snyk.io/
|
||||
CVE-2021-46829;SNYK-AMZN2023-GDKPIXBUF2MODULESDEBUGINFO-5912320;https://security.snyk.io/vuln/SNYK-AMZN2023-GDKPIXBUF2MODULESDEBUGINFO-5912320;yes;no;no;no;
|
||||
CVE-2021-46829;SNYK-AMZN2023-GDKPIXBUF2TESTS-5912326;https://security.snyk.io/vuln/SNYK-AMZN2023-GDKPIXBUF2TESTS-5912326;yes;no;no;no;
|
||||
CVE-2021-46829;SNYK-AMZN2023-GDKPIXBUF2TESTSDEBUGINFO-5912324;https://security.snyk.io/vuln/SNYK-AMZN2023-GDKPIXBUF2TESTSDEBUGINFO-5912324;yes;no;no;no;
|
||||
CVE-2018-20843;SNYK-COCOAPODS-EXPAT-470643;https://security.snyk.io/vuln/SNYK-COCOAPODS-EXPAT-470643;no;no;no;yes;
|
||||
CVE-2023-44487;SNYK-AMZN2023-GOLANG-5971067;https://security.snyk.io/vuln/SNYK-AMZN2023-GOLANG-5971067;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-GOLANGBIN-5971097;https://security.snyk.io/vuln/SNYK-AMZN2023-GOLANGBIN-5971097;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-GOLANGDOCS-5971105;https://security.snyk.io/vuln/SNYK-AMZN2023-GOLANGDOCS-5971105;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-AMZN2023-GOLANGMISC-5971061;https://security.snyk.io/vuln/SNYK-AMZN2023-GOLANGMISC-5971061;yes;no;no;no;
|
||||
@@ -351,6 +354,7 @@ CVE-2023-44487;SNYK-CENTOS9-DOTNETHOSTFXR70-5955981;https://security.snyk.io/vul
|
||||
CVE-2023-44487;SNYK-CENTOS9-DOTNETRUNTIME60-5956044;https://security.snyk.io/vuln/SNYK-CENTOS9-DOTNETRUNTIME60-5956044;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-CENTOS9-DOTNETRUNTIME70-5955924;https://security.snyk.io/vuln/SNYK-CENTOS9-DOTNETRUNTIME70-5955924;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-CENTOS9-DOTNETSDK60-5955946;https://security.snyk.io/vuln/SNYK-CENTOS9-DOTNETSDK60-5955946;yes;no;no;no;
|
||||
CVE-2023-46233;SNYK-CENTOS9-DOTNETSDK60-6037728;https://security.snyk.io/vuln/SNYK-CENTOS9-DOTNETSDK60-6037728;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-CENTOS9-DOTNETSDK60SOURCEBUILTARTIFACTS-5956060;https://security.snyk.io/vuln/SNYK-CENTOS9-DOTNETSDK60SOURCEBUILTARTIFACTS-5956060;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-CENTOS9-DOTNETSDK70-5956027;https://security.snyk.io/vuln/SNYK-CENTOS9-DOTNETSDK70-5956027;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-CENTOS9-DOTNETSDK70SOURCEBUILTARTIFACTS-5955973;https://security.snyk.io/vuln/SNYK-CENTOS9-DOTNETSDK70SOURCEBUILTARTIFACTS-5955973;yes;no;no;no;
|
||||
@@ -424,8 +428,8 @@ CVE-2023-44487;SNYK-CENTOS9-VARNISH-5961704;https://security.snyk.io/vuln/SNYK-C
|
||||
CVE-2023-44487;SNYK-CENTOS9-VARNISHDEVEL-5961708;https://security.snyk.io/vuln/SNYK-CENTOS9-VARNISHDEVEL-5961708;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-CENTOS9-VARNISHDOCS-5961706;https://security.snyk.io/vuln/SNYK-CENTOS9-VARNISHDOCS-5961706;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-CENTOS9-WELDRCLIENT-5956053;https://security.snyk.io/vuln/SNYK-CENTOS9-WELDRCLIENT-5956053;yes;no;no;no;
|
||||
CVE-2023-5574;SNYK-CENTOS9-XORGX11SERVERXEPHYR-6036296;https://security.snyk.io/vuln/SNYK-CENTOS9-XORGX11SERVERXEPHYR-6036296;yes;no;no;no;
|
||||
CVE-2019-19204;SNYK-COCOAPODS-COCOAONIGURUMA-535384;https://security.snyk.io/vuln/SNYK-COCOAPODS-COCOAONIGURUMA-535384;yes;no;no;no;
|
||||
CVE-2018-20843;SNYK-COCOAPODS-EXPAT-470643;https://security.snyk.io/vuln/SNYK-COCOAPODS-EXPAT-470643;no;no;no;yes;
|
||||
CVE-2017-9233;SNYK-COCOAPODS-EXPAT-470947;https://security.snyk.io/vuln/SNYK-COCOAPODS-EXPAT-470947;no;no;no;yes;
|
||||
CVE-2019-15903;SNYK-COCOAPODS-EXPAT-540503;https://security.snyk.io/vuln/SNYK-COCOAPODS-EXPAT-540503;no;no;no;yes;
|
||||
CVE-2016-10190;SNYK-COCOAPODS-FFMPEG-470696;https://security.snyk.io/vuln/SNYK-COCOAPODS-FFMPEG-470696;yes;no;no;no;
|
||||
@@ -489,10 +493,11 @@ CVE-2023-30079;SNYK-DEBIANUNSTABLE-LIBECONF-5850033;https://security.snyk.io/vul
|
||||
CVE-2023-44487;SNYK-DEBIANUNSTABLE-NETTY-5960851;https://security.snyk.io/vuln/SNYK-DEBIANUNSTABLE-NETTY-5960851;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-DEBIANUNSTABLE-NGHTTP2-5953388;https://security.snyk.io/vuln/SNYK-DEBIANUNSTABLE-NGHTTP2-5953388;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-DEBIANUNSTABLE-NGINX-5953385;https://security.snyk.io/vuln/SNYK-DEBIANUNSTABLE-NGINX-5953385;yes;no;no;no;
|
||||
CVE-2021-41087;SNYK-GOLANG-GITHUBCOMINTOTOINTOTOGOLANGINTOTO-1657555;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMINTOTOINTOTOGOLANGINTOTO-1657555;no;no;yes;no;
|
||||
CVE-2021-23772;SNYK-GOLANG-GITHUBCOMKATARASIRIS-2325169;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKATARASIRIS-2325169;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-DEBIANUNSTABLE-TOMCAT10-5954716;https://security.snyk.io/vuln/SNYK-DEBIANUNSTABLE-TOMCAT10-5954716;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-DEBIANUNSTABLE-TOMCAT9-5954737;https://security.snyk.io/vuln/SNYK-DEBIANUNSTABLE-TOMCAT9-5954737;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-DEBIANUNSTABLE-TRAFFICSERVER-5954729;https://security.snyk.io/vuln/SNYK-DEBIANUNSTABLE-TRAFFICSERVER-5954729;yes;no;no;no;
|
||||
CVE-2019-11249;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGKUBECTLCMDCP-2826203;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGKUBECTLCMDCP-2826203;no;no;yes;no;
|
||||
CVE-2015-4670;SNYK-DOTNET-AJAXCONTROLTOOLKIT-174365;https://security.snyk.io/vuln/SNYK-DOTNET-AJAXCONTROLTOOLKIT-174365;no;no;yes;no;
|
||||
CVE-2019-10768;SNYK-DOTNET-ANGULARJSCORE-1579456;https://security.snyk.io/vuln/SNYK-DOTNET-ANGULARJSCORE-1579456;yes;no;no;no;
|
||||
CVE-2019-20627;SNYK-DOTNET-AUTOUPDATERNETOFFICIAL-560985;https://security.snyk.io/vuln/SNYK-DOTNET-AUTOUPDATERNETOFFICIAL-560985;no;no;no;yes;
|
||||
@@ -575,8 +580,8 @@ CVE-2023-1243;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALINSTALL-3350583;https:
|
||||
CVE-2023-1239;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALINSTALL-3350598;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALINSTALL-3350598;yes;no;no;no;
|
||||
CVE-2023-1242;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350580;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350580;yes;no;no;no;
|
||||
CVE-2023-1245;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350581;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350581;yes;no;no;no;
|
||||
CVE-2023-1240;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350600;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350600;yes;no;no;no;
|
||||
CVE-2023-1241;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350584;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350584;yes;no;no;no;
|
||||
CVE-2023-1240;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350600;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERINTERNALSCHEMA-3350600;yes;no;no;no;
|
||||
CVE-2023-0741;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERPKGCONVERTER-3314987;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERPKGCONVERTER-3314987;yes;no;no;no;
|
||||
CVE-2023-0742;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERPKGCONVERTER-3314987;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERPKGCONVERTER-3314987;yes;no;no;no;
|
||||
CVE-2023-1245;SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERPKGCONVERTER-3350582;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMANSWERDEVANSWERPKGCONVERTER-3350582;yes;no;no;no;
|
||||
@@ -689,17 +694,16 @@ CVE-2022-3802;SNYK-GOLANG-GITHUBCOMIBAXIOGOIBAXPACKAGESAPI-3097710;https://secur
|
||||
CVE-2022-3801;SNYK-GOLANG-GITHUBCOMIBAXIOGOIBAXPACKAGESAPI-3097715;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMIBAXIOGOIBAXPACKAGESAPI-3097715;yes;no;no;no;
|
||||
CVE-2022-3800;SNYK-GOLANG-GITHUBCOMIBAXIOGOIBAXPACKAGESAPI-3097716;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMIBAXIOGOIBAXPACKAGESAPI-3097716;yes;no;no;no;
|
||||
CVE-2022-3798;SNYK-GOLANG-GITHUBCOMIBAXIOGOIBAXPACKAGESAPI-3097718;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMIBAXIOGOIBAXPACKAGESAPI-3097718;yes;no;no;no;
|
||||
CVE-2023-26145;SNYK-PYTHON-PYDASH-5916518;https://security.snyk.io/vuln/SNYK-PYTHON-PYDASH-5916518;yes;no;no;no;
|
||||
CVE-2022-41241;SNYK-JAVA-ORGJENKINSCIPLUGINS-3030359;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3030359;no;no;no;yes;
|
||||
CVE-2022-24193;SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSROUTE-2421225;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSROUTE-2421225;yes;no;no;no;
|
||||
CVE-2022-24193;SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSSERVICE-2421227;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSSERVICE-2421227;yes;no;no;no;
|
||||
CVE-2022-24193;SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSTYPES-2421228;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSTYPES-2421228;yes;no;no;no;
|
||||
CVE-2022-24193;SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSWEB-2421226;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMICEWHALETECHCASAOSWEB-2421226;yes;no;no;no;
|
||||
CVE-2023-1496;SNYK-GOLANG-GITHUBCOMIMGPROXYIMGPROXYV3SVG-3364596;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMIMGPROXYIMGPROXYV3SVG-3364596;yes;no;no;no;
|
||||
CVE-2021-41087;SNYK-GOLANG-GITHUBCOMINTOTOINTOTOGOLANGINTOTO-1657555;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMINTOTOINTOTOGOLANGINTOTO-1657555;no;no;yes;no;
|
||||
CVE-2020-26279;SNYK-GOLANG-GITHUBCOMIPFSGOIPFS-1089017;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMIPFSGOIPFS-1089017;no;no;yes;no;
|
||||
CVE-2020-36566;SNYK-GOLANG-GITHUBCOMIPFSGOIPFS-1089017;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMIPFSGOIPFS-1089017;no;no;yes;no;
|
||||
CVE-2018-25059;SNYK-GOLANG-GITHUBCOMJESSFRAZPASTEBINIT-3185201;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMJESSFRAZPASTEBINIT-3185201;no;no;yes;no;
|
||||
CVE-2021-23772;SNYK-GOLANG-GITHUBCOMKATARASIRIS-2325169;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKATARASIRIS-2325169;yes;no;no;no;
|
||||
CVE-2021-23772;SNYK-GOLANG-GITHUBCOMKATARASIRISV12-2325170;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKATARASIRISV12-2325170;yes;no;no;no;
|
||||
CVE-2021-34422;SNYK-GOLANG-GITHUBCOMKEYBASECLIENTGOLIBKB-1920669;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKEYBASECLIENTGOLIBKB-1920669;no;no;yes;no;
|
||||
CVE-2020-1764;SNYK-GOLANG-GITHUBCOMKIALIKIALICONFIG-561354;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKIALIKIALICONFIG-561354;yes;no;no;no;
|
||||
CVE-2020-1764;SNYK-GOLANG-GITHUBCOMKIALIKIALIHANDLERS-561358;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKIALIKIALIHANDLERS-561358;yes;no;no;no;
|
||||
@@ -711,6 +715,8 @@ CVE-2020-8559;SNYK-GOLANG-GITHUBCOMKUBERNETESAPIMACHINERYPKGUTILPROXY-590105;htt
|
||||
CVE-2020-8558;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBEPROXY-575534;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBEPROXY-575534;yes;no;no;no;
|
||||
CVE-2020-8554;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETES-1048854;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETES-1048854;yes;no;no;no;
|
||||
CVE-2021-25735;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGAPISAPPSVALIDATION-1246527;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGAPISAPPSVALIDATION-1246527;yes;no;no;no;
|
||||
CVE-2019-11253;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGAPISERVER-1050876;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGAPISERVER-1050876;yes;no;no;no;
|
||||
CVE-2019-11249;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGKUBECTLCMDCP-2826203;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGKUBECTLCMDCP-2826203;no;no;yes;no;
|
||||
CVE-2019-11246;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGKUBECTLCMDCP-2826206;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGKUBECTLCMDCP-2826206;no;no;yes;no;
|
||||
CVE-2017-1002101;SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGUTILMOUNT-2825262;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMKUBERNETESKUBERNETESPKGUTILMOUNT-2825262;yes;no;no;no;
|
||||
CVE-2020-36565;SNYK-GOLANG-GITHUBCOMLABSTACKECHO-1050889;https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMLABSTACKECHO-1050889;no;no;yes;no;
|
||||
@@ -1205,10 +1211,10 @@ CVE-2022-30947;SNYK-JAVA-ORGJENKINSCIPLUGINS-2855272;https://security.snyk.io/vu
|
||||
CVE-2022-30948;SNYK-JAVA-ORGJENKINSCIPLUGINS-2855295;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-2855295;no;no;yes;no;
|
||||
CVE-2022-34793;SNYK-JAVA-ORGJENKINSCIPLUGINS-2949199;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-2949199;no;no;no;yes;
|
||||
CVE-2022-34179;SNYK-JAVA-ORGJENKINSCIPLUGINS-2982181;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-2982181;no;no;yes;no;
|
||||
CVE-2023-26111;SNYK-JS-NUBOSOFTWARENODESTATIC-3149927;https://security.snyk.io/vuln/SNYK-JS-NUBOSOFTWARENODESTATIC-3149927;yes;no;yes;no;
|
||||
CVE-2021-21669;SNYK-JAVA-ORGJENKINSCIPLUGINS-2994368;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-2994368;no;no;no;yes;
|
||||
CVE-2021-21658;SNYK-JAVA-ORGJENKINSCIPLUGINS-3018919;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3018919;no;no;no;yes;
|
||||
CVE-2022-41235;SNYK-JAVA-ORGJENKINSCIPLUGINS-3030354;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3030354;no;no;yes;no;
|
||||
CVE-2022-41241;SNYK-JAVA-ORGJENKINSCIPLUGINS-3030359;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3030359;no;no;no;yes;
|
||||
CVE-2022-41226;SNYK-JAVA-ORGJENKINSCIPLUGINS-3030593;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3030593;no;no;no;yes;
|
||||
CVE-2022-43415;SNYK-JAVA-ORGJENKINSCIPLUGINS-3057597;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3057597;no;no;no;yes;
|
||||
CVE-2022-45397;SNYK-JAVA-ORGJENKINSCIPLUGINS-3121086;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3121086;no;no;no;yes;
|
||||
@@ -1234,6 +1240,7 @@ CVE-2023-24430;SNYK-JAVA-ORGJENKINSCIPLUGINS-3248515;https://security.snyk.io/vu
|
||||
CVE-2023-24443;SNYK-JAVA-ORGJENKINSCIPLUGINS-3248520;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3248520;no;no;no;yes;
|
||||
CVE-2023-28682;SNYK-JAVA-ORGJENKINSCIPLUGINS-3368238;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3368238;no;no;no;yes;
|
||||
CVE-2023-28681;SNYK-JAVA-ORGJENKINSCIPLUGINS-3368239;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3368239;no;no;no;yes;
|
||||
CVE-2022-2216;SNYK-JS-PARSEURL-2936249;https://security.snyk.io/vuln/SNYK-JS-PARSEURL-2936249;yes;no;no;no;
|
||||
CVE-2023-28680;SNYK-JAVA-ORGJENKINSCIPLUGINS-3368240;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3368240;no;no;no;yes;
|
||||
CVE-2023-28683;SNYK-JAVA-ORGJENKINSCIPLUGINS-3368241;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3368241;no;no;no;yes;
|
||||
CVE-2023-28685;SNYK-JAVA-ORGJENKINSCIPLUGINS-3368243;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-3368243;no;no;no;yes;
|
||||
@@ -1243,8 +1250,12 @@ CVE-2023-41932;SNYK-JAVA-ORGJENKINSCIPLUGINS-5885102;https://security.snyk.io/vu
|
||||
CVE-2023-41933;SNYK-JAVA-ORGJENKINSCIPLUGINS-5885104;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-5885104;no;no;no;yes;
|
||||
CVE-2023-41930;SNYK-JAVA-ORGJENKINSCIPLUGINS-5885105;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-5885105;no;no;yes;no;
|
||||
CVE-2022-30972;SNYK-JAVA-ORGJENKINSCIPLUGINS-6036856;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-6036856;no;no;no;yes;
|
||||
CVE-2022-28140;SNYK-JAVA-ORGJENKINSCIPLUGINS-6037649;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-6037649;no;no;no;yes;
|
||||
CVE-2019-1003015;SNYK-JAVA-ORGJENKINSCIPLUGINS-6037790;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-6037790;no;no;no;yes;
|
||||
CVE-2022-30971;SNYK-JAVA-ORGJENKINSCIPLUGINS-6037815;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-6037815;no;no;no;yes;
|
||||
CVE-2020-2245;SNYK-JAVA-ORGJENKINSCIPLUGINS-609351;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-609351;no;no;no;yes;
|
||||
CVE-2020-2247;SNYK-JAVA-ORGJENKINSCIPLUGINS-609352;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINS-609352;no;no;no;yes;
|
||||
CVE-2019-1003001;SNYK-JAVA-ORGJENKINSCIPLUGINSWORKFLOW-6037648;https://security.snyk.io/vuln/SNYK-JAVA-ORGJENKINSCIPLUGINSWORKFLOW-6037648;yes;no;no;no;
|
||||
CVE-2020-29582;SNYK-JAVA-ORGJETBRAINSKOTLIN-2393744;https://security.snyk.io/vuln/SNYK-JAVA-ORGJETBRAINSKOTLIN-2393744;yes;no;no;no;
|
||||
CVE-2022-29631;SNYK-JAVA-ORGJODD-2859805;https://security.snyk.io/vuln/SNYK-JAVA-ORGJODD-2859805;yes;no;no;no;
|
||||
CVE-2010-3863;SNYK-JAVA-ORGJSECURITY-31217;https://security.snyk.io/vuln/SNYK-JAVA-ORGJSECURITY-31217;no;no;yes;no;
|
||||
@@ -1292,6 +1303,7 @@ CVE-2021-32623;SNYK-JAVA-ORGOPENCASTPROJECT-1309673;https://security.snyk.io/vul
|
||||
CVE-2021-43807;SNYK-JAVA-ORGOPENCASTPROJECT-2320172;https://security.snyk.io/vuln/SNYK-JAVA-ORGOPENCASTPROJECT-2320172;yes;no;no;no;
|
||||
CVE-2021-3312;SNYK-JAVA-ORGOPENCMS-1729976;https://security.snyk.io/vuln/SNYK-JAVA-ORGOPENCMS-1729976;no;no;no;yes;
|
||||
CVE-2022-40084;SNYK-JAVA-ORGOPENCRX-3057921;https://security.snyk.io/vuln/SNYK-JAVA-ORGOPENCRX-3057921;yes;no;no;no;
|
||||
CVE-2023-46502;SNYK-JAVA-ORGOPENCRX-6041264;https://security.snyk.io/vuln/SNYK-JAVA-ORGOPENCRX-6041264;no;no;no;yes;
|
||||
CVE-2021-21266;SNYK-JAVA-ORGOPENHABADDONSBUNDLES-1066395;https://security.snyk.io/vuln/SNYK-JAVA-ORGOPENHABADDONSBUNDLES-1066395;no;no;no;yes;
|
||||
CVE-2021-21266;SNYK-JAVA-ORGOPENHABADDONSBUNDLES-1066396;https://security.snyk.io/vuln/SNYK-JAVA-ORGOPENHABADDONSBUNDLES-1066396;no;no;no;yes;
|
||||
CVE-2021-21266;SNYK-JAVA-ORGOPENHABADDONSBUNDLES-1066397;https://security.snyk.io/vuln/SNYK-JAVA-ORGOPENHABADDONSBUNDLES-1066397;no;no;no;yes;
|
||||
@@ -1948,15 +1960,14 @@ CVE-2021-26504;SNYK-JS-NODEREDCONTRIBHUEMAGIC-5840600;https://security.snyk.io/v
|
||||
CVE-2023-26111;SNYK-JS-NODESTATIC-3149928;https://security.snyk.io/vuln/SNYK-JS-NODESTATIC-3149928;yes;no;yes;no;
|
||||
CVE-2021-23771;SNYK-JS-NOTEVIL-2385946;https://security.snyk.io/vuln/SNYK-JS-NOTEVIL-2385946;yes;no;no;no;
|
||||
CVE-2022-29080;SNYK-JS-NPMDEPENDENCYVERSIONS-2624782;https://security.snyk.io/vuln/SNYK-JS-NPMDEPENDENCYVERSIONS-2624782;yes;no;no;no;
|
||||
CVE-2023-26111;SNYK-JS-NUBOSOFTWARENODESTATIC-3149927;https://security.snyk.io/vuln/SNYK-JS-NUBOSOFTWARENODESTATIC-3149927;yes;no;yes;no;
|
||||
CVE-2023-2142;SNYK-JS-NUNJUCKS-5431309;https://security.snyk.io/vuln/SNYK-JS-NUNJUCKS-5431309;yes;no;no;no;
|
||||
CVE-2021-23702;SNYK-JS-OBJECTEXTEND-2401470;https://security.snyk.io/vuln/SNYK-JS-OBJECTEXTEND-2401470;yes;no;no;no;
|
||||
CVE-2021-23507;SNYK-JS-OBJECTPATHSET-2388576;https://security.snyk.io/vuln/SNYK-JS-OBJECTPATHSET-2388576;yes;no;no;no;
|
||||
CVE-2021-42057;SNYK-JS-OBSIDIANDATAVIEW-1912069;https://security.snyk.io/vuln/SNYK-JS-OBSIDIANDATAVIEW-1912069;yes;no;no;no;
|
||||
CVE-2022-25171;SNYK-JS-P4-3167330;https://security.snyk.io/vuln/SNYK-JS-P4-3167330;yes;no;no;no;
|
||||
CVE-2023-24249;SNYK-PHP-ENCORELARAVELADMIN-3333096;https://security.snyk.io/vuln/SNYK-PHP-ENCORELARAVELADMIN-3333096;yes;no;no;no;
|
||||
CVE-2021-23490;SNYK-JS-PARSELINKHEADER-1582783;https://security.snyk.io/vuln/SNYK-JS-PARSELINKHEADER-1582783;yes;no;no;no;
|
||||
CVE-2022-2217;SNYK-JS-PARSEURL-2935944;https://security.snyk.io/vuln/SNYK-JS-PARSEURL-2935944;yes;no;no;no;
|
||||
CVE-2022-2216;SNYK-JS-PARSEURL-2936249;https://security.snyk.io/vuln/SNYK-JS-PARSEURL-2936249;yes;no;no;no;
|
||||
CVE-2022-2218;SNYK-JS-PARSEURL-2942134;https://security.snyk.io/vuln/SNYK-JS-PARSEURL-2942134;yes;no;no;no;
|
||||
CVE-2022-2900;SNYK-JS-PARSEURL-3023021;https://security.snyk.io/vuln/SNYK-JS-PARSEURL-3023021;yes;no;no;no;
|
||||
CVE-2022-46161;SNYK-JS-PDFMAKE-3160329;https://security.snyk.io/vuln/SNYK-JS-PDFMAKE-3160329;yes;no;no;no;
|
||||
@@ -2338,7 +2349,10 @@ CVE-2020-11823;SNYK-PHP-DOLIBARRDOLIBARR-565917;https://security.snyk.io/vuln/SN
|
||||
CVE-2020-13094;SNYK-PHP-DOLIBARRDOLIBARR-569621;https://security.snyk.io/vuln/SNYK-PHP-DOLIBARRDOLIBARR-569621;yes;no;no;no;
|
||||
CVE-2018-19799;SNYK-PHP-DOLIBARRDOLIBARR-5805369;https://security.snyk.io/vuln/SNYK-PHP-DOLIBARRDOLIBARR-5805369;yes;no;no;no;
|
||||
CVE-2017-7887;SNYK-PHP-DOLIBARRDOLIBARR-5808448;https://security.snyk.io/vuln/SNYK-PHP-DOLIBARRDOLIBARR-5808448;yes;no;no;no;
|
||||
CVE-2016-10127;SNYK-PYTHON-PYSAML2-40373;https://security.snyk.io/vuln/SNYK-PYTHON-PYSAML2-40373;no;no;no;yes;
|
||||
CVE-2016-10149;SNYK-PYTHON-PYSAML2-40373;https://security.snyk.io/vuln/SNYK-PYTHON-PYSAML2-40373;no;no;no;yes;
|
||||
CVE-2023-38886;SNYK-PHP-DOLIBARRDOLIBARR-5910188;https://security.snyk.io/vuln/SNYK-PHP-DOLIBARRDOLIBARR-5910188;yes;no;no;no;
|
||||
CVE-2023-5842;SNYK-PHP-DOLIBARRDOLIBARR-6039294;https://security.snyk.io/vuln/SNYK-PHP-DOLIBARRDOLIBARR-6039294;yes;no;no;no;
|
||||
CVE-2020-14201;SNYK-PHP-DOLIBARRDOLIBARR-608306;https://security.snyk.io/vuln/SNYK-PHP-DOLIBARRDOLIBARR-608306;yes;no;no;no;
|
||||
CVE-2022-0085;SNYK-PHP-DOMPDFDOMPDF-2936790;https://security.snyk.io/vuln/SNYK-PHP-DOMPDFDOMPDF-2936790;yes;no;no;no;
|
||||
CVE-2023-23924;SNYK-PHP-DOMPDFDOMPDF-3261241;https://security.snyk.io/vuln/SNYK-PHP-DOMPDFDOMPDF-3261241;yes;no;no;no;
|
||||
@@ -2351,7 +2365,6 @@ CVE-2015-2067;SNYK-PHP-DWEEVESMAGMI-5812978;https://security.snyk.io/vuln/SNYK-P
|
||||
CVE-2022-40199;SNYK-PHP-ECCUBEECCUBE-3033897;https://security.snyk.io/vuln/SNYK-PHP-ECCUBEECCUBE-3033897;no;no;yes;no;
|
||||
CVE-2020-5590;SNYK-PHP-ECCUBEECCUBE-572838;https://security.snyk.io/vuln/SNYK-PHP-ECCUBEECCUBE-572838;no;no;yes;no;
|
||||
CVE-2018-16387;SNYK-PHP-ELEFANTCMS-5805405;https://security.snyk.io/vuln/SNYK-PHP-ELEFANTCMS-5805405;yes;no;no;no;
|
||||
CVE-2023-24249;SNYK-PHP-ENCORELARAVELADMIN-3333096;https://security.snyk.io/vuln/SNYK-PHP-ENCORELARAVELADMIN-3333096;yes;no;no;no;
|
||||
CVE-2019-10772;SNYK-PHP-ENSHRINEDSVGSANITIZE-536969;https://security.snyk.io/vuln/SNYK-PHP-ENSHRINEDSVGSANITIZE-536969;yes;no;no;no;
|
||||
CVE-2022-23409;SNYK-PHP-ETHERLOGS-2388633;https://security.snyk.io/vuln/SNYK-PHP-ETHERLOGS-2388633;yes;no;yes;no;
|
||||
CVE-2023-43340;SNYK-PHP-EVOLUTIONCMSEVOLUTION-6016642;https://security.snyk.io/vuln/SNYK-PHP-EVOLUTIONCMSEVOLUTION-6016642;yes;no;no;no;
|
||||
@@ -2419,6 +2432,7 @@ CVE-2021-3976;SNYK-PHP-KEVINPAPSTKIMAI2-1922888;https://security.snyk.io/vuln/SN
|
||||
CVE-2021-3957;SNYK-PHP-KEVINPAPSTKIMAI2-1922974;https://security.snyk.io/vuln/SNYK-PHP-KEVINPAPSTKIMAI2-1922974;yes;no;no;no;
|
||||
CVE-2021-3963;SNYK-PHP-KEVINPAPSTKIMAI2-1923008;https://security.snyk.io/vuln/SNYK-PHP-KEVINPAPSTKIMAI2-1923008;yes;no;no;no;
|
||||
CVE-2021-4033;SNYK-PHP-KEVINPAPSTKIMAI2-2314882;https://security.snyk.io/vuln/SNYK-PHP-KEVINPAPSTKIMAI2-2314882;yes;no;no;no;
|
||||
CVE-2023-46245;SNYK-PHP-KIMAIKIMAI-6039895;https://security.snyk.io/vuln/SNYK-PHP-KIMAIKIMAI-6039895;yes;no;no;no;
|
||||
CVE-2019-8979;SNYK-PHP-KOHANACORE-173721;https://security.snyk.io/vuln/SNYK-PHP-KOHANACORE-173721;yes;no;no;no;
|
||||
CVE-2014-8684;SNYK-PHP-KOHANACORE-5848042;https://security.snyk.io/vuln/SNYK-PHP-KOHANACORE-5848042;yes;no;no;no;
|
||||
CVE-2019-8979;SNYK-PHP-KOSEVENKOSEVEN-173713;https://security.snyk.io/vuln/SNYK-PHP-KOSEVENKOSEVEN-173713;yes;no;no;no;
|
||||
@@ -2530,6 +2544,8 @@ CVE-2019-12331;SNYK-PHP-PHPOFFICEPHPSPREADSHEET-480564;https://security.snyk.io/
|
||||
CVE-2018-19277;SNYK-PHP-PHPOFFICEPHPSPREADSHEET-72604;https://security.snyk.io/vuln/SNYK-PHP-PHPOFFICEPHPSPREADSHEET-72604;no;no;no;yes;
|
||||
CVE-2019-10784;SNYK-PHP-PHPPGADMINPHPPGADMIN-543885;https://security.snyk.io/vuln/SNYK-PHP-PHPPGADMINPHPPGADMIN-543885;yes;no;no;no;
|
||||
CVE-2006-3360;SNYK-PHP-PHPSYSINFOPHPSYSINFO-5351798;https://security.snyk.io/vuln/SNYK-PHP-PHPSYSINFOPHPSYSINFO-5351798;no;no;yes;no;
|
||||
CVE-2023-5844;SNYK-PHP-PIMCOREADMINUICLASSICBUNDLE-6039293;https://security.snyk.io/vuln/SNYK-PHP-PIMCOREADMINUICLASSICBUNDLE-6039293;yes;no;no;no;
|
||||
CVE-2023-46722;SNYK-PHP-PIMCOREADMINUICLASSICBUNDLE-6041519;https://security.snyk.io/vuln/SNYK-PHP-PIMCOREADMINUICLASSICBUNDLE-6041519;yes;no;no;no;
|
||||
CVE-2023-2881;SNYK-PHP-PIMCORECUSTOMERMANAGEMENTFRAMEWORKBUNDLE-5602336;https://security.snyk.io/vuln/SNYK-PHP-PIMCORECUSTOMERMANAGEMENTFRAMEWORKBUNDLE-5602336;yes;no;no;no;
|
||||
CVE-2022-0955;SNYK-PHP-PIMCOREDATAHUB-2433096;https://security.snyk.io/vuln/SNYK-PHP-PIMCOREDATAHUB-2433096;yes;no;no;no;
|
||||
CVE-2021-23340;SNYK-PHP-PIMCOREPIMCORE-1070132;https://security.snyk.io/vuln/SNYK-PHP-PIMCOREPIMCORE-1070132;yes;no;no;no;
|
||||
@@ -2815,6 +2831,7 @@ CVE-2023-38896;SNYK-PYTHON-LANGCHAIN-5843451;https://security.snyk.io/vuln/SNYK-
|
||||
CVE-2023-38860;SNYK-PYTHON-LANGCHAIN-5843452;https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAIN-5843452;yes;no;no;no;
|
||||
CVE-2023-39659;SNYK-PYTHON-LANGCHAIN-5843727;https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAIN-5843727;yes;no;no;no;
|
||||
CVE-2023-36281;SNYK-PYTHON-LANGCHAIN-5850009;https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAIN-5850009;yes;no;no;no;
|
||||
CVE-2023-44467;SNYK-PYTHON-LANGCHAIN-6041516;https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAIN-6041516;yes;no;no;no;
|
||||
CVE-2023-44467;SNYK-PYTHON-LANGCHAINEXPERIMENTAL-5952340;https://security.snyk.io/vuln/SNYK-PYTHON-LANGCHAINEXPERIMENTAL-5952340;yes;no;no;no;
|
||||
CVE-2023-38546;SNYK-PYTHON-LIBCURLCT-5933253;https://security.snyk.io/vuln/SNYK-PYTHON-LIBCURLCT-5933253;yes;no;no;no;
|
||||
CVE-2023-38545;SNYK-PYTHON-LIBCURLCT-5933254;https://security.snyk.io/vuln/SNYK-PYTHON-LIBCURLCT-5933254;yes;no;no;no;
|
||||
@@ -2898,7 +2915,6 @@ CVE-2022-44900;SNYK-PYTHON-PY7ZR-3092461;https://security.snyk.io/vuln/SNYK-PYTH
|
||||
CVE-2015-8549;SNYK-PYTHON-PYAMF-2320005;https://security.snyk.io/vuln/SNYK-PYTHON-PYAMF-2320005;no;no;no;yes;
|
||||
CVE-2018-6594;SNYK-PYTHON-PYCRYPTO-42047;https://security.snyk.io/vuln/SNYK-PYTHON-PYCRYPTO-42047;yes;no;no;no;
|
||||
CVE-2018-15560;SNYK-PYTHON-PYCRYPTODOME-42184;https://security.snyk.io/vuln/SNYK-PYTHON-PYCRYPTODOME-42184;yes;no;no;no;
|
||||
CVE-2023-26145;SNYK-PYTHON-PYDASH-5916518;https://security.snyk.io/vuln/SNYK-PYTHON-PYDASH-5916518;yes;no;no;no;
|
||||
CVE-2008-7262;SNYK-PYTHON-PYFTPDLIB-42136;https://security.snyk.io/vuln/SNYK-PYTHON-PYFTPDLIB-42136;no;no;yes;no;
|
||||
CVE-2007-6736;SNYK-PYTHON-PYFTPDLIB-42147;https://security.snyk.io/vuln/SNYK-PYTHON-PYFTPDLIB-42147;no;no;yes;no;
|
||||
CVE-2023-0055;SNYK-PYTHON-PYLOADNG-3225112;https://security.snyk.io/vuln/SNYK-PYTHON-PYLOADNG-3225112;yes;no;no;no;
|
||||
@@ -2908,8 +2924,6 @@ CVE-2023-32309;SNYK-PYTHON-PYMDOWNEXTENSIONS-5537103;https://security.snyk.io/vu
|
||||
CVE-2023-36464;SNYK-PYTHON-PYPDF-5741897;https://security.snyk.io/vuln/SNYK-PYTHON-PYPDF-5741897;yes;no;no;no;
|
||||
CVE-2022-24859;SNYK-PYTHON-PYPDF2-2766479;https://security.snyk.io/vuln/SNYK-PYTHON-PYPDF2-2766479;yes;no;no;no;
|
||||
CVE-2023-36464;SNYK-PYTHON-PYPDF2-5741898;https://security.snyk.io/vuln/SNYK-PYTHON-PYPDF2-5741898;yes;no;no;no;
|
||||
CVE-2016-10127;SNYK-PYTHON-PYSAML2-40373;https://security.snyk.io/vuln/SNYK-PYTHON-PYSAML2-40373;no;no;no;yes;
|
||||
CVE-2016-10149;SNYK-PYTHON-PYSAML2-40373;https://security.snyk.io/vuln/SNYK-PYTHON-PYSAML2-40373;no;no;no;yes;
|
||||
CVE-2016-5851;SNYK-PYTHON-PYTHONDOCX-40402;https://security.snyk.io/vuln/SNYK-PYTHON-PYTHONDOCX-40402;no;no;no;yes;
|
||||
CVE-2020-26705;SNYK-PYTHON-PYTHONEASYXML-1769272;https://security.snyk.io/vuln/SNYK-PYTHON-PYTHONEASYXML-1769272;no;no;no;yes;
|
||||
CVE-2022-30284;SNYK-PYTHON-PYTHONLIBNMAP-2808864;https://security.snyk.io/vuln/SNYK-PYTHON-PYTHONLIBNMAP-2808864;yes;no;no;no;
|
||||
@@ -2942,15 +2956,17 @@ CVE-2022-31558;SNYK-PYTHON-SHIVA-2946748;https://security.snyk.io/vuln/SNYK-PYTH
|
||||
CVE-2020-19000;SNYK-PYTHON-SIMIKI-1570715;https://security.snyk.io/vuln/SNYK-PYTHON-SIMIKI-1570715;yes;no;no;no;
|
||||
CVE-2020-19001;SNYK-PYTHON-SIMIKI-1570716;https://security.snyk.io/vuln/SNYK-PYTHON-SIMIKI-1570716;yes;no;no;no;
|
||||
CVE-2021-22557;SNYK-PYTHON-SLOGENERATOR-1727657;https://security.snyk.io/vuln/SNYK-PYTHON-SLOGENERATOR-1727657;yes;no;no;no;
|
||||
CVE-2020-11023;SNYK-PYTHON-SPHINX-570773;https://security.snyk.io/vuln/SNYK-PYTHON-SPHINX-570773;yes;no;no;no;
|
||||
CVE-2022-42965;SNYK-PYTHON-SNOWFLAKECONNECTORPYTHON-3111888;https://security.snyk.io/vuln/SNYK-PYTHON-SNOWFLAKECONNECTORPYTHON-3111888;yes;no;no;no;
|
||||
CVE-2021-41168;SNYK-PYTHON-SNUDOWN-1766495;https://security.snyk.io/vuln/SNYK-PYTHON-SNUDOWN-1766495;yes;no;no;no;
|
||||
CVE-2021-43811;SNYK-PYTHON-SOCKEYE-2313698;https://security.snyk.io/vuln/SNYK-PYTHON-SOCKEYE-2313698;yes;no;no;no;
|
||||
CVE-2020-11022;SNYK-PYTHON-SPHINX-570772;https://security.snyk.io/vuln/SNYK-PYTHON-SPHINX-570772;yes;no;no;no;
|
||||
CVE-2020-11023;SNYK-PYTHON-SPHINX-570773;https://security.snyk.io/vuln/SNYK-PYTHON-SPHINX-570773;yes;no;no;no;
|
||||
CVE-2023-23608;SNYK-PYTHON-SPOTIPY-3245108;https://security.snyk.io/vuln/SNYK-PYTHON-SPOTIPY-3245108;yes;no;yes;no;
|
||||
CVE-2019-3575;SNYK-PYTHON-SQLAYAMLFIXTURES-1579274;https://security.snyk.io/vuln/SNYK-PYTHON-SQLAYAMLFIXTURES-1579274;yes;no;no;no;
|
||||
CVE-2023-36830;SNYK-PYTHON-SQLFLUFF-5759286;https://security.snyk.io/vuln/SNYK-PYTHON-SQLFLUFF-5759286;yes;no;no;no;
|
||||
CVE-2021-23404;SNYK-PYTHON-SQLITEWEB-1316324;https://security.snyk.io/vuln/SNYK-PYTHON-SQLITEWEB-1316324;yes;no;no;no;
|
||||
CVE-2022-35941;SNYK-PYTHON-TENSORFLOWGPU-3026906;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026906;yes;no;no;no;
|
||||
CVE-2022-35935;SNYK-PYTHON-TENSORFLOWGPU-3026912;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026912;yes;no;no;no;
|
||||
CVE-2023-29159;SNYK-PYTHON-STARLETTE-5538332;https://security.snyk.io/vuln/SNYK-PYTHON-STARLETTE-5538332;yes;no;no;no;
|
||||
CVE-2022-35918;SNYK-PYTHON-STREAMLIT-2964954;https://security.snyk.io/vuln/SNYK-PYTHON-STREAMLIT-2964954;no;no;yes;no;
|
||||
CVE-2017-11610;SNYK-PYTHON-SUPERVISOR-40610;https://security.snyk.io/vuln/SNYK-PYTHON-SUPERVISOR-40610;yes;no;no;no;
|
||||
@@ -3149,8 +3165,6 @@ CVE-2022-35985;SNYK-PYTHON-TENSORFLOWGPU-3026893;https://security.snyk.io/vuln/S
|
||||
CVE-2022-35982;SNYK-PYTHON-TENSORFLOWGPU-3026896;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026896;yes;no;no;no;
|
||||
CVE-2022-35987;SNYK-PYTHON-TENSORFLOWGPU-3026899;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026899;yes;no;no;no;
|
||||
CVE-2022-36018;SNYK-PYTHON-TENSORFLOWGPU-3026903;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026903;yes;no;no;no;
|
||||
CVE-2022-35941;SNYK-PYTHON-TENSORFLOWGPU-3026906;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026906;yes;no;no;no;
|
||||
CVE-2022-35935;SNYK-PYTHON-TENSORFLOWGPU-3026912;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026912;yes;no;no;no;
|
||||
CVE-2022-36004;SNYK-PYTHON-TENSORFLOWGPU-3026924;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026924;yes;no;no;no;
|
||||
CVE-2022-35934;SNYK-PYTHON-TENSORFLOWGPU-3026927;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026927;yes;no;no;no;
|
||||
CVE-2022-36026;SNYK-PYTHON-TENSORFLOWGPU-3026930;https://security.snyk.io/vuln/SNYK-PYTHON-TENSORFLOWGPU-3026930;yes;no;no;no;
|
||||
@@ -3227,6 +3241,7 @@ CVE-2023-44487;SNYK-RHEL7-RHNODEJS14NODEJSDEVEL-5969131;https://security.snyk.io
|
||||
CVE-2023-44487;SNYK-RHEL7-RHNODEJS14NODEJSDOCS-5969128;https://security.snyk.io/vuln/SNYK-RHEL7-RHNODEJS14NODEJSDOCS-5969128;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-RHEL7-RHNODEJS14NODEJSFULLI18N-5969121;https://security.snyk.io/vuln/SNYK-RHEL7-RHNODEJS14NODEJSFULLI18N-5969121;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-RHEL7-RHNODEJS14NPM-5969130;https://security.snyk.io/vuln/SNYK-RHEL7-RHNODEJS14NPM-5969130;yes;no;no;no;
|
||||
CVE-2023-46813;SNYK-RHEL9-KERNELDEBUGCORE-6038699;https://security.snyk.io/vuln/SNYK-RHEL9-KERNELDEBUGCORE-6038699;yes;no;no;no;
|
||||
CVE-2014-0130;SNYK-RUBY-ACTIONPACK-20158;https://security.snyk.io/vuln/SNYK-RUBY-ACTIONPACK-20158;no;no;yes;no;
|
||||
CVE-2022-3704;SNYK-RUBY-ACTIONPACK-3086619;https://security.snyk.io/vuln/SNYK-RUBY-ACTIONPACK-3086619;yes;no;no;no;
|
||||
CVE-2020-8159;SNYK-RUBY-ACTIONPACKPAGECACHING-590072;https://security.snyk.io/vuln/SNYK-RUBY-ACTIONPACKPAGECACHING-590072;no;no;yes;no;
|
||||
@@ -3334,7 +3349,22 @@ CVE-2022-31264;SNYK-RUST-SOLANARBPF-2841478;https://security.snyk.io/vuln/SNYK-R
|
||||
CVE-2021-38511;SNYK-RUST-TAR-1540306;https://security.snyk.io/vuln/SNYK-RUST-TAR-1540306;no;no;yes;no;
|
||||
CVE-2022-39215;SNYK-RUST-TAURI-3025255;https://security.snyk.io/vuln/SNYK-RUST-TAURI-3025255;no;no;yes;no;
|
||||
CVE-2021-41150;SNYK-RUST-TOUGH-1759835;https://security.snyk.io/vuln/SNYK-RUST-TOUGH-1759835;no;no;yes;no;
|
||||
CVE-2023-44487;SNYK-SLES151-NODEJS10-6041577;https://security.snyk.io/vuln/SNYK-SLES151-NODEJS10-6041577;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES151-NODEJS10DEVEL-6041566;https://security.snyk.io/vuln/SNYK-SLES151-NODEJS10DEVEL-6041566;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES151-NODEJS10DOCS-6041595;https://security.snyk.io/vuln/SNYK-SLES151-NODEJS10DOCS-6041595;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES151-NPM10-6041588;https://security.snyk.io/vuln/SNYK-SLES151-NPM10-6041588;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-JETTYHTTP-6037591;https://security.snyk.io/vuln/SNYK-SLES152-JETTYHTTP-6037591;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-JETTYIO-6037598;https://security.snyk.io/vuln/SNYK-SLES152-JETTYIO-6037598;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-JETTYSECURITY-6037587;https://security.snyk.io/vuln/SNYK-SLES152-JETTYSECURITY-6037587;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-JETTYSERVER-6037590;https://security.snyk.io/vuln/SNYK-SLES152-JETTYSERVER-6037590;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-JETTYSERVLET-6037570;https://security.snyk.io/vuln/SNYK-SLES152-JETTYSERVLET-6037570;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-JETTYUTIL-6037621;https://security.snyk.io/vuln/SNYK-SLES152-JETTYUTIL-6037621;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-JETTYUTILAJAX-6037574;https://security.snyk.io/vuln/SNYK-SLES152-JETTYUTILAJAX-6037574;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-NETTYTCNATIVE-6033925;https://security.snyk.io/vuln/SNYK-SLES152-NETTYTCNATIVE-6033925;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-NODEJS10-6041576;https://security.snyk.io/vuln/SNYK-SLES152-NODEJS10-6041576;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-NODEJS10DEVEL-6041580;https://security.snyk.io/vuln/SNYK-SLES152-NODEJS10DEVEL-6041580;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-NODEJS10DOCS-6041582;https://security.snyk.io/vuln/SNYK-SLES152-NODEJS10DOCS-6041582;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-NPM10-6041579;https://security.snyk.io/vuln/SNYK-SLES152-NPM10-6041579;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-TOMCAT-6016595;https://security.snyk.io/vuln/SNYK-SLES152-TOMCAT-6016595;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-TOMCATADMINWEBAPPS-6016573;https://security.snyk.io/vuln/SNYK-SLES152-TOMCATADMINWEBAPPS-6016573;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-TOMCATEL30API-6016582;https://security.snyk.io/vuln/SNYK-SLES152-TOMCATEL30API-6016582;yes;no;no;no;
|
||||
@@ -3342,7 +3372,18 @@ CVE-2023-44487;SNYK-SLES152-TOMCATJSP23API-6016601;https://security.snyk.io/vuln
|
||||
CVE-2023-44487;SNYK-SLES152-TOMCATLIB-6016589;https://security.snyk.io/vuln/SNYK-SLES152-TOMCATLIB-6016589;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-TOMCATSERVLET40API-6016600;https://security.snyk.io/vuln/SNYK-SLES152-TOMCATSERVLET40API-6016600;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES152-TOMCATWEBAPPS-6016594;https://security.snyk.io/vuln/SNYK-SLES152-TOMCATWEBAPPS-6016594;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-JETTYHTTP-6037608;https://security.snyk.io/vuln/SNYK-SLES153-JETTYHTTP-6037608;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-JETTYIO-6037622;https://security.snyk.io/vuln/SNYK-SLES153-JETTYIO-6037622;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-JETTYSECURITY-6037568;https://security.snyk.io/vuln/SNYK-SLES153-JETTYSECURITY-6037568;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-JETTYSERVER-6037583;https://security.snyk.io/vuln/SNYK-SLES153-JETTYSERVER-6037583;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-JETTYSERVLET-6037606;https://security.snyk.io/vuln/SNYK-SLES153-JETTYSERVLET-6037606;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-JETTYUTIL-6037620;https://security.snyk.io/vuln/SNYK-SLES153-JETTYUTIL-6037620;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-JETTYUTILAJAX-6037579;https://security.snyk.io/vuln/SNYK-SLES153-JETTYUTILAJAX-6037579;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-NETTYTCNATIVE-6033915;https://security.snyk.io/vuln/SNYK-SLES153-NETTYTCNATIVE-6033915;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-NODEJS16-6037292;https://security.snyk.io/vuln/SNYK-SLES153-NODEJS16-6037292;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-NODEJS16DEVEL-6037298;https://security.snyk.io/vuln/SNYK-SLES153-NODEJS16DEVEL-6037298;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-NODEJS16DOCS-6037304;https://security.snyk.io/vuln/SNYK-SLES153-NODEJS16DOCS-6037304;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-NPM16-6037313;https://security.snyk.io/vuln/SNYK-SLES153-NPM16-6037313;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-TOMCAT-6016580;https://security.snyk.io/vuln/SNYK-SLES153-TOMCAT-6016580;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-TOMCATADMINWEBAPPS-6016578;https://security.snyk.io/vuln/SNYK-SLES153-TOMCATADMINWEBAPPS-6016578;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES153-TOMCATEL30API-6016585;https://security.snyk.io/vuln/SNYK-SLES153-TOMCATEL30API-6016585;yes;no;no;no;
|
||||
@@ -3353,6 +3394,13 @@ CVE-2023-44487;SNYK-SLES153-TOMCATWEBAPPS-6016571;https://security.snyk.io/vuln/
|
||||
CVE-2023-44487;SNYK-SLES154-GO120-5965701;https://security.snyk.io/vuln/SNYK-SLES154-GO120-5965701;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-GO120DOC-5965709;https://security.snyk.io/vuln/SNYK-SLES154-GO120DOC-5965709;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-GO120RACE-5965719;https://security.snyk.io/vuln/SNYK-SLES154-GO120RACE-5965719;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-JETTYHTTP-6037610;https://security.snyk.io/vuln/SNYK-SLES154-JETTYHTTP-6037610;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-JETTYIO-6037626;https://security.snyk.io/vuln/SNYK-SLES154-JETTYIO-6037626;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-JETTYSECURITY-6037612;https://security.snyk.io/vuln/SNYK-SLES154-JETTYSECURITY-6037612;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-JETTYSERVER-6037631;https://security.snyk.io/vuln/SNYK-SLES154-JETTYSERVER-6037631;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-JETTYSERVLET-6037604;https://security.snyk.io/vuln/SNYK-SLES154-JETTYSERVLET-6037604;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-JETTYUTIL-6037628;https://security.snyk.io/vuln/SNYK-SLES154-JETTYUTIL-6037628;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-JETTYUTILAJAX-6037638;https://security.snyk.io/vuln/SNYK-SLES154-JETTYUTILAJAX-6037638;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-NETTYTCNATIVE-6033912;https://security.snyk.io/vuln/SNYK-SLES154-NETTYTCNATIVE-6033912;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-NODEJS16-6028206;https://security.snyk.io/vuln/SNYK-SLES154-NODEJS16-6028206;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES154-NODEJS16DEVEL-6028181;https://security.snyk.io/vuln/SNYK-SLES154-NODEJS16DEVEL-6028181;yes;no;no;no;
|
||||
@@ -3372,6 +3420,13 @@ CVE-2023-44487;SNYK-SLES154-TOMCATWEBAPPS-6016598;https://security.snyk.io/vuln/
|
||||
CVE-2023-44487;SNYK-SLES155-GO120-5965732;https://security.snyk.io/vuln/SNYK-SLES155-GO120-5965732;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-GO120DOC-5965705;https://security.snyk.io/vuln/SNYK-SLES155-GO120DOC-5965705;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-GO120RACE-5965731;https://security.snyk.io/vuln/SNYK-SLES155-GO120RACE-5965731;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-JETTYHTTP-6037575;https://security.snyk.io/vuln/SNYK-SLES155-JETTYHTTP-6037575;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-JETTYIO-6037596;https://security.snyk.io/vuln/SNYK-SLES155-JETTYIO-6037596;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-JETTYSECURITY-6037613;https://security.snyk.io/vuln/SNYK-SLES155-JETTYSECURITY-6037613;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-JETTYSERVER-6037581;https://security.snyk.io/vuln/SNYK-SLES155-JETTYSERVER-6037581;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-JETTYSERVLET-6037617;https://security.snyk.io/vuln/SNYK-SLES155-JETTYSERVLET-6037617;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-JETTYUTIL-6037607;https://security.snyk.io/vuln/SNYK-SLES155-JETTYUTIL-6037607;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-JETTYUTILAJAX-6037572;https://security.snyk.io/vuln/SNYK-SLES155-JETTYUTILAJAX-6037572;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-NETTY-6033920;https://security.snyk.io/vuln/SNYK-SLES155-NETTY-6033920;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-NETTYJAVADOC-6033933;https://security.snyk.io/vuln/SNYK-SLES155-NETTYJAVADOC-6033933;yes;no;no;no;
|
||||
CVE-2023-44487;SNYK-SLES155-NETTYPOMS-6033930;https://security.snyk.io/vuln/SNYK-SLES155-NETTYPOMS-6033930;yes;no;no;no;
|
||||
@@ -3595,6 +3650,7 @@ CVE-2023-27730;SNYK-UNMANAGED-NGINXNJS-5416712;https://security.snyk.io/vuln/SNY
|
||||
CVE-2022-31901;SNYK-UNMANAGED-NOTEPADPLUSPLUSNOTEPADPLUSPLUS-3245093;https://security.snyk.io/vuln/SNYK-UNMANAGED-NOTEPADPLUSPLUSNOTEPADPLUSPLUS-3245093;yes;yes;no;no;
|
||||
CVE-2022-31902;SNYK-UNMANAGED-NOTEPADPLUSPLUSNOTEPADPLUSPLUS-3261248;https://security.snyk.io/vuln/SNYK-UNMANAGED-NOTEPADPLUSPLUSNOTEPADPLUSPLUS-3261248;yes;no;no;no;
|
||||
CVE-2023-43898;SNYK-UNMANAGED-NOTHINGSSTB-5929476;https://security.snyk.io/vuln/SNYK-UNMANAGED-NOTHINGSSTB-5929476;yes;no;no;no;
|
||||
CVE-2023-43281;SNYK-UNMANAGED-NOTHINGSSTB-6039488;https://security.snyk.io/vuln/SNYK-UNMANAGED-NOTHINGSSTB-6039488;yes;no;no;no;
|
||||
CVE-2022-30288;SNYK-UNMANAGED-OHLER55AGOO-2812448;https://security.snyk.io/vuln/SNYK-UNMANAGED-OHLER55AGOO-2812448;yes;no;no;no;
|
||||
CVE-2022-40890;SNYK-UNMANAGED-OPEN5GSOPEN5GS-3037336;https://security.snyk.io/vuln/SNYK-UNMANAGED-OPEN5GSOPEN5GS-3037336;yes;no;no;no;
|
||||
CVE-2022-43223;SNYK-UNMANAGED-OPEN5GSOPEN5GS-3098064;https://security.snyk.io/vuln/SNYK-UNMANAGED-OPEN5GSOPEN5GS-3098064;yes;no;no;no;
|
||||
|
||||
|
@@ -1022,3 +1022,6 @@
|
||||
"CVE-2023-4966","Citrix","NetScaler ADC and NetScaler Gateway","Citrix NetScaler ADC and NetScaler Gateway Buffer Overflow Vulnerability","2023-10-18","Citrix NetScaler ADC and NetScaler Gateway contain a buffer overflow vulnerability that allows for sensitive information disclosure when configured as a Gateway (VPN virtual server, ICA Proxy, CVPN, RDP Proxy) or AAA virtual server.","Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.","2023-11-08","Unknown","https://support.citrix.com/article/CTX579459/netscaler-adc-and-netscaler-gateway-security-bulletin-for-cve20234966-and-cve20234967"
|
||||
"CVE-2023-20273","Cisco","Cisco IOS XE Web UI","Cisco IOS XE Web UI Command Injection Vulnerability","2023-10-23","Cisco IOS XE contains a command injection vulnerability in the web user interface. When chained with CVE-2023-20198, the attacker can leverage the new local user to elevate privilege to root and write the implant to the file system. Cisco identified CVE-2023-20273 as the vulnerability exploited to deploy the implant. CVE-2021-1435, previously associated with the exploitation events, is no longer believed to be related to this activity.","Verify that instances of Cisco IOS XE Web UI are in compliance with BOD 23-02 and apply mitigations per vendor instructions. For affected products (Cisco IOS XE Web UI exposed to the internet or to untrusted networks), follow vendor instructions to determine if a system may have been compromised and immediately report positive findings to CISA.","2023-10-27","Unknown","https://sec.cloudapps.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-iosxe-webui-privesc-j22SaA4z"
|
||||
"CVE-2023-5631","Roundcube","Webmail","Roundcube Webmail Persistent Cross-Site Scripting (XSS) Vulnerability","2023-10-26","Roundcube Webmail contains a persistent cross-site scripting (XSS) vulnerability that allows a remote attacker to run malicious JavaScript code.","Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.","2023-11-16","Unknown","https://roundcube.net/news/2023/10/16/security-update-1.6.4-released, https://roundcube.net/news/2023/10/16/security-updates-1.5.5-and-1.4.15"
|
||||
"CVE-2023-46748","F5","BIG-IP Configuration Utility","F5 BIG-IP Configuration Utility SQL Injection Vulnerability","2023-10-31","F5 BIG-IP Configuration utility contains an SQL injection vulnerability that may allow an authenticated attacker with network access through the BIG-IP management port and/or self IP addresses to execute system commands. This vulnerability can be used in conjunction with CVE-2023-46747.","Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.","2023-11-21","Unknown","https://my.f5.com/manage/s/article/K000137365"
|
||||
"CVE-2023-46747","F5","BIG-IP Configuration Utility","F5 BIG-IP Configuration Utility Authentication Bypass Vulnerability","2023-10-31","F5 BIG-IP Configuration utility contains an authentication bypass using an alternate path or channel vulnerability due to undisclosed requests that may allow an unauthenticated attacker with network access to the BIG-IP system through the management port and/or self IP addresses to execute system commands. This vulnerability can be used in conjunction with CVE-2023-46748.","Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.","2023-11-21","Unknown","https://my.f5.com/manage/s/article/K000137353"
|
||||
"CVE-2023-46604","Apache","ActiveMQ","Apache ActiveMQ Deserialization of Untrusted Data Vulnerability","2023-11-02","Apache ActiveMQ contains a deserialization of untrusted data vulnerability that may allow a remote attacker with network access to a broker to run shell commands by manipulating serialized class types in the OpenWire protocol to cause the broker to instantiate any class on the classpath.","Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.","2023-11-23","Unknown","https://activemq.apache.org/security-advisories.data/CVE-2023-46604-announcement.txt"
|
||||
|
||||
|
@@ -326,6 +326,7 @@
|
||||
/modules/auxiliary/scanner/http/cisco_ios_auth_bypass.rb:CVE-2001-0537
|
||||
/modules/auxiliary/scanner/http/cisco_nac_manager_traversal.rb:CVE-2011-3305
|
||||
/modules/auxiliary/scanner/http/cisco_ssl_vpn_priv_esc.rb:CVE-2014-2127
|
||||
/modules/auxiliary/scanner/http/citrix_bleed_cve_2023_4966.rb:CVE-2023-4966
|
||||
/modules/auxiliary/scanner/http/citrix_dir_traversal.rb:CVE-2019-19781
|
||||
/modules/auxiliary/scanner/http/cnpilot_r_web_login_loot.rb:CVE-2017-5260
|
||||
/modules/auxiliary/scanner/http/coldfusion_locale_traversal.rb:CVE-2010-2861
|
||||
@@ -712,7 +713,8 @@
|
||||
/modules/exploits/linux/http/eyesofnetwork_autodiscovery_rce.rb:CVE-2020-8656
|
||||
/modules/exploits/linux/http/eyesofnetwork_autodiscovery_rce.rb:CVE-2020-8657
|
||||
/modules/exploits/linux/http/eyesofnetwork_autodiscovery_rce.rb:CVE-2020-9465
|
||||
/modules/exploits/linux/http/f5_bigip_tmui_rce.rb:CVE-2020-5902
|
||||
/modules/exploits/linux/http/f5_bigip_tmui_rce_cve_2020_5902.rb:CVE-2020-5902
|
||||
/modules/exploits/linux/http/f5_bigip_tmui_rce_cve_2023_46747.rb:CVE-2023-46747
|
||||
/modules/exploits/linux/http/f5_icall_cmd.rb:CVE-2015-3628
|
||||
/modules/exploits/linux/http/f5_icontrol_exec.rb:CVE-2014-2928
|
||||
/modules/exploits/linux/http/f5_icontrol_rce.rb:CVE-2022-1388
|
||||
@@ -771,6 +773,7 @@
|
||||
/modules/exploits/linux/http/linksys_wvbr0_user_agent_exec_noauth.rb:CVE-2017-17411
|
||||
/modules/exploits/linux/http/linuxki_rce.rb:CVE-2020-7209
|
||||
/modules/exploits/linux/http/lucee_admin_imgprocess_file_write.rb:CVE-2021-21307
|
||||
/modules/exploits/linux/http/magnusbilling_unauth_rce_cve_2023_30258.rb:CVE-2023-30258
|
||||
/modules/exploits/linux/http/mailcleaner_exec.rb:CVE-2018-20323
|
||||
/modules/exploits/linux/http/metabase_setup_token_rce.rb:CVE-2023-38646
|
||||
/modules/exploits/linux/http/microfocus_obr_cmd_injection.rb:CVE-2021-22502
|
||||
@@ -2084,6 +2087,7 @@
|
||||
/modules/exploits/windows/http/adobe_robohelper_authbypass.rb:CVE-2009-3068
|
||||
/modules/exploits/windows/http/advantech_iview_networkservlet_cmd_inject.rb:CVE-2022-2143
|
||||
/modules/exploits/windows/http/advantech_iview_unauth_rce.rb:CVE-2021-22652
|
||||
/modules/exploits/windows/http/ajaxpro_deserialization_rce.rb:CVE-2021-23758
|
||||
/modules/exploits/windows/http/altn_securitygateway.rb:CVE-2008-4193
|
||||
/modules/exploits/windows/http/altn_webadmin.rb:CVE-2003-0471
|
||||
/modules/exploits/windows/http/apache_activemq_traversal_upload.rb:CVE-2015-1830
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_output "[*] Exploitability notes:"
|
||||
print_output "$(indent "${ORANGE}R$NC - remote exploits")"
|
||||
print_output "$(indent "${ORANGE}L$NC - local exploits")"
|
||||
print_output "$(indent "${ORANGE}D$NC - DoS exploits")"
|
||||
# print_output "$(indent "${ORANGE}G$NC - PoC code found on Github (unknown exploit vector)")"
|
||||
print_output "$(indent "${ORANGE}R${NC} - remote exploits")"
|
||||
print_output "$(indent "${ORANGE}L${NC} - local exploits")"
|
||||
print_output "$(indent "${ORANGE}D${NC} - DoS exploits")"
|
||||
# print_output "$(indent "${ORANGE}G${NC} - PoC code found on Github (unknown exploit vector)")"
|
||||
# write_link "https://github.com/trickest/cve"
|
||||
print_output "$(indent "${ORANGE}P$NC - PoC code found on Packetstormsecurity (unknown exploit vector)")"
|
||||
print_output "$(indent "${ORANGE}P${NC} - PoC code found on Packetstormsecurity (unknown exploit vector)")"
|
||||
write_link "https://packetstormsecurity.com/files/tags/exploit/"
|
||||
print_output "$(indent "${ORANGE}S$NC - PoC code found on Snyk vulnerability database (unknown exploit vector)")"
|
||||
print_output "$(indent "${ORANGE}S${NC} - PoC code found on Snyk vulnerability database (unknown exploit vector)")"
|
||||
write_link "https://security.snyk.io/vuln"
|
||||
print_output "$(indent "${ORANGE}X$NC - Vulnerability is known as exploited")"
|
||||
print_output "$(indent "${ORANGE}X${NC} - Vulnerability is known as exploited")"
|
||||
write_link "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
|
||||
if [[ -f "$LOG_DIR"/s26_kernel_vuln_verifier.txt ]]; then
|
||||
print_output "$(indent "${ORANGE}V$NC - Kernel vulnerability was verified from module s26")"
|
||||
if [[ -f "${LOG_DIR}"/s26_kernel_vuln_verifier.txt ]]; then
|
||||
print_output "$(indent "${ORANGE}V${NC} - Kernel vulnerability was verified from module s26")"
|
||||
write_link "s26"
|
||||
fi
|
||||
print_ln
|
||||
print_ln
|
||||
print_output "[*] Source notes:"
|
||||
print_output "$(indent "${ORANGE}STAT$NC - Details found by static modules (S06, S09, S24, S25)")"
|
||||
print_output "$(indent "${ORANGE}PACK$NC - Details found by package management environment (S08)")"
|
||||
print_output "$(indent "${ORANGE}UEMU$NC - Details found by dynamic user-mode emulation modules (S115, S116)")"
|
||||
print_output "$(indent "${ORANGE}SEMU$NC - Details found by dynamic system emulation modules (L*)")"
|
||||
print_output "$(indent "${ORANGE}STAT${NC} - Details found by static modules (S06, S09, S24, S25)")"
|
||||
print_output "$(indent "${ORANGE}PACK${NC} - Details found by package management environment (S08)")"
|
||||
print_output "$(indent "${ORANGE}UEMU${NC} - Details found by dynamic user-mode emulation modules (S115, S116)")"
|
||||
print_output "$(indent "${ORANGE}SEMU${NC} - Details found by dynamic system emulation modules (L*)")"
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
print_output "EMBA was able to identify an encrypted ${ORANGE}D'Link${NC} firmware image. This firmware image was protected with leaked key material and it is possible to decrypt the firmware for further analysis."
|
||||
print_ln
|
||||
print_output "While EMBA is currently able to decrypt firmware with the different header details, like ${ORANGE}SHRS${NC} and ${ORANGE}encrpted_img${NC}, others can't be decrypted by EMBA."
|
||||
if [[ "$DLINK_ENC_DETECTED" -eq 1 ]]; then
|
||||
if [[ "${DLINK_ENC_DETECTED}" -eq 1 ]]; then
|
||||
print_ln
|
||||
print_output "In the current case the original firmware was encrypted with the ${ORANGE}SHRS${NC} mechanism and was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
|
||||
elif [[ "$DLINK_ENC_DETECTED" -eq 2 ]]; then
|
||||
print_output "In the current case the original firmware was encrypted with the ${ORANGE}SHRS${NC} mechanism and was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
|
||||
elif [[ "${DLINK_ENC_DETECTED}" -eq 2 ]]; then
|
||||
print_ln
|
||||
print_output "In the current case the original firmware was encrypted with the ${ORANGE}encrpted_img${NC} mechanism and was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
|
||||
print_output "In the current case the original firmware was encrypted with the ${ORANGE}encrpted_img${NC} mechanism and was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
|
||||
fi
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
print_output "EMBA was able to identify an encrypted ${ORANGE}EnGenius${NC} firmware image. This firmware image was protected with leaked key material and it is possible to decrypt the firmware for further analysis."
|
||||
print_ln
|
||||
print_output "The original firmware was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
|
||||
print_output "The original firmware was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
print_output "EMBA was able to identify an encrypted ${ORANGE}QNAP${NC} firmware image. This firmware image was protected with leaked key material and it is possible to decrypt the firmware for further analysis."
|
||||
print_ln
|
||||
print_output "The original firmware was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
|
||||
print_output "The original firmware was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}readelf$NC."
|
||||
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}readelf${NC}."
|
||||
print_output "Examples of binary functions are system, strcpy, printf and strcat. These functions are listed in the configuration"
|
||||
print_output "file config/functions.cfg."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}objdump$NC."
|
||||
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}objdump${NC}."
|
||||
print_output "Examples of binary functions are system, strcpy, printf and strcat. These functions are configured in the configuration"
|
||||
print_output "file config/functions.cfg. The module counts the usages per binary. For strcpy functions it also counts strlen functions"
|
||||
print_output "right before the strcpy function. Additionally it checks if the binary is a known Linux binary or unknown and probably"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}radare2$NC."
|
||||
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}radare2${NC}."
|
||||
print_output "Examples of binary functions are system, strcpy, printf and strcat. These functions are configured in the configuration"
|
||||
print_output "file config/functions.cfg. The module counts the usages per binary. For strcpy functions it also counts strlen functions"
|
||||
print_output "right before the strcpy function. Additionally it checks if the binary is a known Linux binary or unknown and probably"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_output "[*] Exploitability notes:"
|
||||
print_output "$(indent "${ORANGE}EDB$NC - Exploit code found in the Exploit database")"
|
||||
print_output "$(indent "${ORANGE}EDB${NC} - Exploit code found in the Exploit database")"
|
||||
write_link "https://exploit-db.com"
|
||||
print_output "$(indent "${ORANGE}MSF$NC - Exploit code found in the Metasploit framework")"
|
||||
print_output "$(indent "${ORANGE}MSF${NC} - Exploit code found in the Metasploit framework")"
|
||||
write_link "https://github.com/rapid7/metasploit-framework"
|
||||
# print_output "$(indent "${ORANGE}GH$NC - PoC code found on Github (via trickest)")"
|
||||
# print_output "$(indent "${ORANGE}GH${NC} - PoC code found on Github (via trickest)")"
|
||||
# write_link "https://github.com/trickest/cve"
|
||||
print_output "$(indent "${ORANGE}PS$NC - PoC code found on Packetstormsecurity")"
|
||||
print_output "$(indent "${ORANGE}PS${NC} - PoC code found on Packetstormsecurity")"
|
||||
write_link "https://packetstormsecurity.com/files/tags/exploit/"
|
||||
print_output "$(indent "${ORANGE}SNYK$NC - PoC code found on Snyk vulnerability database")"
|
||||
print_output "$(indent "${ORANGE}SNYK${NC} - PoC code found on Snyk vulnerability database")"
|
||||
write_link "https://security.snyk.io/vuln"
|
||||
print_output "$(indent "${ORANGE}EXP$NC - Vulnerability is known as exploited")"
|
||||
print_output "$(indent "${ORANGE}EXP${NC} - Vulnerability is known as exploited")"
|
||||
write_link "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
|
||||
|
||||
@@ -564,7 +564,7 @@ dependency_check()
|
||||
check_dep_file "sudo-parser script" "${EXT_DIR}""/sudo-parser.pl"
|
||||
|
||||
# BMC firmware decryptor - https://github.com/c0d3z3r0/smcbmc
|
||||
check_dep_file "BMC decryptor" "$EXT_DIR""/smcbmc/smcbmc.py"
|
||||
check_dep_file "BMC decryptor" "${EXT_DIR}""/smcbmc/smcbmc.py"
|
||||
|
||||
# sh3llcheck - I know it's a typo, but this particular tool nags about it
|
||||
check_dep_tool "shellcheck script" "shellcheck"
|
||||
|
||||
@@ -239,6 +239,7 @@ enable_strict_mode() {
|
||||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
|
||||
# https://github.com/tests-always-included/wick/blob/master/doc/bash-strict-mode.md
|
||||
# shellcheck source=./installer/wickStrictModeFail.sh
|
||||
# shellcheck disable=SC1091
|
||||
source ./installer/wickStrictModeFail.sh
|
||||
load_strict_mode_settings
|
||||
trap 'wickStrictModeFail $? | tee -a "${LOG_DIR}"/emba_error.log' ERR # The ERR trap is triggered when a script catches an error
|
||||
|
||||
+69
-69
@@ -20,14 +20,14 @@
|
||||
STRICT_MODE=1
|
||||
|
||||
ORIG_USER="${SUDO_USER:-${USER}}"
|
||||
ORIG_GROUP=$(groups "$ORIG_USER" | cut -d: -f2 | awk '{print $1}')
|
||||
ORIG_GROUP=$(groups "${ORIG_USER}" | cut -d: -f2 | awk '{print $1}')
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export INSTALL_APP_LIST=()
|
||||
export DOWNLOAD_FILE_LIST=()
|
||||
export INSTALLER_DIR="./installer"
|
||||
|
||||
if [[ "$STRICT_MODE" -eq 1 ]]; then
|
||||
if [[ "${STRICT_MODE}" -eq 1 ]]; then
|
||||
export DEBUG_SCRIPT=0
|
||||
if [[ -f "./helpers/helpers_emba_load_strict_settings.sh" ]]; then
|
||||
# shellcheck source=/dev/null
|
||||
@@ -68,58 +68,58 @@ export NC="\033[0m" # no color
|
||||
## Attribute definition
|
||||
export BOLD="\033[1m"
|
||||
|
||||
echo -e "\\n""$ORANGE""$BOLD""EMBA - Embedded Linux Analyzer Installer""$NC"
|
||||
echo -e "$BOLD""=================================================================""$NC"
|
||||
echo -e "\\n""${ORANGE}""${BOLD}""EMBA - Embedded Linux Analyzer Installer""${NC}"
|
||||
echo -e "${BOLD}""=================================================================""${NC}"
|
||||
|
||||
# import all the installation modules
|
||||
mapfile -t INSTALLERS < <(find "$INSTALLER_DIR" -iname "*.sh" 2> /dev/null)
|
||||
mapfile -t INSTALLERS < <(find "${INSTALLER_DIR}" -iname "*.sh" 2> /dev/null)
|
||||
INSTALLER_COUNT=0
|
||||
for INSTALLER_FILE in "${INSTALLERS[@]}" ; do
|
||||
# https://github.com/koalaman/shellcheck/wiki/SC1090
|
||||
# shellcheck source=/dev/null
|
||||
source "$INSTALLER_FILE"
|
||||
source "${INSTALLER_FILE}"
|
||||
(( INSTALLER_COUNT+=1 ))
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo -e "==> ""$GREEN""Imported ""$INSTALLER_COUNT"" installer module files""$NC"
|
||||
echo -e "==> ""${GREEN}""Imported ""${INSTALLER_COUNT}"" installer module files""${NC}"
|
||||
echo ""
|
||||
|
||||
if [[ "$#" -le 1 ]] && [[ "$#" -gt 2 ]]; then
|
||||
echo -e "$RED""$BOLD""Invalid number of arguments""$NC"
|
||||
echo -e "${RED}""${BOLD}""Invalid number of arguments""${NC}"
|
||||
echo -e "\n\n------------------------------------------------------------------"
|
||||
echo -e "If you are going to install EMBA in default mode you can use:"
|
||||
echo -e "$CYAN"" sudo ./installer.sh -d""$NC"
|
||||
echo -e "${CYAN}"" sudo ./installer.sh -d""${NC}"
|
||||
echo -e "------------------------------------------------------------------\n\n"
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts CdDFghlrsc: OPT ; do
|
||||
case $OPT in
|
||||
case ${OPT} in
|
||||
d)
|
||||
export DOCKER_SETUP=1
|
||||
export CVE_SEARCH=0
|
||||
echo -e "$GREEN""$BOLD""Install all dependecies for EMBA in default/docker mode""$NC"
|
||||
echo -e "${GREEN}""${BOLD}""Install all dependecies for EMBA in default/docker mode""${NC}"
|
||||
;;
|
||||
D)
|
||||
export IN_DOCKER=1
|
||||
export DOCKER_SETUP=0
|
||||
export CVE_SEARCH=0
|
||||
echo -e "$GREEN""$BOLD""Install EMBA in docker image - used for building a docker image""$NC"
|
||||
echo -e "${GREEN}""${BOLD}""Install EMBA in docker image - used for building a docker image""${NC}"
|
||||
;;
|
||||
F)
|
||||
export FULL=1
|
||||
export DOCKER_SETUP=0
|
||||
export CVE_SEARCH=1
|
||||
echo -e "$GREEN""$BOLD""Install all dependecies for developer mode""$NC"
|
||||
echo -e "${GREEN}""${BOLD}""Install all dependecies for developer mode""${NC}"
|
||||
;;
|
||||
g)
|
||||
export DOCKER_SETUP=1
|
||||
export GH_ACTION=1
|
||||
export CVE_SEARCH=0
|
||||
echo -e "$GREEN""$BOLD""Install all dependecies for EMBA test via Github actions""$NC"
|
||||
echo -e "$GREEN""$BOLD""This mode is a default installation without populating the CVE-search database""$NC"
|
||||
echo -e "${GREEN}""${BOLD}""Install all dependecies for EMBA test via Github actions""${NC}"
|
||||
echo -e "${GREEN}""${BOLD}""This mode is a default installation without populating the CVE-search database""${NC}"
|
||||
;;
|
||||
h)
|
||||
print_help
|
||||
@@ -129,21 +129,21 @@ while getopts CdDFghlrsc: OPT ; do
|
||||
export LIST_DEP=1
|
||||
export CVE_SEARCH=0
|
||||
export DOCKER_SETUP=0
|
||||
echo -e "$GREEN""$BOLD""List all dependecies (Warning: deprecated feature)""$NC"
|
||||
echo -e "${GREEN}""${BOLD}""List all dependecies (Warning: deprecated feature)""${NC}"
|
||||
;;
|
||||
r)
|
||||
export REMOVE=1
|
||||
echo -e "$GREEN""$BOLD""Remove EMBA from the system""$NC"
|
||||
echo -e "${GREEN}""${BOLD}""Remove EMBA from the system""${NC}"
|
||||
;;
|
||||
s)
|
||||
export SSL_REPOS=1
|
||||
echo -e "$GREEN""$BOLD""HTTPS repos are used for installation""$NC"
|
||||
echo -e "${GREEN}""${BOLD}""HTTPS repos are used for installation""${NC}"
|
||||
;;
|
||||
c)
|
||||
export CONTAINER="$OPTARG"
|
||||
export CONTAINER="${OPTARG}"
|
||||
;;
|
||||
*)
|
||||
echo -e "$RED""$BOLD""Invalid option""$NC"
|
||||
echo -e "${RED}""${BOLD}""Invalid option""${NC}"
|
||||
print_help
|
||||
exit 1
|
||||
;;
|
||||
@@ -158,24 +158,24 @@ if ! [[ -v CONTAINER ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$LIST_DEP" -eq 1 ]]; then
|
||||
echo -e "\n${ORANGE}WARNING: This feature is deprecated and not maintained anymore.$NC"
|
||||
if [[ "${LIST_DEP}" -eq 1 ]]; then
|
||||
echo -e "\n${ORANGE}WARNING: This feature is deprecated and not maintained anymore.${NC}"
|
||||
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
|
||||
fi
|
||||
|
||||
# WSL support - currently experimental!
|
||||
if grep -q -i wsl /proc/version; then
|
||||
echo -e "\n${ORANGE}INFO: System running in WSL environment!$NC"
|
||||
echo -e "\n${ORANGE}INFO: WSL is currently experimental!$NC"
|
||||
echo -e "\n${ORANGE}Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites$NC"
|
||||
echo -e "\n${ORANGE}WARNING: If you are using WSL2, disable docker integration from the docker-desktop daemon!$NC"
|
||||
echo -e "\n${ORANGE}INFO: System running in WSL environment!${NC}"
|
||||
echo -e "\n${ORANGE}INFO: WSL is currently experimental!${NC}"
|
||||
echo -e "\n${ORANGE}Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites${NC}"
|
||||
echo -e "\n${ORANGE}WARNING: If you are using WSL2, disable docker integration from the docker-desktop daemon!${NC}"
|
||||
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
|
||||
WSL=1
|
||||
fi
|
||||
|
||||
# distribution check
|
||||
if ! grep -Eq "ID(_LIKE)?=(\")?(ubuntu)?( )?(debian)?" /etc/os-release 2>/dev/null ; then
|
||||
echo -e "\\n""$RED""EMBA only supports debian based distributions!""$NC\\n"
|
||||
echo -e "\\n""${RED}""EMBA only supports debian based distributions!""${NC}\\n"
|
||||
print_help
|
||||
exit 1
|
||||
elif ! grep -q "kali" /etc/debian_version 2>/dev/null ; then
|
||||
@@ -184,14 +184,14 @@ elif ! grep -q "kali" /etc/debian_version 2>/dev/null ; then
|
||||
OTHER_OS=1
|
||||
UBUNTU_OS=1
|
||||
elif grep -q "PRETTY_NAME=\"Ubuntu 20.04 LTS\"" /etc/os-release 2>/dev/null ; then
|
||||
echo -e "\\n""$RED""EMBA is not fully supported on Ubuntu 20.04 LTS.""$NC"
|
||||
echo -e "$RED""For EMBA installation you need to update docker-compose manually. See also https://github.com/e-m-b-a/emba/issues/247""$NC"
|
||||
echo -e "\\n""$ORANGE""Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites""$NC"
|
||||
echo -e "\\n""${RED}""EMBA is not fully supported on Ubuntu 20.04 LTS.""${NC}"
|
||||
echo -e "${RED}""For EMBA installation you need to update docker-compose manually. See also https://github.com/e-m-b-a/emba/issues/247""${NC}"
|
||||
echo -e "\\n""${ORANGE}""Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites""${NC}"
|
||||
read -p "If you have updated docker-compose you can press any key to continue ..." -n1 -s -r
|
||||
OTHER_OS=0 # installation procedure identical to kali install
|
||||
UBUNTU_OS=0 # installation procedure identical to kali install
|
||||
else
|
||||
echo -e "\n${ORANGE}WARNING: compatibility of distribution/version unknown!$NC"
|
||||
echo -e "\n${ORANGE}WARNING: compatibility of distribution/version unknown!${NC}"
|
||||
OTHER_OS=1
|
||||
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
|
||||
fi
|
||||
@@ -205,8 +205,8 @@ if ! uname -m | grep -q "x86_64" 2>/dev/null; then
|
||||
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
|
||||
fi
|
||||
|
||||
if ! [[ $EUID -eq 0 ]] && [[ $LIST_DEP -eq 0 ]] ; then
|
||||
echo -e "\\n""$RED""Run EMBA installation script with root permissions!""$NC\\n"
|
||||
if ! [[ ${EUID} -eq 0 ]] && [[ ${LIST_DEP} -eq 0 ]] ; then
|
||||
echo -e "\\n""${RED}""Run EMBA installation script with root permissions!""${NC}\\n"
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
@@ -215,14 +215,14 @@ fi
|
||||
|
||||
HOME_PATH=$(pwd)
|
||||
|
||||
if [[ "$REMOVE" -eq 1 ]]; then
|
||||
if [[ "${REMOVE}" -eq 1 ]]; then
|
||||
R00_emba_remove
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# quick check if we have enough disk space for the docker image
|
||||
|
||||
if [[ "$IN_DOCKER" -eq 0 ]]; then
|
||||
if [[ "${IN_DOCKER}" -eq 0 ]]; then
|
||||
if [[ -d "/var/lib/docker/" ]]; then
|
||||
# docker is already installed
|
||||
DDISK="/var/lib/docker"
|
||||
@@ -231,11 +231,11 @@ if [[ "$IN_DOCKER" -eq 0 ]]; then
|
||||
DDISK="/var/lib/"
|
||||
fi
|
||||
|
||||
FREE_SPACE=$(df --output=avail "$DDISK" | awk 'NR==2')
|
||||
if [[ "$FREE_SPACE" -lt 13000000 ]]; then
|
||||
echo -e "\\n""$ORANGE""EMBA installation in default mode needs a minimum of 13Gig for the docker image""$NC"
|
||||
echo -e "\\n""$ORANGE""Please free enough space on /var/lib/docker""$NC"
|
||||
echo -e "\\n""$ORANGE""Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites""$NC"
|
||||
FREE_SPACE=$(df --output=avail "${DDISK}" | awk 'NR==2')
|
||||
if [[ "${FREE_SPACE}" -lt 13000000 ]]; then
|
||||
echo -e "\\n""${ORANGE}""EMBA installation in default mode needs a minimum of 13Gig for the docker image""${NC}"
|
||||
echo -e "\\n""${ORANGE}""Please free enough space on /var/lib/docker""${NC}"
|
||||
echo -e "\\n""${ORANGE}""Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites""${NC}"
|
||||
echo ""
|
||||
df -h || true
|
||||
echo ""
|
||||
@@ -243,29 +243,29 @@ if [[ "$IN_DOCKER" -eq 0 ]]; then
|
||||
fi
|
||||
|
||||
TOTAL_MEMORY="$(grep MemTotal /proc/meminfo | awk '{print $2}' || true)"
|
||||
if [[ "$TOTAL_MEMORY" -lt 4000000 ]]; then
|
||||
echo -e "\\n""$ORANGE""EMBA installation in default mode needs a minimum of 4Gig of RAM""$NC"
|
||||
echo -e "\\n""$ORANGE""Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites""$NC"
|
||||
if [[ "${TOTAL_MEMORY}" -lt 4000000 ]]; then
|
||||
echo -e "\\n""${ORANGE}""EMBA installation in default mode needs a minimum of 4Gig of RAM""${NC}"
|
||||
echo -e "\\n""${ORANGE}""Please check the documentation https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites""${NC}"
|
||||
echo ""
|
||||
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $LIST_DEP -eq 0 ]] ; then
|
||||
if [[ ${LIST_DEP} -eq 0 ]] ; then
|
||||
if ! [[ -d "external" ]] ; then
|
||||
echo -e "\\n""$ORANGE""Created external directory: ./external""$NC"
|
||||
echo -e "\\n""${ORANGE}""Created external directory: ./external""${NC}"
|
||||
mkdir external
|
||||
# currently this is needed for full install on Ubuntu
|
||||
# the freetz installation is running as freetzuser and needs write access:
|
||||
chown "$ORIG_USER":"$ORIG_GROUP" ./external
|
||||
chown "${ORIG_USER}":"${ORIG_GROUP}" ./external
|
||||
chmod 777 ./external
|
||||
else
|
||||
echo -e "\\n""$ORANGE""WARNING: external directory available: ./external""$NC"
|
||||
echo -e "$ORANGE""Please remove it before proceeding ... exit now""$NC"
|
||||
echo -e "\\n""${ORANGE}""WARNING: external directory available: ./external""${NC}"
|
||||
echo -e "${ORANGE}""Please remove it before proceeding ... exit now""${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\\n""$ORANGE""Update package lists.""$NC"
|
||||
echo -e "\\n""${ORANGE}""Update package lists.""${NC}"
|
||||
if [[ "${SSL_REPOS}" -eq 1 ]]; then
|
||||
sed -i 's/deb http:\/\//deb https:\/\//g' /etc/apt/sources.list
|
||||
sed -i 's/deb-src http:\/\//deb-src https:\/\//g' /etc/apt/sources.list
|
||||
@@ -283,30 +283,30 @@ activate_pipenv "./external/emba_venv"
|
||||
I01_default_apps_host
|
||||
|
||||
DOCKER_COMP_VER=$(docker-compose -v | grep version | tr '-' ' ' | awk '{print $4}' | tr -d ',' | sed 's/^v//')
|
||||
if [[ $(version "$DOCKER_COMP_VER") -lt $(version "1.28.5") ]]; then
|
||||
echo -e "\n${ORANGE}WARNING: compatibility of the used docker-compose version is unknown!$NC"
|
||||
echo -e "\n${ORANGE}Please consider updating your docker-compose installation to version 1.28.5 or later.$NC"
|
||||
echo -e "\n${ORANGE}Please check the EMBA wiki for further details: https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites$NC"
|
||||
if [[ $(version "${DOCKER_COMP_VER}") -lt $(version "1.28.5") ]]; then
|
||||
echo -e "\n${ORANGE}WARNING: compatibility of the used docker-compose version is unknown!${NC}"
|
||||
echo -e "\n${ORANGE}Please consider updating your docker-compose installation to version 1.28.5 or later.${NC}"
|
||||
echo -e "\n${ORANGE}Please check the EMBA wiki for further details: https://github.com/e-m-b-a/emba/wiki/Installation#prerequisites${NC}"
|
||||
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
|
||||
fi
|
||||
|
||||
if [[ "$OTHER_OS" -eq 1 ]]; then
|
||||
if [[ "${OTHER_OS}" -eq 1 ]]; then
|
||||
# UBUNTU
|
||||
if [[ "$UBUNTU_OS" -eq 1 ]]; then
|
||||
if [[ "${UBUNTU_OS}" -eq 1 ]]; then
|
||||
ID1_ubuntu_os
|
||||
fi
|
||||
fi
|
||||
|
||||
INSTALL_APP_LIST=()
|
||||
|
||||
if [[ "$WSL" -eq 1 ]]; then
|
||||
if [[ "${WSL}" -eq 1 ]]; then
|
||||
echo "[*] Starting dockerd manually in wsl environments:"
|
||||
dockerd --iptables=false &
|
||||
sleep 3
|
||||
reset
|
||||
fi
|
||||
|
||||
if [[ "$CVE_SEARCH" -ne 1 ]] || [[ "$DOCKER_SETUP" -ne 1 ]] || [[ "$IN_DOCKER" -eq 1 ]]; then
|
||||
if [[ "${CVE_SEARCH}" -ne 1 ]] || [[ "${DOCKER_SETUP}" -ne 1 ]] || [[ "${IN_DOCKER}" -eq 1 ]]; then
|
||||
|
||||
I01_default_apps
|
||||
|
||||
@@ -349,25 +349,25 @@ fi
|
||||
IF20_cve_search
|
||||
deactivate
|
||||
|
||||
cd "$HOME_PATH" || exit 1
|
||||
cd "${HOME_PATH}" || exit 1
|
||||
|
||||
# we reset the permissions of external from 777 back to 755:
|
||||
chmod 755 ./external
|
||||
|
||||
if [[ "$LIST_DEP" -eq 0 ]] || [[ $IN_DOCKER -eq 0 ]] || [[ $DOCKER_SETUP -eq 1 ]] || [[ $FULL -eq 1 ]]; then
|
||||
echo -e "\\n""$MAGENTA""$BOLD""Installation notes:""$NC"
|
||||
echo -e "\\n""$MAGENTA""INFO: The cron.daily update script for EMBA is located in config/emba_updater""$NC"
|
||||
echo -e "$MAGENTA""INFO: For automatic updates it should be copied to /etc/cron.daily/""$NC"
|
||||
echo -e "$MAGENTA""INFO: For manual updates just start it via sudo ./config/emba_updater""$NC"
|
||||
if [[ "${LIST_DEP}" -eq 0 ]] || [[ ${IN_DOCKER} -eq 0 ]] || [[ ${DOCKER_SETUP} -eq 1 ]] || [[ ${FULL} -eq 1 ]]; then
|
||||
echo -e "\\n""${MAGENTA}""${BOLD}""Installation notes:""${NC}"
|
||||
echo -e "\\n""${MAGENTA}""INFO: The cron.daily update script for EMBA is located in config/emba_updater""${NC}"
|
||||
echo -e "${MAGENTA}""INFO: For automatic updates it should be copied to /etc/cron.daily/""${NC}"
|
||||
echo -e "${MAGENTA}""INFO: For manual updates just start it via sudo ./config/emba_updater""${NC}"
|
||||
|
||||
echo -e "\\n""$MAGENTA""WARNING: If you plan using the emulator (-E switch) your host and your internal network needs to be protected.""$NC"
|
||||
echo -e "\\n""${MAGENTA}""WARNING: If you plan using the emulator (-E switch) your host and your internal network needs to be protected.""${NC}"
|
||||
|
||||
echo -e "\\n""$MAGENTA""INFO: Do not forget to checkout current development of EMBA at https://github.com/e-m-b-a.""$NC"
|
||||
echo -e "\\n""${MAGENTA}""INFO: Do not forget to checkout current development of EMBA at https://github.com/e-m-b-a.""${NC}"
|
||||
fi
|
||||
if [[ "$WSL" -eq 1 ]]; then
|
||||
echo -e "\\n""$MAGENTA""INFO: In the current WSL installation the docker and mongod services started manually!""$NC"
|
||||
if [[ "${WSL}" -eq 1 ]]; then
|
||||
echo -e "\\n""${MAGENTA}""INFO: In the current WSL installation the docker and mongod services started manually!""${NC}"
|
||||
fi
|
||||
|
||||
if [[ "$LIST_DEP" -eq 0 ]]; then
|
||||
echo -e "$GREEN""EMBA installation finished ""$NC"
|
||||
if [[ "${LIST_DEP}" -eq 0 ]]; then
|
||||
echo -e "${GREEN}""EMBA installation finished ""${NC}"
|
||||
fi
|
||||
|
||||
@@ -27,11 +27,11 @@ D02_firmware_diffing_bin_details() {
|
||||
module_title "Firmware differ - binary details"
|
||||
local NEG_LOG=0
|
||||
|
||||
if ! [[ -f "$FIRMWARE_PATH" ]]; then
|
||||
if ! [[ -f "${FIRMWARE_PATH}" ]]; then
|
||||
print_output "[-] No 1st file for diffing provided"
|
||||
return
|
||||
fi
|
||||
if ! [[ -f "$FIRMWARE_PATH1" ]]; then
|
||||
if ! [[ -f "${FIRMWARE_PATH1}" ]]; then
|
||||
print_output "[-] No 2nd file for diffing provided"
|
||||
return
|
||||
fi
|
||||
@@ -56,8 +56,8 @@ D02_firmware_diffing_bin_details() {
|
||||
print_fw_file_details "${FIRMWARE_PATH}"
|
||||
# generate_pixde "${FIRMWARE_PATH}"
|
||||
fw_bin_detector "${FIRMWARE_PATH}"
|
||||
if [[ -f "$LOG_DIR"/firmware_entropy.png ]]; then
|
||||
mv "$LOG_DIR"/firmware_entropy.png "${LOG_PATH_MODULE}"/firmware1_entropy.png
|
||||
if [[ -f "${LOG_DIR}"/firmware_entropy.png ]]; then
|
||||
mv "${LOG_DIR}"/firmware_entropy.png "${LOG_PATH_MODULE}"/firmware1_entropy.png
|
||||
write_link "${LOG_PATH_MODULE}"/firmware1_entropy.png
|
||||
fi
|
||||
|
||||
@@ -67,10 +67,10 @@ D02_firmware_diffing_bin_details() {
|
||||
print_fw_file_details "${FIRMWARE_PATH1}"
|
||||
# generate_pixde "${FIRMWARE_PATH1}"
|
||||
fw_bin_detector "${FIRMWARE_PATH1}"
|
||||
if [[ -f "$LOG_DIR"/firmware_entropy.png ]]; then
|
||||
mv "$LOG_DIR"/firmware_entropy.png "${LOG_PATH_MODULE}"/firmware2_entropy.png
|
||||
if [[ -f "${LOG_DIR}"/firmware_entropy.png ]]; then
|
||||
mv "${LOG_DIR}"/firmware_entropy.png "${LOG_PATH_MODULE}"/firmware2_entropy.png
|
||||
write_link "${LOG_PATH_MODULE}"/firmware2_entropy.png
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
@@ -46,24 +46,24 @@ D05_firmware_diffing_extractor() {
|
||||
OUTPUT_DIR_UNBLOB1="${LOG_PATH_MODULE}"/extractor_"$(basename "${FIRMWARE_PATH}")"
|
||||
unblobber "${FIRMWARE_PATH}" "${OUTPUT_DIR_UNBLOB1}" 0
|
||||
|
||||
if [[ -d "$OUTPUT_DIR_UNBLOB1" ]]; then
|
||||
if [[ -d "${OUTPUT_DIR_UNBLOB1}" ]]; then
|
||||
NEG_LOG=1
|
||||
linux_basic_identification_unblobber "${OUTPUT_DIR_UNBLOB1}"
|
||||
FILES_EXT_UB=$(find "$OUTPUT_DIR_UNBLOB1" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES_UB=$(find "$OUTPUT_DIR_UNBLOB1" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT_UB=$(find "$OUTPUT_DIR_UNBLOB1" -xdev -type d | wc -l )
|
||||
tree -Csh "$OUTPUT_DIR_UNBLOB1" > "${LOG_PATH_MODULE}"/firmware_image1.txt
|
||||
FILES_EXT_UB=$(find "${OUTPUT_DIR_UNBLOB1}" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES_UB=$(find "${OUTPUT_DIR_UNBLOB1}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT_UB=$(find "${OUTPUT_DIR_UNBLOB1}" -xdev -type d | wc -l )
|
||||
tree -Csh "${OUTPUT_DIR_UNBLOB1}" > "${LOG_PATH_MODULE}"/firmware_image1.txt
|
||||
|
||||
print_ln
|
||||
print_output "[*] ${ORANGE}Unblob$NC results:"
|
||||
print_output "[*] Found $ORANGE$FILES_EXT_UB$NC files ($ORANGE$UNIQUE_FILES_UB$NC unique files) and $ORANGE$DIRS_EXT_UB$NC directories at all."
|
||||
print_output "[*] ${ORANGE}Unblob${NC} results:"
|
||||
print_output "[*] Found ${ORANGE}${FILES_EXT_UB}${NC} files (${ORANGE}${UNIQUE_FILES_UB}${NC} unique files) and ${ORANGE}${DIRS_EXT_UB}${NC} directories at all."
|
||||
if [[ -f "${LOG_PATH_MODULE}"/firmware_image1.txt ]]; then
|
||||
write_link "${LOG_PATH_MODULE}"/firmware_image1.txt
|
||||
fi
|
||||
print_output "[*] Additionally the Linux path counter is $ORANGE$LINUX_PATH_COUNTER_UNBLOB$NC."
|
||||
print_output "[*] Additionally the Linux path counter is ${ORANGE}${LINUX_PATH_COUNTER_UNBLOB}${NC}."
|
||||
prepare_binary_arr "${OUTPUT_DIR_UNBLOB1}"
|
||||
architecture_check
|
||||
detect_root_dir_helper "$OUTPUT_DIR_UNBLOB1"
|
||||
detect_root_dir_helper "${OUTPUT_DIR_UNBLOB1}"
|
||||
print_ln
|
||||
fi
|
||||
|
||||
@@ -71,24 +71,24 @@ D05_firmware_diffing_extractor() {
|
||||
OUTPUT_DIR_UNBLOB2="${LOG_PATH_MODULE}"/extractor_"$(basename "${FIRMWARE_PATH1}")"
|
||||
unblobber "${FIRMWARE_PATH1}" "${OUTPUT_DIR_UNBLOB2}" 0
|
||||
|
||||
if [[ -d "$OUTPUT_DIR_UNBLOB2" ]]; then
|
||||
if [[ -d "${OUTPUT_DIR_UNBLOB2}" ]]; then
|
||||
NEG_LOG=1
|
||||
linux_basic_identification_unblobber "${OUTPUT_DIR_UNBLOB2}"
|
||||
FILES_EXT_UB=$(find "$OUTPUT_DIR_UNBLOB2" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES_UB=$(find "$OUTPUT_DIR_UNBLOB2" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT_UB=$(find "$OUTPUT_DIR_UNBLOB2" -xdev -type d | wc -l )
|
||||
tree -Csh "$OUTPUT_DIR_UNBLOB2" > "${LOG_PATH_MODULE}"/firmware_image2.txt
|
||||
FILES_EXT_UB=$(find "${OUTPUT_DIR_UNBLOB2}" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES_UB=$(find "${OUTPUT_DIR_UNBLOB2}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT_UB=$(find "${OUTPUT_DIR_UNBLOB2}" -xdev -type d | wc -l )
|
||||
tree -Csh "${OUTPUT_DIR_UNBLOB2}" > "${LOG_PATH_MODULE}"/firmware_image2.txt
|
||||
|
||||
print_ln
|
||||
print_output "[*] ${ORANGE}Unblob$NC results:"
|
||||
print_output "[*] Found $ORANGE$FILES_EXT_UB$NC files ($ORANGE$UNIQUE_FILES_UB$NC unique files) and $ORANGE$DIRS_EXT_UB$NC directories at all."
|
||||
print_output "[*] ${ORANGE}Unblob${NC} results:"
|
||||
print_output "[*] Found ${ORANGE}${FILES_EXT_UB}${NC} files (${ORANGE}${UNIQUE_FILES_UB}${NC} unique files) and ${ORANGE}${DIRS_EXT_UB}${NC} directories at all."
|
||||
if [[ -f "${LOG_PATH_MODULE}"/firmware_image2.txt ]]; then
|
||||
write_link "${LOG_PATH_MODULE}"/firmware_image2.txt
|
||||
fi
|
||||
print_output "[*] Additionally the Linux path counter is $ORANGE$LINUX_PATH_COUNTER_UNBLOB$NC."
|
||||
print_output "[*] Additionally the Linux path counter is ${ORANGE}${LINUX_PATH_COUNTER_UNBLOB}${NC}."
|
||||
prepare_binary_arr "${OUTPUT_DIR_UNBLOB2}"
|
||||
architecture_check
|
||||
detect_root_dir_helper "$OUTPUT_DIR_UNBLOB2"
|
||||
detect_root_dir_helper "${OUTPUT_DIR_UNBLOB2}"
|
||||
|
||||
# detect_root_dir_helper includes a link to a module that is usually not executed in diff mode
|
||||
# let's remove this link now:
|
||||
@@ -98,6 +98,6 @@ D05_firmware_diffing_extractor() {
|
||||
print_ln
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ F10_license_summary() {
|
||||
local LICENSE=""
|
||||
local TYPE=""
|
||||
|
||||
mapfile -t LICENSE_DETECTION_STATIC < <(grep -v "version_rule" "$CSV_DIR"/s09_*.csv 2>/dev/null | cut -d\; -f1,4,5 | sort -u || true)
|
||||
mapfile -t LICENSE_DETECTION_DYN < <(grep -v "version_rule" "$CSV_DIR"/s116_*.csv 2>/dev/null | cut -d\; -f1,4,5 |sort -u || true)
|
||||
mapfile -t LICENSE_DETECTION_STATIC < <(grep -v "version_rule" "${CSV_DIR}"/s09_*.csv 2>/dev/null | cut -d\; -f1,4,5 | sort -u || true)
|
||||
mapfile -t LICENSE_DETECTION_DYN < <(grep -v "version_rule" "${CSV_DIR}"/s116_*.csv 2>/dev/null | cut -d\; -f1,4,5 |sort -u || true)
|
||||
# TODO: Currently the final kernel details from s25 are missing
|
||||
|
||||
write_csv_log "binary/file" "version_rule" "version_detected" "csv_rule" "license" "static/emulation"
|
||||
@@ -44,16 +44,16 @@ F10_license_summary() {
|
||||
if [[ "${#LICENSE_DETECTION_STATIC[@]}" -gt 0 ]]; then
|
||||
TYPE="static"
|
||||
for ENTRY in "${LICENSE_DETECTION_STATIC[@]}"; do
|
||||
if [[ -z "$ENTRY" ]]; then
|
||||
if [[ -z "${ENTRY}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
BINARY="$(safe_echo "$ENTRY" | cut -d\; -f1)"
|
||||
VERSION="$(safe_echo "$ENTRY" | cut -d\; -f2 | cut -d: -f2-)"
|
||||
LICENSE="$(safe_echo "$ENTRY" | cut -d\; -f3)"
|
||||
BINARY="$(safe_echo "${ENTRY}" | cut -d\; -f1)"
|
||||
VERSION="$(safe_echo "${ENTRY}" | cut -d\; -f2 | cut -d: -f2-)"
|
||||
LICENSE="$(safe_echo "${ENTRY}" | cut -d\; -f3)"
|
||||
|
||||
print_output "[+] Binary: $ORANGE$(basename "$BINARY" | cut -d\ -f1)$GREEN / Version: $ORANGE$VERSION$GREEN / License: $ORANGE$LICENSE$NC"
|
||||
write_csv_log "$BINARY" "$VERSION_RULE" "$VERSION" "$CSV_RULE" "$LICENSE" "$TYPE"
|
||||
print_output "[+] Binary: ${ORANGE}$(basename "${BINARY}" | cut -d\ -f1)${GREEN} / Version: ${ORANGE}${VERSION}${GREEN} / License: ${ORANGE}${LICENSE}${NC}"
|
||||
write_csv_log "${BINARY}" "${VERSION_RULE}" "${VERSION}" "${CSV_RULE}" "${LICENSE}" "${TYPE}"
|
||||
((COUNT_LIC+=1))
|
||||
done
|
||||
fi
|
||||
@@ -62,19 +62,19 @@ F10_license_summary() {
|
||||
if [[ "${#LICENSE_DETECTION_DYN[@]}" -gt 0 ]]; then
|
||||
TYPE="emulation"
|
||||
for ENTRY in "${LICENSE_DETECTION_DYN[@]}"; do
|
||||
if [[ -z "$ENTRY" ]]; then
|
||||
if [[ -z "${ENTRY}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
BINARY="$(safe_echo "$ENTRY" | cut -d\; -f1)"
|
||||
VERSION="$(safe_echo "$ENTRY" | cut -d\; -f2 | cut -d: -f2-)"
|
||||
LICENSE="$(safe_echo "$ENTRY" | cut -d\; -f3)"
|
||||
BINARY="$(safe_echo "${ENTRY}" | cut -d\; -f1)"
|
||||
VERSION="$(safe_echo "${ENTRY}" | cut -d\; -f2 | cut -d: -f2-)"
|
||||
LICENSE="$(safe_echo "${ENTRY}" | cut -d\; -f3)"
|
||||
|
||||
print_output "[+] Binary: $ORANGE$(basename "$BINARY")$GREEN / Version: $ORANGE$VERSION$GREEN / License: $ORANGE$LICENSE$NC"
|
||||
write_csv_log "$BINARY" "$VERSION_RULE" "$VERSION" "$CSV_RULE" "$LICENSE" "$TYPE"
|
||||
print_output "[+] Binary: ${ORANGE}$(basename "${BINARY}")${GREEN} / Version: ${ORANGE}${VERSION}${GREEN} / License: ${ORANGE}${LICENSE}${NC}"
|
||||
write_csv_log "${BINARY}" "${VERSION_RULE}" "${VERSION}" "${CSV_RULE}" "${LICENSE}" "${TYPE}"
|
||||
((COUNT_LIC+=1))
|
||||
done
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$COUNT_LIC"
|
||||
module_end_log "${FUNCNAME[0]}" "${COUNT_LIC}"
|
||||
}
|
||||
|
||||
+403
-403
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ F21_cyclonedx_sbom() {
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "CycloneDX SBOM converter"
|
||||
|
||||
local F20_LOG="$CSV_DIR""/f20_vul_aggregator.csv"
|
||||
local F20_LOG="${CSV_DIR}""/f20_vul_aggregator.csv"
|
||||
local BIN_VER_SBOM_ARR=()
|
||||
local BIN_VER_SBOM_ENTRY=""
|
||||
local BINARY=""
|
||||
@@ -27,39 +27,39 @@ F21_cyclonedx_sbom() {
|
||||
local NEG_LOG=0
|
||||
|
||||
if ! command -v cyclonedx > /dev/null; then
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$F20_LOG" ]] && [[ "$(wc -l "$F20_LOG" | awk '{print $1}')" -gt 1 ]]; then
|
||||
if [[ -f "$CSV_DIR"/f21_cyclonedx_sbom.csv ]]; then
|
||||
rm "$CSV_DIR"/f21_cyclonedx_sbom.csv
|
||||
if [[ -f "${F20_LOG}" ]] && [[ "$(wc -l "${F20_LOG}" | awk '{print $1}')" -gt 1 ]]; then
|
||||
if [[ -f "${CSV_DIR}"/f21_cyclonedx_sbom.csv ]]; then
|
||||
rm "${CSV_DIR}"/f21_cyclonedx_sbom.csv
|
||||
fi
|
||||
if [[ -f "$CSV_DIR"/f21_cyclonedx_sbom.json ]]; then
|
||||
rm "$CSV_DIR"/f21_cyclonedx_sbom.json
|
||||
if [[ -f "${CSV_DIR}"/f21_cyclonedx_sbom.json ]]; then
|
||||
rm "${CSV_DIR}"/f21_cyclonedx_sbom.json
|
||||
fi
|
||||
|
||||
write_csv_log "Type" "MimeType" "Supplier" "Author" "Publisher" "Group" "Name" "Version" "Scope" "LicenseExpressions" "LicenseNames" "Copyright" "Cpe" "Purl" "Modified" "SwidTagId" "SwidName" "SwidVersion" "SwidTagVersion" "SwidPatch" "SwidTextContentType" "SwidTextEncoding" "SwidTextContent" "SwidUrl" "MD5" "SHA-1" "SHA-256" "SHA-512" "BLAKE2b-256" "BLAKE2b-384" "BLAKE2b-512" "SHA-384" "SHA3-256" "SHA3-384" "SHA3-512" "BLAKE3" "Description"
|
||||
print_output "[*] Collect SBOM details of module $(basename "$F20_LOG")."
|
||||
mapfile -t BIN_VER_SBOM_ARR < <(cut -d\; -f1,2 "$F20_LOG" | tail -n +2 | sort -u)
|
||||
print_output "[*] Collect SBOM details of module $(basename "${F20_LOG}")."
|
||||
mapfile -t BIN_VER_SBOM_ARR < <(cut -d\; -f1,2 "${F20_LOG}" | tail -n +2 | sort -u)
|
||||
for BIN_VER_SBOM_ENTRY in "${BIN_VER_SBOM_ARR[@]}"; do
|
||||
BINARY=$(echo "$BIN_VER_SBOM_ENTRY" | cut -d\; -f1)
|
||||
VERSION=$(echo "$BIN_VER_SBOM_ENTRY" | cut -d\; -f2)
|
||||
write_csv_log "" "" "" "" "" "" "$BINARY" "$VERSION" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
|
||||
BINARY=$(echo "${BIN_VER_SBOM_ENTRY}" | cut -d\; -f1)
|
||||
VERSION=$(echo "${BIN_VER_SBOM_ENTRY}" | cut -d\; -f2)
|
||||
write_csv_log "" "" "" "" "" "" "${BINARY}" "${VERSION}" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
|
||||
done
|
||||
if [[ -f "$CSV_DIR"/f21_cyclonedx_sbom.csv ]]; then
|
||||
if [[ -f "${CSV_DIR}"/f21_cyclonedx_sbom.csv ]]; then
|
||||
# our csv is with ";" as deliminiter. cyclonedx needs "," -> lets do a quick tranlation
|
||||
sed -i 's/\;/,/g' "$CSV_DIR"/f21_cyclonedx_sbom.csv
|
||||
cyclonedx convert --input-file "$CSV_DIR"/f21_cyclonedx_sbom.csv --output-file "$LOG_DIR"/f21_cyclonedx_sbom.json || true
|
||||
sed -i 's/\;/,/g' "${CSV_DIR}"/f21_cyclonedx_sbom.csv
|
||||
cyclonedx convert --input-file "${CSV_DIR}"/f21_cyclonedx_sbom.csv --output-file "${LOG_DIR}"/f21_cyclonedx_sbom.json || true
|
||||
fi
|
||||
if [[ -f "$LOG_DIR"/f21_cyclonedx_sbom.json ]]; then
|
||||
print_output "[+] SBOM in json format created:" "" "$LOG_DIR/f21_cyclonedx_sbom.json"
|
||||
if [[ -f "${LOG_DIR}"/f21_cyclonedx_sbom.json ]]; then
|
||||
print_output "[+] SBOM in json format created:" "" "${LOG_DIR}/f21_cyclonedx_sbom.json"
|
||||
print_ln
|
||||
tee -a "$LOG_FILE" < "$LOG_DIR"/f21_cyclonedx_sbom.json
|
||||
tee -a "${LOG_FILE}" < "${LOG_DIR}"/f21_cyclonedx_sbom.json
|
||||
print_ln
|
||||
local NEG_LOG=1
|
||||
fi
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
+441
-441
File diff suppressed because it is too large
Load Diff
@@ -12,11 +12,11 @@ BUSYBOX="/busybox"
|
||||
|
||||
# print input if not symlink, otherwise attempt to resolve symlink
|
||||
resolve_link() {
|
||||
TARGET=$("$BUSYBOX" readlink "$1")
|
||||
if [ -z "$TARGET" ]; then
|
||||
echo "$1"
|
||||
TARGET=$("${BUSYBOX}" readlink "${1}")
|
||||
if [ -z "${TARGET}" ]; then
|
||||
echo "${1}"
|
||||
fi
|
||||
echo "$TARGET"
|
||||
echo "${TARGET}"
|
||||
}
|
||||
|
||||
if ("${FIRMAE_BOOT}"); then
|
||||
@@ -77,8 +77,8 @@ fi
|
||||
# make /dev and add default device nodes if current /dev does not have greater
|
||||
# than 5 device nodes
|
||||
mkdir -p "$(resolve_link /dev)"
|
||||
FILECOUNT="$("$BUSYBOX" find /dev -maxdepth 1 -type b -o -type c -print | "$BUSYBOX" wc -l)"
|
||||
if [ "$FILECOUNT" -lt "5" ]; then
|
||||
FILECOUNT="$("${BUSYBOX}" find /dev -maxdepth 1 -type b -o -type c -print | "${BUSYBOX}" wc -l)"
|
||||
if [ "${FILECOUNT}" -lt "5" ]; then
|
||||
echo "Warning: Recreating device nodes!"
|
||||
|
||||
if ("${FIRMAE_ETC}"); then
|
||||
@@ -185,9 +185,9 @@ if [ "$FILECOUNT" -lt "5" ]; then
|
||||
fi
|
||||
|
||||
# create a gpio file required for linksys to make the watchdog happy
|
||||
if ("$BUSYBOX" grep -sq "/dev/gpio/in" /bin/gpio) ||
|
||||
("$BUSYBOX" grep -sq "/dev/gpio/in" /usr/lib/libcm.so) ||
|
||||
("$BUSYBOX" grep -sq "/dev/gpio/in" /usr/lib/libshared.so); then
|
||||
if ("${BUSYBOX}" grep -sq "/dev/gpio/in" /bin/gpio) ||
|
||||
("${BUSYBOX}" grep -sq "/dev/gpio/in" /usr/lib/libcm.so) ||
|
||||
("${BUSYBOX}" grep -sq "/dev/gpio/in" /usr/lib/libshared.so); then
|
||||
echo "Creating /dev/gpio/in!"
|
||||
if ("${FIRMAE_BOOT}"); then
|
||||
rm /dev/gpio
|
||||
@@ -205,32 +205,32 @@ echo "Removing /etc/scripts/sys_resetbutton!"
|
||||
rm -f /etc/scripts/sys_resetbutton
|
||||
|
||||
# add some default nvram entries
|
||||
if "$BUSYBOX" grep -sq "ipv6_6to4_lan_ip" /sbin/rc; then
|
||||
if "${BUSYBOX}" grep -sq "ipv6_6to4_lan_ip" /sbin/rc; then
|
||||
echo "Creating default ipv6_6to4_lan_ip!"
|
||||
echo -n "2002:7f00:0001::" > /firmadyne/libnvram.override/ipv6_6to4_lan_ip
|
||||
fi
|
||||
|
||||
if "$BUSYBOX" grep -sq "time_zone_x" /lib/libacos_shared.so; then
|
||||
if "${BUSYBOX}" grep -sq "time_zone_x" /lib/libacos_shared.so; then
|
||||
echo "Creating default time_zone_x!"
|
||||
echo -n "0" > /firmadyne/libnvram.override/time_zone_x
|
||||
fi
|
||||
|
||||
if "$BUSYBOX" grep -sq "rip_multicast" /usr/sbin/httpd; then
|
||||
if "${BUSYBOX}" grep -sq "rip_multicast" /usr/sbin/httpd; then
|
||||
echo "Creating default rip_multicast!"
|
||||
echo -n "0" > /firmadyne/libnvram.override/rip_multicast
|
||||
fi
|
||||
|
||||
if "$BUSYBOX" grep -sq "bs_trustedip_enable" /usr/sbin/httpd; then
|
||||
if "${BUSYBOX}" grep -sq "bs_trustedip_enable" /usr/sbin/httpd; then
|
||||
echo "Creating default bs_trustedip_enable!"
|
||||
echo -n "0" > /firmadyne/libnvram.override/bs_trustedip_enable
|
||||
fi
|
||||
|
||||
if "$BUSYBOX" grep -sq "filter_rule_tbl" /usr/sbin/httpd; then
|
||||
if "${BUSYBOX}" grep -sq "filter_rule_tbl" /usr/sbin/httpd; then
|
||||
echo "Creating default filter_rule_tbl!"
|
||||
echo -n "" > /firmadyne/libnvram.override/filter_rule_tbl
|
||||
fi
|
||||
|
||||
if "$BUSYBOX" grep -sq "rip_enable" /sbin/acos_service; then
|
||||
if "${BUSYBOX}" grep -sq "rip_enable" /sbin/acos_service; then
|
||||
echo "Creating default rip_enable!"
|
||||
echo -n "0" > /firmadyne/libnvram.override/rip_enable
|
||||
fi
|
||||
|
||||
@@ -16,7 +16,7 @@ if ("${FIRMAE_BOOT}"); then
|
||||
do
|
||||
# shellcheck disable=SC2016
|
||||
FULL_PATH=$("${BUSYBOX}" echo "${FILE}" | "${BUSYBOX}" awk '{split($0,a,"="); print a[2]}')
|
||||
"${BUSYBOX}" echo "[*] Found kernelInit $FULL_PATH"
|
||||
"${BUSYBOX}" echo "[*] Found kernelInit ${FULL_PATH}"
|
||||
arr+=("${FULL_PATH}")
|
||||
done
|
||||
fi
|
||||
@@ -28,19 +28,19 @@ if ("${FIRMAE_BOOT}"); then
|
||||
fi
|
||||
for FILE in $("${BUSYBOX}" find / -name "preinitMT" -o -name "preinit" -o -name "rcS*" -o -name "rc.sysinit" -o -name "rc.local" -o -name "rc.common" -o -name "init" -o -name "linuxrc")
|
||||
do
|
||||
"${BUSYBOX}" echo "[*] Found boot file $FILE"
|
||||
"${BUSYBOX}" echo "[*] Found boot file ${FILE}"
|
||||
arr+=("${FILE}")
|
||||
done
|
||||
|
||||
# find and parse inittab file
|
||||
for FILE in $("${BUSYBOX}" find / -name "inittab" -type f)
|
||||
do
|
||||
"${BUSYBOX}" echo "[*] Found boot file $FILE"
|
||||
"${BUSYBOX}" echo "[*] Found boot file ${FILE}"
|
||||
# sysinit entry is the one to look for
|
||||
# shellcheck disable=SC2016
|
||||
for STARTUP_FILE in $("${BUSYBOX}" grep "^:.*sysinit:" "$FILE" | "${BUSYBOX}" rev | "${BUSYBOX}" cut -d: -f1 | "${BUSYBOX}" rev | "${BUSYBOX}" awk '{print $1}' | "${BUSYBOX}" sort -u)
|
||||
for STARTUP_FILE in $("${BUSYBOX}" grep "^:.*sysinit:" "${FILE}" | "${BUSYBOX}" rev | "${BUSYBOX}" cut -d: -f1 | "${BUSYBOX}" rev | "${BUSYBOX}" awk '{print $1}' | "${BUSYBOX}" sort -u)
|
||||
do
|
||||
"${BUSYBOX}" echo "[*] Found possible startup file $STARTUP_FILE"
|
||||
"${BUSYBOX}" echo "[*] Found possible startup file ${STARTUP_FILE}"
|
||||
arr+=("${STARTUP_FILE}")
|
||||
#if [ -e "${STARTUP_FILE}" ]; then
|
||||
# arr+=("${STARTUP_FILE}")
|
||||
@@ -59,7 +59,7 @@ if ("${FIRMAE_BOOT}"); then
|
||||
if [ -d "${FILE}" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$FILE" = "/firmadyne/init" ]; then
|
||||
if [ "${FILE}" = "/firmadyne/init" ]; then
|
||||
# skip our own init
|
||||
continue
|
||||
fi
|
||||
@@ -72,14 +72,14 @@ if ("${FIRMAE_BOOT}"); then
|
||||
FILE_NAME=$("${BUSYBOX}" basename "${FILE}")
|
||||
if ("${BUSYBOX}" find /bin /sbin /usr/sbin /usr/sbin -type f -exec "${BUSYBOX}" grep -qr "${FILE_NAME}" {} \;); then
|
||||
TARGET_FILE=$("${BUSYBOX}" find /bin /sbin /usr/sbin /usr/sbin -type f -exec "${BUSYBOX}" egrep -rl "${FILE_NAME}" {} \; | "${BUSYBOX}" head -1)
|
||||
"${BUSYBOX}" echo "[*] Re-creating symlink $TARGET_FILE -> $FILE"
|
||||
"${BUSYBOX}" echo "[*] Re-creating symlink ${TARGET_FILE} -> ${FILE}"
|
||||
"${BUSYBOX}" ln -s "${TARGET_FILE}" "${FILE}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
if [ -e "${FILE}" ]; then
|
||||
"${BUSYBOX}" echo "[*] Writing firmadyne init $FILE"
|
||||
"${BUSYBOX}" echo "[*] Writing firmadyne init ${FILE}"
|
||||
"${BUSYBOX}" echo "${FILE}" >> /firmadyne/init_tmp
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -85,42 +85,42 @@ for BINARY in $("${BUSYBOX}" find / -name "lighttpd" -type f -o -name "upnp" -ty
|
||||
# check if we have a configuration available and iterate
|
||||
for LIGHT_CONFIG in $("${BUSYBOX}" find / -name "*lighttpd*.conf" -type f); do
|
||||
# write the service starter with config file
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for $ORANGE${BINARY} - ${LIGHT_CONFIG}$NC"
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY} - ${LIGHT_CONFIG}${NC}"
|
||||
"${BUSYBOX}" echo -e -n "${BINARY} -f ${LIGHT_CONFIG}\n" >> /firmadyne/service
|
||||
done
|
||||
# fi
|
||||
elif [ "$("${BUSYBOX}" echo "${SERVICE_NAME}")" == "miniupnpd" ]; then
|
||||
if ! "${BUSYBOX}" grep -q "${SERVICE_NAME}" /firmadyne/service 2>/dev/null; then
|
||||
for MINIUPNPD_CONFIG in $("${BUSYBOX}" find / -name "*miniupnpd*.conf" -type f); do
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for $ORANGE${BINARY} - ${MINIUPNPD_CONFIG}$NC"
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY} - ${MINIUPNPD_CONFIG}${NC}"
|
||||
"${BUSYBOX}" echo -e -n "${BINARY} -f ${MINIUPNPD_CONFIG}\n" >> /firmadyne/service
|
||||
done
|
||||
fi
|
||||
elif [ "$("${BUSYBOX}" echo "${SERVICE_NAME}")" == "wscd" ]; then
|
||||
if ! "${BUSYBOX}" grep -q "${SERVICE_NAME}" /firmadyne/service 2>/dev/null; then
|
||||
for WSCD_CONFIG in $("${BUSYBOX}" find / -name "*wscd*.conf" -type f); do
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for $ORANGE${BINARY} - ${WSCD_CONFIG}$NC"
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY} - ${WSCD_CONFIG}${NC}"
|
||||
"${BUSYBOX}" echo -e -n "${BINARY} -c ${WSCD_CONFIG}\n" >> /firmadyne/service
|
||||
done
|
||||
fi
|
||||
elif [ "$("${BUSYBOX}" echo "${SERVICE_NAME}")" == "upnpd" ]; then
|
||||
if ! "${BUSYBOX}" grep -q "${SERVICE_NAME}" /firmadyne/service 2>/dev/null; then
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for $ORANGE${BINARY}$NC"
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY}${NC}"
|
||||
"${BUSYBOX}" echo -e -n "${BINARY}\n" >> /firmadyne/service
|
||||
|
||||
# let's try upnpd with a basic configuration:
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for $ORANGE${BINARY} ppp0 eth0$NC"
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY} ppp0 eth0${NC}"
|
||||
"${BUSYBOX}" echo -e -n "${BINARY} ppp0 eth0\n" >> /firmadyne/service
|
||||
fi
|
||||
elif [ "$("${BUSYBOX}" echo "${SERVICE_NAME}")" == "ftpd" ]; then
|
||||
if ! "${BUSYBOX}" grep -q "${SERVICE_NAME}" /firmadyne/service 2>/dev/null; then
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for $ORANGE${BINARY}$NC"
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY}${NC}"
|
||||
"${BUSYBOX}" echo -e -n "${BINARY} -D\n" >> /firmadyne/service
|
||||
fi
|
||||
fi
|
||||
# this is the default case - without config but only if the service is not already in the service file
|
||||
if ! "${BUSYBOX}" grep -q "${SERVICE_NAME}" /firmadyne/service 2>/dev/null; then
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for $ORANGE${BINARY}$NC"
|
||||
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY}${NC}"
|
||||
"${BUSYBOX}" echo -e -n "${BINARY}\n" >> /firmadyne/service
|
||||
fi
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
BUSYBOX=/firmadyne/busybox
|
||||
ACTION=$("${BUSYBOX}" cat /firmadyne/network_type)
|
||||
|
||||
"${BUSYBOX}" echo "[*] Network configuration - ACTION: $ACTION"
|
||||
"${BUSYBOX}" echo "[*] Network configuration - ACTION: ${ACTION}"
|
||||
|
||||
if ("${FIRMAE_NET}"); then
|
||||
"${BUSYBOX}" echo "[*] Starting network configuration"
|
||||
@@ -16,9 +16,9 @@ if ("${FIRMAE_NET}"); then
|
||||
|
||||
if [ "${ACTION}" = "default" ]; then
|
||||
IP_DEFAULT=$("${BUSYBOX}" cat /firmadyne/ip_default)
|
||||
"${BUSYBOX}" echo "[*] starting network configuration br0 - $IP_DEFAULT"
|
||||
"${BUSYBOX}" echo "[*] starting network configuration br0 - ${IP_DEFAULT}"
|
||||
"${BUSYBOX}" brctl addbr br0
|
||||
"${BUSYBOX}" ifconfig br0 "$IP_DEFAULT"
|
||||
"${BUSYBOX}" ifconfig br0 "${IP_DEFAULT}"
|
||||
"${BUSYBOX}" echo "[*] starting network configuration eth0 - 0.0.0.0"
|
||||
"${BUSYBOX}" brctl addif br0 eth0
|
||||
"${BUSYBOX}" ifconfig eth0 0.0.0.0 up
|
||||
@@ -30,7 +30,7 @@ if ("${FIRMAE_NET}"); then
|
||||
CNT=0
|
||||
while (true); do
|
||||
CNT=$((CNT+1))
|
||||
echo "[*] Waiting CNT: $CNT / 40"
|
||||
echo "[*] Waiting CNT: ${CNT} / 40"
|
||||
"${BUSYBOX}" sleep 5
|
||||
if ("${BUSYBOX}" brctl show | "${BUSYBOX}" grep -sq "${NET_BRIDGE}"); then
|
||||
break
|
||||
@@ -47,10 +47,10 @@ if ("${FIRMAE_NET}"); then
|
||||
# shellcheck disable=SC2016
|
||||
if ("${BUSYBOX}" ip addr show "${NET_BRIDGE}" | "${BUSYBOX}" grep -m1 "inet\b" | "${BUSYBOX}" awk '{print $2}' | "${BUSYBOX}" cut -d/ -f1); then
|
||||
IP=$("${BUSYBOX}" ip addr show "${NET_BRIDGE}" | "${BUSYBOX}" grep -m1 "inet\b" | "${BUSYBOX}" awk '{print $2}' | "${BUSYBOX}" cut -d/ -f1)
|
||||
"${BUSYBOX}" echo "[*] Identified IP address: $IP"
|
||||
"${BUSYBOX}" echo "[*] Identified IP address: ${IP}"
|
||||
else
|
||||
IP=$("${BUSYBOX}" cat /firmadyne/ip_default)
|
||||
"${BUSYBOX}" echo "[*] Setting default IP address: $IP"
|
||||
"${BUSYBOX}" echo "[*] Setting default IP address: ${IP}"
|
||||
fi
|
||||
# tplink TL-WA860RE_EU_UK_US__V5_171116
|
||||
"${BUSYBOX}" ifconfig "${NET_BRIDGE}" "${IP}"
|
||||
@@ -72,10 +72,10 @@ if ("${FIRMAE_NET}"); then
|
||||
# shellcheck disable=SC2016
|
||||
if ("${BUSYBOX}" ip addr show "${NET_BRIDGE}" | "${BUSYBOX}" grep -m1 "inet\b" | "${BUSYBOX}" awk '{print $2}' | "${BUSYBOX}" cut -d/ -f1); then
|
||||
IP=$("${BUSYBOX}" ip addr show "${NET_BRIDGE}" | "${BUSYBOX}" grep -m1 "inet\b" | "${BUSYBOX}" awk '{print $2}' | "${BUSYBOX}" cut -d/ -f1)
|
||||
"${BUSYBOX}" echo "[*] Identified IP address: $IP"
|
||||
"${BUSYBOX}" echo "[*] Identified IP address: ${IP}"
|
||||
else
|
||||
IP=$("${BUSYBOX}" cat /firmadyne/ip_default)
|
||||
"${BUSYBOX}" echo "[*] Setting default IP address: $IP"
|
||||
"${BUSYBOX}" echo "[*] Setting default IP address: ${IP}"
|
||||
fi
|
||||
|
||||
"${BUSYBOX}" ifconfig "${NET_BRIDGE}" "${IP}"
|
||||
|
||||
@@ -26,7 +26,7 @@ if ("${FIRMAE_ETC}"); then
|
||||
BINARY_NAME=$("${BUSYBOX}" echo "${_BINARY}" | "${BUSYBOX}" cut -d\ -f1)
|
||||
BINARY_NAME=$("${BUSYBOX}" basename "${BINARY_NAME}")
|
||||
if ( ! ("${BUSYBOX}" ps | "${BUSYBOX}" grep -v grep | "${BUSYBOX}" grep -sqi "${BINARY_NAME}") ); then
|
||||
"${BUSYBOX}" echo "[*] Starting $BINARY_NAME service ..."
|
||||
"${BUSYBOX}" echo "[*] Starting ${BINARY_NAME} service ..."
|
||||
#BINARY variable could be something like: binary parameter parameter ...
|
||||
${_BINARY} &
|
||||
"${BUSYBOX}" sleep 5
|
||||
|
||||
@@ -22,21 +22,21 @@ L15_emulated_checks_nmap() {
|
||||
export NMAP_SERVICES=()
|
||||
export NMAP_PORTS_SERVICES=()
|
||||
|
||||
if [[ "$SYS_ONLINE" -eq 1 ]] && [[ "$TCP" == "ok" ]]; then
|
||||
if [[ "${SYS_ONLINE}" -eq 1 ]] && [[ "${TCP}" == "ok" ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Nmap scans of emulated device."
|
||||
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
if [[ -v IP_ADDRESS_ ]]; then
|
||||
check_live_nmap_basic "$IP_ADDRESS_"
|
||||
check_live_nmap_basic "${IP_ADDRESS_}"
|
||||
MODULE_END=1
|
||||
else
|
||||
print_output "[!] No IP address found"
|
||||
fi
|
||||
write_log ""
|
||||
write_log "[*] Statistics:${#NMAP_SERVICES[@]}"
|
||||
module_end_log "${FUNCNAME[0]}" "$MODULE_END"
|
||||
module_end_log "${FUNCNAME[0]}" "${MODULE_END}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -52,58 +52,58 @@ check_live_nmap_basic() {
|
||||
local TYPE=""
|
||||
export NMAP_PORTS_SERVICES=()
|
||||
|
||||
sub_module_title "Nmap portscans for emulated system with IP $ORANGE$IP_ADDRESS_$NC"
|
||||
sub_module_title "Nmap portscans for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC}"
|
||||
|
||||
cp "$ARCHIVE_PATH"/nmap_emba_"$IP_ADDRESS_"*.gnmap "$LOG_PATH_MODULE" 2>/dev/null || true
|
||||
cp "$ARCHIVE_PATH"/nmap_emba_"$IP_ADDRESS_"*.nmap "$LOG_PATH_MODULE" 2>/dev/null || true
|
||||
cp "${ARCHIVE_PATH}"/nmap_emba_"${IP_ADDRESS_}"*.gnmap "${LOG_PATH_MODULE}" 2>/dev/null || true
|
||||
cp "${ARCHIVE_PATH}"/nmap_emba_"${IP_ADDRESS_}"*.nmap "${LOG_PATH_MODULE}" 2>/dev/null || true
|
||||
|
||||
# find all Nmap results
|
||||
mapfile -t NMAP_RESULT_FILES < <(find "$LOG_PATH_MODULE" -name "*.nmap")
|
||||
mapfile -t NMAP_RESULT_FILES < <(find "${LOG_PATH_MODULE}" -name "*.nmap")
|
||||
write_csv_log "---" "service identifier" "version_detected" "csv_rule" "license" "static/emulation/nmap/nikto"
|
||||
|
||||
if [[ -v NMAP_RESULT_FILES[@] ]]; then
|
||||
for NMAP_RESULTF in "${NMAP_RESULT_FILES[@]}"; do
|
||||
print_output "[*] Found Nmap results $ORANGE$(basename "$NMAP_RESULTF")$NC:"
|
||||
tee -a "$LOG_FILE" < "$NMAP_RESULTF"
|
||||
print_output "[*] Found Nmap results ${ORANGE}$(basename "${NMAP_RESULTF}")${NC}:"
|
||||
tee -a "${LOG_FILE}" < "${NMAP_RESULTF}"
|
||||
print_ln
|
||||
done
|
||||
else
|
||||
# if no Nmap results are found we initiate a scan
|
||||
if ! system_online_check "${IP_ADDRESS_}" ; then
|
||||
if ! restart_emulation "$IP_ADDRESS_" "$IMAGE_NAME" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
if ! restart_emulation "${IP_ADDRESS_}" "${IMAGE_NAME}" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
print_output "[-] System not responding - Not performing Nmap checks"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
nmap -Pn -n -sSV -A --host-timeout 30m "$IP_ADDRESS_" -oA "$LOG_PATH_MODULE"/nmap-basic-"$IP_ADDRESS_" | tee -a "$LOG_FILE"
|
||||
nmap -Pn -n -sSV -A --host-timeout 30m "${IP_ADDRESS_}" -oA "${LOG_PATH_MODULE}"/nmap-basic-"${IP_ADDRESS_}" | tee -a "${LOG_FILE}"
|
||||
fi
|
||||
print_ln
|
||||
|
||||
# extract only the service details from gnmap output file:
|
||||
mapfile -t NMAP_SERVICES < <(grep -a "open" "$LOG_PATH_MODULE"/*.gnmap | cut -d: -f2- | sed s/'\t'/'\n\t'/g | sed s/'\/, '/'\n\t\t'/g | sed s/'Ports: '/'Ports:\n\t\t'/g | grep -v "/closed/\|filtered/" | grep -v "Host: \|Ports:\|Ignored State:\|OS: \|Seq Index: \|Status: \|IP ID Seq: \|^# " | sed 's/^[[:blank:]].*\/\///' | sed 's/\/$//g'| sort -u || true)
|
||||
mapfile -t NMAP_PORTS_SERVICES < <(grep -a "open" "$LOG_PATH_MODULE"/*.nmap | cut -d: -f2- | awk '{print $1,$3}' | grep "[0-9]" | sort -u || true)
|
||||
mapfile -t NMAP_SERVICES < <(grep -a "open" "${LOG_PATH_MODULE}"/*.gnmap | cut -d: -f2- | sed s/'\t'/'\n\t'/g | sed s/'\/, '/'\n\t\t'/g | sed s/'Ports: '/'Ports:\n\t\t'/g | grep -v "/closed/\|filtered/" | grep -v "Host: \|Ports:\|Ignored State:\|OS: \|Seq Index: \|Status: \|IP ID Seq: \|^# " | sed 's/^[[:blank:]].*\/\///' | sed 's/\/$//g'| sort -u || true)
|
||||
mapfile -t NMAP_PORTS_SERVICES < <(grep -a "open" "${LOG_PATH_MODULE}"/*.nmap | cut -d: -f2- | awk '{print $1,$3}' | grep "[0-9]" | sort -u || true)
|
||||
# extract cpe information like the following:
|
||||
# Service Info: OS: Linux; Device: WAP; CPE: cpe:/h:dlink:dir-300:2.14, cpe:/o:linux:linux_kernel, cpe:/h:d-link:dir-300
|
||||
mapfile -t NMAP_CPE_DETECTION < <(grep -ah "Service Info: " "$LOG_PATH_MODULE"/*.nmap | grep -a "CPE: .*" | sort -u || true)
|
||||
mapfile -t NMAP_CPE_DETECTION < <(grep -ah "Service Info: " "${LOG_PATH_MODULE}"/*.nmap | grep -a "CPE: .*" | sort -u || true)
|
||||
|
||||
TYPE="Nmap scan (Scan info)"
|
||||
|
||||
if [[ "${#NMAP_CPE_DETECTION[@]}" -gt 0 ]]; then
|
||||
for NMAP_CPES in "${NMAP_CPE_DETECTION[@]}"; do
|
||||
NMAP_CPES=$(echo "$NMAP_CPES" | grep -o "cpe:.*" || true)
|
||||
NMAP_CPES=$(echo "${NMAP_CPES}" | grep -o "cpe:.*" || true)
|
||||
# rewrite the string into an array:
|
||||
readarray -d ', ' -t NMAP_CPES_ARR < <(printf "%s" "$NMAP_CPES")
|
||||
readarray -d ', ' -t NMAP_CPES_ARR < <(printf "%s" "${NMAP_CPES}")
|
||||
for NMAP_CPE in "${NMAP_CPES_ARR[@]}"; do
|
||||
if [[ "$NMAP_CPE" == *"windows"* ]]; then
|
||||
if [[ "${NMAP_CPE}" == *"windows"* ]]; then
|
||||
# we emulate only Linux -> if windows is detected this is a FP
|
||||
continue
|
||||
fi
|
||||
NMAP_CPE=${NMAP_CPE/ /}
|
||||
NMAP_CPE=${NMAP_CPE//cpe:\/}
|
||||
# just to ensure there is some kind of version information in our entry
|
||||
if [[ "$NMAP_CPE" =~ .*[0-9].* ]]; then
|
||||
print_output "[*] CPE details detected: $ORANGE$NMAP_CPE$NC"
|
||||
write_csv_log "---" "NA" "NA" "$NMAP_CPE" "NA" "$TYPE"
|
||||
if [[ "${NMAP_CPE}" =~ .*[0-9].* ]]; then
|
||||
print_output "[*] CPE details detected: ${ORANGE}${NMAP_CPE}${NC}"
|
||||
write_csv_log "---" "NA" "NA" "${NMAP_CPE}" "NA" "${TYPE}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
@@ -113,31 +113,31 @@ check_live_nmap_basic() {
|
||||
|
||||
if [[ "${#NMAP_PORTS_SERVICES[@]}" -gt 0 ]]; then
|
||||
for SERVICE in "${NMAP_PORTS_SERVICES[@]}"; do
|
||||
print_output "[*] Service detected: $ORANGE$SERVICE$NC"
|
||||
SERVICE_NAME="$(escape_echo "$(echo "$SERVICE" | awk '{print $2}')")"
|
||||
print_output "[*] Service detected: ${ORANGE}${SERVICE}${NC}"
|
||||
SERVICE_NAME="$(escape_echo "$(echo "${SERVICE}" | awk '{print $2}')")"
|
||||
# just in case we have a / in our SERVICE_NAME
|
||||
SERVICE_NAME="${SERVICE_NAME/\//\\\/}"
|
||||
if [[ "$SERVICE_NAME" == "unknown" ]] || [[ "$SERVICE_NAME" == "tcpwrapped" ]] || [[ -z "$SERVICE_NAME" ]]; then
|
||||
if [[ "${SERVICE_NAME}" == "unknown" ]] || [[ "${SERVICE_NAME}" == "tcpwrapped" ]] || [[ -z "${SERVICE_NAME}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -f "$CSV_DIR"/s09_firmware_base_version_check.csv ]]; then
|
||||
if [[ -f "${CSV_DIR}"/s09_firmware_base_version_check.csv ]]; then
|
||||
# Let's check if we have already found details about this service in our other modules (S09, S115/S116)
|
||||
mapfile -t S09_L15_CHECK < <(awk -v IGNORECASE=1 -F\; '$2 $3 ~ /'"$SERVICE_NAME"'/' "$CSV_DIR"/s09_firmware_base_version_check.csv || true)
|
||||
mapfile -t S09_L15_CHECK < <(awk -v IGNORECASE=1 -F\; '$2 $3 ~ /'"${SERVICE_NAME}"'/' "${CSV_DIR}"/s09_firmware_base_version_check.csv || true)
|
||||
if [[ "${#S09_L15_CHECK[@]}" -gt 0 ]]; then
|
||||
for S09_L15_MATCH in "${S09_L15_CHECK[@]}"; do
|
||||
echo "$S09_L15_MATCH" >> "$CSV_DIR"/l15_emulated_checks_nmap.csv
|
||||
echo "${S09_L15_MATCH}" >> "${CSV_DIR}"/l15_emulated_checks_nmap.csv
|
||||
S09_L15_MATCH=$(echo "${S09_L15_MATCH}" | cut -d ';' -f3)
|
||||
print_output "[+] Service also detected with static analysis (S09): ${ORANGE}${S09_L15_MATCH}${NC}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f "$CSV_DIR"/s116_qemu_version_detection.csv ]]; then
|
||||
mapfile -t S116_L15_CHECK < <(awk -v IGNORECASE=1 -F\; '$2 $3 ~ /'"$SERVICE_NAME"'/' "$CSV_DIR"/s116_qemu_version_detection.csv || true)
|
||||
if [[ -f "${CSV_DIR}"/s116_qemu_version_detection.csv ]]; then
|
||||
mapfile -t S116_L15_CHECK < <(awk -v IGNORECASE=1 -F\; '$2 $3 ~ /'"${SERVICE_NAME}"'/' "${CSV_DIR}"/s116_qemu_version_detection.csv || true)
|
||||
if [[ "${#S116_L15_CHECK[@]}" -gt 0 ]]; then
|
||||
for S116_L15_MATCH in "${S116_L15_CHECK[@]}"; do
|
||||
echo "$S116_L15_MATCH" >> "$CSV_DIR"/l15_emulated_checks_nmap.csv
|
||||
echo "${S116_L15_MATCH}" >> "${CSV_DIR}"/l15_emulated_checks_nmap.csv
|
||||
S116_L15_MATCH=$(echo "${S116_L15_MATCH}" | cut -d ';' -f3)
|
||||
print_output "[+] Service also detected with dynamic user-mode emulation (S115/S116): ${ORANGE}${S116_L15_MATCH}${NC}"
|
||||
done
|
||||
@@ -149,15 +149,15 @@ check_live_nmap_basic() {
|
||||
if [[ "${#NMAP_SERVICES[@]}" -gt 0 ]]; then
|
||||
print_ln
|
||||
for SERVICE in "${NMAP_SERVICES[@]}"; do
|
||||
if ! echo "$SERVICE" | grep -q "[0-9]"; then
|
||||
if ! echo "${SERVICE}" | grep -q "[0-9]"; then
|
||||
continue
|
||||
fi
|
||||
l15_version_detector "$SERVICE" "$TYPE"
|
||||
l15_version_detector "${SERVICE}" "${TYPE}"
|
||||
done
|
||||
fi
|
||||
|
||||
print_ln
|
||||
print_output "[*] Nmap portscans for emulated system with IP $ORANGE$IP_ADDRESS_$NC finished"
|
||||
print_output "[*] Nmap portscans for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC} finished"
|
||||
}
|
||||
|
||||
l15_version_detector() {
|
||||
@@ -172,47 +172,47 @@ l15_version_detector() {
|
||||
local VERSION_IDENTIFIER=""
|
||||
local VERSION_FINDER=""
|
||||
|
||||
print_output "[*] Testing detected service ${ORANGE}$SERVICE_$NC" "no_log"
|
||||
print_output "[*] Testing detected service ${ORANGE}${SERVICE_}${NC}" "no_log"
|
||||
|
||||
if ! [[ -f "$CONFIG_DIR"/bin_version_strings.cfg ]]; then
|
||||
if ! [[ -f "${CONFIG_DIR}"/bin_version_strings.cfg ]]; then
|
||||
print_output "[-] Missing configuration file - check your installation!"
|
||||
return
|
||||
fi
|
||||
|
||||
while read -r VERSION_LINE; do
|
||||
if echo "$VERSION_LINE" | grep -v -q "^[^#*/;]"; then
|
||||
if echo "${VERSION_LINE}" | grep -v -q "^[^#*/;]"; then
|
||||
continue
|
||||
fi
|
||||
if echo "$VERSION_LINE" | grep -q "no_static"; then
|
||||
if echo "${VERSION_LINE}" | grep -q "no_static"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
STRICT="$(echo "$VERSION_LINE" | cut -d\; -f2)"
|
||||
IDENTIFIER="$(echo "$VERSION_LINE" | cut -d\; -f1)"
|
||||
STRICT="$(echo "${VERSION_LINE}" | cut -d\; -f2)"
|
||||
IDENTIFIER="$(echo "${VERSION_LINE}" | cut -d\; -f1)"
|
||||
|
||||
if [[ $STRICT == *"strict"* ]]; then
|
||||
if [[ ${STRICT} == *"strict"* ]]; then
|
||||
continue
|
||||
elif [[ $STRICT == "zgrep" ]]; then
|
||||
elif [[ ${STRICT} == "zgrep" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
LIC="$(echo "$VERSION_LINE" | cut -d\; -f3)"
|
||||
CSV_REGEX="$(echo "$VERSION_LINE" | cut -d\; -f5)"
|
||||
# VERSION_IDENTIFIER="$(echo "$VERSION_LINE" | cut -d\; -f4 | sed s/^\"// | sed s/\"$//)"
|
||||
VERSION_IDENTIFIER="$(echo "$VERSION_LINE" | cut -d\; -f4)"
|
||||
LIC="$(echo "${VERSION_LINE}" | cut -d\; -f3)"
|
||||
CSV_REGEX="$(echo "${VERSION_LINE}" | cut -d\; -f5)"
|
||||
# VERSION_IDENTIFIER="$(echo "${VERSION_LINE}" | cut -d\; -f4 | sed s/^\"// | sed s/\"$//)"
|
||||
VERSION_IDENTIFIER="$(echo "${VERSION_LINE}" | cut -d\; -f4)"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER/\"}"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER%\"}"
|
||||
|
||||
VERSION_FINDER=$(echo "$SERVICE_" | grep -o -a -E "$VERSION_IDENTIFIER" | head -1 2>/dev/null || true)
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
print_output "[+] Version information found ${RED}""$VERSION_FINDER""${NC}${GREEN} in $TYPE_ log."
|
||||
VERSION_FINDER=$(echo "${SERVICE_}" | grep -o -a -E "${VERSION_IDENTIFIER}" | head -1 2>/dev/null || true)
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_output "[+] Version information found ${RED}""${VERSION_FINDER}""${NC}${GREEN} in ${TYPE_} log."
|
||||
# use get_csv_rule from s09:
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
# get rid of ; which destroys our csv:
|
||||
VERSION_FINDER="${VERSION_FINDER/;}"
|
||||
write_csv_log "---" "$IDENTIFIER" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE_"
|
||||
write_csv_log "---" "${IDENTIFIER}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE_}"
|
||||
continue
|
||||
fi
|
||||
done < "$CONFIG_DIR"/bin_version_strings.cfg
|
||||
done < "${CONFIG_DIR}"/bin_version_strings.cfg
|
||||
}
|
||||
|
||||
|
||||
+41
-41
@@ -20,26 +20,26 @@ L20_snmp_checks() {
|
||||
|
||||
export SNMP_UP=0
|
||||
|
||||
if [[ "$SYS_ONLINE" -eq 1 ]] && [[ "$TCP" == "ok" ]]; then
|
||||
if [[ "${SYS_ONLINE}" -eq 1 ]] && [[ "${TCP}" == "ok" ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Live SNMP tests of emulated device."
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
if [[ $IN_DOCKER -eq 0 ]] ; then
|
||||
if [[ ${IN_DOCKER} -eq 0 ]] ; then
|
||||
print_output "[!] This module should not be used in developer mode and could harm your host environment."
|
||||
fi
|
||||
|
||||
if [[ -v IP_ADDRESS_ ]]; then
|
||||
if ! system_online_check "${IP_ADDRESS_}" ; then
|
||||
if ! restart_emulation "$IP_ADDRESS_" "$IMAGE_NAME" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
if ! restart_emulation "${IP_ADDRESS_}" "${IMAGE_NAME}" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
print_output "[-] System not responding - Not performing SNMP checks"
|
||||
module_end_log "${FUNCNAME[0]}" "$SNMP_UP"
|
||||
module_end_log "${FUNCNAME[0]}" "${SNMP_UP}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [[ "${NMAP_PORTS_SERVICES[*]}" == *"snmp"* ]]; then
|
||||
check_basic_snmp "$IP_ADDRESS_"
|
||||
check_snmp_vulns "$IP_ADDRESS_"
|
||||
check_basic_snmp "${IP_ADDRESS_}"
|
||||
check_snmp_vulns "${IP_ADDRESS_}"
|
||||
else
|
||||
print_output "[*] No SNMP services detected"
|
||||
fi
|
||||
@@ -48,56 +48,56 @@ L20_snmp_checks() {
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "Statistics:$SNMP_UP"
|
||||
module_end_log "${FUNCNAME[0]}" "$SNMP_UP"
|
||||
write_log "Statistics:${SNMP_UP}"
|
||||
module_end_log "${FUNCNAME[0]}" "${SNMP_UP}"
|
||||
fi
|
||||
}
|
||||
|
||||
check_basic_snmp() {
|
||||
local IP_ADDRESS_="${1:-}"
|
||||
|
||||
sub_module_title "SNMP enumeration for emulated system with IP $ORANGE$IP_ADDRESS_$NC"
|
||||
sub_module_title "SNMP enumeration for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC}"
|
||||
|
||||
if command -v snmp-check > /dev/null; then
|
||||
print_output "[*] SNMP scan with community name ${ORANGE}public$NC"
|
||||
snmp-check -w "$IP_ADDRESS_" >> "$LOG_PATH_MODULE"/snmp-check-public-"$IP_ADDRESS_".txt
|
||||
if [[ -f "$LOG_PATH_MODULE"/snmp-check-public-"$IP_ADDRESS_".txt ]]; then
|
||||
write_link "$LOG_PATH_MODULE"/snmp-check-public-"$IP_ADDRESS_".txt
|
||||
cat "$LOG_PATH_MODULE"/snmp-check-public-"$IP_ADDRESS_".txt
|
||||
print_output "[*] SNMP scan with community name ${ORANGE}public${NC}"
|
||||
snmp-check -w "${IP_ADDRESS_}" >> "${LOG_PATH_MODULE}"/snmp-check-public-"${IP_ADDRESS_}".txt
|
||||
if [[ -f "${LOG_PATH_MODULE}"/snmp-check-public-"${IP_ADDRESS_}".txt ]]; then
|
||||
write_link "${LOG_PATH_MODULE}"/snmp-check-public-"${IP_ADDRESS_}".txt
|
||||
cat "${LOG_PATH_MODULE}"/snmp-check-public-"${IP_ADDRESS_}".txt
|
||||
fi
|
||||
print_ln
|
||||
print_output "[*] SNMP scan with community name ${ORANGE}private$NC"
|
||||
snmp-check -c private -w "$IP_ADDRESS_" >> "$LOG_PATH_MODULE"/snmp-check-private-"$IP_ADDRESS_".txt
|
||||
if [[ -f "$LOG_PATH_MODULE"/snmp-check-private-"$IP_ADDRESS_".txt ]]; then
|
||||
write_link "$LOG_PATH_MODULE"/snmp-check-private-"$IP_ADDRESS_".txt
|
||||
cat "$LOG_PATH_MODULE"/snmp-check-private-"$IP_ADDRESS_".txt
|
||||
print_output "[*] SNMP scan with community name ${ORANGE}private${NC}"
|
||||
snmp-check -c private -w "${IP_ADDRESS_}" >> "${LOG_PATH_MODULE}"/snmp-check-private-"${IP_ADDRESS_}".txt
|
||||
if [[ -f "${LOG_PATH_MODULE}"/snmp-check-private-"${IP_ADDRESS_}".txt ]]; then
|
||||
write_link "${LOG_PATH_MODULE}"/snmp-check-private-"${IP_ADDRESS_}".txt
|
||||
cat "${LOG_PATH_MODULE}"/snmp-check-private-"${IP_ADDRESS_}".txt
|
||||
fi
|
||||
fi
|
||||
|
||||
print_output "[*] SNMP walk with community name ${ORANGE}public$NC"
|
||||
snmpwalk -v2c -c public "$IP_ADDRESS_" .iso | tee "$LOG_PATH_MODULE"/snmpwalk-public-"$IP_ADDRESS_".txt || true
|
||||
if [[ -f "$LOG_PATH_MODULE"/snmpwalk-public-"$IP_ADDRESS_".txt ]]; then
|
||||
write_link "$LOG_PATH_MODULE"/snmpwalk-public-"$IP_ADDRESS_".txt
|
||||
cat "$LOG_PATH_MODULE"/snmpwalk-public-"$IP_ADDRESS_".txt
|
||||
print_output "[*] SNMP walk with community name ${ORANGE}public${NC}"
|
||||
snmpwalk -v2c -c public "${IP_ADDRESS_}" .iso | tee "${LOG_PATH_MODULE}"/snmpwalk-public-"${IP_ADDRESS_}".txt || true
|
||||
if [[ -f "${LOG_PATH_MODULE}"/snmpwalk-public-"${IP_ADDRESS_}".txt ]]; then
|
||||
write_link "${LOG_PATH_MODULE}"/snmpwalk-public-"${IP_ADDRESS_}".txt
|
||||
cat "${LOG_PATH_MODULE}"/snmpwalk-public-"${IP_ADDRESS_}".txt
|
||||
fi
|
||||
print_ln
|
||||
print_output "[*] SNMP walk with community name ${ORANGE}private$NC"
|
||||
snmpwalk -v2c -c private "$IP_ADDRESS_" .iso | tee "$LOG_PATH_MODULE"/snmapwalk-private-"$IP_ADDRESS_".txt || true
|
||||
if [[ -f "$LOG_PATH_MODULE"/snmpwalk-private-"$IP_ADDRESS_".txt ]]; then
|
||||
write_link "$LOG_PATH_MODULE"/snmpwalk-private-"$IP_ADDRESS_".txt
|
||||
cat "$LOG_PATH_MODULE"/snmpwalk-private-"$IP_ADDRESS_".txt
|
||||
print_output "[*] SNMP walk with community name ${ORANGE}private${NC}"
|
||||
snmpwalk -v2c -c private "${IP_ADDRESS_}" .iso | tee "${LOG_PATH_MODULE}"/snmapwalk-private-"${IP_ADDRESS_}".txt || true
|
||||
if [[ -f "${LOG_PATH_MODULE}"/snmpwalk-private-"${IP_ADDRESS_}".txt ]]; then
|
||||
write_link "${LOG_PATH_MODULE}"/snmpwalk-private-"${IP_ADDRESS_}".txt
|
||||
cat "${LOG_PATH_MODULE}"/snmpwalk-private-"${IP_ADDRESS_}".txt
|
||||
fi
|
||||
|
||||
SNMP_UP=$(wc -l "$LOG_PATH_MODULE"/snmp* | tail -1 | awk '{print $1}')
|
||||
SNMP_UP=$(wc -l "${LOG_PATH_MODULE}"/snmp* | tail -1 | awk '{print $1}')
|
||||
|
||||
if [[ "$SNMP_UP" -gt 20 ]]; then
|
||||
if [[ "${SNMP_UP}" -gt 20 ]]; then
|
||||
SNMP_UP=1
|
||||
else
|
||||
SNMP_UP=0
|
||||
fi
|
||||
|
||||
print_ln
|
||||
print_output "[*] SNMP basic tests for emulated system with IP $ORANGE$IP_ADDRESS_$NC finished"
|
||||
print_output "[*] SNMP basic tests for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC} finished"
|
||||
}
|
||||
|
||||
check_snmp_vulns() {
|
||||
@@ -114,29 +114,29 @@ check_snmp_vulns() {
|
||||
"iso.3.6.1.4.1.4526.100.7.10.1.7" )
|
||||
|
||||
for OID in "${OIDs[@]}"; do
|
||||
print_output "[*] Testing OID ${ORANGE}${OID}${NC} on IP address $ORANGE$IP_ADDRESS_$NC ..."
|
||||
snmpwalk -v 2c -c public "${IP_ADDRESS_}" "${OID}" >> "$LOG_PATH_MODULE"/snmpwalk-firmadyne_disclosure-"$IP_ADDRESS_"-"${OID}".txt || true
|
||||
snmpwalk -v 1 -c public "${IP_ADDRESS_}" "${OID}" >> "$LOG_PATH_MODULE"/snmpwalk-firmadyne_disclosure-"$IP_ADDRESS_"-"${OID}".txt || true
|
||||
print_output "[*] Testing OID ${ORANGE}${OID}${NC} on IP address ${ORANGE}${IP_ADDRESS_}${NC} ..."
|
||||
snmpwalk -v 2c -c public "${IP_ADDRESS_}" "${OID}" >> "${LOG_PATH_MODULE}"/snmpwalk-firmadyne_disclosure-"${IP_ADDRESS_}"-"${OID}".txt || true
|
||||
snmpwalk -v 1 -c public "${IP_ADDRESS_}" "${OID}" >> "${LOG_PATH_MODULE}"/snmpwalk-firmadyne_disclosure-"${IP_ADDRESS_}"-"${OID}".txt || true
|
||||
# remove "No Such Object" entries from the counting results:
|
||||
if [[ $(grep -v -c "No Such Object" "$LOG_PATH_MODULE"/snmpwalk-firmadyne_disclosure-"$IP_ADDRESS_"-"${OID}".txt) -gt 0 ]]; then
|
||||
if [[ $(grep -v -c "No Such Object" "${LOG_PATH_MODULE}"/snmpwalk-firmadyne_disclosure-"${IP_ADDRESS_}"-"${OID}".txt) -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] Possible credential disclosure detected (${ORANGE}CVE-2016-1557 / CVE-2016-1559${GREEN}):${NC}"
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/snmpwalk-firmadyne_disclosure-"$IP_ADDRESS_"-"${OID}".txt
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/snmpwalk-firmadyne_disclosure-"${IP_ADDRESS_}"-"${OID}".txt
|
||||
print_ln
|
||||
else
|
||||
rm "$LOG_PATH_MODULE"/snmpwalk-firmadyne_disclosure-"$IP_ADDRESS_"-"${OID}".txt || true
|
||||
rm "${LOG_PATH_MODULE}"/snmpwalk-firmadyne_disclosure-"${IP_ADDRESS_}"-"${OID}".txt || true
|
||||
fi
|
||||
done
|
||||
|
||||
SNMP_UP_tmp=$(wc -l "$LOG_PATH_MODULE"/snmp* | tail -1 | awk '{print $1}')
|
||||
SNMP_UP_tmp=$(wc -l "${LOG_PATH_MODULE}"/snmp* | tail -1 | awk '{print $1}')
|
||||
|
||||
if [[ "$SNMP_UP_tmp" -gt 20 ]]; then
|
||||
if [[ "${SNMP_UP_tmp}" -gt 20 ]]; then
|
||||
SNMP_UP=1
|
||||
fi
|
||||
|
||||
# TODO: check output for vulnerability and integrate it into f20/f50
|
||||
|
||||
print_ln
|
||||
print_output "[*] SNMP vulnerability tests for emulated system with IP $ORANGE$IP_ADDRESS_$NC finished"
|
||||
print_output "[*] SNMP vulnerability tests for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC} finished"
|
||||
|
||||
}
|
||||
|
||||
@@ -22,27 +22,27 @@ L22_upnp_hnap_checks() {
|
||||
export HNAP_UP=0
|
||||
export JNAP_UP=0
|
||||
|
||||
if [[ "$SYS_ONLINE" -eq 1 ]] && [[ "$TCP" == "ok" ]]; then
|
||||
if [[ "${SYS_ONLINE}" -eq 1 ]] && [[ "${TCP}" == "ok" ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Live UPnP/HNAP tests of emulated device."
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
if [[ $IN_DOCKER -eq 0 ]] ; then
|
||||
if [[ ${IN_DOCKER} -eq 0 ]] ; then
|
||||
print_output "[!] This module should not be used in developer mode and could harm your host environment."
|
||||
fi
|
||||
|
||||
if [[ -v IP_ADDRESS_ ]]; then
|
||||
if ! system_online_check "${IP_ADDRESS_}"; then
|
||||
if ! restart_emulation "$IP_ADDRESS_" "$IMAGE_NAME" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
if ! restart_emulation "${IP_ADDRESS_}" "${IMAGE_NAME}" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
print_output "[-] System not responding - Not performing UPnP/HNAP checks"
|
||||
module_end_log "${FUNCNAME[0]}" "$UPNP_UP"
|
||||
module_end_log "${FUNCNAME[0]}" "${UPNP_UP}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
if [[ -v HOSTNETDEV_ARR ]]; then
|
||||
check_basic_upnp "${HOSTNETDEV_ARR[@]}"
|
||||
check_basic_hnap_jnap
|
||||
[[ "$JNAP_UP" -gt 0 ]] && check_jnap_access
|
||||
[[ "${JNAP_UP}" -gt 0 ]] && check_jnap_access
|
||||
else
|
||||
print_output "[!] No network interface found"
|
||||
fi
|
||||
@@ -51,30 +51,30 @@ L22_upnp_hnap_checks() {
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "Statistics:$UPNP_UP:$HNAP_UP:$JNAP_UP"
|
||||
module_end_log "${FUNCNAME[0]}" "$UPNP_UP"
|
||||
write_log "Statistics:${UPNP_UP}:${HNAP_UP}:${JNAP_UP}"
|
||||
module_end_log "${FUNCNAME[0]}" "${UPNP_UP}"
|
||||
fi
|
||||
}
|
||||
|
||||
check_basic_upnp() {
|
||||
local INTERFACE_ARR=("$@")
|
||||
|
||||
sub_module_title "UPnP enumeration for emulated system with IP $ORANGE$IP_ADDRESS_$NC"
|
||||
sub_module_title "UPnP enumeration for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC}"
|
||||
|
||||
if command -v upnpc > /dev/null; then
|
||||
for INTERFACE in "${INTERFACE_ARR[@]}"; do
|
||||
print_output "[*] UPnP scan with upnpc on local network interface $ORANGE$INTERFACE$NC"
|
||||
upnpc -m "$INTERFACE" -P >> "$LOG_PATH_MODULE"/upnp-discovery-check.txt || true
|
||||
if [[ -f "$LOG_PATH_MODULE"/upnp-discovery-check.txt ]]; then
|
||||
print_output "[*] UPnP scan with upnpc on local network interface ${ORANGE}${INTERFACE}${NC}"
|
||||
upnpc -m "${INTERFACE}" -P >> "${LOG_PATH_MODULE}"/upnp-discovery-check.txt || true
|
||||
if [[ -f "${LOG_PATH_MODULE}"/upnp-discovery-check.txt ]]; then
|
||||
print_ln
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/upnp-discovery-check.txt
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/upnp-discovery-check.txt
|
||||
print_ln
|
||||
fi
|
||||
done
|
||||
UPNP_UP=$(grep -c "desc\|IGD" "$LOG_PATH_MODULE"/upnp-discovery-check.txt || true)
|
||||
UPNP_UP=$(grep -c "desc\|IGD" "${LOG_PATH_MODULE}"/upnp-discovery-check.txt || true)
|
||||
fi
|
||||
|
||||
if [[ "$UPNP_UP" -gt 0 ]]; then
|
||||
if [[ "${UPNP_UP}" -gt 0 ]]; then
|
||||
UPNP_UP=1
|
||||
print_output "[+] UPnP service successfully identified"
|
||||
fi
|
||||
@@ -88,28 +88,28 @@ check_basic_hnap_jnap() {
|
||||
local SERVICE=""
|
||||
local SSL=0
|
||||
|
||||
sub_module_title "HNAP/JNAP enumeration for emulated system with IP $ORANGE$IP_ADDRESS_$NC"
|
||||
sub_module_title "HNAP/JNAP enumeration for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC}"
|
||||
|
||||
if [[ "${#NMAP_PORTS_SERVICES[@]}" -gt 0 ]]; then
|
||||
for PORT_SERVICE in "${NMAP_PORTS_SERVICES[@]}"; do
|
||||
[[ "$HNAP_UP" -eq 1 && "$JNAP_UP" -eq 1 ]] && break
|
||||
[[ "${HNAP_UP}" -eq 1 && "${JNAP_UP}" -eq 1 ]] && break
|
||||
|
||||
PORT=$(echo "$PORT_SERVICE" | cut -d/ -f1 | tr -d "[:blank:]")
|
||||
SERVICE=$(echo "$PORT_SERVICE" | awk '{print $2}' | tr -d "[:blank:]")
|
||||
if [[ "$SERVICE" == "unknown" ]] || [[ "$SERVICE" == "tcpwrapped" ]]; then
|
||||
PORT=$(echo "${PORT_SERVICE}" | cut -d/ -f1 | tr -d "[:blank:]")
|
||||
SERVICE=$(echo "${PORT_SERVICE}" | awk '{print $2}' | tr -d "[:blank:]")
|
||||
if [[ "${SERVICE}" == "unknown" ]] || [[ "${SERVICE}" == "tcpwrapped" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$SERVICE" == *"ssl|http"* ]] || [[ "$SERVICE" == *"ssl/http"* ]];then
|
||||
if [[ "${SERVICE}" == *"ssl|http"* ]] || [[ "${SERVICE}" == *"ssl/http"* ]];then
|
||||
SSL=1
|
||||
elif [[ "$SERVICE" == *"http"* ]];then
|
||||
elif [[ "${SERVICE}" == *"http"* ]];then
|
||||
SSL=0
|
||||
else
|
||||
# no http service - check the next one
|
||||
continue
|
||||
fi
|
||||
|
||||
print_output "[*] Analyzing service $ORANGE$SERVICE - $PORT - $IP_ADDRESS_$NC" "no_log"
|
||||
print_output "[*] Analyzing service ${ORANGE}${SERVICE} - ${PORT} - ${IP_ADDRESS_}${NC}" "no_log"
|
||||
|
||||
if ! command -v curl > /dev/null; then
|
||||
print_output "[-] WARNING: No curl command available - your installation seems to be weird"
|
||||
@@ -118,43 +118,43 @@ check_basic_hnap_jnap() {
|
||||
|
||||
# we use the following JNAP-Action for identifying JNAP services on Linksys routers:
|
||||
JNAP_ACTION="X-JNAP-Action: http://cisco.com/jnap/core/GetDeviceInfo"
|
||||
if [[ "$SSL" -eq 0 ]]; then
|
||||
if [[ "${SSL}" -eq 0 ]]; then
|
||||
# HNAP
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X GET http://"${IP_ADDRESS_}":"${PORT}"/HNAP/ >> "$LOG_PATH_MODULE"/hnap-discovery-check.txt || true
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X GET http://"${IP_ADDRESS_}":"${PORT}"/HNAP1/ >> "$LOG_PATH_MODULE"/hnap-discovery-check.txt || true
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X GET http://"${IP_ADDRESS_}":"${PORT}"/HNAP/ >> "${LOG_PATH_MODULE}"/hnap-discovery-check.txt || true
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X GET http://"${IP_ADDRESS_}":"${PORT}"/HNAP1/ >> "${LOG_PATH_MODULE}"/hnap-discovery-check.txt || true
|
||||
# JNAP
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X POST -H "${JNAP_ACTION}" -d "{}" http://"${IP_ADDRESS_}":"${PORT}"/JNAP/ >> "$LOG_PATH_MODULE"/jnap-discovery-check.txt || true
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X POST -H "${JNAP_ACTION}" -d "{}" http://"${IP_ADDRESS_}":"${PORT}"/JNAP/ >> "${LOG_PATH_MODULE}"/jnap-discovery-check.txt || true
|
||||
else
|
||||
# HNAP - SSL
|
||||
curl -v -L -k --noproxy '*' --max-redir 0 -f -m 5 -s -X GET https://"${IP_ADDRESS_}":"${PORT}"/HNAP/ >> "$LOG_PATH_MODULE"/hnap-discovery-check.txt || true
|
||||
curl -v -L -k --noproxy '*' --max-redir 0 -f -m 5 -s -X GET https://"${IP_ADDRESS_}":"${PORT}"/HNAP1/ >> "$LOG_PATH_MODULE"/hnap-discovery-check.txt || true
|
||||
curl -v -L -k --noproxy '*' --max-redir 0 -f -m 5 -s -X GET https://"${IP_ADDRESS_}":"${PORT}"/HNAP/ >> "${LOG_PATH_MODULE}"/hnap-discovery-check.txt || true
|
||||
curl -v -L -k --noproxy '*' --max-redir 0 -f -m 5 -s -X GET https://"${IP_ADDRESS_}":"${PORT}"/HNAP1/ >> "${LOG_PATH_MODULE}"/hnap-discovery-check.txt || true
|
||||
# JNAP - SSL
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X POST -H "${JNAP_ACTION}" -d "{}" https://"${IP_ADDRESS_}":"${PORT}"/JNAP/ >> "$LOG_PATH_MODULE"/jnap-discovery-check.txt || true
|
||||
curl -v -L --noproxy '*' --max-redir 0 -f -m 5 -s -X POST -H "${JNAP_ACTION}" -d "{}" https://"${IP_ADDRESS_}":"${PORT}"/JNAP/ >> "${LOG_PATH_MODULE}"/jnap-discovery-check.txt || true
|
||||
fi
|
||||
|
||||
if [[ -s "$LOG_PATH_MODULE"/hnap-discovery-check.txt ]]; then
|
||||
if [[ -s "${LOG_PATH_MODULE}"/hnap-discovery-check.txt ]]; then
|
||||
print_ln
|
||||
# tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/hnap-discovery-check.txt
|
||||
sed 's/></>\n</g' "$LOG_PATH_MODULE"/hnap-discovery-check.txt | tee -a "$LOG_FILE"
|
||||
# tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/hnap-discovery-check.txt
|
||||
sed 's/></>\n</g' "${LOG_PATH_MODULE}"/hnap-discovery-check.txt | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
|
||||
HNAP_UP=$(grep -c "HNAP1" "$LOG_PATH_MODULE"/hnap-discovery-check.txt || true)
|
||||
HNAP_UP=$(grep -c "HNAP1" "${LOG_PATH_MODULE}"/hnap-discovery-check.txt || true)
|
||||
fi
|
||||
|
||||
if [[ -s "$LOG_PATH_MODULE"/jnap-discovery-check.txt ]]; then
|
||||
if [[ -s "${LOG_PATH_MODULE}"/jnap-discovery-check.txt ]]; then
|
||||
print_ln
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/jnap-discovery-check.txt
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/jnap-discovery-check.txt
|
||||
print_ln
|
||||
|
||||
JNAP_UP=$(grep -c "/jnap/" "$LOG_PATH_MODULE"/jnap-discovery-check.txt || true)
|
||||
JNAP_UP=$(grep -c "/jnap/" "${LOG_PATH_MODULE}"/jnap-discovery-check.txt || true)
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$HNAP_UP" -gt 0 ]]; then
|
||||
if [[ "${HNAP_UP}" -gt 0 ]]; then
|
||||
HNAP_UP=1
|
||||
print_output "[+] HNAP service successfully identified"
|
||||
fi
|
||||
if [[ "$JNAP_UP" -gt 0 ]]; then
|
||||
if [[ "${JNAP_UP}" -gt 0 ]]; then
|
||||
JNAP_UP=1
|
||||
print_output "[+] JNAP service successfully identified"
|
||||
fi
|
||||
@@ -173,13 +173,13 @@ check_jnap_access() {
|
||||
local SYSINFO_CGI=""
|
||||
local JNAP_EPT=""
|
||||
|
||||
mapfile -t JNAP_ENDPOINTS < <(find "$LOG_DIR"/firmware -type f -exec grep -a "\[.*/jnap/.*\]\ =" {} \; | cut -d\' -f2 | sort -u 2>/dev/null || true)
|
||||
mapfile -t JNAP_ENDPOINTS < <(find "${LOG_DIR}"/firmware -type f -exec grep -a "\[.*/jnap/.*\]\ =" {} \; | cut -d\' -f2 | sort -u 2>/dev/null || true)
|
||||
|
||||
# Todo: PORT!!!
|
||||
local PORT=80
|
||||
|
||||
# https://korelogic.com/Resources/Advisories/KL-001-2015-006.txt
|
||||
mapfile -t SYSINFO_CGI_ARR < <(find "$LOG_DIR"/firmware -type f -name "sysinfo.cgi" -o -name "getstinfo.cgi"| sort -u 2>/dev/null || true)
|
||||
mapfile -t SYSINFO_CGI_ARR < <(find "${LOG_DIR}"/firmware -type f -name "sysinfo.cgi" -o -name "getstinfo.cgi"| sort -u 2>/dev/null || true)
|
||||
|
||||
for SYSINFO_CGI in "${SYSINFO_CGI_ARR[@]}"; do
|
||||
print_output "[*] Testing for sysinfo.cgi" "no_log"
|
||||
@@ -188,7 +188,7 @@ check_jnap_access() {
|
||||
if [[ -f "${LOG_PATH_MODULE}"/JNAP_"${SYSINFO_CGI}".log ]]; then
|
||||
if grep -q "wl0_ssid=\|wl1_ssid=\|wl0_passphrase=\|wl1_passphrase=\|wps_pin=\|default_passphrase=" "${LOG_PATH_MODULE}"/JNAP_"${SYSINFO_CGI}".log; then
|
||||
print_output "[+] Found sensitive information in sysinfo.cgi - see https://korelogic.com/Resources/Advisories/KL-001-2015-006.txt:"
|
||||
grep "wl0_ssid=\|wl1_ssid=\|wl0_passphrase=\|wl1_passphrase=\|wps_pin=\|default_passphrase=" "${LOG_PATH_MODULE}"/JNAP_"${SYSINFO_CGI}".log | tee -a "$LOG_FILE"
|
||||
grep "wl0_ssid=\|wl1_ssid=\|wl0_passphrase=\|wl1_passphrase=\|wps_pin=\|default_passphrase=" "${LOG_PATH_MODULE}"/JNAP_"${SYSINFO_CGI}".log | tee -a "${LOG_FILE}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
+18
-18
@@ -20,19 +20,19 @@ L30_routersploit() {
|
||||
|
||||
export MODULE_END=0
|
||||
|
||||
if [[ "$SYS_ONLINE" -eq 1 ]] && [[ "$TCP" == "ok" ]]; then
|
||||
if [[ "${SYS_ONLINE}" -eq 1 ]] && [[ "${TCP}" == "ok" ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Routersploit tests of emulated device."
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
if [[ $IN_DOCKER -eq 0 ]] ; then
|
||||
if [[ ${IN_DOCKER} -eq 0 ]] ; then
|
||||
print_output "[!] This module should not be used in developer mode and could harm your host environment."
|
||||
fi
|
||||
if [[ -v IP_ADDRESS_ ]]; then
|
||||
if ! system_online_check "${IP_ADDRESS_}"; then
|
||||
if ! restart_emulation "$IP_ADDRESS_" "$IMAGE_NAME" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
if ! restart_emulation "${IP_ADDRESS_}" "${IMAGE_NAME}" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
print_output "[-] System not responding - Not performing routersploit checks"
|
||||
module_end_log "${FUNCNAME[0]}" "$MODULE_END"
|
||||
module_end_log "${FUNCNAME[0]}" "${MODULE_END}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -41,41 +41,41 @@ L30_routersploit() {
|
||||
print_output "[!] No IP address found"
|
||||
fi
|
||||
write_log ""
|
||||
module_end_log "${FUNCNAME[0]}" "$MODULE_END"
|
||||
module_end_log "${FUNCNAME[0]}" "${MODULE_END}"
|
||||
fi
|
||||
}
|
||||
|
||||
check_live_routersploit() {
|
||||
sub_module_title "Routersploit tests for emulated system with IP $ORANGE$IP_ADDRESS_$NC"
|
||||
sub_module_title "Routersploit tests for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC}"
|
||||
|
||||
if [[ -f /tmp/routersploit.log ]]; then
|
||||
rm /tmp/routersploit.log
|
||||
fi
|
||||
|
||||
timeout --preserve-status --signal SIGINT 300 "$EXT_DIR"/routersploit/rsf.py "$IP_ADDRESS_" 2>&1 | tee -a "$LOG_PATH_MODULE"/routersploit-"$IP_ADDRESS_".txt || true
|
||||
timeout --preserve-status --signal SIGINT 300 "${EXT_DIR}"/routersploit/rsf.py "${IP_ADDRESS_}" 2>&1 | tee -a "${LOG_PATH_MODULE}"/routersploit-"${IP_ADDRESS_}".txt || true
|
||||
|
||||
if [[ -f /tmp/routersploit.log ]]; then
|
||||
mv /tmp/routersploit.log "$LOG_PATH_MODULE"/routersploit-detail-"$IP_ADDRESS_".txt
|
||||
mv /tmp/routersploit.log "${LOG_PATH_MODULE}"/routersploit-detail-"${IP_ADDRESS_}".txt
|
||||
fi
|
||||
|
||||
print_ln
|
||||
if grep -q "Target is vulnerable" "$LOG_PATH_MODULE"/routersploit-"$IP_ADDRESS_".txt; then
|
||||
print_output "[+] Found the following vulnerabilities:" "" "$LOG_PATH_MODULE/routersploit-$IP_ADDRESS_.txt"
|
||||
grep -B 1 "Target is vulnerable" "$LOG_PATH_MODULE"/routersploit-"$IP_ADDRESS_".txt | tee -a "$LOG_FILE"
|
||||
if grep -q "Target is vulnerable" "${LOG_PATH_MODULE}"/routersploit-"${IP_ADDRESS_}".txt; then
|
||||
print_output "[+] Found the following vulnerabilities:" "" "${LOG_PATH_MODULE}/routersploit-${IP_ADDRESS_}.txt"
|
||||
grep -B 1 "Target is vulnerable" "${LOG_PATH_MODULE}"/routersploit-"${IP_ADDRESS_}".txt | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
MODULE_END=1
|
||||
fi
|
||||
if grep -q "Target seems to be vulnerable" "$LOG_PATH_MODULE"/routersploit-"$IP_ADDRESS_".txt; then
|
||||
if grep -q "Target seems to be vulnerable" "${LOG_PATH_MODULE}"/routersploit-"${IP_ADDRESS_}".txt; then
|
||||
print_ln
|
||||
print_output "[+] Found the following possible vulnerabilities:" "" "$LOG_PATH_MODULE/routersploit-$IP_ADDRESS_.txt"
|
||||
grep -B 1 "Target seems to be vulnerable" "$LOG_PATH_MODULE"/routersploit-"$IP_ADDRESS_".txt | tee -a "$LOG_FILE"
|
||||
print_output "[+] Found the following possible vulnerabilities:" "" "${LOG_PATH_MODULE}/routersploit-${IP_ADDRESS_}.txt"
|
||||
grep -B 1 "Target seems to be vulnerable" "${LOG_PATH_MODULE}"/routersploit-"${IP_ADDRESS_}".txt | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
MODULE_END=1
|
||||
fi
|
||||
|
||||
color_routersploit_log "$LOG_PATH_MODULE/routersploit-$IP_ADDRESS_.txt"
|
||||
color_routersploit_log "${LOG_PATH_MODULE}/routersploit-${IP_ADDRESS_}.txt"
|
||||
|
||||
print_output "[*] Routersploit tests for emulated system with IP $ORANGE$IP_ADDRESS_$NC finished"
|
||||
print_output "[*] Routersploit tests for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC} finished"
|
||||
}
|
||||
|
||||
color_routersploit_log() {
|
||||
@@ -84,6 +84,6 @@ color_routersploit_log() {
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i -r "s/Target is vulnerable/\x1b[32m&\x1b[0m/" "$RSPLOIT_LOG_FILE_"
|
||||
sed -i -r "s/Target seems to be vulnerable/\x1b[32m&\x1b[0m/" "$RSPLOIT_LOG_FILE_"
|
||||
sed -i -r "s/Target is vulnerable/\x1b[32m&\x1b[0m/" "${RSPLOIT_LOG_FILE_}"
|
||||
sed -i -r "s/Target seems to be vulnerable/\x1b[32m&\x1b[0m/" "${RSPLOIT_LOG_FILE_}"
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
L35_metasploit_check() {
|
||||
|
||||
local MODULE_END=0
|
||||
if [[ "$SYS_ONLINE" -eq 1 ]] && [[ "$TCP" == "ok" ]]; then
|
||||
if [[ "${SYS_ONLINE}" -eq 1 ]] && [[ "${TCP}" == "ok" ]]; then
|
||||
if ! command -v msfconsole > /dev/null; then
|
||||
print_output "[-] Metasploit not available - Not performing Metasploit checks"
|
||||
return
|
||||
fi
|
||||
if ! [[ -f "$HELP_DIR""/l35_msf_check.rc" ]]; then
|
||||
if ! [[ -f "${HELP_DIR}""/l35_msf_check.rc" ]]; then
|
||||
print_output "[-] Metasploit resource script not available - Not performing Metasploit checks"
|
||||
return
|
||||
fi
|
||||
@@ -33,15 +33,15 @@ L35_metasploit_check() {
|
||||
module_title "Metasploit exploit checks of emulated device."
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
if [[ $IN_DOCKER -eq 0 ]] ; then
|
||||
if [[ ${IN_DOCKER} -eq 0 ]] ; then
|
||||
print_output "[!] This module should not be used in developer mode and could harm your host environment."
|
||||
fi
|
||||
|
||||
if [[ -v IP_ADDRESS_ ]]; then
|
||||
if ! system_online_check "${IP_ADDRESS_}"; then
|
||||
if ! restart_emulation "$IP_ADDRESS_" "$IMAGE_NAME" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
if ! restart_emulation "${IP_ADDRESS_}" "${IMAGE_NAME}" 1 "${STATE_CHECK_MECHANISM}"; then
|
||||
print_output "[-] System not responding - Not performing Metasploit checks"
|
||||
module_end_log "${FUNCNAME[0]}" "$MODULE_END"
|
||||
module_end_log "${FUNCNAME[0]}" "${MODULE_END}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -52,12 +52,12 @@ L35_metasploit_check() {
|
||||
print_output "[!] No IP address found"
|
||||
fi
|
||||
write_log ""
|
||||
module_end_log "${FUNCNAME[0]}" "$MODULE_END"
|
||||
module_end_log "${FUNCNAME[0]}" "${MODULE_END}"
|
||||
fi
|
||||
}
|
||||
|
||||
check_live_metasploit() {
|
||||
sub_module_title "Metasploit tests for emulated system with IP $ORANGE$IP_ADDRESS_$NC"
|
||||
sub_module_title "Metasploit tests for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC}"
|
||||
local PORTS=""
|
||||
local PORTS_ARR=()
|
||||
local MSF_VULN=""
|
||||
@@ -66,10 +66,10 @@ check_live_metasploit() {
|
||||
local ARCH_END=""
|
||||
|
||||
if [[ -v ARCHIVE_PATH ]]; then
|
||||
mapfile -t PORTS_ARR < <(find "$ARCHIVE_PATH" -name "*.xml" -exec grep -a -h "<state state=\"open\"" {} \; | grep -o -E "portid=\"[0-9]+" | cut -d\" -f2 | sort -u || true)
|
||||
mapfile -t PORTS_ARR < <(find "${ARCHIVE_PATH}" -name "*.xml" -exec grep -a -h "<state state=\"open\"" {} \; | grep -o -E "portid=\"[0-9]+" | cut -d\" -f2 | sort -u || true)
|
||||
else
|
||||
print_output "[-] Warning: No ARCHIVE_PATH found"
|
||||
mapfile -t PORTS_ARR < <(find "$LOG_DIR"/l10_system_emulation/ -name "*.xml" -exec grep -a -h "<state state=\"open\"" {} \; | grep -o -E "portid=\"[0-9]+" | cut -d\" -f2 | sort -u || true)
|
||||
mapfile -t PORTS_ARR < <(find "${LOG_DIR}"/l10_system_emulation/ -name "*.xml" -exec grep -a -h "<state state=\"open\"" {} \; | grep -o -E "portid=\"[0-9]+" | cut -d\" -f2 | sort -u || true)
|
||||
fi
|
||||
if [[ "${#PORTS_ARR[@]}" -eq 0 ]]; then
|
||||
print_output "[-] No open ports identified ..."
|
||||
@@ -79,64 +79,64 @@ check_live_metasploit() {
|
||||
printf -v PORTS "%s " "${PORTS_ARR[@]}"
|
||||
PORTS=${PORTS//\ /,}
|
||||
PORTS="${PORTS%,}"
|
||||
print_output "[*] Testing system with IP address $ORANGE$IP_ADDRESS_$NC and ports $ORANGE$PORTS$NC."
|
||||
print_output "[*] Testing system with IP address ${ORANGE}${IP_ADDRESS_}${NC} and ports ${ORANGE}${PORTS}${NC}."
|
||||
|
||||
# metasploit tries to parse env variables and our environment is wasted!
|
||||
export PORT=""
|
||||
D_END="$(echo "$D_END" | tr '[:upper:]' '[:lower:]')"
|
||||
if [[ "$D_END" == "el" ]]; then D_END="le"; fi
|
||||
if [[ "$D_END" == "eb" ]]; then D_END="be"; fi
|
||||
ARCH_END="$(echo "$ARCH" | tr '[:upper:]' '[:lower:]')$(echo "$D_END" | tr '[:upper:]' '[:lower:]')"
|
||||
D_END="$(echo "${D_END}" | tr '[:upper:]' '[:lower:]')"
|
||||
if [[ "${D_END}" == "el" ]]; then D_END="le"; fi
|
||||
if [[ "${D_END}" == "eb" ]]; then D_END="be"; fi
|
||||
ARCH_END="$(echo "${ARCH}" | tr '[:upper:]' '[:lower:]')$(echo "${D_END}" | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
timeout --preserve-status --signal SIGINT -k 60 2000 msfconsole -q -n -r "$HELP_DIR"/l35_msf_check.rc "$IP_ADDRESS_" "$PORTS" "$ARCH_END"| tee -a "$LOG_PATH_MODULE"/metasploit-check-"$IP_ADDRESS_".txt || true
|
||||
timeout --preserve-status --signal SIGINT -k 60 2000 msfconsole -q -n -r "${HELP_DIR}"/l35_msf_check.rc "${IP_ADDRESS_}" "${PORTS}" "${ARCH_END}"| tee -a "${LOG_PATH_MODULE}"/metasploit-check-"${IP_ADDRESS_}".txt || true
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE"/metasploit-check-"$IP_ADDRESS_".txt ]] && [[ $(grep -a -i -c "Vulnerability identified for module" "$LOG_PATH_MODULE"/metasploit-check-"$IP_ADDRESS_".txt) -gt 0 ]]; then
|
||||
if [[ -f "${LOG_PATH_MODULE}"/metasploit-check-"${IP_ADDRESS_}".txt ]] && [[ $(grep -a -i -c "Vulnerability identified for module" "${LOG_PATH_MODULE}"/metasploit-check-"${IP_ADDRESS_}".txt) -gt 0 ]]; then
|
||||
write_csv_log "Source" "Module" "CVE" "ARCH_END" "IP_ADDRESS" "PORTS"
|
||||
print_ln
|
||||
print_output "[+] Metasploit results for verification" "" "$LOG_PATH_MODULE/metasploit-check-$IP_ADDRESS_.txt"
|
||||
mapfile -t MSF_VULNS_VERIFIED < <(grep -a -i "Vulnerability identified for module" "$LOG_PATH_MODULE"/metasploit-check-"$IP_ADDRESS_".txt || true)
|
||||
print_output "[+] Metasploit results for verification" "" "${LOG_PATH_MODULE}/metasploit-check-${IP_ADDRESS_}.txt"
|
||||
mapfile -t MSF_VULNS_VERIFIED < <(grep -a -i "Vulnerability identified for module" "${LOG_PATH_MODULE}"/metasploit-check-"${IP_ADDRESS_}".txt || true)
|
||||
for MSF_VULN in "${MSF_VULNS_VERIFIED[@]}"; do
|
||||
local MSF_CVE=""
|
||||
MSF_MODULE="$(echo "$MSF_VULN" | sed 's/.*module\ //' | sed 's/\ -\ .*//')"
|
||||
mapfile -t MSF_CVEs < <(grep "$MSF_MODULE" "$MSF_DB_PATH" | cut -d: -f2 || true)
|
||||
MSF_MODULE="$(echo "${MSF_VULN}" | sed 's/.*module\ //' | sed 's/\ -\ .*//')"
|
||||
mapfile -t MSF_CVEs < <(grep "${MSF_MODULE}" "${MSF_DB_PATH}" | cut -d: -f2 || true)
|
||||
printf -v MSF_CVE "%s " "${MSF_CVEs[@]}"
|
||||
MSF_CVE="${MSF_CVE%\ }"
|
||||
if [[ -n "$MSF_CVE" ]]; then
|
||||
print_output "[+] Vulnerability verified: $ORANGE$MSF_MODULE$GREEN / $ORANGE$MSF_CVE$GREEN."
|
||||
if [[ -n "${MSF_CVE}" ]]; then
|
||||
print_output "[+] Vulnerability verified: ${ORANGE}${MSF_MODULE}${GREEN} / ${ORANGE}${MSF_CVE}${GREEN}."
|
||||
write_link "https://github.com/rapid7/metasploit-framework/tree/master/modules/exploits/${MSF_MODULE}.rb"
|
||||
# we write our csv entry later for every CVE entry
|
||||
else
|
||||
print_output "[+] Vulnerability verified: $ORANGE$MSF_MODULE$GREEN."
|
||||
print_output "[+] Vulnerability verified: ${ORANGE}${MSF_MODULE}${GREEN}."
|
||||
write_link "https://github.com/rapid7/metasploit-framework/tree/master/modules/exploits/${MSF_MODULE}.rb"
|
||||
MSF_CVE="NA"
|
||||
# if we have no CVE entry we can directly write our csv entry:
|
||||
write_csv_log "Metasploit framework" "$MSF_MODULE" "$MSF_CVE" "$ARCH_END" "$IP_ADDRESS_" "$PORTS"
|
||||
write_csv_log "Metasploit framework" "${MSF_MODULE}" "${MSF_CVE}" "${ARCH_END}" "${IP_ADDRESS_}" "${PORTS}"
|
||||
fi
|
||||
for MSF_CVE in "${MSF_CVEs[@]}"; do
|
||||
# per CVE one csv entry:
|
||||
write_csv_log "Metasploit framework" "$MSF_MODULE" "$MSF_CVE" "$ARCH_END" "$IP_ADDRESS_" "$PORTS"
|
||||
write_csv_log "Metasploit framework" "${MSF_MODULE}" "${MSF_CVE}" "${ARCH_END}" "${IP_ADDRESS_}" "${PORTS}"
|
||||
done
|
||||
done
|
||||
|
||||
print_ln
|
||||
|
||||
if grep -q "Active sessions" "$LOG_PATH_MODULE/metasploit-check-$IP_ADDRESS_.txt"; then
|
||||
if grep -q "Active sessions" "${LOG_PATH_MODULE}/metasploit-check-${IP_ADDRESS_}.txt"; then
|
||||
print_ln
|
||||
print_output "[+] Possible Metasploit sessions for verification:" "" "$LOG_PATH_MODULE/metasploit-check-$IP_ADDRESS_.txt"
|
||||
print_output "[+] Possible Metasploit sessions for verification:" "" "${LOG_PATH_MODULE}/metasploit-check-${IP_ADDRESS_}.txt"
|
||||
# sometimes we need two print_ln to get one in the web report?!?
|
||||
print_ln
|
||||
print_ln
|
||||
# Print the session output from the metasploit log:
|
||||
sed -n '/Active sessions/,/Stopping all jobs/p' "$LOG_PATH_MODULE"/metasploit-check-"$IP_ADDRESS_".txt | tee -a "$LOG_FILE" || true
|
||||
sed -n '/Active sessions/,/Stopping all jobs/p' "${LOG_PATH_MODULE}"/metasploit-check-"${IP_ADDRESS_}".txt | tee -a "${LOG_FILE}" || true
|
||||
print_ln
|
||||
else
|
||||
print_output "[-] No Metasploit session detected"
|
||||
fi
|
||||
elif [[ -f "$LOG_PATH_MODULE"/metasploit-check-"$IP_ADDRESS_".txt ]]; then
|
||||
elif [[ -f "${LOG_PATH_MODULE}"/metasploit-check-"${IP_ADDRESS_}".txt ]]; then
|
||||
# just for link the log file in the web reporter
|
||||
print_output "[-] No Metasploit results detected" "" "$LOG_PATH_MODULE/metasploit-check-$IP_ADDRESS_.txt"
|
||||
print_output "[-] No Metasploit results detected" "" "${LOG_PATH_MODULE}/metasploit-check-${IP_ADDRESS_}.txt"
|
||||
else
|
||||
print_output "[-] No Metasploit results detected"
|
||||
fi
|
||||
print_output "[*] Metasploit tests for emulated system with IP $ORANGE$IP_ADDRESS_$NC finished"
|
||||
print_output "[*] Metasploit tests for emulated system with IP ${ORANGE}${IP_ADDRESS_}${NC} finished"
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
L99_cleanup() {
|
||||
local MODULE_END=0
|
||||
|
||||
if [[ "$SYS_ONLINE" -eq 1 ]] && [[ "$TCP" == "ok" ]]; then
|
||||
if [[ "${SYS_ONLINE}" -eq 1 ]] && [[ "${TCP}" == "ok" ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Cleanup of emulated environment."
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
# as we are running from the run.sh startup script the network is also reconfigured
|
||||
stopping_emulation_process "$IMAGE_NAME"
|
||||
stopping_emulation_process "${IMAGE_NAME}"
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$MODULE_END"
|
||||
module_end_log "${FUNCNAME[0]}" "${MODULE_END}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -28,26 +28,26 @@ P02_firmware_bin_file_check() {
|
||||
export UEFI_DETECTED=0
|
||||
|
||||
write_csv_log "Entity" "data" "Notes"
|
||||
write_csv_log "Firmware path" "$FIRMWARE_PATH" "NA"
|
||||
write_csv_log "Firmware path" "${FIRMWARE_PATH}" "NA"
|
||||
|
||||
if [[ -d "$FIRMWARE_PATH" ]]; then
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
if [[ -d "${FIRMWARE_PATH}" ]]; then
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
fi
|
||||
|
||||
if [[ -f "$FIRMWARE_PATH" ]]; then
|
||||
if [[ -f "${FIRMWARE_PATH}" ]]; then
|
||||
get_fw_file_details "${FIRMWARE_PATH}"
|
||||
generate_entropy_graph "${FIRMWARE_PATH}"
|
||||
fi
|
||||
|
||||
local FILE_LS_OUT
|
||||
FILE_LS_OUT=$(ls -lh "$FIRMWARE_PATH")
|
||||
FILE_LS_OUT=$(ls -lh "${FIRMWARE_PATH}")
|
||||
|
||||
print_ln
|
||||
print_output "[*] Details of the firmware file:"
|
||||
print_ln
|
||||
print_output "$(indent "$FILE_LS_OUT")"
|
||||
print_output "$(indent "${FILE_LS_OUT}")"
|
||||
print_ln
|
||||
if [[ -f "$FIRMWARE_PATH" ]]; then
|
||||
if [[ -f "${FIRMWARE_PATH}" ]]; then
|
||||
print_fw_file_details "${FIRMWARE_PATH}"
|
||||
generate_pixde "${FIRMWARE_PATH}"
|
||||
fw_bin_detector "${FIRMWARE_PATH}"
|
||||
@@ -78,23 +78,23 @@ print_fw_file_details() {
|
||||
print_ln
|
||||
print_output "$(indent "$(file "${FIRMWARE_PATH_BIN}")")"
|
||||
print_ln
|
||||
hexdump -C "${FIRMWARE_PATH_BIN}"| head | tee -a "$LOG_FILE" || true
|
||||
hexdump -C "${FIRMWARE_PATH_BIN}"| head | tee -a "${LOG_FILE}" || true
|
||||
print_ln
|
||||
print_output "[*] SHA512 checksum: $ORANGE$SHA512_CHECKSUM$NC"
|
||||
print_output "[*] SHA512 checksum: ${ORANGE}${SHA512_CHECKSUM}${NC}"
|
||||
print_ln
|
||||
print_output "$(indent "$ENTROPY")"
|
||||
print_output "$(indent "${ENTROPY}")"
|
||||
print_ln
|
||||
}
|
||||
|
||||
generate_pixde() {
|
||||
local FIRMWARE_PATH_BIN="${1:-}"
|
||||
local PIXD_PNG_PATH="$LOG_DIR"/pixd.png
|
||||
local PIXD_PNG_PATH="${LOG_DIR}"/pixd.png
|
||||
|
||||
if [[ -x "$EXT_DIR"/pixde ]]; then
|
||||
if [[ -x "${EXT_DIR}"/pixde ]]; then
|
||||
print_output "[*] Visualized firmware file (first 2000 bytes):\n"
|
||||
"$EXT_DIR"/pixde -r-0x2000 "${FIRMWARE_PATH_BIN}" | tee -a "$LOG_DIR"/p02_pixd.txt
|
||||
"${EXT_DIR}"/pixde -r-0x2000 "${FIRMWARE_PATH_BIN}" | tee -a "${LOG_DIR}"/p02_pixd.txt
|
||||
print_ln
|
||||
python3 "$EXT_DIR"/pixd_png.py -i "$LOG_DIR"/p02_pixd.txt -o "${PIXD_PNG_PATH}" -p 10 > /dev/null
|
||||
python3 "${EXT_DIR}"/pixd_png.py -i "${LOG_DIR}"/p02_pixd.txt -o "${PIXD_PNG_PATH}" -p 10 > /dev/null
|
||||
write_link "${PIXD_PNG_PATH}"
|
||||
fi
|
||||
}
|
||||
@@ -130,18 +130,18 @@ generate_entropy_graph() {
|
||||
local FIRMWARE_PATH_BIN="${1:-}"
|
||||
|
||||
# we use the original FIRMWARE_PATH for entropy testing, just if it is a file
|
||||
if [[ -f "${FIRMWARE_PATH_BIN}" ]] && ! [[ -f "$LOG_DIR"/firmware_entropy.png ]]; then
|
||||
if [[ -f "${FIRMWARE_PATH_BIN}" ]] && ! [[ -f "${LOG_DIR}"/firmware_entropy.png ]]; then
|
||||
print_output "[*] Entropy testing with binwalk ... "
|
||||
# we have to change the working directory for binwalk, because everything except the log directory is read-only in
|
||||
# Docker container and binwalk fails to save the entropy picture there
|
||||
if [[ $IN_DOCKER -eq 1 ]] ; then
|
||||
cd "$LOG_DIR" || return
|
||||
print_output "$("${BINWALK_BIN[@]}" -E -F -J "$FIRMWARE_PATH_BIN")"
|
||||
mv "$(basename "$FIRMWARE_PATH_BIN".png)" "$LOG_DIR"/firmware_entropy.png 2> /dev/null || true
|
||||
if [[ ${IN_DOCKER} -eq 1 ]] ; then
|
||||
cd "${LOG_DIR}" || return
|
||||
print_output "$("${BINWALK_BIN[@]}" -E -F -J "${FIRMWARE_PATH_BIN}")"
|
||||
mv "$(basename "${FIRMWARE_PATH_BIN}".png)" "${LOG_DIR}"/firmware_entropy.png 2> /dev/null || true
|
||||
cd /emba || return
|
||||
else
|
||||
print_output "$("${BINWALK_BIN[@]}" -E -F -J "$FIRMWARE_PATH_BIN")"
|
||||
mv "$(basename "$FIRMWARE_PATH_BIN".png)" "$LOG_DIR"/firmware_entropy.png 2> /dev/null || true
|
||||
print_output "$("${BINWALK_BIN[@]}" -E -F -J "${FIRMWARE_PATH_BIN}")"
|
||||
mv "$(basename "${FIRMWARE_PATH_BIN}".png)" "${LOG_DIR}"/firmware_entropy.png 2> /dev/null || true
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -156,23 +156,23 @@ fw_bin_detector() {
|
||||
|
||||
set_p02_default_exports
|
||||
|
||||
FILE_BIN_OUT=$(file "$CHECK_FILE")
|
||||
DLINK_ENC_CHECK=$(hexdump -C "$CHECK_FILE" | head -1 || true)
|
||||
FILE_BIN_OUT=$(file "${CHECK_FILE}")
|
||||
DLINK_ENC_CHECK=$(hexdump -C "${CHECK_FILE}" | head -1 || true)
|
||||
AVM_CHECK=$(strings "${CHECK_FILE}" | grep -c "AVM GmbH .*. All rights reserved.\|(C) Copyright .* AVM" || true)
|
||||
BMC_CHECK=$(strings "${CHECK_FILE}" | grep -c "libipmi.so" || true)
|
||||
# we are running binwalk on the file to analyze the output afterwards:
|
||||
"${BINWALK_BIN[@]}" "$CHECK_FILE" > "$TMP_DIR"/s02_binwalk_output.txt
|
||||
if [[ -f "$TMP_DIR"/s02_binwalk_output.txt ]]; then
|
||||
QNAP_ENC_CHECK=$(grep -a -i "qnap encrypted" "$TMP_DIR"/s02_binwalk_output.txt || true)
|
||||
"${BINWALK_BIN[@]}" "${CHECK_FILE}" > "${TMP_DIR}"/s02_binwalk_output.txt
|
||||
if [[ -f "${TMP_DIR}"/s02_binwalk_output.txt ]]; then
|
||||
QNAP_ENC_CHECK=$(grep -a -i "qnap encrypted" "${TMP_DIR}"/s02_binwalk_output.txt || true)
|
||||
else
|
||||
QNAP_ENC_CHECK=$("${BINWALK_BIN[@]}" -y "qnap encrypted" "$CHECK_FILE")
|
||||
QNAP_ENC_CHECK=$("${BINWALK_BIN[@]}" -y "qnap encrypted" "${CHECK_FILE}")
|
||||
fi
|
||||
UEFI_CHECK=$(grep -c "UEFI" "$TMP_DIR"/s02_binwalk_output.txt || true)
|
||||
UEFI_CHECK=$(( "$UEFI_CHECK" + "$(grep -c "UEFI" "$CHECK_FILE" || true)" ))
|
||||
UEFI_CHECK=$(grep -c "UEFI" "${TMP_DIR}"/s02_binwalk_output.txt || true)
|
||||
UEFI_CHECK=$(( "${UEFI_CHECK}" + "$(grep -c "UEFI" "${CHECK_FILE}" || true)" ))
|
||||
|
||||
if [[ -f "$KERNEL_CONFIG" ]] && [[ "$KERNEL" -eq 1 ]]; then
|
||||
if [[ -f "${KERNEL_CONFIG}" ]] && [[ "${KERNEL}" -eq 1 ]]; then
|
||||
# we set the FIRMWARE_PATH to the kernel config path if we have only -k parameter
|
||||
if [[ "$(md5sum "$KERNEL_CONFIG" | awk '{print $1}')" == "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" ]]; then
|
||||
if [[ "$(md5sum "${KERNEL_CONFIG}" | awk '{print $1}')" == "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" ]]; then
|
||||
print_output "[+] Identified Linux kernel configuration file"
|
||||
write_csv_log "kernel config" "yes" "NA"
|
||||
export SKIP_PRE_CHECKERS=1
|
||||
@@ -185,126 +185,126 @@ fw_bin_detector() {
|
||||
export BMC_ENC_DETECTED=1
|
||||
write_csv_log "BMC encrypted" "yes" "NA"
|
||||
fi
|
||||
if [[ "$UEFI_CHECK" -gt 0 ]]; then
|
||||
if [[ "${UEFI_CHECK}" -gt 0 ]]; then
|
||||
print_output "[+] Identified possible UEFI firmware - using fwhunt-scan vulnerability scanning module"
|
||||
export UEFI_DETECTED=1
|
||||
UEFI_AMI_CAPSULE=$(grep -c "AMI.*EFI.*capsule" "$TMP_DIR"/s02_binwalk_output.txt || true)
|
||||
if [[ "$UEFI_AMI_CAPSULE" -gt 0 ]]; then
|
||||
UEFI_AMI_CAPSULE=$(grep -c "AMI.*EFI.*capsule" "${TMP_DIR}"/s02_binwalk_output.txt || true)
|
||||
if [[ "${UEFI_AMI_CAPSULE}" -gt 0 ]]; then
|
||||
print_output "[+] Identified possible UEFI-AMI capsule firmware - using capsule extractors"
|
||||
fi
|
||||
write_csv_log "UEFI firmware detected" "yes" "NA"
|
||||
fi
|
||||
if [[ "$AVM_CHECK" -gt 0 ]] || [[ "$FW_VENDOR" == *"AVM"* ]]; then
|
||||
if [[ "${AVM_CHECK}" -gt 0 ]] || [[ "${FW_VENDOR}" == *"AVM"* ]]; then
|
||||
print_output "[+] Identified AVM firmware - using AVM extraction module"
|
||||
export AVM_DETECTED=1
|
||||
write_csv_log "AVM firmware detected" "yes" "NA"
|
||||
fi
|
||||
# if we have a zip, tgz, tar archive we are going to use the patools extractor
|
||||
if [[ "$FILE_BIN_OUT" == *"gzip compressed data"* || "$FILE_BIN_OUT" == *"Zip archive data"* || \
|
||||
"$FILE_BIN_OUT" == *"POSIX tar archive"* || "$FILE_BIN_OUT" == *"ISO 9660 CD-ROM filesystem data"* || \
|
||||
"$FILE_BIN_OUT" == *"7-zip archive data"* || "$FILE_BIN_OUT" == *"XZ compressed data"* || \
|
||||
"$FILE_BIN_OUT" == *"bzip2 compressed data"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"gzip compressed data"* || "${FILE_BIN_OUT}" == *"Zip archive data"* || \
|
||||
"${FILE_BIN_OUT}" == *"POSIX tar archive"* || "${FILE_BIN_OUT}" == *"ISO 9660 CD-ROM filesystem data"* || \
|
||||
"${FILE_BIN_OUT}" == *"7-zip archive data"* || "${FILE_BIN_OUT}" == *"XZ compressed data"* || \
|
||||
"${FILE_BIN_OUT}" == *"bzip2 compressed data"* ]]; then
|
||||
# as the AVM images are also zip files we need to bypass it here:
|
||||
if [[ "$AVM_DETECTED" -ne 1 ]]; then
|
||||
if [[ "${AVM_DETECTED}" -ne 1 ]]; then
|
||||
print_output "[+] Identified gzip/zip/tar/iso/xz/bzip2 archive file - using patools extraction module"
|
||||
export PATOOLS_INIT=1
|
||||
write_csv_log "basic compressed (patool)" "yes" "NA"
|
||||
fi
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"QEMU QCOW2 Image"* ]] || [[ "$FILE_BIN_OUT" == *"QEMU QCOW Image"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"QEMU QCOW2 Image"* ]] || [[ "${FILE_BIN_OUT}" == *"QEMU QCOW Image"* ]]; then
|
||||
print_output "[+] Identified Qemu QCOW image - using QCOW extraction module"
|
||||
export QCOW_DETECTED=1
|
||||
write_csv_log "Qemu QCOW firmware detected" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"VMware4 disk image"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"VMware4 disk image"* ]]; then
|
||||
print_output "[+] Identified VMWware VMDK archive file - using VMDK extraction module"
|
||||
export VMDK_DETECTED=1
|
||||
write_csv_log "VMDK" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"UBI image"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"UBI image"* ]]; then
|
||||
print_output "[+] Identified UBI filesystem image - using UBI extraction module"
|
||||
export UBI_IMAGE=1
|
||||
write_csv_log "UBI filesystem" "yes" "NA"
|
||||
fi
|
||||
if [[ "$DLINK_ENC_CHECK" == *"SHRS"* ]]; then
|
||||
if [[ "${DLINK_ENC_CHECK}" == *"SHRS"* ]]; then
|
||||
print_output "[+] Identified D-Link SHRS encrpyted firmware - using D-Link extraction module"
|
||||
export DLINK_ENC_DETECTED=1
|
||||
write_csv_log "D-Link SHRS" "yes" "NA"
|
||||
fi
|
||||
if [[ "$DLINK_ENC_CHECK" =~ 00000000\ \ 00\ 00\ 00\ 00\ 00\ 00\ 0.\ ..\ \ 00\ 00\ 0.\ ..\ 31\ 32\ 33\ 00 ]]; then
|
||||
if [[ "${DLINK_ENC_CHECK}" =~ 00000000\ \ 00\ 00\ 00\ 00\ 00\ 00\ 0.\ ..\ \ 00\ 00\ 0.\ ..\ 31\ 32\ 33\ 00 ]]; then
|
||||
print_output "[+] Identified EnGenius encrpyted firmware - using EnGenius extraction module"
|
||||
export ENGENIUS_ENC_DETECTED=1
|
||||
write_csv_log "EnGenius encrypted" "yes" "NA"
|
||||
fi
|
||||
if [[ "$DLINK_ENC_CHECK" =~ 00000000\ \ 00\ 00\ 00\ 00\ 00\ 00\ 01\ 01\ \ 00\ 00\ 0.\ ..\ 33\ 2e\ 3[89]\ 2e ]]; then
|
||||
if [[ "${DLINK_ENC_CHECK}" =~ 00000000\ \ 00\ 00\ 00\ 00\ 00\ 00\ 01\ 01\ \ 00\ 00\ 0.\ ..\ 33\ 2e\ 3[89]\ 2e ]]; then
|
||||
print_output "[+] Identified EnGenius encrpyted firmware - using EnGenius extraction module"
|
||||
export ENGENIUS_ENC_DETECTED=1
|
||||
write_csv_log "EnGenius encrypted" "yes" "NA"
|
||||
fi
|
||||
if [[ "$DLINK_ENC_CHECK" == *"encrpted_img"* ]]; then
|
||||
if [[ "${DLINK_ENC_CHECK}" == *"encrpted_img"* ]]; then
|
||||
print_output "[+] Identified D-Link encrpted_img encrpyted firmware - using D-Link extraction module"
|
||||
export DLINK_ENC_DETECTED=2
|
||||
write_csv_log "D-Link encrpted_img encrypted" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"u-boot legacy uImage"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"u-boot legacy uImage"* ]]; then
|
||||
print_output "[+] Identified u-boot firmware image"
|
||||
export UBOOT_IMAGE=1
|
||||
write_csv_log "Uboot image" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"Unix Fast File system [v2]"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"Unix Fast File system [v2]"* ]]; then
|
||||
print_output "[+] Identified UFS filesytem - using UFS filesytem extraction module"
|
||||
export BSD_UFS=1
|
||||
write_csv_log "BSD UFS filesystem" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"Linux rev 1.0 ext2 filesystem data"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"Linux rev 1.0 ext2 filesystem data"* ]]; then
|
||||
print_output "[+] Identified Linux ext2 filesytem - using EXT filesytem extraction module"
|
||||
export EXT_IMAGE=1
|
||||
write_csv_log "EXT2 filesystem" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"Linux rev 1.0 ext3 filesystem data"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"Linux rev 1.0 ext3 filesystem data"* ]]; then
|
||||
print_output "[+] Identified Linux ext3 filesytem - using EXT filesytem extraction module"
|
||||
export EXT_IMAGE=1
|
||||
write_csv_log "EXT3 filesystem" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"Linux rev 1.0 ext4 filesystem data"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"Linux rev 1.0 ext4 filesystem data"* ]]; then
|
||||
print_output "[+] Identified Linux ext4 filesytem - using EXT filesytem extraction module"
|
||||
export EXT_IMAGE=1
|
||||
write_csv_log "EXT4 filesystem" "yes" "NA"
|
||||
fi
|
||||
if [[ "$QNAP_ENC_CHECK" == *"QNAP encrypted firmware footer , model"* ]]; then
|
||||
if [[ "${QNAP_ENC_CHECK}" == *"QNAP encrypted firmware footer , model"* ]]; then
|
||||
print_output "[+] Identified QNAP encrpyted firmware - using QNAP extraction module"
|
||||
export QNAP_ENC_DETECTED=1
|
||||
write_csv_log "QNAP encrypted filesystem" "yes" "NA"
|
||||
fi
|
||||
# probably we need to take a deeper look to identify the gpg compressed firmware files better.
|
||||
# Currently this detection mechanism works quite good on the known firmware images
|
||||
if [[ "$DLINK_ENC_CHECK" =~ 00000000\ \ a3\ 01\ ]]; then
|
||||
GPG_CHECK="$(gpg --list-packets "$FIRMWARE_PATH" | grep "compressed packet:" || true)"
|
||||
if [[ "$GPG_CHECK" == *"compressed packet: algo="* ]]; then
|
||||
if [[ "${DLINK_ENC_CHECK}" =~ 00000000\ \ a3\ 01\ ]]; then
|
||||
GPG_CHECK="$(gpg --list-packets "${FIRMWARE_PATH}" | grep "compressed packet:" || true)"
|
||||
if [[ "${GPG_CHECK}" == *"compressed packet: algo="* ]]; then
|
||||
print_output "[+] Identified GPG compressed firmware - using GPG extraction module"
|
||||
export GPG_COMPRESS=1
|
||||
write_csv_log "GPG compressed firmware" "yes" "NA"
|
||||
fi
|
||||
fi
|
||||
if [[ "$DLINK_ENC_CHECK" == *"CrAU"* ]]; then
|
||||
if [[ "${DLINK_ENC_CHECK}" == *"CrAU"* ]]; then
|
||||
print_output "[+] Identified Android OTA payload.bin update file - using Android extraction module"
|
||||
export ANDROID_OTA=1
|
||||
write_csv_log "Android OTA update" "yes" "NA"
|
||||
fi
|
||||
if [[ "$FILE_BIN_OUT" == *"openssl enc'd data with salted password"* ]]; then
|
||||
if [[ "${FILE_BIN_OUT}" == *"openssl enc'd data with salted password"* ]]; then
|
||||
print_output "[+] Identified OpenSSL encrypted file - trying OpenSSL module for Foscam firmware"
|
||||
export OPENSSL_ENC_DETECTED=1
|
||||
write_csv_log "OpenSSL encrypted" "yes" "NA"
|
||||
fi
|
||||
# This check is currently only tested on one firmware - further tests needed:
|
||||
if [[ "$DLINK_ENC_CHECK" =~ 00000000\ \ 62\ 67\ 6e\ 00\ 00\ 00\ 00\ 00\ \ 00\ 00\ 00\ ]]; then
|
||||
if [[ "${DLINK_ENC_CHECK}" =~ 00000000\ \ 62\ 67\ 6e\ 00\ 00\ 00\ 00\ 00\ \ 00\ 00\ 00\ ]]; then
|
||||
print_output "[+] Identified Buffalo encrpyted firmware - using Buffalo extraction module"
|
||||
export BUFFALO_ENC_DETECTED=1
|
||||
write_csv_log "Buffalo encrypted" "yes" "NA"
|
||||
fi
|
||||
if [[ "$(basename "$CHECK_FILE")" =~ .*\.ri ]] && [[ "$FILE_BIN_OUT" == *"data"* ]]; then
|
||||
if [[ "$(basename "${CHECK_FILE}")" =~ .*\.ri ]] && [[ "${FILE_BIN_OUT}" == *"data"* ]]; then
|
||||
# ri files are usually used by zyxel
|
||||
if [[ $(find "$LOG_DIR"/firmware -name "$(basename -s .ri "$CHECK_FILE")".bin | wc -l) -gt 0 ]]; then
|
||||
if [[ $(find "${LOG_DIR}"/firmware -name "$(basename -s .ri "${CHECK_FILE}")".bin | wc -l) -gt 0 ]]; then
|
||||
# if we find a bin file with the same name then it is a Zyxel firmware image
|
||||
print_output "[+] Identified ZyXel encrpyted ZIP firmware - using ZyXel extraction module"
|
||||
export ZYXEL_ZIP=1
|
||||
@@ -315,22 +315,22 @@ fw_bin_detector() {
|
||||
}
|
||||
|
||||
backup_p02_vars() {
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
backup_var "UEFI_DETECTED" "$UEFI_DETECTED"
|
||||
backup_var "AVM_DETECTED" "$AVM_DETECTED"
|
||||
backup_var "PATOOLS_INIT" "$PATOOLS_INIT"
|
||||
backup_var "VMDK_DETECTED" "$VMDK_DETECTED"
|
||||
backup_var "UBI_IMAGE" "$UBI_IMAGE"
|
||||
backup_var "DLINK_ENC_DETECTED" "$DLINK_ENC_DETECTED"
|
||||
backup_var "ENGENIUS_ENC_DETECTED" "$ENGENIUS_ENC_DETECTED"
|
||||
backup_var "UBOOT_IMAGE" "$UBOOT_IMAGE"
|
||||
backup_var "BSD_UFS" "$BSD_UFS"
|
||||
backup_var "EXT_IMAGE" "$EXT_IMAGE"
|
||||
backup_var "QNAP_ENC_DETECTED" "$QNAP_ENC_DETECTED"
|
||||
backup_var "GPG_COMPRESS" "$GPG_COMPRESS"
|
||||
backup_var "ANDROID_OTA" "$ANDROID_OTA"
|
||||
backup_var "OPENSSL_ENC_DETECTED" "$OPENSSL_ENC_DETECTED"
|
||||
backup_var "BUFFALO_ENC_DETECTED" "$BUFFALO_ENC_DETECTED"
|
||||
backup_var "ZYXEL_ZIP" "$ZYXEL_ZIP"
|
||||
backup_var "QCOW_DETECTED" "$QCOW_DETECTED"
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
backup_var "UEFI_DETECTED" "${UEFI_DETECTED}"
|
||||
backup_var "AVM_DETECTED" "${AVM_DETECTED}"
|
||||
backup_var "PATOOLS_INIT" "${PATOOLS_INIT}"
|
||||
backup_var "VMDK_DETECTED" "${VMDK_DETECTED}"
|
||||
backup_var "UBI_IMAGE" "${UBI_IMAGE}"
|
||||
backup_var "DLINK_ENC_DETECTED" "${DLINK_ENC_DETECTED}"
|
||||
backup_var "ENGENIUS_ENC_DETECTED" "${ENGENIUS_ENC_DETECTED}"
|
||||
backup_var "UBOOT_IMAGE" "${UBOOT_IMAGE}"
|
||||
backup_var "BSD_UFS" "${BSD_UFS}"
|
||||
backup_var "EXT_IMAGE" "${EXT_IMAGE}"
|
||||
backup_var "QNAP_ENC_DETECTED" "${QNAP_ENC_DETECTED}"
|
||||
backup_var "GPG_COMPRESS" "${GPG_COMPRESS}"
|
||||
backup_var "ANDROID_OTA" "${ANDROID_OTA}"
|
||||
backup_var "OPENSSL_ENC_DETECTED" "${OPENSSL_ENC_DETECTED}"
|
||||
backup_var "BUFFALO_ENC_DETECTED" "${BUFFALO_ENC_DETECTED}"
|
||||
backup_var "ZYXEL_ZIP" "${ZYXEL_ZIP}"
|
||||
backup_var "QCOW_DETECTED" "${QCOW_DETECTED}"
|
||||
}
|
||||
|
||||
+26
-26
@@ -19,23 +19,23 @@ export PRE_THREAD_ENA=0
|
||||
P05_patools_init() {
|
||||
local NEG_LOG=0
|
||||
|
||||
if [[ "$PATOOLS_INIT" -eq 1 ]]; then
|
||||
if [[ "${PATOOLS_INIT}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Initial extractor of different archive types via patools"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/patool_extraction/
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/patool_extraction/
|
||||
|
||||
patools_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
patools_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
|
||||
if [[ "$FILES_PATOOLS" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ "${FILES_PATOOLS}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -48,50 +48,50 @@ patools_extractor() {
|
||||
local DIRS_PATOOLS=0
|
||||
local FIRMWARE_NAME_=""
|
||||
|
||||
if ! [[ -f "$FIRMWARE_PATH_" ]]; then
|
||||
if ! [[ -f "${FIRMWARE_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
FIRMWARE_NAME_="$(basename "$FIRMWARE_PATH_")"
|
||||
FIRMWARE_NAME_="$(basename "${FIRMWARE_PATH_}")"
|
||||
|
||||
[[ "$STRICT_MODE" -eq 1 ]] && set +e
|
||||
[[ "${STRICT_MODE}" -eq 1 ]] && set +e
|
||||
|
||||
patool -v test "$FIRMWARE_PATH_" | tee -a "$LOG_PATH_MODULE"/paextract_test_"$FIRMWARE_NAME_".log
|
||||
patool -v test "${FIRMWARE_PATH_}" | tee -a "${LOG_PATH_MODULE}"/paextract_test_"${FIRMWARE_NAME_}".log
|
||||
|
||||
[[ "$STRICT_MODE" -eq 1 ]] && set -e
|
||||
[[ "${STRICT_MODE}" -eq 1 ]] && set -e
|
||||
|
||||
cat "$LOG_PATH_MODULE"/paextract_test_"$FIRMWARE_NAME_".log >> "$LOG_FILE"
|
||||
cat "${LOG_PATH_MODULE}"/paextract_test_"${FIRMWARE_NAME_}".log >> "${LOG_FILE}"
|
||||
|
||||
if ! [[ -d "$EXTRACTION_DIR_" ]]; then
|
||||
mkdir "$EXTRACTION_DIR_"
|
||||
if ! [[ -d "${EXTRACTION_DIR_}" ]]; then
|
||||
mkdir "${EXTRACTION_DIR_}"
|
||||
fi
|
||||
|
||||
if grep -q "patool: ... tested ok." "$LOG_PATH_MODULE"/paextract_test_"$FIRMWARE_NAME_".log ; then
|
||||
if grep -q "patool: ... tested ok." "${LOG_PATH_MODULE}"/paextract_test_"${FIRMWARE_NAME_}".log ; then
|
||||
|
||||
print_ln
|
||||
print_output "[*] Valid compressed file detected - extraction process via patool started"
|
||||
|
||||
patool -v extract "$FIRMWARE_PATH_" --outdir "$EXTRACTION_DIR_" | tee -a "$LOG_PATH_MODULE"/paextract_extract_"$FIRMWARE_NAME_".log
|
||||
cat "$LOG_PATH_MODULE"/paextract_extract_"$FIRMWARE_NAME_".log >> "$LOG_FILE"
|
||||
patool -v extract "${FIRMWARE_PATH_}" --outdir "${EXTRACTION_DIR_}" | tee -a "${LOG_PATH_MODULE}"/paextract_extract_"${FIRMWARE_NAME_}".log
|
||||
cat "${LOG_PATH_MODULE}"/paextract_extract_"${FIRMWARE_NAME_}".log >> "${LOG_FILE}"
|
||||
|
||||
else
|
||||
# Fallback if unzip does not work:
|
||||
print_ln
|
||||
print_output "[*] No valid compressed file detected - extraction process via unblob started"
|
||||
|
||||
unblobber "$FIRMWARE_PATH_" "$EXTRACTION_DIR_"
|
||||
unblobber "${FIRMWARE_PATH_}" "${EXTRACTION_DIR_}"
|
||||
fi
|
||||
|
||||
print_ln
|
||||
print_output "[*] Using the following firmware directory ($ORANGE$EXTRACTION_DIR_$NC) as base directory:"
|
||||
find "$EXTRACTION_DIR_" -xdev -maxdepth 1 -ls | tee -a "$LOG_FILE"
|
||||
print_output "[*] Using the following firmware directory (${ORANGE}${EXTRACTION_DIR_}${NC}) as base directory:"
|
||||
find "${EXTRACTION_DIR_}" -xdev -maxdepth 1 -ls | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
|
||||
FILES_PATOOLS=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
DIRS_PATOOLS=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_PATOOLS$NC files and $ORANGE$DIRS_PATOOLS$NC directories from the firmware image."
|
||||
FILES_PATOOLS=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
DIRS_PATOOLS=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_PATOOLS}${NC} files and ${ORANGE}${DIRS_PATOOLS}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "Patool extractor" "$FIRMWARE_PATH_" "$EXTRACTION_DIR_" "$FILES_PATOOLS" "$DIRS_PATOOLS" "NA"
|
||||
write_csv_log "Patool extractor" "${FIRMWARE_PATH_}" "${EXTRACTION_DIR_}" "${FILES_PATOOLS}" "${DIRS_PATOOLS}" "NA"
|
||||
print_ln
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ P10_vmdk_extractor() {
|
||||
if [[ "${VMDK_DETECTED-0}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "VMDK (Virtual Machine Disk) extractor"
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/vmdk_extractor/
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/vmdk_extractor/
|
||||
|
||||
vmdk_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
vmdk_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
|
||||
if [[ "$VMDK_FILES" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ "${VMDK_FILES}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -41,67 +41,67 @@ vmdk_extractor() {
|
||||
local EXTRACTION_DIR_="${2:-}"
|
||||
local MOUNT_DEV=""
|
||||
local DEV_NAME=""
|
||||
local TMP_VMDK_MNT="$TMP_DIR/vmdk_mount_$RANDOM"
|
||||
local TMP_VMDK_MNT="${TMP_DIR}/vmdk_mount_${RANDOM}"
|
||||
local VMDK_DIRS=0
|
||||
local RET=0
|
||||
VMDK_FILES=0
|
||||
|
||||
if ! [[ -f "$VMDK_PATH_" ]]; then
|
||||
if ! [[ -f "${VMDK_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "VMDK (Virtual Machine Disk) extractor"
|
||||
|
||||
print_output "[*] Enumeration of devices in VMDK images $ORANGE$VMDK_PATH_$NC"
|
||||
disable_strict_mode "$STRICT_MODE" 0
|
||||
virt-filesystems -a "$VMDK_PATH_" > "$TMP_DIR"/vmdk.log
|
||||
print_output "[*] Enumeration of devices in VMDK images ${ORANGE}${VMDK_PATH_}${NC}"
|
||||
disable_strict_mode "${STRICT_MODE}" 0
|
||||
virt-filesystems -a "${VMDK_PATH_}" > "${TMP_DIR}"/vmdk.log
|
||||
RET="$?"
|
||||
|
||||
if [[ "$RET" -ne 0 ]]; then
|
||||
if [[ "${RET}" -ne 0 ]]; then
|
||||
# backup with 7z
|
||||
7z x -o"$EXTRACTION_DIR_" "$VMDK_PATH_"
|
||||
7z x -o"${EXTRACTION_DIR_}" "${VMDK_PATH_}"
|
||||
RET="$?"
|
||||
if [[ "$RET" -ne 0 ]]; then
|
||||
if [[ "${RET}" -ne 0 ]]; then
|
||||
print_output "[-] WARNING: VMDK filesystem not enumerated"
|
||||
enable_strict_mode "$STRICT_MODE" 0
|
||||
enable_strict_mode "${STRICT_MODE}" 0
|
||||
return
|
||||
fi
|
||||
else
|
||||
mapfile -t VMDK_VIRT_FS < "$TMP_DIR"/vmdk.log
|
||||
mapfile -t VMDK_VIRT_FS < "${TMP_DIR}"/vmdk.log
|
||||
for MOUNT_DEV in "${VMDK_VIRT_FS[@]}"; do
|
||||
print_output "[*] Found device $ORANGE$MOUNT_DEV$NC"
|
||||
print_output "[*] Found device ${ORANGE}${MOUNT_DEV}${NC}"
|
||||
done
|
||||
fi
|
||||
enable_strict_mode "$STRICT_MODE" 0
|
||||
enable_strict_mode "${STRICT_MODE}" 0
|
||||
|
||||
mkdir -p "$TMP_VMDK_MNT" || true
|
||||
mkdir -p "${TMP_VMDK_MNT}" || true
|
||||
|
||||
for MOUNT_DEV in "${VMDK_VIRT_FS[@]}"; do
|
||||
DEV_NAME=$(basename "$MOUNT_DEV")
|
||||
print_output "[*] Trying to mount $ORANGE$MOUNT_DEV$NC to $ORANGE$TMP_VMDK_MNT$NC directory"
|
||||
DEV_NAME=$(basename "${MOUNT_DEV}")
|
||||
print_output "[*] Trying to mount ${ORANGE}${MOUNT_DEV}${NC} to ${ORANGE}${TMP_VMDK_MNT}${NC} directory"
|
||||
# if troubles ahead with vmdk mount, remove the error redirection
|
||||
guestmount -a "$VMDK_PATH_" -m "$MOUNT_DEV" --ro "$TMP_VMDK_MNT" 2>/dev/null || true
|
||||
guestmount -a "${VMDK_PATH_}" -m "${MOUNT_DEV}" --ro "${TMP_VMDK_MNT}" 2>/dev/null || true
|
||||
if mount | grep -q vmdk_mount; then
|
||||
print_output "[*] Copying $ORANGE$MOUNT_DEV$NC to firmware directory $ORANGE$EXTRACTION_DIR_/$DEV_NAME$NC"
|
||||
mkdir -p "$EXTRACTION_DIR_"/"$DEV_NAME"/ || true
|
||||
cp -pri "$TMP_VMDK_MNT"/* "$EXTRACTION_DIR_"/"$DEV_NAME"/ || true
|
||||
umount "$TMP_VMDK_MNT"
|
||||
print_output "[*] Copying ${ORANGE}${MOUNT_DEV}${NC} to firmware directory ${ORANGE}${EXTRACTION_DIR_}/${DEV_NAME}${NC}"
|
||||
mkdir -p "${EXTRACTION_DIR_}"/"${DEV_NAME}"/ || true
|
||||
cp -pri "${TMP_VMDK_MNT}"/* "${EXTRACTION_DIR_}"/"${DEV_NAME}"/ || true
|
||||
umount "${TMP_VMDK_MNT}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -d "$EXTRACTION_DIR_" ]]; then
|
||||
VMDK_FILES=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
VMDK_DIRS=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
if [[ -d "${EXTRACTION_DIR_}" ]]; then
|
||||
VMDK_FILES=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
VMDK_DIRS=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
fi
|
||||
|
||||
if [[ "$VMDK_FILES" -gt 0 ]]; then
|
||||
if [[ "${VMDK_FILES}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[*] Extracted $ORANGE$VMDK_FILES$NC files and $ORANGE$VMDK_DIRS$NC directories from the firmware image."
|
||||
print_output "[*] Extracted ${ORANGE}${VMDK_FILES}${NC} files and ${ORANGE}${VMDK_DIRS}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "VMDK extractor" "$VMDK_PATH_" "$EXTRACTION_DIR_" "$VMDK_FILES" "$VMDK_DIRS" "NA"
|
||||
write_csv_log "VMDK extractor" "${VMDK_PATH_}" "${EXTRACTION_DIR_}" "${VMDK_FILES}" "${VMDK_DIRS}" "NA"
|
||||
# currently unblob has issues with VMDKs. We need to disable it for this extraction process
|
||||
safe_echo 0 > "$TMP_DIR"/unblob_disable.cfg
|
||||
safe_echo 0 > "${TMP_DIR}"/unblob_disable.cfg
|
||||
fi
|
||||
rm -r "$TMP_VMDK_MNT" || true
|
||||
rm -r "${TMP_VMDK_MNT}" || true
|
||||
}
|
||||
|
||||
+26
-26
@@ -18,60 +18,60 @@ export PRE_THREAD_ENA=0
|
||||
|
||||
P14_ext_mounter() {
|
||||
local NEG_LOG=0
|
||||
if [[ "$EXT_IMAGE" -eq 1 ]]; then
|
||||
if [[ "${EXT_IMAGE}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "EXT filesystem extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
print_output "[*] Connect to device $ORANGE$FIRMWARE_PATH$NC"
|
||||
print_output "[*] Connect to device ${ORANGE}${FIRMWARE_PATH}${NC}"
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/ext_mount_filesystem/
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/ext_mount_filesystem/
|
||||
|
||||
ext_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
ext_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
|
||||
if [[ "$FILES_EXT_MOUNT" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ "${FILES_EXT_MOUNT}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
ext_extractor() {
|
||||
local EXT_PATH_="${1:-}"
|
||||
local EXTRACTION_DIR_="${2:-}"
|
||||
local TMP_EXT_MOUNT="$TMP_DIR""/ext_mount_$RANDOM"
|
||||
local TMP_EXT_MOUNT="${TMP_DIR}""/ext_mount_${RANDOM}"
|
||||
local DIRS_EXT_MOUNT=0
|
||||
FILES_EXT_MOUNT=0
|
||||
|
||||
if ! [[ -f "$EXT_PATH_" ]]; then
|
||||
if ! [[ -f "${EXT_PATH_}" ]]; then
|
||||
print_output "[-] No file for decryption provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "EXT filesystem extractor"
|
||||
|
||||
mkdir -p "$TMP_EXT_MOUNT" || true
|
||||
print_output "[*] Trying to mount $ORANGE$EXT_PATH_$NC to $ORANGE$TMP_EXT_MOUNT$NC directory"
|
||||
mount -o ro "$EXT_PATH_" "$TMP_EXT_MOUNT"
|
||||
mkdir -p "${TMP_EXT_MOUNT}" || true
|
||||
print_output "[*] Trying to mount ${ORANGE}${EXT_PATH_}${NC} to ${ORANGE}${TMP_EXT_MOUNT}${NC} directory"
|
||||
mount -o ro "${EXT_PATH_}" "${TMP_EXT_MOUNT}"
|
||||
if mount | grep -q ext_mount; then
|
||||
print_output "[*] Copying $ORANGE$TMP_EXT_MOUNT$NC to firmware tmp directory ($EXTRACTION_DIR_)"
|
||||
mkdir -p "$EXTRACTION_DIR_"
|
||||
cp -pri "$TMP_EXT_MOUNT"/* "$EXTRACTION_DIR_"
|
||||
print_output "[*] Copying ${ORANGE}${TMP_EXT_MOUNT}${NC} to firmware tmp directory (${EXTRACTION_DIR_})"
|
||||
mkdir -p "${EXTRACTION_DIR_}"
|
||||
cp -pri "${TMP_EXT_MOUNT}"/* "${EXTRACTION_DIR_}"
|
||||
print_ln
|
||||
print_output "[*] Using the following firmware directory ($ORANGE$EXTRACTION_DIR_$NC) as base directory:"
|
||||
find "$EXTRACTION_DIR_" -xdev -maxdepth 1 -ls | tee -a "$LOG_FILE"
|
||||
print_output "[*] Using the following firmware directory (${ORANGE}${EXTRACTION_DIR_}${NC}) as base directory:"
|
||||
find "${EXTRACTION_DIR_}" -xdev -maxdepth 1 -ls | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
print_output "[*] Unmounting $ORANGE$TMP_EXT_MOUNT$NC directory"
|
||||
print_output "[*] Unmounting ${ORANGE}${TMP_EXT_MOUNT}${NC} directory"
|
||||
|
||||
FILES_EXT_MOUNT=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
DIRS_EXT_MOUNT=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_EXT_MOUNT$NC files and $ORANGE$DIRS_EXT_MOUNT$NC directories from the firmware image."
|
||||
FILES_EXT_MOUNT=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
DIRS_EXT_MOUNT=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_EXT_MOUNT}${NC} files and ${ORANGE}${DIRS_EXT_MOUNT}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "EXT filesystem extractor" "$EXT_PATH_" "$EXTRACTION_DIR_" "$FILES_EXT_MOUNT" "$DIRS_EXT_MOUNT" "NA"
|
||||
umount "$TMP_EXT_MOUNT" || true
|
||||
write_csv_log "EXT filesystem extractor" "${EXT_PATH_}" "${EXTRACTION_DIR_}" "${FILES_EXT_MOUNT}" "${DIRS_EXT_MOUNT}" "NA"
|
||||
umount "${TMP_EXT_MOUNT}" || true
|
||||
fi
|
||||
rm -r "$TMP_EXT_MOUNT"
|
||||
rm -r "${TMP_EXT_MOUNT}"
|
||||
}
|
||||
|
||||
@@ -18,23 +18,23 @@ export PRE_THREAD_ENA=0
|
||||
|
||||
P15_ubi_extractor() {
|
||||
local NEG_LOG=0
|
||||
if [[ "$UBI_IMAGE" -eq 1 ]]; then
|
||||
if [[ "${UBI_IMAGE}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "UBI filesystem extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR/firmware/ubi_extracted"
|
||||
mkdir -p "$EXTRACTION_DIR" || true
|
||||
EXTRACTION_DIR="${LOG_DIR}/firmware/ubi_extracted"
|
||||
mkdir -p "${EXTRACTION_DIR}" || true
|
||||
|
||||
ubi_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
ubi_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
|
||||
if [[ "$FILES_UBI_EXT" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ "${FILES_UBI_EXT}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -47,49 +47,49 @@ ubi_extractor() {
|
||||
local UBI_DATA=""
|
||||
local DIRS_UBI_EXT=0
|
||||
FILES_UBI_EXT=0
|
||||
if ! [[ -f "$UBI_PATH_" ]]; then
|
||||
if ! [[ -f "${UBI_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "UBI filesystem extractor"
|
||||
|
||||
print_output "[*] Extracts UBI firmware image $ORANGE$UBI_PATH_$NC with ${ORANGE}ubireader_extract_images$NC."
|
||||
print_output "[*] File details: $ORANGE$(file "$UBI_PATH_" | cut -d ':' -f2-)$NC"
|
||||
ubireader_extract_images -i -v -w -o "$EXTRACTION_DIR_"/ubi_images "$UBI_PATH_" | tee -a "$LOG_FILE" || true
|
||||
FILES_UBI_EXT=$(find "$EXTRACTION_DIR_"/ubi_images -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "$EXTRACTION_DIR_"/ubi_images -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_UBI_EXT$NC files and $ORANGE$DIRS_UBI_EXT$NC directories from the firmware image via UBI extraction round 1."
|
||||
print_output "[*] Extracts UBI firmware image ${ORANGE}${UBI_PATH_}${NC} with ${ORANGE}ubireader_extract_images${NC}."
|
||||
print_output "[*] File details: ${ORANGE}$(file "${UBI_PATH_}" | cut -d ':' -f2-)${NC}"
|
||||
ubireader_extract_images -i -v -w -o "${EXTRACTION_DIR_}"/ubi_images "${UBI_PATH_}" | tee -a "${LOG_FILE}" || true
|
||||
FILES_UBI_EXT=$(find "${EXTRACTION_DIR_}"/ubi_images -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "${EXTRACTION_DIR_}"/ubi_images -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_UBI_EXT}${NC} files and ${ORANGE}${DIRS_UBI_EXT}${NC} directories from the firmware image via UBI extraction round 1."
|
||||
|
||||
print_output "[*] Extracts UBI firmware image $ORANGE$UBI_PATH_$NC with ${ORANGE}ubireader_extract_files$NC."
|
||||
ubireader_extract_files -i -v -w -o "$EXTRACTION_DIR_"/ubi_files "$UBI_PATH_" | tee -a "$LOG_FILE" || true
|
||||
FILES_UBI_EXT=$(find "$EXTRACTION_DIR_"/ubi_files -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "$EXTRACTION_DIR_"/ubi_files -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_UBI_EXT$NC files and $ORANGE$DIRS_UBI_EXT$NC directories from the firmware image via UBI extraction round 2."
|
||||
print_output "[*] Extracts UBI firmware image ${ORANGE}${UBI_PATH_}${NC} with ${ORANGE}ubireader_extract_files${NC}."
|
||||
ubireader_extract_files -i -v -w -o "${EXTRACTION_DIR_}"/ubi_files "${UBI_PATH_}" | tee -a "${LOG_FILE}" || true
|
||||
FILES_UBI_EXT=$(find "${EXTRACTION_DIR_}"/ubi_files -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "${EXTRACTION_DIR_}"/ubi_files -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_UBI_EXT}${NC} files and ${ORANGE}${DIRS_UBI_EXT}${NC} directories from the firmware image via UBI extraction round 2."
|
||||
|
||||
if [[ -d "$EXTRACTION_DIR_" ]]; then
|
||||
mapfile -t UBI_1st_ROUND < <(find "$EXTRACTION_DIR_" -type f -exec file {} \; | grep "UBI image" || true)
|
||||
if [[ -d "${EXTRACTION_DIR_}" ]]; then
|
||||
mapfile -t UBI_1st_ROUND < <(find "${EXTRACTION_DIR_}" -type f -exec file {} \; | grep "UBI image" || true)
|
||||
|
||||
for UBI_DATA in "${UBI_1st_ROUND[@]}"; do
|
||||
UBI_FILE=$(safe_echo "$UBI_DATA" | cut -d: -f1)
|
||||
UBI_INFO=$(safe_echo "$UBI_DATA" | cut -d: -f2)
|
||||
if [[ "$UBI_INFO" == *"UBIfs image"* ]]; then
|
||||
UBI_FILE=$(safe_echo "${UBI_DATA}" | cut -d: -f1)
|
||||
UBI_INFO=$(safe_echo "${UBI_DATA}" | cut -d: -f2)
|
||||
if [[ "${UBI_INFO}" == *"UBIfs image"* ]]; then
|
||||
sub_module_title "UBIfs deep extraction"
|
||||
print_output "[*] Extracts UBIfs firmware image $ORANGE$UBI_PATH_$NC with ${ORANGE}ubireader_extract_files$NC."
|
||||
print_output "[*] File details: $ORANGE$(file "$UBI_FILE" | cut -d ':' -f2-)$NC"
|
||||
ubireader_extract_files -l -i -w -v -o "$EXTRACTION_DIR_"/UBIfs_extracted "$UBI_FILE" | tee -a "$LOG_FILE" || true
|
||||
FILES_UBI_EXT=$(find "$EXTRACTION_DIR_"/UBIfs_extracted -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "$EXTRACTION_DIR_"/UBIfs_extracted -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_UBI_EXT$NC files and $ORANGE$DIRS_UBI_EXT$NC directories from the firmware image via UBI deep extraction."
|
||||
print_output "[*] Extracts UBIfs firmware image ${ORANGE}${UBI_PATH_}${NC} with ${ORANGE}ubireader_extract_files${NC}."
|
||||
print_output "[*] File details: ${ORANGE}$(file "${UBI_FILE}" | cut -d ':' -f2-)${NC}"
|
||||
ubireader_extract_files -l -i -w -v -o "${EXTRACTION_DIR_}"/UBIfs_extracted "${UBI_FILE}" | tee -a "${LOG_FILE}" || true
|
||||
FILES_UBI_EXT=$(find "${EXTRACTION_DIR_}"/UBIfs_extracted -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "${EXTRACTION_DIR_}"/UBIfs_extracted -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_UBI_EXT}${NC} files and ${ORANGE}${DIRS_UBI_EXT}${NC} directories from the firmware image via UBI deep extraction."
|
||||
fi
|
||||
done
|
||||
|
||||
print_ln
|
||||
FILES_UBI_EXT=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_UBI_EXT$NC files and $ORANGE$DIRS_UBI_EXT$NC directories from the firmware image."
|
||||
FILES_UBI_EXT=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
DIRS_UBI_EXT=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_UBI_EXT}${NC} files and ${ORANGE}${DIRS_UBI_EXT}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "UBI filesystem extractor" "$UBI_PATH_" "$EXTRACTION_DIR_" "$FILES_UBI_EXT" "$DIRS_UBI_EXT" "NA"
|
||||
write_csv_log "UBI filesystem extractor" "${UBI_PATH_}" "${EXTRACTION_DIR_}" "${FILES_UBI_EXT}" "${DIRS_UBI_EXT}" "NA"
|
||||
else
|
||||
print_output "[-] First round UBI extractor failed!"
|
||||
fi
|
||||
|
||||
@@ -21,17 +21,17 @@ export PRE_THREAD_ENA=0
|
||||
P17_gpg_decompress() {
|
||||
local NEG_LOG=0
|
||||
|
||||
if [[ "$GPG_COMPRESS" -eq 1 ]]; then
|
||||
if [[ "${GPG_COMPRESS}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "GPG compressed firmware extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTION_FILE="$LOG_DIR"/firmware/firmware_gpg_dec.bin
|
||||
EXTRACTION_FILE="${LOG_DIR}"/firmware/firmware_gpg_dec.bin
|
||||
|
||||
gpg_decompress_extractor "$FIRMWARE_PATH" "$EXTRACTION_FILE"
|
||||
gpg_decompress_extractor "${FIRMWARE_PATH}" "${EXTRACTION_FILE}"
|
||||
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -39,26 +39,26 @@ gpg_decompress_extractor() {
|
||||
local GPG_FILE_PATH_="${1:-}"
|
||||
local EXTRACTION_FILE_="${2:-}"
|
||||
|
||||
if ! [[ -f "$GPG_FILE_PATH_" ]]; then
|
||||
if ! [[ -f "${GPG_FILE_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "GPG compressed firmware extractor"
|
||||
|
||||
gpg --list-packets "$GPG_FILE_PATH_" 2>/dev/null | tee -a "$LOG_FILE"
|
||||
gpg --decrypt "$GPG_FILE_PATH_" > "$EXTRACTION_FILE_" || true
|
||||
gpg --list-packets "${GPG_FILE_PATH_}" 2>/dev/null | tee -a "${LOG_FILE}"
|
||||
gpg --decrypt "${GPG_FILE_PATH_}" > "${EXTRACTION_FILE_}" || true
|
||||
|
||||
print_ln
|
||||
if [[ -f "$EXTRACTION_FILE_" ]]; then
|
||||
print_output "[+] Extracted GPG compressed firmware file to $ORANGE$EXTRACTION_FILE_$NC"
|
||||
export FIRMWARE_PATH="$EXTRACTION_FILE_"
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ -f "${EXTRACTION_FILE_}" ]]; then
|
||||
print_output "[+] Extracted GPG compressed firmware file to ${ORANGE}${EXTRACTION_FILE_}${NC}"
|
||||
export FIRMWARE_PATH="${EXTRACTION_FILE_}"
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
print_ln
|
||||
print_output "[*] Firmware file details: $ORANGE$(file "$EXTRACTION_FILE_")$NC"
|
||||
unblobber "$EXTRACTION_FILE_" "$LOG_DIR"/firmware/firmware_gpg_extracted
|
||||
print_output "[*] Firmware file details: ${ORANGE}$(file "${EXTRACTION_FILE_}")${NC}"
|
||||
unblobber "${EXTRACTION_FILE_}" "${LOG_DIR}"/firmware/firmware_gpg_extracted
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "GPG decompression" "$GPG_FILE_PATH_" "$EXTRACTION_FILE_" "1" "NA" "NA"
|
||||
write_csv_log "GPG decompression" "${GPG_FILE_PATH_}" "${EXTRACTION_FILE_}" "1" "NA" "NA"
|
||||
else
|
||||
print_output "[-] Extraction of GPG compressed firmware file failed"
|
||||
fi
|
||||
|
||||
@@ -18,62 +18,62 @@ export PRE_THREAD_ENA=0
|
||||
|
||||
P19_bsd_ufs_mounter() {
|
||||
local NEG_LOG=0
|
||||
if [[ "$BSD_UFS" -eq 1 ]]; then
|
||||
if [[ "${BSD_UFS}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "BSD UFS filesystem extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
print_output "[*] Connect to device $ORANGE$FIRMWARE_PATH$NC"
|
||||
print_output "[*] Connect to device ${ORANGE}${FIRMWARE_PATH}${NC}"
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/ufs_mount_filesystem/
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/ufs_mount_filesystem/
|
||||
|
||||
ufs_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
ufs_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
|
||||
if [[ "$FILES_UFS_MOUNT" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ "${FILES_UFS_MOUNT}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
ufs_extractor() {
|
||||
local UFS_PATH_="${1:-}"
|
||||
local EXTRACTION_DIR_="${2:-}"
|
||||
local TMP_UFS_MOUNT="$TMP_DIR""/ufs_mount_$RANDOM"
|
||||
local TMP_UFS_MOUNT="${TMP_DIR}""/ufs_mount_${RANDOM}"
|
||||
local DIRS_UFS_MOUNT=0
|
||||
FILES_UFS_MOUNT=0
|
||||
|
||||
if ! [[ -f "$UFS_PATH_" ]]; then
|
||||
if ! [[ -f "${UFS_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "UFS filesystem extractor"
|
||||
|
||||
mkdir -p "$TMP_UFS_MOUNT" 2>/dev/null || true
|
||||
print_output "[*] Trying to mount $ORANGE$UFS_PATH_$NC to $ORANGE$TMP_UFS_MOUNT$NC directory"
|
||||
mkdir -p "${TMP_UFS_MOUNT}" 2>/dev/null || true
|
||||
print_output "[*] Trying to mount ${ORANGE}${UFS_PATH_}${NC} to ${ORANGE}${TMP_UFS_MOUNT}${NC} directory"
|
||||
modprobe ufs
|
||||
mount -r -t ufs -o ufstype=ufs2 "$UFS_PATH_" "$TMP_UFS_MOUNT"
|
||||
mount -r -t ufs -o ufstype=ufs2 "${UFS_PATH_}" "${TMP_UFS_MOUNT}"
|
||||
|
||||
if mount | grep -q ufs_mount; then
|
||||
print_output "[*] Copying $ORANGE$TMP_UFS_MOUNT$NC to firmware tmp directory ($ORANGE$EXTRACTION_DIR_$NC)"
|
||||
mkdir -p "$EXTRACTION_DIR_" 2>/dev/null || true
|
||||
cp -pri "$TMP_UFS_MOUNT"/* "$EXTRACTION_DIR_" 2>/dev/null || true
|
||||
print_output "[*] Copying ${ORANGE}${TMP_UFS_MOUNT}${NC} to firmware tmp directory (${ORANGE}${EXTRACTION_DIR_}${NC})"
|
||||
mkdir -p "${EXTRACTION_DIR_}" 2>/dev/null || true
|
||||
cp -pri "${TMP_UFS_MOUNT}"/* "${EXTRACTION_DIR_}" 2>/dev/null || true
|
||||
print_ln
|
||||
print_output "[*] Using the following firmware directory ($ORANGE$EXTRACTION_DIR_$NC) as base directory:"
|
||||
find "$EXTRACTION_DIR_" -xdev -maxdepth 1 -ls | tee -a "$LOG_FILE"
|
||||
print_output "[*] Using the following firmware directory (${ORANGE}${EXTRACTION_DIR_}${NC}) as base directory:"
|
||||
find "${EXTRACTION_DIR_}" -xdev -maxdepth 1 -ls | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
print_output "[*] Unmounting $ORANGE$TMP_UFS_MOUNT$NC directory"
|
||||
print_output "[*] Unmounting ${ORANGE}${TMP_UFS_MOUNT}${NC} directory"
|
||||
|
||||
FILES_UFS_MOUNT=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
DIRS_UFS_MOUNT=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_UFS_MOUNT$NC files and $ORANGE$DIRS_UFS_MOUNT$NC directories from the firmware image."
|
||||
FILES_UFS_MOUNT=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
DIRS_UFS_MOUNT=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_UFS_MOUNT}${NC} files and ${ORANGE}${DIRS_UFS_MOUNT}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "UFS filesystem extractor" "$UFS_PATH_" "$EXTRACTION_DIR_" "$FILES_UFS_MOUNT" "$DIRS_UFS_MOUNT" "NA"
|
||||
umount "$TMP_UFS_MOUNT" 2>/dev/null || true
|
||||
write_csv_log "UFS filesystem extractor" "${UFS_PATH_}" "${EXTRACTION_DIR_}" "${FILES_UFS_MOUNT}" "${DIRS_UFS_MOUNT}" "NA"
|
||||
umount "${TMP_UFS_MOUNT}" 2>/dev/null || true
|
||||
fi
|
||||
rm -r "$TMP_UFS_MOUNT"
|
||||
rm -r "${TMP_UFS_MOUNT}"
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ export PRE_THREAD_ENA=0
|
||||
P20_foscam_decryptor() {
|
||||
local NEG_LOG=0
|
||||
|
||||
if [[ "$OPENSSL_ENC_DETECTED" -ne 0 ]]; then
|
||||
if [[ "${OPENSSL_ENC_DETECTED}" -ne 0 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Foscam encrypted firmware extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTION_FILE="$LOG_DIR"/firmware/firmware_foscam_dec.bin
|
||||
EXTRACTION_FILE="${LOG_DIR}"/firmware/firmware_foscam_dec.bin
|
||||
|
||||
foscam_enc_extractor "$FIRMWARE_PATH" "$EXTRACTION_FILE"
|
||||
foscam_enc_extractor "${FIRMWARE_PATH}" "${EXTRACTION_FILE}"
|
||||
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -40,53 +40,53 @@ foscam_enc_extractor() {
|
||||
local FOSCAM_ENC_PATH_="${1:-}"
|
||||
local EXTRACTION_FILE_="${2:-}"
|
||||
local FOSCAM_FILE_CHECK=""
|
||||
local KEY_FILE="$CONFIG_DIR/foscam_enc_keys.txt"
|
||||
local KEY_FILE="${CONFIG_DIR}/foscam_enc_keys.txt"
|
||||
|
||||
if ! [[ -f "$FOSCAM_ENC_PATH_" ]]; then
|
||||
if ! [[ -f "${FOSCAM_ENC_PATH_}" ]]; then
|
||||
print_output "[-] No file for decryption provided"
|
||||
return
|
||||
fi
|
||||
if ! [[ -f "$KEY_FILE" ]]; then
|
||||
if ! [[ -f "${KEY_FILE}" ]]; then
|
||||
print_output "[-] No key file found in config directory"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "Foscam encrypted firmware extractor"
|
||||
|
||||
hexdump -C "$FOSCAM_ENC_PATH_" | head | tee -a "$LOG_FILE" || true
|
||||
hexdump -C "${FOSCAM_ENC_PATH_}" | head | tee -a "${LOG_FILE}" || true
|
||||
|
||||
mapfile FOSCAM_KEYS < <(grep -v "ID" "$KEY_FILE" | cut -d\; -f2 | tr -d \')
|
||||
mapfile FOSCAM_KEYS < <(grep -v "ID" "${KEY_FILE}" | cut -d\; -f2 | tr -d \')
|
||||
for _FOSCAM_KEY in "${FOSCAM_KEYS[@]}"; do
|
||||
FOSCAM_DECRYTED=0
|
||||
print_output "[*] Testing FOSCAM decryption key $ORANGE$_FOSCAM_KEY$NC."
|
||||
print_output "[*] Testing FOSCAM decryption key ${ORANGE}${_FOSCAM_KEY}${NC}."
|
||||
# shellcheck disable=SC2086
|
||||
openssl enc -d -aes-128-cbc -md md5 -k $_FOSCAM_KEY -in "$FOSCAM_ENC_PATH_" > "$EXTRACTION_FILE_" || true
|
||||
openssl enc -d -aes-128-cbc -md md5 -k ${_FOSCAM_KEY} -in "${FOSCAM_ENC_PATH_}" > "${EXTRACTION_FILE_}" || true
|
||||
|
||||
if [[ -f "$EXTRACTION_FILE_" ]]; then
|
||||
FOSCAM_FILE_CHECK=$(file "$EXTRACTION_FILE_")
|
||||
if [[ "$FOSCAM_FILE_CHECK" =~ .*gzip\ compressed\ data.* ]]; then
|
||||
if [[ -f "${EXTRACTION_FILE_}" ]]; then
|
||||
FOSCAM_FILE_CHECK=$(file "${EXTRACTION_FILE_}")
|
||||
if [[ "${FOSCAM_FILE_CHECK}" =~ .*gzip\ compressed\ data.* ]]; then
|
||||
print_ln
|
||||
print_output "[+] Decrypted Foscam firmware file to $ORANGE$EXTRACTION_FILE_$NC"
|
||||
export FIRMWARE_PATH="$EXTRACTION_FILE_"
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
print_output "[+] Decrypted Foscam firmware file to ${ORANGE}${EXTRACTION_FILE_}${NC}"
|
||||
export FIRMWARE_PATH="${EXTRACTION_FILE_}"
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
print_ln
|
||||
print_output "[*] Firmware file details: $ORANGE$(file "$EXTRACTION_FILE_")$NC"
|
||||
print_output "[*] Firmware file details: ${ORANGE}$(file "${EXTRACTION_FILE_}")${NC}"
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "Foscam decryptor" "$FOSCAM_ENC_PATH_" "$EXTRACTION_FILE_" "1" "NA" "NA"
|
||||
write_csv_log "Foscam decryptor" "${FOSCAM_ENC_PATH_}" "${EXTRACTION_FILE_}" "1" "NA" "NA"
|
||||
FOSCAM_DECRYTED=1
|
||||
if [[ -z "${FW_VENDOR:-}" ]]; then
|
||||
FW_VENDOR="Foscam"
|
||||
fi
|
||||
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FOSCAM_ENC_PATH_" | awk '{print $1}')" )
|
||||
foscam_ubi_extractor "$EXTRACTION_FILE_"
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FOSCAM_ENC_PATH_}" | awk '{print $1}')" )
|
||||
foscam_ubi_extractor "${EXTRACTION_FILE_}"
|
||||
# as we have already found a working key we can now exit the loop
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$FOSCAM_DECRYTED" -ne 1 ]]; then
|
||||
if [[ "${FOSCAM_DECRYTED}" -ne 1 ]]; then
|
||||
print_output "[-] Decryption of Foscam firmware file failed"
|
||||
fi
|
||||
}
|
||||
@@ -97,22 +97,22 @@ foscam_enc_extractor() {
|
||||
foscam_ubi_extractor() {
|
||||
local FIRMWARE_PATH_="${1:-}"
|
||||
local MTD_DEVICE=""
|
||||
local UBI_MNT_PT="$LOG_DIR"/tmp/ubi_mnt_foscam
|
||||
local EXTRACTION_DIR_="$LOG_DIR/firmware/foscam_ubi_extractor"
|
||||
local EXTRACTION_DIR_GZ="$LOG_DIR/firmware/foscam_gz_extractor"
|
||||
local UBI_MNT_PT="${LOG_DIR}"/tmp/ubi_mnt_foscam
|
||||
local EXTRACTION_DIR_="${LOG_DIR}/firmware/foscam_ubi_extractor"
|
||||
local EXTRACTION_DIR_GZ="${LOG_DIR}/firmware/foscam_gz_extractor"
|
||||
local UBI_DEV=""
|
||||
local UBI_DEVS=()
|
||||
FOSCAM_UBI_FILES=0
|
||||
FOSCAM_UBI_DIRS=0
|
||||
|
||||
if ! [[ -f "$FIRMWARE_PATH_" ]]; then
|
||||
if ! [[ -f "${FIRMWARE_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction found"
|
||||
return
|
||||
fi
|
||||
|
||||
print_output "[*] Extracting decrypted firmware to $ORANGE$EXTRACTION_DIR_GZ$NC"
|
||||
mkdir -p "$EXTRACTION_DIR_GZ" || true
|
||||
tar -xzf "$FIRMWARE_PATH_" -C "$EXTRACTION_DIR_GZ" || true
|
||||
print_output "[*] Extracting decrypted firmware to ${ORANGE}${EXTRACTION_DIR_GZ}${NC}"
|
||||
mkdir -p "${EXTRACTION_DIR_GZ}" || true
|
||||
tar -xzf "${FIRMWARE_PATH_}" -C "${EXTRACTION_DIR_GZ}" || true
|
||||
|
||||
# check if we have the kernel modules available - special interest in docker
|
||||
if ! [[ -d "/lib/modules/" ]]; then
|
||||
@@ -120,8 +120,8 @@ foscam_ubi_extractor() {
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$EXTRACTION_DIR_GZ"/app_ubifs ]]; then
|
||||
print_output "[*] 2nd extraction round successful - ${ORANGE}app_ubifs$NC found"
|
||||
if [[ -f "${EXTRACTION_DIR_GZ}"/app_ubifs ]]; then
|
||||
print_output "[*] 2nd extraction round successful - ${ORANGE}app_ubifs${NC} found"
|
||||
print_output "[*] Loading nandsim kernel module"
|
||||
if lsmod | grep -q "^nandsim[[:space:]]"; then
|
||||
# we need to load nandsim with some parameters - unload it before
|
||||
@@ -129,30 +129,30 @@ foscam_ubi_extractor() {
|
||||
fi
|
||||
modprobe nandsim first_id_byte=0x2c second_id_byte=0xac third_id_byte=0x90 fourth_id_byte=0x15
|
||||
MTD_DEVICE=$(grep "mtd[0-9]" /proc/mtd | cut -d: -f1)
|
||||
print_output "[*] Found $ORANGE/dev/$MTD_DEVICE$NC MTD device"
|
||||
print_output "[*] Erasing $ORANGE/dev/$MTD_DEVICE$NC MTD device"
|
||||
flash_erase /dev/"$MTD_DEVICE" 0 0 || true
|
||||
print_output "[*] Formating $ORANGE/dev/$MTD_DEVICE$NC MTD device"
|
||||
ubiformat /dev/"$MTD_DEVICE" -O 2048 -f "$EXTRACTION_DIR_GZ"/app_ubifs || true
|
||||
print_output "[*] Found ${ORANGE}/dev/${MTD_DEVICE}${NC} MTD device"
|
||||
print_output "[*] Erasing ${ORANGE}/dev/${MTD_DEVICE}${NC} MTD device"
|
||||
flash_erase /dev/"${MTD_DEVICE}" 0 0 || true
|
||||
print_output "[*] Formating ${ORANGE}/dev/${MTD_DEVICE}${NC} MTD device"
|
||||
ubiformat /dev/"${MTD_DEVICE}" -O 2048 -f "${EXTRACTION_DIR_GZ}"/app_ubifs || true
|
||||
if ! lsmod | grep -q "^ubi[[:space:]]"; then
|
||||
print_output "[*] Loading ubi kernel module"
|
||||
modprobe ubi
|
||||
fi
|
||||
print_output "[*] Attaching ubi device"
|
||||
ubiattach -p /dev/"$MTD_DEVICE" -O 2048
|
||||
ubiattach -p /dev/"${MTD_DEVICE}" -O 2048
|
||||
|
||||
# should be only one UBI dev, but just in case ...
|
||||
mapfile -t UBI_DEVS < <(find /dev -iname "ubi[0-9]_[0-9]")
|
||||
for UBI_DEV in "${UBI_DEVS[@]}"; do
|
||||
local UBI_MNT_PT="$UBI_MNT_PT-$RANDOM"
|
||||
print_output "[*] Mounting $ORANGE$UBI_DEV$NC ubi device to $ORANGE$UBI_MNT_PT$NC"
|
||||
mkdir -p "$UBI_MNT_PT" || true
|
||||
mount -t ubifs "$UBI_DEV" "$UBI_MNT_PT"
|
||||
print_output "[*] Copy mounted ubi device to $ORANGE$EXTRACTION_DIR_/$UBI_DEV$NC"
|
||||
mkdir -p "$EXTRACTION_DIR_/$UBI_DEV"
|
||||
cp -pri "$UBI_MNT_PT" "$EXTRACTION_DIR_/$UBI_DEV"
|
||||
umount "$UBI_MNT_PT" || true
|
||||
rm -r "$UBI_MNT_PT" || true
|
||||
local UBI_MNT_PT="${UBI_MNT_PT}-${RANDOM}"
|
||||
print_output "[*] Mounting ${ORANGE}${UBI_DEV}${NC} ubi device to ${ORANGE}${UBI_MNT_PT}${NC}"
|
||||
mkdir -p "${UBI_MNT_PT}" || true
|
||||
mount -t ubifs "${UBI_DEV}" "${UBI_MNT_PT}"
|
||||
print_output "[*] Copy mounted ubi device to ${ORANGE}${EXTRACTION_DIR_}/${UBI_DEV}${NC}"
|
||||
mkdir -p "${EXTRACTION_DIR_}/${UBI_DEV}"
|
||||
cp -pri "${UBI_MNT_PT}" "${EXTRACTION_DIR_}/${UBI_DEV}"
|
||||
umount "${UBI_MNT_PT}" || true
|
||||
rm -r "${UBI_MNT_PT}" || true
|
||||
done
|
||||
|
||||
# do some cleanup
|
||||
@@ -163,18 +163,18 @@ foscam_ubi_extractor() {
|
||||
print_output "[*] Unloading ubi module"
|
||||
modprobe -r ubi || true
|
||||
|
||||
if [[ -d "$EXTRACTION_DIR_" ]]; then
|
||||
FOSCAM_UBI_FILES=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
FOSCAM_UBI_DIRS=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
if [[ -d "${EXTRACTION_DIR_}" ]]; then
|
||||
FOSCAM_UBI_FILES=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
FOSCAM_UBI_DIRS=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
fi
|
||||
|
||||
if [[ "$FOSCAM_UBI_FILES" -gt 0 ]]; then
|
||||
if [[ "${FOSCAM_UBI_FILES}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[*] Extracted $ORANGE$FOSCAM_UBI_FILES$NC files and $ORANGE$FOSCAM_UBI_DIRS$NC directories from the firmware image."
|
||||
write_csv_log "Foscam UBI extractor" "$FIRMWARE_PATH_" "$EXTRACTION_DIR_" "$FOSCAM_UBI_FILES" "$FOSCAM_UBI_DIRS" "NA"
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
write_csv_log "Foscam decryptor/extractor" "$FIRMWARE_PATH_" "$EXTRACTION_DIR_" "$FOSCAM_UBI_FILES" "$FOSCAM_UBI_DIRS" "NA"
|
||||
print_output "[*] Extracted ${ORANGE}${FOSCAM_UBI_FILES}${NC} files and ${ORANGE}${FOSCAM_UBI_DIRS}${NC} directories from the firmware image."
|
||||
write_csv_log "Foscam UBI extractor" "${FIRMWARE_PATH_}" "${EXTRACTION_DIR_}" "${FOSCAM_UBI_FILES}" "${FOSCAM_UBI_DIRS}" "NA"
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
write_csv_log "Foscam decryptor/extractor" "${FIRMWARE_PATH_}" "${EXTRACTION_DIR_}" "${FOSCAM_UBI_FILES}" "${FOSCAM_UBI_DIRS}" "NA"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -20,17 +20,17 @@ export PRE_THREAD_ENA=0
|
||||
P21_buffalo_decryptor() {
|
||||
local NEG_LOG=0
|
||||
|
||||
if [[ "$BUFFALO_ENC_DETECTED" -ne 0 ]]; then
|
||||
if [[ "${BUFFALO_ENC_DETECTED}" -ne 0 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Buffalo encrypted firmware extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTION_FILE="$LOG_DIR"/firmware/firmware_buffalo_dec.bin
|
||||
EXTRACTION_FILE="${LOG_DIR}"/firmware/firmware_buffalo_dec.bin
|
||||
|
||||
buffalo_enc_extractor "$FIRMWARE_PATH" "$EXTRACTION_FILE"
|
||||
buffalo_enc_extractor "${FIRMWARE_PATH}" "${EXTRACTION_FILE}"
|
||||
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -39,58 +39,58 @@ buffalo_enc_extractor() {
|
||||
local EXTRACTION_FILE_="${2:-}"
|
||||
local BUFFALO_FILE_CHECK=""
|
||||
|
||||
if ! [[ -f "$BUFFALO_ENC_PATH_" ]]; then
|
||||
if ! [[ -f "${BUFFALO_ENC_PATH_}" ]]; then
|
||||
print_output "[-] No file for decryption provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "Buffalo encrypted firmware extractor"
|
||||
|
||||
hexdump -C "$BUFFALO_ENC_PATH_" | head | tee -a "$LOG_FILE" || true
|
||||
hexdump -C "${BUFFALO_ENC_PATH_}" | head | tee -a "${LOG_FILE}" || true
|
||||
print_ln
|
||||
|
||||
BUFFALO_DECRYTED=0
|
||||
local BUFFALO_ENC_PATH_STRIPPED
|
||||
BUFFALO_ENC_PATH_STRIPPED="$LOG_DIR/firmware/$(basename "$BUFFALO_ENC_PATH_").stripped"
|
||||
BUFFALO_ENC_PATH_STRIPPED="${LOG_DIR}/firmware/$(basename "${BUFFALO_ENC_PATH_}").stripped"
|
||||
|
||||
print_output "[*] Removing initial 208 bytes from header to prepare firmware for decryption"
|
||||
# on other tests we had 208 -> check again with firmware that failed here:
|
||||
dd bs=208 skip=1 if="$BUFFALO_ENC_PATH_" of="$BUFFALO_ENC_PATH_STRIPPED""_208" || true
|
||||
dd bs=208 skip=1 if="${BUFFALO_ENC_PATH_}" of="${BUFFALO_ENC_PATH_STRIPPED}""_208" || true
|
||||
|
||||
if [[ -f "$BUFFALO_ENC_PATH_STRIPPED""_208" ]]; then
|
||||
hexdump -C "$BUFFALO_ENC_PATH_STRIPPED""_208" | head | tee -a "$LOG_FILE" || true
|
||||
if [[ -f "${BUFFALO_ENC_PATH_STRIPPED}""_208" ]]; then
|
||||
hexdump -C "${BUFFALO_ENC_PATH_STRIPPED}""_208" | head | tee -a "${LOG_FILE}" || true
|
||||
print_ln
|
||||
fi
|
||||
|
||||
print_output "[*] Removing initial 228 bytes from header to prepare firmware for decryption"
|
||||
dd bs=228 skip=1 if="$BUFFALO_ENC_PATH_" of="$BUFFALO_ENC_PATH_STRIPPED""_228" || true
|
||||
dd bs=228 skip=1 if="${BUFFALO_ENC_PATH_}" of="${BUFFALO_ENC_PATH_STRIPPED}""_228" || true
|
||||
|
||||
if [[ -f "$BUFFALO_ENC_PATH_STRIPPED""_228" ]]; then
|
||||
hexdump -C "$BUFFALO_ENC_PATH_STRIPPED""_228" | head | tee -a "$LOG_FILE" || true
|
||||
if [[ -f "${BUFFALO_ENC_PATH_STRIPPED}""_228" ]]; then
|
||||
hexdump -C "${BUFFALO_ENC_PATH_STRIPPED}""_228" | head | tee -a "${LOG_FILE}" || true
|
||||
print_ln
|
||||
fi
|
||||
|
||||
print_output "[*] Decrypting firmware ... offset 208"
|
||||
"$EXT_DIR"/buffalo-enc.elf -d -i "$BUFFALO_ENC_PATH_STRIPPED""_208" -o "$EXTRACTION_FILE_" || true
|
||||
if ! [[ -f "$EXTRACTION_FILE_" ]]; then
|
||||
"${EXT_DIR}"/buffalo-enc.elf -d -i "${BUFFALO_ENC_PATH_STRIPPED}""_208" -o "${EXTRACTION_FILE_}" || true
|
||||
if ! [[ -f "${EXTRACTION_FILE_}" ]]; then
|
||||
print_output "[*] Decrypting firmware ... offset 228"
|
||||
"$EXT_DIR"/buffalo-enc.elf -d -i "$BUFFALO_ENC_PATH_STRIPPED""_228" -o "$EXTRACTION_FILE_" || true
|
||||
"${EXT_DIR}"/buffalo-enc.elf -d -i "${BUFFALO_ENC_PATH_STRIPPED}""_228" -o "${EXTRACTION_FILE_}" || true
|
||||
fi
|
||||
hexdump -C "$EXTRACTION_FILE_" | head | tee -a "$LOG_FILE" || true
|
||||
hexdump -C "${EXTRACTION_FILE_}" | head | tee -a "${LOG_FILE}" || true
|
||||
print_ln
|
||||
|
||||
if [[ -f "$EXTRACTION_FILE_" ]]; then
|
||||
BUFFALO_FILE_CHECK=$(file "$EXTRACTION_FILE_")
|
||||
if [[ "$BUFFALO_FILE_CHECK" =~ .*u-boot\ legacy\ uImage,\ .* ]]; then
|
||||
if [[ -f "${EXTRACTION_FILE_}" ]]; then
|
||||
BUFFALO_FILE_CHECK=$(file "${EXTRACTION_FILE_}")
|
||||
if [[ "${BUFFALO_FILE_CHECK}" =~ .*u-boot\ legacy\ uImage,\ .* ]]; then
|
||||
print_ln
|
||||
print_output "[+] Decrypted Buffalo firmware file to $ORANGE$EXTRACTION_FILE_$NC"
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$BUFFALO_ENC_PATH_" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$EXTRACTION_FILE_"
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
print_output "[+] Decrypted Buffalo firmware file to ${ORANGE}${EXTRACTION_FILE_}${NC}"
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${BUFFALO_ENC_PATH_}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${EXTRACTION_FILE_}"
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
print_ln
|
||||
print_output "[*] Firmware file details: $ORANGE$(file "$EXTRACTION_FILE_")$NC"
|
||||
print_output "[*] Firmware file details: ${ORANGE}$(file "${EXTRACTION_FILE_}")${NC}"
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "Buffalo decryptor" "$BUFFALO_ENC_PATH_" "$EXTRACTION_FILE_" "1" "NA" "NA"
|
||||
write_csv_log "Buffalo decryptor" "${BUFFALO_ENC_PATH_}" "${EXTRACTION_FILE_}" "1" "NA" "NA"
|
||||
BUFFALO_DECRYTED=1
|
||||
if [[ -z "${FW_VENDOR:-}" ]]; then
|
||||
FW_VENDOR="BUFFALO"
|
||||
@@ -98,7 +98,7 @@ buffalo_enc_extractor() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$BUFFALO_DECRYTED" -ne 1 ]]; then
|
||||
if [[ "${BUFFALO_DECRYTED}" -ne 1 ]]; then
|
||||
print_output "[-] Decryption of Buffalo firmware file failed"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ export PRE_THREAD_ENA=0
|
||||
P22_Zyxel_zip_decrypt() {
|
||||
local NEG_LOG=0
|
||||
|
||||
if [[ "$ZYXEL_ZIP" -eq 1 ]]; then
|
||||
if [[ "${ZYXEL_ZIP}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Zyxel protected ZIP firmware extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/firmware_zyxel_zip
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/firmware_zyxel_zip
|
||||
|
||||
zyxel_zip_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
zyxel_zip_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -49,16 +49,16 @@ zyxel_zip_extractor() {
|
||||
|
||||
sub_module_title "Zyxel protected ZIP firmware extractor"
|
||||
|
||||
if ! [[ -f "$RI_FILE_" ]]; then
|
||||
if ! [[ -f "${RI_FILE_}" ]]; then
|
||||
print_output "[-] Zyxel - No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
if ! [[ "$RI_FILE_" =~ .*\.ri ]]; then
|
||||
if ! [[ "${RI_FILE_}" =~ .*\.ri ]]; then
|
||||
print_output "[-] Zyxel - No valid ri file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
unblobber "$RI_FILE_" "$EXTRACTION_DIR_"
|
||||
unblobber "${RI_FILE_}" "${EXTRACTION_DIR_}"
|
||||
print_ln
|
||||
|
||||
if command -v jchroot > /dev/null; then
|
||||
@@ -71,50 +71,50 @@ zyxel_zip_extractor() {
|
||||
return
|
||||
fi
|
||||
|
||||
mapfile -t ZLD_BINS < <(find "$EXTRACTION_DIR_" -name "zld_fsextract")
|
||||
RI_FILE_BIN="$(basename -s .ri "$RI_FILE_")".bin
|
||||
mapfile -t ZLD_BINS < <(find "${EXTRACTION_DIR_}" -name "zld_fsextract")
|
||||
RI_FILE_BIN="$(basename -s .ri "${RI_FILE_}")".bin
|
||||
|
||||
for ZLD_BIN in "${ZLD_BINS[@]}"; do
|
||||
local FILES_ZYXEL=0
|
||||
local DIRS_ZYXEL=0
|
||||
print_output "[*] Checking $ORANGE$ZLD_BIN$NC"
|
||||
print_output "[*] Checking ${ORANGE}${ZLD_BIN}${NC}"
|
||||
|
||||
ZLD_DIR=$(dirname "$ZLD_BIN")
|
||||
RI_FILE_BIN_PATH=$(find "$LOG_DIR"/firmware -name "$RI_FILE_BIN" | head -1)
|
||||
ZLD_DIR=$(dirname "${ZLD_BIN}")
|
||||
RI_FILE_BIN_PATH=$(find "${LOG_DIR}"/firmware -name "${RI_FILE_BIN}" | head -1)
|
||||
# => this should be the protected Zip file
|
||||
|
||||
if [[ $(file "$ZLD_BIN") == *"ELF"* ]] && [[ $(file "$RI_FILE_BIN_PATH") == *"Zip archive data"* ]]; then
|
||||
print_output "[*] Found Zyxel environment in $ORANGE$ZLD_DIR$NC"
|
||||
if [[ $(file "${ZLD_BIN}") == *"ELF"* ]] && [[ $(file "${RI_FILE_BIN_PATH}") == *"Zip archive data"* ]]; then
|
||||
print_output "[*] Found Zyxel environment in ${ORANGE}${ZLD_DIR}${NC}"
|
||||
# now we know that we have an elf for extraction and and unzip binary in the extraction dir
|
||||
# this is everything we need for the key
|
||||
if ( file "$ZLD_BIN" | grep -q "ELF 32-bit MSB executable, MIPS, N32 MIPS64 rel2 version 1" ) ; then
|
||||
if ( file "${ZLD_BIN}" | grep -q "ELF 32-bit MSB executable, MIPS, N32 MIPS64 rel2 version 1" ) ; then
|
||||
# todo: check if Zyxel also uses other architectures
|
||||
local EMULATOR="qemu-mipsn32-static"
|
||||
print_output "[*] Found valid emulator $ORANGE$EMULATOR$NC"
|
||||
print_output "[*] Found valid emulator ${ORANGE}${EMULATOR}${NC}"
|
||||
else
|
||||
print_output "[-] WARNING: Unsupported architecture for key identification:"
|
||||
print_output "$(indent "$(file "$ZLD_BIN")")"
|
||||
print_output "$(indent "$(file "${ZLD_BIN}")")"
|
||||
print_output "[-] Please open an issue at https://github.com/e-m-b-a/emba/issues"
|
||||
continue
|
||||
fi
|
||||
|
||||
print_output "[*] Running Zyxel emulation for key extraction ..."
|
||||
|
||||
if ! [[ -e "$(command -v "$EMULATOR")" ]]; then
|
||||
print_output "[-] No valid emulator ($ORANGE$EMULATOR$NC) found in your environment"
|
||||
if ! [[ -e "$(command -v "${EMULATOR}")" ]]; then
|
||||
print_output "[-] No valid emulator (${ORANGE}${EMULATOR}${NC}) found in your environment"
|
||||
return
|
||||
fi
|
||||
|
||||
cp "$(command -v "$EMULATOR")" "$ZLD_DIR" || ( print_output "[-] Something went wrong" && return)
|
||||
cp "$RI_FILE_BIN_PATH" "$ZLD_DIR" || ( print_output "[-] Something went wrong" && return)
|
||||
ZLD_BIN=$(basename "$ZLD_BIN")
|
||||
cp "$(command -v "${EMULATOR}")" "${ZLD_DIR}" || ( print_output "[-] Something went wrong" && return)
|
||||
cp "${RI_FILE_BIN_PATH}" "${ZLD_DIR}" || ( print_output "[-] Something went wrong" && return)
|
||||
ZLD_BIN=$(basename "${ZLD_BIN}")
|
||||
|
||||
chmod +x "$ZLD_DIR"/"$ZLD_BIN"
|
||||
timeout --preserve-status --signal SIGINT 2s "$CHROOT" "${OPTS[@]}" "$ZLD_DIR" -- ./"$EMULATOR" -strace ./"$ZLD_BIN" "$RI_FILE_BIN" AABBCCDD >> "$LOG_PATH_MODULE"/zld_strace.log 2>&1 || true
|
||||
rm "$ZLD_DIR"/"$EMULATOR" || true
|
||||
chmod +x "${ZLD_DIR}"/"${ZLD_BIN}"
|
||||
timeout --preserve-status --signal SIGINT 2s "${CHROOT}" "${OPTS[@]}" "${ZLD_DIR}" -- ./"${EMULATOR}" -strace ./"${ZLD_BIN}" "${RI_FILE_BIN}" AABBCCDD >> "${LOG_PATH_MODULE}"/zld_strace.log 2>&1 || true
|
||||
rm "${ZLD_DIR}"/"${EMULATOR}" || true
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE"/zld_strace.log ]] && [[ -s "$LOG_PATH_MODULE"/zld_strace.log ]]; then
|
||||
ZIP_KEY=$(grep -a -E "^[0-9]+\ execve.*AABBCCDD\",\"-o" "$LOG_PATH_MODULE"/zld_strace.log| cut -d, -f6 | sort -u | sed 's/^\"//' | sed 's/\"$//')
|
||||
if [[ -f "${LOG_PATH_MODULE}"/zld_strace.log ]] && [[ -s "${LOG_PATH_MODULE}"/zld_strace.log ]]; then
|
||||
ZIP_KEY=$(grep -a -E "^[0-9]+\ execve.*AABBCCDD\",\"-o" "${LOG_PATH_MODULE}"/zld_strace.log| cut -d, -f6 | sort -u | sed 's/^\"//' | sed 's/\"$//')
|
||||
else
|
||||
print_output "[-] No qemu strace log generated -> no further processing possible"
|
||||
fi
|
||||
@@ -122,38 +122,38 @@ zyxel_zip_extractor() {
|
||||
# if we have found a ZIP_KEY:
|
||||
if [[ -v ZIP_KEY ]]; then
|
||||
print_ln
|
||||
print_output "[+] Possible ZIP key detected: $ORANGE$ZIP_KEY$NC" "" "$LOG_PATH_MODULE/zld_strace.log"
|
||||
print_output "[+] Possible ZIP key detected: ${ORANGE}${ZIP_KEY}${NC}" "" "${LOG_PATH_MODULE}/zld_strace.log"
|
||||
|
||||
7z x -p"$ZIP_KEY" -o"$EXTRACTION_DIR_"/firmware_zyxel_extracted "$RI_FILE_BIN_PATH" || true
|
||||
7z x -p"${ZIP_KEY}" -o"${EXTRACTION_DIR_}"/firmware_zyxel_extracted "${RI_FILE_BIN_PATH}" || true
|
||||
|
||||
FILES_ZYXEL=$(find "$EXTRACTION_DIR_"/firmware_zyxel_extracted -type f | wc -l)
|
||||
DIRS_ZYXEL=$(find "$EXTRACTION_DIR_"/firmware_zyxel_extracted -type d | wc -l)
|
||||
FILES_ZYXEL=$(find "${EXTRACTION_DIR_}"/firmware_zyxel_extracted -type f | wc -l)
|
||||
DIRS_ZYXEL=$(find "${EXTRACTION_DIR_}"/firmware_zyxel_extracted -type d | wc -l)
|
||||
|
||||
print_ln
|
||||
print_output "[*] Zyxel 1st stage - Extracted $ORANGE$FILES_ZYXEL$NC files and $ORANGE$DIRS_ZYXEL$NC directories from the firmware image."
|
||||
print_output "[*] Zyxel 1st stage - Extracted ${ORANGE}${FILES_ZYXEL}${NC} files and ${ORANGE}${DIRS_ZYXEL}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "Zyxel extractor" "$RI_FILE_BIN_PATH" "$EXTRACTION_DIR_/firmware_zyxel_extracted" "$FILES_ZYXEL" "$DIRS_ZYXEL" "NA"
|
||||
write_csv_log "Zyxel extractor" "${RI_FILE_BIN_PATH}" "${EXTRACTION_DIR_}/firmware_zyxel_extracted" "${FILES_ZYXEL}" "${DIRS_ZYXEL}" "NA"
|
||||
else
|
||||
print_output "[-] No ZIP key detected -> no further processing possible"
|
||||
fi
|
||||
|
||||
# if it was possible to extract something with the key:
|
||||
if [[ "$FILES_ZYXEL" -gt 0 ]]; then
|
||||
if [[ "${FILES_ZYXEL}" -gt 0 ]]; then
|
||||
# compress.img ist the firmware -> letz search for it
|
||||
COMPRESS_IMG=$(find "$EXTRACTION_DIR_"/firmware_zyxel_extracted -type f -name compress.img | sort -u)
|
||||
if [[ $(file "$COMPRESS_IMG") == *"Squashfs"* ]]; then
|
||||
print_output "[+] Found valid ${ORANGE}compress.img$GREEN and extract it now"
|
||||
unblobber "$COMPRESS_IMG" "$EXTRACTION_DIR_/firmware_zyxel_extracted/compress_img_extracted"
|
||||
FILES_ZYXEL=$(find "$EXTRACTION_DIR_"/firmware_zyxel_extracted/compress_img_extracted -type f | wc -l)
|
||||
DIRS_ZYXEL=$(find "$EXTRACTION_DIR_"/firmware_zyxel_extracted/compress_img_extracted -type d | wc -l)
|
||||
print_output "[*] Zyxel 2nd stage - Extracted $ORANGE$FILES_ZYXEL$NC files and $ORANGE$DIRS_ZYXEL$NC directories from the firmware image."
|
||||
write_csv_log "Zyxel extractor" "$RI_FILE_BIN_PATH" "$EXTRACTION_DIR_/firmware_zyxel_extracted/compress_img_extracted" "$FILES_ZYXEL" "$DIRS_ZYXEL" "NA"
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
COMPRESS_IMG=$(find "${EXTRACTION_DIR_}"/firmware_zyxel_extracted -type f -name compress.img | sort -u)
|
||||
if [[ $(file "${COMPRESS_IMG}") == *"Squashfs"* ]]; then
|
||||
print_output "[+] Found valid ${ORANGE}compress.img${GREEN} and extract it now"
|
||||
unblobber "${COMPRESS_IMG}" "${EXTRACTION_DIR_}/firmware_zyxel_extracted/compress_img_extracted"
|
||||
FILES_ZYXEL=$(find "${EXTRACTION_DIR_}"/firmware_zyxel_extracted/compress_img_extracted -type f | wc -l)
|
||||
DIRS_ZYXEL=$(find "${EXTRACTION_DIR_}"/firmware_zyxel_extracted/compress_img_extracted -type d | wc -l)
|
||||
print_output "[*] Zyxel 2nd stage - Extracted ${ORANGE}${FILES_ZYXEL}${NC} files and ${ORANGE}${DIRS_ZYXEL}${NC} directories from the firmware image."
|
||||
write_csv_log "Zyxel extractor" "${RI_FILE_BIN_PATH}" "${EXTRACTION_DIR_}/firmware_zyxel_extracted/compress_img_extracted" "${FILES_ZYXEL}" "${DIRS_ZYXEL}" "NA"
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
print_ln
|
||||
break
|
||||
else
|
||||
print_output "[-] No valid ${ORANGE}compress.img$NC file found"
|
||||
print_output "[-] No valid ${ORANGE}compress.img${NC} file found"
|
||||
fi
|
||||
else
|
||||
print_output "[-] 1st stage Zip extraction failed"
|
||||
|
||||
@@ -18,57 +18,57 @@ export PRE_THREAD_ENA=0
|
||||
|
||||
P23_qemu_qcow_mounter() {
|
||||
local NEG_LOG=0
|
||||
if [[ "$QCOW_DETECTED" -eq 1 ]]; then
|
||||
if [[ "${QCOW_DETECTED}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Qemu QCOW filesystem extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/qemu_qcow_mount_filesystem/
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/qemu_qcow_mount_filesystem/
|
||||
local FIRMWARE_PATHx=""
|
||||
|
||||
if [[ "$IN_DOCKER" -eq 1 ]]; then
|
||||
if [[ "${IN_DOCKER}" -eq 1 ]]; then
|
||||
# we need rw access to firmware -> in docker container we need to copy
|
||||
# the firmware to TMP_DIR and use this for extraction
|
||||
# afterwards we are going to remove this path
|
||||
cp /firmware "$TMP_DIR"
|
||||
FIRMWARE_PATHx="$TMP_DIR"/firmware
|
||||
cp /firmware "${TMP_DIR}"
|
||||
FIRMWARE_PATHx="${TMP_DIR}"/firmware
|
||||
else
|
||||
FIRMWARE_PATHx="$FIRMWARE_PATH"
|
||||
FIRMWARE_PATHx="${FIRMWARE_PATH}"
|
||||
fi
|
||||
|
||||
qcow_extractor "$FIRMWARE_PATHx" "$EXTRACTION_DIR"
|
||||
qcow_extractor "${FIRMWARE_PATHx}" "${EXTRACTION_DIR}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/firmware ]]; then
|
||||
rm "$TMP_DIR"/firmware
|
||||
if [[ -f "${TMP_DIR}"/firmware ]]; then
|
||||
rm "${TMP_DIR}"/firmware
|
||||
fi
|
||||
|
||||
if [[ "$FILES_QCOW_MOUNT" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ "${FILES_QCOW_MOUNT}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
qcow_extractor() {
|
||||
local QCOW_PATH_="${1:-}"
|
||||
local EXTRACTION_DIR_="${2:-}"
|
||||
local TMP_QCOW_MOUNT="$TMP_DIR""/qcow_mount_$RANDOM"
|
||||
local TMP_QCOW_MOUNT="${TMP_DIR}""/qcow_mount_${RANDOM}"
|
||||
local DIRS_QCOW_MOUNT=0
|
||||
FILES_QCOW_MOUNT=0
|
||||
|
||||
if ! [[ -f "$QCOW_PATH_" ]]; then
|
||||
if ! [[ -f "${QCOW_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "Qemu QCOW filesystem extractor"
|
||||
|
||||
mkdir -p "$TMP_QCOW_MOUNT" 2>/dev/null || true
|
||||
print_output "[*] Trying to mount $ORANGE$QCOW_PATH_$NC to $ORANGE$TMP_QCOW_MOUNT$NC directory"
|
||||
mkdir -p "${TMP_QCOW_MOUNT}" 2>/dev/null || true
|
||||
print_output "[*] Trying to mount ${ORANGE}${QCOW_PATH_}${NC} to ${ORANGE}${TMP_QCOW_MOUNT}${NC} directory"
|
||||
|
||||
if lsmod | grep -q nbd; then
|
||||
rmmod nbd || true
|
||||
@@ -76,14 +76,14 @@ qcow_extractor() {
|
||||
if ! [[ -d /var/lock ]]; then
|
||||
mkdir /var/lock || true
|
||||
fi
|
||||
print_output "[*] Load kernel module ${ORANGE}nbd$NC."
|
||||
print_output "[*] Load kernel module ${ORANGE}nbd${NC}."
|
||||
modprobe nbd max_part=8
|
||||
print_output "[*] Qemu disconnect device ${ORANGE}/dev/nbd$NC."
|
||||
print_output "[*] Qemu disconnect device ${ORANGE}/dev/nbd${NC}."
|
||||
qemu-nbd --disconnect /dev/nbd0
|
||||
print_output "[*] Qemu connect device ${ORANGE}/dev/nbd$NC."
|
||||
qemu-nbd --connect=/dev/nbd0 "$QCOW_PATH_"
|
||||
print_output "[*] Qemu connect device ${ORANGE}/dev/nbd${NC}."
|
||||
qemu-nbd --connect=/dev/nbd0 "${QCOW_PATH_}"
|
||||
|
||||
print_output "[*] Identification of partitions on ${ORANGE}/dev/nbd$NC."
|
||||
print_output "[*] Identification of partitions on ${ORANGE}/dev/nbd${NC}."
|
||||
mapfile -t NBD_DEVS < <(fdisk -l /dev/nbd0 | grep "^/dev/" | awk '{print $1}' || true)
|
||||
if [[ "${#NBD_DEVS[@]}" -eq 0 ]]; then
|
||||
# sometimes we are not able to find the partitions with fdisk -> fallback
|
||||
@@ -95,39 +95,39 @@ qcow_extractor() {
|
||||
print_ln
|
||||
|
||||
for NBD_DEV in "${NBD_DEVS[@]}"; do
|
||||
print_output "[*] Extract data from partition $ORANGE$NBD_DEV$NC"
|
||||
mount "$NBD_DEV" "$TMP_QCOW_MOUNT" || true
|
||||
print_output "[*] Extract data from partition ${ORANGE}${NBD_DEV}${NC}"
|
||||
mount "${NBD_DEV}" "${TMP_QCOW_MOUNT}" || true
|
||||
|
||||
if mount | grep -q "$NBD_DEV"; then
|
||||
EXTRACTION_DIR_FINAL="$EXTRACTION_DIR_"/"$(basename "$NBD_DEV")"
|
||||
copy_qemu_nbd "$TMP_QCOW_MOUNT" "$EXTRACTION_DIR_FINAL"
|
||||
if mount | grep -q "${NBD_DEV}"; then
|
||||
EXTRACTION_DIR_FINAL="${EXTRACTION_DIR_}"/"$(basename "${NBD_DEV}")"
|
||||
copy_qemu_nbd "${TMP_QCOW_MOUNT}" "${EXTRACTION_DIR_FINAL}"
|
||||
|
||||
FILES_QCOW_MOUNT=$(find "$EXTRACTION_DIR_FINAL" -type f | wc -l)
|
||||
DIRS_QCOW_MOUNT=$(find "$EXTRACTION_DIR_FINAL" -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_QCOW_MOUNT$NC files and $ORANGE$DIRS_QCOW_MOUNT$NC directories from the firmware image."
|
||||
FILES_QCOW_MOUNT=$(find "${EXTRACTION_DIR_FINAL}" -type f | wc -l)
|
||||
DIRS_QCOW_MOUNT=$(find "${EXTRACTION_DIR_FINAL}" -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_QCOW_MOUNT}${NC} files and ${ORANGE}${DIRS_QCOW_MOUNT}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "Qemu QCOW filesystem extractor" "$QCOW_PATH_" "$EXTRACTION_DIR_FINAL" "$FILES_QCOW_MOUNT" "$DIRS_QCOW_MOUNT" "NA"
|
||||
write_csv_log "Qemu QCOW filesystem extractor" "${QCOW_PATH_}" "${EXTRACTION_DIR_FINAL}" "${FILES_QCOW_MOUNT}" "${DIRS_QCOW_MOUNT}" "NA"
|
||||
|
||||
print_output "[*] Unmounting $ORANGE$TMP_QCOW_MOUNT$NC directory"
|
||||
umount "$TMP_QCOW_MOUNT"
|
||||
print_output "[*] Unmounting ${ORANGE}${TMP_QCOW_MOUNT}${NC} directory"
|
||||
umount "${TMP_QCOW_MOUNT}"
|
||||
fi
|
||||
done
|
||||
qemu-nbd --disconnect /dev/nbd0
|
||||
rm -r "$TMP_QCOW_MOUNT"
|
||||
rm -r "${TMP_QCOW_MOUNT}"
|
||||
}
|
||||
|
||||
copy_qemu_nbd() {
|
||||
local SOURCE_CP="${1:-}"
|
||||
local DEST_CP="${2:-}"
|
||||
if ! [[ -d "$SOURCE_CP" ]]; then
|
||||
if ! [[ -d "${SOURCE_CP}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
print_output "[*] Copying $ORANGE$SOURCE_CP$NC to firmware tmp directory ($ORANGE$DEST_CP$NC)"
|
||||
mkdir -p "$DEST_CP" 2>/dev/null || true
|
||||
cp -pri "$SOURCE_CP"/* "$DEST_CP" 2>/dev/null || true
|
||||
print_output "[*] Copying ${ORANGE}${SOURCE_CP}${NC} to firmware tmp directory (${ORANGE}${DEST_CP}${NC})"
|
||||
mkdir -p "${DEST_CP}" 2>/dev/null || true
|
||||
cp -pri "${SOURCE_CP}"/* "${DEST_CP}" 2>/dev/null || true
|
||||
print_ln
|
||||
print_output "[*] Using the following firmware directory ($ORANGE$DEST_CP$NC) as base directory:"
|
||||
find "$DEST_CP" -xdev -maxdepth 1 -ls | tee -a "$LOG_FILE"
|
||||
print_output "[*] Using the following firmware directory (${ORANGE}${DEST_CP}${NC}) as base directory:"
|
||||
find "${DEST_CP}" -xdev -maxdepth 1 -ls | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
}
|
||||
|
||||
+18
-18
@@ -18,52 +18,52 @@ export PRE_THREAD_ENA=0
|
||||
|
||||
P25_android_ota() {
|
||||
local NEG_LOG=0
|
||||
if [[ "$ANDROID_OTA" -eq 1 ]]; then
|
||||
if [[ "${ANDROID_OTA}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Android OTA payload.bin extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/android_ota/
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/android_ota/
|
||||
|
||||
android_ota_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
android_ota_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
|
||||
if [[ "$FILES_OTA" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
if [[ "${FILES_OTA}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
android_ota_extractor() {
|
||||
local OTA_INIT_PATH_="$1"
|
||||
local EXTRACTION_DIR_="$2"
|
||||
local OTA_INIT_PATH_="${1}"
|
||||
local EXTRACTION_DIR_="${2}"
|
||||
local DIRS_OTA=0
|
||||
FILES_OTA=0
|
||||
|
||||
if ! [[ -f "$OTA_INIT_PATH_" ]]; then
|
||||
if ! [[ -f "${OTA_INIT_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
sub_module_title "Android OTA extractor"
|
||||
|
||||
hexdump -C "$OTA_INIT_PATH_" | head | tee -a "$LOG_FILE" || true
|
||||
hexdump -C "${OTA_INIT_PATH_}" | head | tee -a "${LOG_FILE}" || true
|
||||
|
||||
if [[ -d "$EXT_DIR"/payload_dumper ]]; then
|
||||
if [[ -d "${EXT_DIR}"/payload_dumper ]]; then
|
||||
print_ln
|
||||
print_output "[*] Extracting Android OTA payload.bin file ..."
|
||||
print_ln
|
||||
|
||||
python3 "$EXT_DIR"/payload_dumper/payload_dumper.py --out "$EXTRACTION_DIR_" "$OTA_INIT_PATH_" | tee -a "$LOG_FILE"
|
||||
python3 "${EXT_DIR}"/payload_dumper/payload_dumper.py --out "${EXTRACTION_DIR_}" "${OTA_INIT_PATH_}" | tee -a "${LOG_FILE}"
|
||||
|
||||
FILES_OTA=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
DIRS_OTA=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_OTA$NC files and $ORANGE$DIRS_OTA$NC directories from the firmware image."
|
||||
FILES_OTA=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
DIRS_OTA=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_OTA}${NC} files and ${ORANGE}${DIRS_OTA}${NC} directories from the firmware image."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "Android OTA extractor" "$OTA_INIT_PATH_" "$EXTRACTION_DIR_" "$FILES_OTA" "$DIRS_OTA" "via payload_dumper.py"
|
||||
write_csv_log "Android OTA extractor" "${OTA_INIT_PATH_}" "${EXTRACTION_DIR_}" "${FILES_OTA}" "${DIRS_OTA}" "via payload_dumper.py"
|
||||
else
|
||||
print_output "[-] Android OTA payload.bin extractor not found - check your installation"
|
||||
fi
|
||||
|
||||
@@ -20,27 +20,27 @@ export PRE_THREAD_ENA=0
|
||||
P35_UEFI_extractor() {
|
||||
local NEG_LOG=0
|
||||
|
||||
if [[ "$UEFI_DETECTED" -eq 1 ]]; then
|
||||
if [[ "${UEFI_DETECTED}" -eq 1 ]]; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "UEFI extractor"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
export FILES_UEFI=0
|
||||
|
||||
EXTRACTION_DIR="$LOG_DIR"/firmware/uefi_extraction/
|
||||
EXTRACTION_DIR="${LOG_DIR}"/firmware/uefi_extraction/
|
||||
|
||||
# if [[ "$UEFI_AMI_CAPSULE" -gt 0 ]]; then
|
||||
# ami_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
# if [[ "${UEFI_AMI_CAPSULE}" -gt 0 ]]; then
|
||||
# ami_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
# else
|
||||
uefi_extractor "$FIRMWARE_PATH" "$EXTRACTION_DIR"
|
||||
uefi_extractor "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"
|
||||
# fi
|
||||
|
||||
if [[ "$FILES_UEFI" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "$FIRMWARE_PATH" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="$LOG_DIR"/firmware/
|
||||
if [[ "${FILES_UEFI}" -gt 0 ]]; then
|
||||
MD5_DONE_DEEP+=( "$(md5sum "${FIRMWARE_PATH}" | awk '{print $1}')" )
|
||||
export FIRMWARE_PATH="${LOG_DIR}"/firmware/
|
||||
NEG_LOG=1
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -53,29 +53,29 @@ P35_UEFI_extractor() {
|
||||
# local DIRS_UEFI=0
|
||||
# local FIRMWARE_NAME_=""
|
||||
#
|
||||
# if ! [[ -f "$FIRMWARE_PATH_" ]]; then
|
||||
# if ! [[ -f "${FIRMWARE_PATH_}" ]]; then
|
||||
# print_output "[-] No file for extraction provided"
|
||||
# return
|
||||
# fi
|
||||
#
|
||||
# FIRMWARE_NAME_="$(basename "$FIRMWARE_PATH_")"
|
||||
# FIRMWARE_NAME_="$(basename "${FIRMWARE_PATH_}")"
|
||||
#
|
||||
# echo -ne '\n' | python3 "$EXT_DIR"/BIOSUtilities/AMI_PFAT_Extract.py -o "$EXTRACTION_DIR_" "$FIRMWARE_PATH_" &> "$LOG_PATH_MODULE"/uefi_ami_"$FIRMWARE_NAME_".log
|
||||
# echo -ne '\n' | python3 "${EXT_DIR}"/BIOSUtilities/AMI_PFAT_Extract.py -o "${EXTRACTION_DIR_}" "${FIRMWARE_PATH_}" &> "${LOG_PATH_MODULE}"/uefi_ami_"${FIRMWARE_NAME_}".log
|
||||
#
|
||||
# if [[ -f "$LOG_PATH_MODULE"/uefi_ami_"$FIRMWARE_NAME_".log ]]; then
|
||||
# tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/uefi_ami_"$FIRMWARE_NAME_".log
|
||||
# if [[ -f "${LOG_PATH_MODULE}"/uefi_ami_"${FIRMWARE_NAME_}".log ]]; then
|
||||
# tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/uefi_ami_"${FIRMWARE_NAME_}".log
|
||||
# fi
|
||||
#
|
||||
# print_ln
|
||||
# print_output "[*] Using the following firmware directory ($ORANGE$EXTRACTION_DIR_$NC) as base directory:"
|
||||
# find "$EXTRACTION_DIR_" -xdev -maxdepth 1 -ls | tee -a "$LOG_FILE"
|
||||
# find "${EXTRACTION_DIR_}" -xdev -maxdepth 1 -ls | tee -a "${LOG_FILE}"
|
||||
# print_ln
|
||||
#
|
||||
# FILES_UEFI=$(find "$EXTRACTION_DIR_" -type f | wc -l)
|
||||
# DIRS_UEFI=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
# FILES_UEFI=$(find "${EXTRACTION_DIR_}" -type f | wc -l)
|
||||
# DIRS_UEFI=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
# print_output "[*] Extracted $ORANGE$FILES_UEFI$NC files and $ORANGE$DIRS_UEFI$NC directories from the firmware image."
|
||||
# write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
# write_csv_log "UEFI AMI extractor" "$FIRMWARE_PATH_" "$EXTRACTION_DIR_" "$FILES_UEFI" "$DIRS_UEFI" "NA"
|
||||
# write_csv_log "UEFI AMI extractor" "${FIRMWARE_PATH_}" "${EXTRACTION_DIR_}" "${FILES_UEFI}" "${DIRS_UEFI}" "NA"
|
||||
# print_ln
|
||||
# }
|
||||
|
||||
@@ -88,57 +88,57 @@ uefi_extractor(){
|
||||
local FIRMWARE_NAME_=""
|
||||
local UEFI_EXTRACT_REPORT_FILE=""
|
||||
|
||||
local UEFI_EXTRACT_BIN="$EXT_DIR""/UEFITool/UEFIExtract"
|
||||
local UEFI_EXTRACT_BIN="${EXT_DIR}""/UEFITool/UEFIExtract"
|
||||
local FILES_UEFI=0
|
||||
local DIRS_UEFI=0
|
||||
local NVARS=0
|
||||
local PE32_IMAGE=0
|
||||
local EFI_ARCH=""
|
||||
|
||||
if ! [[ -f "$FIRMWARE_PATH_" ]]; then
|
||||
if ! [[ -f "${FIRMWARE_PATH_}" ]]; then
|
||||
print_output "[-] No file for extraction provided"
|
||||
return
|
||||
fi
|
||||
|
||||
FIRMWARE_NAME_="$(basename "$FIRMWARE_PATH_")"
|
||||
if ! [[ -d "$EXTRACTION_DIR_" ]]; then
|
||||
mkdir -p "$EXTRACTION_DIR_"
|
||||
FIRMWARE_NAME_="$(basename "${FIRMWARE_PATH_}")"
|
||||
if ! [[ -d "${EXTRACTION_DIR_}" ]]; then
|
||||
mkdir -p "${EXTRACTION_DIR_}"
|
||||
fi
|
||||
cp "$FIRMWARE_PATH_" "$EXTRACTION_DIR_"
|
||||
"$UEFI_EXTRACT_BIN" "$EXTRACTION_DIR_"firmware all &> "$LOG_PATH_MODULE"/uefi_extractor_"$FIRMWARE_NAME_".log
|
||||
UEFI_EXTRACT_REPORT_FILE="$EXTRACTION_DIR_"firmware.report.txt
|
||||
mv "$UEFI_EXTRACT_REPORT_FILE" "$LOG_PATH_MODULE"
|
||||
UEFI_EXTRACT_REPORT_FILE="$LOG_PATH_MODULE"/firmware.report.txt
|
||||
if [[ -f "$EXTRACTION_DIR_"/firmware ]]; then
|
||||
rm "$EXTRACTION_DIR_"/firmware
|
||||
cp "${FIRMWARE_PATH_}" "${EXTRACTION_DIR_}"
|
||||
"${UEFI_EXTRACT_BIN}" "${EXTRACTION_DIR_}"firmware all &> "${LOG_PATH_MODULE}"/uefi_extractor_"${FIRMWARE_NAME_}".log
|
||||
UEFI_EXTRACT_REPORT_FILE="${EXTRACTION_DIR_}"firmware.report.txt
|
||||
mv "${UEFI_EXTRACT_REPORT_FILE}" "${LOG_PATH_MODULE}"
|
||||
UEFI_EXTRACT_REPORT_FILE="${LOG_PATH_MODULE}"/firmware.report.txt
|
||||
if [[ -f "${EXTRACTION_DIR_}"/firmware ]]; then
|
||||
rm "${EXTRACTION_DIR_}"/firmware
|
||||
fi
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE"/uefi_extractor_"$FIRMWARE_NAME_".log ]]; then
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/uefi_extractor_"$FIRMWARE_NAME_".log
|
||||
if [[ -f "${LOG_PATH_MODULE}"/uefi_extractor_"${FIRMWARE_NAME_}".log ]]; then
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/uefi_extractor_"${FIRMWARE_NAME_}".log
|
||||
fi
|
||||
|
||||
print_ln
|
||||
print_output "[*] Using the following firmware directory ($ORANGE${EXTRACTION_DIR_}firmware.dump$NC) as base directory:"
|
||||
find "$EXTRACTION_DIR_"firmware.dump -xdev -maxdepth 1 -ls | tee -a "$LOG_FILE"
|
||||
print_output "[*] Using the following firmware directory (${ORANGE}${EXTRACTION_DIR_}firmware.dump${NC}) as base directory:"
|
||||
find "${EXTRACTION_DIR_}"firmware.dump -xdev -maxdepth 1 -ls | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
|
||||
NVARS=$(grep -c "NVAR entry" "$UEFI_EXTRACT_REPORT_FILE" || true)
|
||||
PE32_IMAGE=$(grep -c "PE32 image" "$UEFI_EXTRACT_REPORT_FILE" || true)
|
||||
DRIVER_COUNT=$(grep -c "DXE driver" "$UEFI_EXTRACT_REPORT_FILE" || true)
|
||||
EFI_ARCH=$(find "$EXTRACTION_DIR_" -name 'info.txt' -exec grep 'Machine type:' {} \; | sed -E 's/Machine\ type\:\ //g' | uniq | head -n 1)
|
||||
NVARS=$(grep -c "NVAR entry" "${UEFI_EXTRACT_REPORT_FILE}" || true)
|
||||
PE32_IMAGE=$(grep -c "PE32 image" "${UEFI_EXTRACT_REPORT_FILE}" || true)
|
||||
DRIVER_COUNT=$(grep -c "DXE driver" "${UEFI_EXTRACT_REPORT_FILE}" || true)
|
||||
EFI_ARCH=$(find "${EXTRACTION_DIR_}" -name 'info.txt' -exec grep 'Machine type:' {} \; | sed -E 's/Machine\ type\:\ //g' | uniq | head -n 1)
|
||||
|
||||
if [[ -n "$EFI_ARCH" ]]; then
|
||||
print_output "[*] Found $ORANGE$PE32_IMAGE$NC PE32 images for architecture $ORANGE$EFI_ARCH$NC drivers."
|
||||
print_output "[+] Possible architecture details found ($ORANGE UEFI Extractor $GREEN): $ORANGE$EFI_ARCH$NC"
|
||||
if [[ -n "${EFI_ARCH}" ]]; then
|
||||
print_output "[*] Found ${ORANGE}${PE32_IMAGE}${NC} PE32 images for architecture ${ORANGE}${EFI_ARCH}${NC} drivers."
|
||||
print_output "[+] Possible architecture details found (${ORANGE} UEFI Extractor ${GREEN}): ${ORANGE}${EFI_ARCH}${NC}"
|
||||
export EFI_ARCH
|
||||
backup_var "EFI_ARCH" "$EFI_ARCH"
|
||||
backup_var "EFI_ARCH" "${EFI_ARCH}"
|
||||
fi
|
||||
|
||||
FILES_UEFI=$(grep -c "File" "$UEFI_EXTRACT_REPORT_FILE" || true)
|
||||
DIRS_UEFI=$(find "$EXTRACTION_DIR_" -type d | wc -l)
|
||||
print_output "[*] Extracted $ORANGE$FILES_UEFI$NC files and $ORANGE$DIRS_UEFI$NC directories from the firmware image."
|
||||
print_output "[*] Found $ORANGE$NVARS$NC NVARS and $ORANGE$DRIVER_COUNT$NC drivers."
|
||||
FILES_UEFI=$(grep -c "File" "${UEFI_EXTRACT_REPORT_FILE}" || true)
|
||||
DIRS_UEFI=$(find "${EXTRACTION_DIR_}" -type d | wc -l)
|
||||
print_output "[*] Extracted ${ORANGE}${FILES_UEFI}${NC} files and ${ORANGE}${DIRS_UEFI}${NC} directories from the firmware image."
|
||||
print_output "[*] Found ${ORANGE}${NVARS}${NC} NVARS and ${ORANGE}${DRIVER_COUNT}${NC} drivers."
|
||||
write_csv_log "Extractor module" "Original file" "extracted file/dir" "file counter" "directory counter" "further details"
|
||||
write_csv_log "UEFI extractor" "$FIRMWARE_PATH_" "$EXTRACTION_DIR_" "$FILES_UEFI" "$DIRS_UEFI" "NA"
|
||||
write_csv_log "UEFI extractor" "${FIRMWARE_PATH_}" "${EXTRACTION_DIR_}" "${FILES_UEFI}" "${DIRS_UEFI}" "NA"
|
||||
print_ln
|
||||
}
|
||||
|
||||
@@ -24,24 +24,24 @@ P55_unblob_extractor() {
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
if [[ -d "${FIRMWARE_PATH}" ]] && [[ "$RTOS" -eq 1 ]]; then
|
||||
detect_root_dir_helper "$FIRMWARE_PATH"
|
||||
if [[ -d "${FIRMWARE_PATH}" ]] && [[ "${RTOS}" -eq 1 ]]; then
|
||||
detect_root_dir_helper "${FIRMWARE_PATH}"
|
||||
fi
|
||||
|
||||
# If we have not found a linux filesystem we try to do an unblob extraction round
|
||||
if [[ $RTOS -eq 0 ]] ; then
|
||||
if [[ ${RTOS} -eq 0 ]] ; then
|
||||
module_end_log "${FUNCNAME[0]}" 0
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$TMP_DIR""/unblob_disable.cfg" ]]; then
|
||||
if [[ -f "${TMP_DIR}""/unblob_disable.cfg" ]]; then
|
||||
# if we disable unblob from a background module we need to work with a file to
|
||||
# store the state of this variable (bash rules ;))
|
||||
UNBLOB="$(cat "$TMP_DIR"/unblob_disable.cfg)"
|
||||
UNBLOB="$(cat "${TMP_DIR}"/unblob_disable.cfg)"
|
||||
fi
|
||||
|
||||
if [[ "$UNBLOB" -eq 0 ]]; then
|
||||
if [[ -f "$TMP_DIR""/unblob_disable.cfg" ]]; then
|
||||
if [[ "${UNBLOB}" -eq 0 ]]; then
|
||||
if [[ -f "${TMP_DIR}""/unblob_disable.cfg" ]]; then
|
||||
print_output "[-] Unblob module automatically disabled from other module."
|
||||
else
|
||||
print_output "[-] Unblob module currently disabled - enable it in emba setting the UNBLOB variable to 1"
|
||||
@@ -50,9 +50,9 @@ P55_unblob_extractor() {
|
||||
return
|
||||
fi
|
||||
|
||||
local FW_PATH_UNBLOB="$FIRMWARE_PATH"
|
||||
local FW_PATH_UNBLOB="${FIRMWARE_PATH}"
|
||||
|
||||
if [[ -d "$FW_PATH_UNBLOB" ]]; then
|
||||
if [[ -d "${FW_PATH_UNBLOB}" ]]; then
|
||||
print_output "[-] Unblob module only deals with firmware files - directories are handled via deep extractor"
|
||||
module_end_log "${FUNCNAME[0]}" 0
|
||||
return
|
||||
@@ -72,40 +72,40 @@ P55_unblob_extractor() {
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
export LINUX_PATH_COUNTER_UNBLOB=0
|
||||
export OUTPUT_DIR_UNBLOB="$LOG_DIR"/firmware/unblob_extracted
|
||||
export OUTPUT_DIR_UNBLOB="${LOG_DIR}"/firmware/unblob_extracted
|
||||
|
||||
if [[ -f "$FW_PATH_UNBLOB" ]]; then
|
||||
unblobber "$FW_PATH_UNBLOB" "$OUTPUT_DIR_UNBLOB"
|
||||
if [[ -f "${FW_PATH_UNBLOB}" ]]; then
|
||||
unblobber "${FW_PATH_UNBLOB}" "${OUTPUT_DIR_UNBLOB}"
|
||||
fi
|
||||
|
||||
linux_basic_identification_unblobber "$OUTPUT_DIR_UNBLOB"
|
||||
linux_basic_identification_unblobber "${OUTPUT_DIR_UNBLOB}"
|
||||
|
||||
print_ln
|
||||
|
||||
if [[ -d "$OUTPUT_DIR_UNBLOB" ]]; then
|
||||
FILES_EXT_UB=$(find "$OUTPUT_DIR_UNBLOB" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES_UB=$(find "$OUTPUT_DIR_UNBLOB" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT_UB=$(find "$OUTPUT_DIR_UNBLOB" -xdev -type d | wc -l )
|
||||
BINS_UB=$(find "$OUTPUT_DIR_UNBLOB" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
if [[ -d "${OUTPUT_DIR_UNBLOB}" ]]; then
|
||||
FILES_EXT_UB=$(find "${OUTPUT_DIR_UNBLOB}" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES_UB=$(find "${OUTPUT_DIR_UNBLOB}" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT_UB=$(find "${OUTPUT_DIR_UNBLOB}" -xdev -type d | wc -l )
|
||||
BINS_UB=$(find "${OUTPUT_DIR_UNBLOB}" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
fi
|
||||
|
||||
if [[ "$BINS_UB" -gt 0 ]] || [[ "$FILES_EXT_UB" -gt 0 ]]; then
|
||||
if [[ "${BINS_UB}" -gt 0 ]] || [[ "${FILES_EXT_UB}" -gt 0 ]]; then
|
||||
sub_module_title "Firmware extraction details"
|
||||
print_output "[*] ${ORANGE}Unblob$NC results:"
|
||||
print_output "[*] Found $ORANGE$FILES_EXT_UB$NC files ($ORANGE$UNIQUE_FILES_UB$NC unique files) and $ORANGE$DIRS_EXT_UB$NC directories at all."
|
||||
print_output "[*] Found $ORANGE$BINS_UB$NC binaries."
|
||||
print_output "[*] Additionally the Linux path counter is $ORANGE$LINUX_PATH_COUNTER_UNBLOB$NC."
|
||||
print_output "[*] ${ORANGE}Unblob${NC} results:"
|
||||
print_output "[*] Found ${ORANGE}${FILES_EXT_UB}${NC} files (${ORANGE}${UNIQUE_FILES_UB}${NC} unique files) and ${ORANGE}${DIRS_EXT_UB}${NC} directories at all."
|
||||
print_output "[*] Found ${ORANGE}${BINS_UB}${NC} binaries."
|
||||
print_output "[*] Additionally the Linux path counter is ${ORANGE}${LINUX_PATH_COUNTER_UNBLOB}${NC}."
|
||||
print_ln
|
||||
tree -sh "$OUTPUT_DIR_UNBLOB" | tee -a "$LOG_FILE"
|
||||
tree -sh "${OUTPUT_DIR_UNBLOB}" | tee -a "${LOG_FILE}"
|
||||
print_ln
|
||||
|
||||
detect_root_dir_helper "$OUTPUT_DIR_UNBLOB"
|
||||
detect_root_dir_helper "${OUTPUT_DIR_UNBLOB}"
|
||||
|
||||
write_csv_log "FILES Unblob" "UNIQUE FILES Unblob" "directories Unblob" "Binaries Unblob" "LINUX_PATH_COUNTER Unblob"
|
||||
write_csv_log "$FILES_EXT_UB" "$UNIQUE_FILES_UB" "$DIRS_EXT_UB" "$BINS_UB" "$LINUX_PATH_COUNTER_UNBLOB"
|
||||
write_csv_log "${FILES_EXT_UB}" "${UNIQUE_FILES_UB}" "${DIRS_EXT_UB}" "${BINS_UB}" "${LINUX_PATH_COUNTER_UNBLOB}"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$FILES_EXT_UB"
|
||||
module_end_log "${FUNCNAME[0]}" "${FILES_EXT_UB}"
|
||||
}
|
||||
|
||||
unblobber() {
|
||||
@@ -120,16 +120,16 @@ unblobber() {
|
||||
sub_module_title "Analyze binary firmware blob with unblob"
|
||||
fi
|
||||
|
||||
print_output "[*] Extracting firmware to directory $ORANGE$OUTPUT_DIR_UNBLOB$NC"
|
||||
print_output "[*] Extracting firmware to directory ${ORANGE}${OUTPUT_DIR_UNBLOB}${NC}"
|
||||
|
||||
if ! [[ -d "$OUTPUT_DIR_UNBLOB" ]]; then
|
||||
mkdir -p "$OUTPUT_DIR_UNBLOB"
|
||||
if ! [[ -d "${OUTPUT_DIR_UNBLOB}" ]]; then
|
||||
mkdir -p "${OUTPUT_DIR_UNBLOB}"
|
||||
fi
|
||||
|
||||
if [[ "${VERBOSE}" -eq 1 ]]; then
|
||||
timeout --preserve-status --signal SIGINT 300 "$UNBLOB_BIN" -v -k --log "$LOG_PATH_MODULE"/unblob_"$(basename "$FIRMWARE_PATH_")".log -e "$OUTPUT_DIR_UNBLOB" "$FIRMWARE_PATH_" | tee -a "$LOG_FILE" || true
|
||||
timeout --preserve-status --signal SIGINT 300 "${UNBLOB_BIN}" -v -k --log "${LOG_PATH_MODULE}"/unblob_"$(basename "${FIRMWARE_PATH_}")".log -e "${OUTPUT_DIR_UNBLOB}" "${FIRMWARE_PATH_}" | tee -a "${LOG_FILE}" || true
|
||||
else
|
||||
COLUMNS=100 timeout --preserve-status --signal SIGINT 300 "$UNBLOB_BIN" -k --log "$LOG_PATH_MODULE"/unblob_"$(basename "$FIRMWARE_PATH_")".log -e "$OUTPUT_DIR_UNBLOB" "$FIRMWARE_PATH_" | tee -a "$LOG_FILE" || true
|
||||
COLUMNS=100 timeout --preserve-status --signal SIGINT 300 "${UNBLOB_BIN}" -k --log "${LOG_PATH_MODULE}"/unblob_"$(basename "${FIRMWARE_PATH_}")".log -e "${OUTPUT_DIR_UNBLOB}" "${FIRMWARE_PATH_}" | tee -a "${LOG_FILE}" || true
|
||||
fi
|
||||
|
||||
print_ln
|
||||
@@ -137,8 +137,8 @@ unblobber() {
|
||||
|
||||
linux_basic_identification_unblobber() {
|
||||
local FIRMWARE_PATH_CHECK="${1:-}"
|
||||
if ! [[ -d "$FIRMWARE_PATH_CHECK" ]]; then
|
||||
if ! [[ -d "${FIRMWARE_PATH_CHECK}" ]]; then
|
||||
return
|
||||
fi
|
||||
LINUX_PATH_COUNTER_UNBLOB="$(find "$FIRMWARE_PATH_CHECK" "${EXCL_FIND[@]}" -xdev -type d -iname bin -o -type f -iname busybox -o -type f -name shadow -o -type f -name passwd -o -type d -iname sbin -o -type d -iname etc 2> /dev/null | wc -l)"
|
||||
LINUX_PATH_COUNTER_UNBLOB="$(find "${FIRMWARE_PATH_CHECK}" "${EXCL_FIND[@]}" -xdev -type d -iname bin -o -type f -iname busybox -o -type f -name shadow -o -type f -name passwd -o -type d -iname sbin -o -type d -iname etc 2> /dev/null | wc -l)"
|
||||
}
|
||||
|
||||
+150
-150
@@ -26,73 +26,73 @@ P60_deep_extractor() {
|
||||
export DISK_SPACE_CRIT=0
|
||||
|
||||
# If we have not found a linux filesystem we try to do an extraction round on every file multiple times
|
||||
if [[ $RTOS -eq 0 ]] ; then
|
||||
if [[ ${RTOS} -eq 0 ]] ; then
|
||||
module_end_log "${FUNCNAME[0]}" 0
|
||||
return
|
||||
fi
|
||||
|
||||
check_disk_space
|
||||
if ! [[ "$DISK_SPACE" -gt "$MAX_EXT_SPACE" ]]; then
|
||||
if ! [[ "${DISK_SPACE}" -gt "${MAX_EXT_SPACE}" ]]; then
|
||||
deep_extractor
|
||||
else
|
||||
print_output "[!] $(date) - Extractor needs too much disk space $DISK_SPACE" "main"
|
||||
print_output "[!] $(date) - Extractor needs too much disk space ${DISK_SPACE}" "main"
|
||||
print_output "[!] $(date) - Ending extraction processes - no deep extraction performed" "main"
|
||||
DISK_SPACE_CRIT=1
|
||||
fi
|
||||
|
||||
sub_module_title "Extration results"
|
||||
|
||||
FILES_EXT=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES=$(find "$FIRMWARE_PATH_CP" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT=$(find "$FIRMWARE_PATH_CP" -xdev -type d | wc -l )
|
||||
BINS=$(find "$FIRMWARE_PATH_CP" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
FILES_EXT=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES=$(find "${FIRMWARE_PATH_CP}" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT=$(find "${FIRMWARE_PATH_CP}" -xdev -type d | wc -l )
|
||||
BINS=$(find "${FIRMWARE_PATH_CP}" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
|
||||
if [[ "$BINS" -gt 0 || "$UNIQUE_FILES" -gt 0 ]]; then
|
||||
if [[ "${BINS}" -gt 0 || "${UNIQUE_FILES}" -gt 0 ]]; then
|
||||
export LINUX_PATH_COUNTER=0
|
||||
linux_basic_identification_helper "$FIRMWARE_PATH_CP"
|
||||
linux_basic_identification_helper "${FIRMWARE_PATH_CP}"
|
||||
print_ln
|
||||
print_output "[*] Found $ORANGE$FILES_EXT$NC files ($ORANGE$UNIQUE_FILES$NC unique files) and $ORANGE$DIRS_EXT$NC directories at all."
|
||||
print_output "[*] Found $ORANGE$BINS$NC binaries."
|
||||
print_output "[*] Additionally the Linux path counter is $ORANGE$LINUX_PATH_COUNTER$NC."
|
||||
print_output "[*] Found ${ORANGE}${FILES_EXT}${NC} files (${ORANGE}${UNIQUE_FILES}${NC} unique files) and ${ORANGE}${DIRS_EXT}${NC} directories at all."
|
||||
print_output "[*] Found ${ORANGE}${BINS}${NC} binaries."
|
||||
print_output "[*] Additionally the Linux path counter is ${ORANGE}${LINUX_PATH_COUNTER}${NC}."
|
||||
|
||||
tree -csh "$FIRMWARE_PATH_CP" | tee -a "$LOG_FILE"
|
||||
tree -csh "${FIRMWARE_PATH_CP}" | tee -a "${LOG_FILE}"
|
||||
|
||||
# now it should be fine to also set the FIRMWARE_PATH ot the FIRMWARE_PATH_CP
|
||||
export FIRMWARE_PATH="$FIRMWARE_PATH_CP"
|
||||
export FIRMWARE_PATH="${FIRMWARE_PATH_CP}"
|
||||
|
||||
if [[ "${#ROOT_PATH[@]}" -gt 0 ]] ; then
|
||||
write_csv_log "FILES" "UNIQUE_FILES" "DIRS" "Binaries" "LINUX_PATH_COUNTER" "Root PATH detected"
|
||||
for R_PATH in "${ROOT_PATH[@]}"; do
|
||||
write_csv_log "$FILES_EXT" "$UNIQUE_FILES" "$DIRS_EXT" "$BINS" "$LINUX_PATH_COUNTER" "$R_PATH"
|
||||
write_csv_log "${FILES_EXT}" "${UNIQUE_FILES}" "${DIRS_EXT}" "${BINS}" "${LINUX_PATH_COUNTER}" "${R_PATH}"
|
||||
done
|
||||
fi
|
||||
backup_var "FILES_EXT" "$FILES_EXT"
|
||||
backup_var "FILES_EXT" "${FILES_EXT}"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$FILES_EXT"
|
||||
module_end_log "${FUNCNAME[0]}" "${FILES_EXT}"
|
||||
}
|
||||
|
||||
check_disk_space() {
|
||||
export DISK_SPACE
|
||||
DISK_SPACE=$(du -hm "$FIRMWARE_PATH_CP" --max-depth=1 --exclude="proc" 2>/dev/null | awk '{ print $1 }' | sort -hr | head -1 || true)
|
||||
DISK_SPACE=$(du -hm "${FIRMWARE_PATH_CP}" --max-depth=1 --exclude="proc" 2>/dev/null | awk '{ print $1 }' | sort -hr | head -1 || true)
|
||||
}
|
||||
|
||||
disk_space_protection() {
|
||||
local SEARCHER="${1:-}"
|
||||
local DDISK="$LOG_DIR"
|
||||
local DDISK="${LOG_DIR}"
|
||||
local FREE_SPACE=""
|
||||
|
||||
check_disk_space
|
||||
FREE_SPACE=$(df --output=avail "$DDISK" | awk 'NR==2')
|
||||
if [[ "$FREE_SPACE" -lt 100000 ]] || [[ "$DISK_SPACE" -gt "$MAX_EXT_SPACE" ]]; then
|
||||
FREE_SPACE=$(df --output=avail "${DDISK}" | awk 'NR==2')
|
||||
if [[ "${FREE_SPACE}" -lt 100000 ]] || [[ "${DISK_SPACE}" -gt "${MAX_EXT_SPACE}" ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[!] $(date) - Extractor needs too much disk space $DISK_SPACE" "main"
|
||||
print_output "[!] $(date) - Extractor needs too much disk space ${DISK_SPACE}" "main"
|
||||
print_output "[!] $(date) - Ending extraction processes" "main"
|
||||
pgrep -a -f "binwalk.*$SEARCHER.*" || true
|
||||
pkill -f ".*binwalk.*$SEARCHER.*" || true
|
||||
pkill -f ".*extract\.py.*$SEARCHER.*" || true
|
||||
pgrep -a -f "binwalk.*${SEARCHER}.*" || true
|
||||
pkill -f ".*binwalk.*${SEARCHER}.*" || true
|
||||
pkill -f ".*extract\.py.*${SEARCHER}.*" || true
|
||||
# PID is from wait_for_extractor
|
||||
kill -9 "$PID" 2>/dev/null || true
|
||||
kill -9 "${PID}" 2>/dev/null || true
|
||||
DISK_SPACE_CRIT=1
|
||||
fi
|
||||
}
|
||||
@@ -102,192 +102,192 @@ deep_extractor() {
|
||||
|
||||
FILE_MD5=""
|
||||
|
||||
FILES_BEFORE_DEEP=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
FILES_BEFORE_DEEP=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
|
||||
# if we run into the deep extraction mode we always do at least one extraction round:
|
||||
if [[ "$DISK_SPACE_CRIT" -eq 0 ]]; then
|
||||
if [[ "${DISK_SPACE_CRIT}" -eq 0 ]]; then
|
||||
print_output "[*] Deep extraction - 1st round"
|
||||
print_output "[*] Walking through all files and try to extract what ever possible"
|
||||
|
||||
deeper_extractor_helper
|
||||
detect_root_dir_helper "$FIRMWARE_PATH_CP"
|
||||
detect_root_dir_helper "${FIRMWARE_PATH_CP}"
|
||||
fi
|
||||
|
||||
if [[ $RTOS -eq 1 && "$DISK_SPACE_CRIT" -eq 0 ]]; then
|
||||
if [[ ${RTOS} -eq 1 && "${DISK_SPACE_CRIT}" -eq 0 ]]; then
|
||||
print_output "[*] Deep extraction - 2nd round"
|
||||
print_output "[*] Walking through all files and try to extract what ever possible"
|
||||
|
||||
deeper_extractor_helper
|
||||
detect_root_dir_helper "$FIRMWARE_PATH_CP"
|
||||
detect_root_dir_helper "${FIRMWARE_PATH_CP}"
|
||||
fi
|
||||
|
||||
if [[ $RTOS -eq 1 && "$DISK_SPACE_CRIT" -eq 0 ]]; then
|
||||
if [[ ${RTOS} -eq 1 && "${DISK_SPACE_CRIT}" -eq 0 ]]; then
|
||||
print_output "[*] Deep extraction - 3rd round"
|
||||
print_output "[*] Walking through all files and try to extract what ever possible"
|
||||
|
||||
deeper_extractor_helper
|
||||
detect_root_dir_helper "$FIRMWARE_PATH_CP"
|
||||
detect_root_dir_helper "${FIRMWARE_PATH_CP}"
|
||||
fi
|
||||
|
||||
if [[ $RTOS -eq 1 && "$DISK_SPACE_CRIT" -eq 0 ]]; then
|
||||
if [[ ${RTOS} -eq 1 && "${DISK_SPACE_CRIT}" -eq 0 ]]; then
|
||||
print_output "[*] Deep extraction - 4th round"
|
||||
print_output "[*] Walking through all files and try to extract what ever possible with binwalk matryoshka mode"
|
||||
print_output "[*] WARNING: This is the last extraction round that is executed."
|
||||
|
||||
# if we are already that far we do a final matryoshka extraction mode
|
||||
deeper_extractor_helper
|
||||
detect_root_dir_helper "$FIRMWARE_PATH_CP"
|
||||
detect_root_dir_helper "${FIRMWARE_PATH_CP}"
|
||||
fi
|
||||
|
||||
FILES_AFTER_DEEP=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
FILES_AFTER_DEEP=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
|
||||
print_output "[*] Before deep extraction we had $ORANGE$FILES_BEFORE_DEEP$NC files, after deep extraction we have now $ORANGE$FILES_AFTER_DEEP$NC files extracted."
|
||||
print_output "[*] Before deep extraction we had ${ORANGE}${FILES_BEFORE_DEEP}${NC} files, after deep extraction we have now ${ORANGE}${FILES_AFTER_DEEP}${NC} files extracted."
|
||||
}
|
||||
|
||||
deeper_extractor_helper() {
|
||||
local FILE_TMP=""
|
||||
local FILE_MD5=""
|
||||
|
||||
prepare_file_arr_limited "$FIRMWARE_PATH_CP"
|
||||
prepare_file_arr_limited "${FIRMWARE_PATH_CP}"
|
||||
|
||||
for FILE_TMP in "${FILE_ARR_LIMITED[@]}"; do
|
||||
|
||||
FILE_MD5="$(md5sum "$FILE_TMP" | awk '{print $1}')"
|
||||
FILE_MD5="$(md5sum "${FILE_TMP}" | awk '{print $1}')"
|
||||
# let's check the current md5sum against our array of unique md5sums - if we have a match this is already extracted
|
||||
# already extracted stuff is ignored
|
||||
|
||||
[[ "${MD5_DONE_DEEP[*]}" == *"${FILE_MD5}"* ]] && continue
|
||||
|
||||
print_output "[*] Details of file: $ORANGE$FILE_TMP$NC"
|
||||
print_output "$(indent "$(orange "$(file "$FILE_TMP")")")"
|
||||
print_output "$(indent "$(orange "$(md5sum "$FILE_TMP")")")"
|
||||
print_output "[*] Details of file: ${ORANGE}${FILE_TMP}${NC}"
|
||||
print_output "$(indent "$(orange "$(file "${FILE_TMP}")")")"
|
||||
print_output "$(indent "$(orange "$(md5sum "${FILE_TMP}")")")"
|
||||
|
||||
# do a quick check if EMBA should handle the file or we give it to unblob:
|
||||
# fw_bin_detector is a function from p02
|
||||
fw_bin_detector "$FILE_TMP"
|
||||
fw_bin_detector "${FILE_TMP}"
|
||||
|
||||
if [[ "$VMDK_DETECTED" -eq 1 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
vmdk_extractor "$FILE_TMP" "${FILE_TMP}_vmdk_extracted" &
|
||||
if [[ "${VMDK_DETECTED}" -eq 1 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
vmdk_extractor "${FILE_TMP}" "${FILE_TMP}_vmdk_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
vmdk_extractor "$FILE_TMP" "${FILE_TMP}_vmdk_extracted"
|
||||
vmdk_extractor "${FILE_TMP}" "${FILE_TMP}_vmdk_extracted"
|
||||
fi
|
||||
elif [[ "$UBI_IMAGE" -eq 1 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
ubi_extractor "$FILE_TMP" "${FILE_TMP}_ubi_extracted" &
|
||||
elif [[ "${UBI_IMAGE}" -eq 1 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
ubi_extractor "${FILE_TMP}" "${FILE_TMP}_ubi_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
ubi_extractor "$FILE_TMP" "${FILE_TMP}_ubi_extracted"
|
||||
ubi_extractor "${FILE_TMP}" "${FILE_TMP}_ubi_extracted"
|
||||
fi
|
||||
# now handled via unblob
|
||||
# elif [[ "$DLINK_ENC_DETECTED" -eq 1 ]]; then
|
||||
# if [[ "$THREADED" -eq 1 ]]; then
|
||||
# dlink_SHRS_enc_extractor "$FILE_TMP" "${FILE_TMP}_shrs_extracted" &
|
||||
# elif [[ "${DLINK_ENC_DETECTED}" -eq 1 ]]; then
|
||||
# if [[ "${THREADED}" -eq 1 ]]; then
|
||||
# dlink_SHRS_enc_extractor "${FILE_TMP}" "${FILE_TMP}_shrs_extracted" &
|
||||
# BIN_PID="$!"
|
||||
# store_kill_pids "$BIN_PID"
|
||||
# disown "$BIN_PID" 2> /dev/null || true
|
||||
# WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
# store_kill_pids "${BIN_PID}"
|
||||
# disown "${BIN_PID}" 2> /dev/null || true
|
||||
# WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
# else
|
||||
# dlink_SHRS_enc_extractor "$FILE_TMP" "${FILE_TMP}_shrs_extracted"
|
||||
# dlink_SHRS_enc_extractor "${FILE_TMP}" "${FILE_TMP}_shrs_extracted"
|
||||
# fi
|
||||
# now handled via unblob
|
||||
# elif [[ "$DLINK_ENC_DETECTED" -eq 2 ]]; then
|
||||
# if [[ "$THREADED" -eq 1 ]]; then
|
||||
# dlink_enc_img_extractor "$FILE_TMP" "${FILE_TMP}_enc_img_extracted" &
|
||||
# elif [[ "${DLINK_ENC_DETECTED}" -eq 2 ]]; then
|
||||
# if [[ "${THREADED}" -eq 1 ]]; then
|
||||
# dlink_enc_img_extractor "${FILE_TMP}" "${FILE_TMP}_enc_img_extracted" &
|
||||
# BIN_PID="$!"
|
||||
# store_kill_pids "$BIN_PID"
|
||||
# disown "$BIN_PID" 2> /dev/null || true
|
||||
# WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
# store_kill_pids "${BIN_PID}"
|
||||
# disown "${BIN_PID}" 2> /dev/null || true
|
||||
# WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
# else
|
||||
# dlink_enc_img_extractor "$FILE_TMP" "${FILE_TMP}_enc_img_extracted"
|
||||
# dlink_enc_img_extractor "${FILE_TMP}" "${FILE_TMP}_enc_img_extracted"
|
||||
# fi
|
||||
elif [[ "$EXT_IMAGE" -eq 1 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
ext_extractor "$FILE_TMP" "${FILE_TMP}_ext_extracted" &
|
||||
elif [[ "${EXT_IMAGE}" -eq 1 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
ext_extractor "${FILE_TMP}" "${FILE_TMP}_ext_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
ext_extractor "$FILE_TMP" "${FILE_TMP}_ext_extracted"
|
||||
ext_extractor "${FILE_TMP}" "${FILE_TMP}_ext_extracted"
|
||||
fi
|
||||
# now handled via unblob
|
||||
# elif [[ "$ENGENIUS_ENC_DETECTED" -ne 0 ]]; then
|
||||
# if [[ "$THREADED" -eq 1 ]]; then
|
||||
# engenius_enc_extractor "$FILE_TMP" "${FILE_TMP}_engenius_extracted" &
|
||||
# elif [[ "${ENGENIUS_ENC_DETECTED}" -ne 0 ]]; then
|
||||
# if [[ "${THREADED}" -eq 1 ]]; then
|
||||
# engenius_enc_extractor "${FILE_TMP}" "${FILE_TMP}_engenius_extracted" &
|
||||
# BIN_PID="$!"
|
||||
# store_kill_pids "$BIN_PID"
|
||||
# disown "$BIN_PID" 2> /dev/null || true
|
||||
# WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
# store_kill_pids "${BIN_PID}"
|
||||
# disown "${BIN_PID}" 2> /dev/null || true
|
||||
# WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
# else
|
||||
# engenius_enc_extractor "$FILE_TMP" "${FILE_TMP}_engenius_extracted"
|
||||
# engenius_enc_extractor "${FILE_TMP}" "${FILE_TMP}_engenius_extracted"
|
||||
# fi
|
||||
elif [[ "$BSD_UFS" -ne 0 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
ufs_extractor "$FILE_TMP" "${FILE_TMP}_bsd_ufs_extracted" &
|
||||
elif [[ "${BSD_UFS}" -ne 0 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
ufs_extractor "${FILE_TMP}" "${FILE_TMP}_bsd_ufs_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
ufs_extractor "$FILE_TMP" "${FILE_TMP}_bsd_ufs_extracted"
|
||||
ufs_extractor "${FILE_TMP}" "${FILE_TMP}_bsd_ufs_extracted"
|
||||
fi
|
||||
elif [[ "$ANDROID_OTA" -ne 0 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
android_ota_extractor "$FILE_TMP" "${FILE_TMP}_android_ota_extracted" &
|
||||
elif [[ "${ANDROID_OTA}" -ne 0 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
android_ota_extractor "${FILE_TMP}" "${FILE_TMP}_android_ota_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
android_ota_extractor "$FILE_TMP" "${FILE_TMP}_android_ota_extracted"
|
||||
android_ota_extractor "${FILE_TMP}" "${FILE_TMP}_android_ota_extracted"
|
||||
fi
|
||||
elif [[ "$OPENSSL_ENC_DETECTED" -ne 0 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
foscam_enc_extractor "$FILE_TMP" "${FILE_TMP}_foscam_enc_extracted" &
|
||||
elif [[ "${OPENSSL_ENC_DETECTED}" -ne 0 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
foscam_enc_extractor "${FILE_TMP}" "${FILE_TMP}_foscam_enc_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
foscam_enc_extractor "$FILE_TMP" "${FILE_TMP}_foscam_enc_extracted"
|
||||
foscam_enc_extractor "${FILE_TMP}" "${FILE_TMP}_foscam_enc_extracted"
|
||||
fi
|
||||
elif [[ "$BUFFALO_ENC_DETECTED" -ne 0 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
buffalo_enc_extractor "$FILE_TMP" "${FILE_TMP}_buffalo_enc_extracted" &
|
||||
elif [[ "${BUFFALO_ENC_DETECTED}" -ne 0 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
buffalo_enc_extractor "${FILE_TMP}" "${FILE_TMP}_buffalo_enc_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
buffalo_enc_extractor "$FILE_TMP" "${FILE_TMP}_buffalo_enc_extracted"
|
||||
buffalo_enc_extractor "${FILE_TMP}" "${FILE_TMP}_buffalo_enc_extracted"
|
||||
fi
|
||||
elif [[ "$ZYXEL_ZIP" -ne 0 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
zyxel_zip_extractor "$FILE_TMP" "${FILE_TMP}_zyxel_enc_extracted" &
|
||||
elif [[ "${ZYXEL_ZIP}" -ne 0 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
zyxel_zip_extractor "${FILE_TMP}" "${FILE_TMP}_zyxel_enc_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
zyxel_zip_extractor "$FILE_TMP" "${FILE_TMP}_zyxel_enc_extracted"
|
||||
zyxel_zip_extractor "${FILE_TMP}" "${FILE_TMP}_zyxel_enc_extracted"
|
||||
fi
|
||||
elif [[ "$QCOW_DETECTED" -ne 0 ]]; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
qcow_extractor "$FILE_TMP" "${FILE_TMP}_qemu_qcow_extracted" &
|
||||
elif [[ "${QCOW_DETECTED}" -ne 0 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
qcow_extractor "${FILE_TMP}" "${FILE_TMP}_qemu_qcow_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
qcow_extractor "$FILE_TMP" "${FILE_TMP}_qemu_qcow_extracted"
|
||||
qcow_extractor "${FILE_TMP}" "${FILE_TMP}_qemu_qcow_extracted"
|
||||
fi
|
||||
elif [[ "${BMC_ENC_DETECTED}" -ne 0 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
@@ -301,68 +301,68 @@ deeper_extractor_helper() {
|
||||
fi
|
||||
else
|
||||
# default case to Unblob
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
unblobber "$FILE_TMP" "${FILE_TMP}_unblob_extracted" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
unblobber "${FILE_TMP}" "${FILE_TMP}_unblob_extracted" &
|
||||
BIN_PID="$!"
|
||||
store_kill_pids "$BIN_PID"
|
||||
disown "$BIN_PID" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "$BIN_PID" )
|
||||
store_kill_pids "${BIN_PID}"
|
||||
disown "${BIN_PID}" 2> /dev/null || true
|
||||
WAIT_PIDS_P20+=( "${BIN_PID}" )
|
||||
else
|
||||
unblobber "$FILE_TMP" "${FILE_TMP}_unblob_extracted"
|
||||
unblobber "${FILE_TMP}" "${FILE_TMP}_unblob_extracted"
|
||||
fi
|
||||
fi
|
||||
|
||||
MD5_DONE_DEEP+=( "$FILE_MD5" )
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_P20[@]}"
|
||||
MD5_DONE_DEEP+=( "${FILE_MD5}" )
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_P20[@]}"
|
||||
|
||||
check_disk_space
|
||||
|
||||
FREE_SPACE=$(df --output=avail "$LOG_DIR" | awk 'NR==2')
|
||||
if [[ "$FREE_SPACE" -lt 100000 ]]; then
|
||||
FREE_SPACE=$(df --output=avail "${LOG_DIR}" | awk 'NR==2')
|
||||
if [[ "${FREE_SPACE}" -lt 100000 ]]; then
|
||||
# this should stop the complete EMBA test in the future - currenlty it is work in progress
|
||||
print_output "[!] $(date) - The system is running out of disk space $ORANGE$FREE_SPACE$NC" "main"
|
||||
print_output "[!] $(date) - The system is running out of disk space ${ORANGE}${FREE_SPACE}${NC}" "main"
|
||||
print_output "[!] $(date) - Ending EMBA firmware analysis processes" "main"
|
||||
cleaner 1
|
||||
exit
|
||||
elif [[ "$DISK_SPACE" -gt "$MAX_EXT_SPACE" ]]; then
|
||||
elif [[ "${DISK_SPACE}" -gt "${MAX_EXT_SPACE}" ]]; then
|
||||
# this stops the deep extractor but not EMBA
|
||||
print_output "[!] $(date) - Extractor needs too much disk space $DISK_SPACE" "main"
|
||||
print_output "[!] $(date) - Extractor needs too much disk space ${DISK_SPACE}" "main"
|
||||
print_output "[!] $(date) - Ending extraction processes" "main"
|
||||
DISK_SPACE_CRIT=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_P20[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_P20[@]}"
|
||||
}
|
||||
|
||||
linux_basic_identification_helper() {
|
||||
local FIRMWARE_PATH_CHECK="${1:-}"
|
||||
if ! [[ -d "$FIRMWARE_PATH_CHECK" ]]; then
|
||||
if ! [[ -d "${FIRMWARE_PATH_CHECK}" ]]; then
|
||||
LINUX_PATH_COUNTER=0
|
||||
return
|
||||
fi
|
||||
LINUX_PATH_COUNTER="$(find "$FIRMWARE_PATH_CHECK" "${EXCL_FIND[@]}" -xdev -type d -iname bin -o -type f -iname busybox -o -type f -name shadow -o -type f -name passwd -o -type d -iname sbin -o -type d -iname etc 2> /dev/null | wc -l)"
|
||||
backup_var "LINUX_PATH_COUNTER" "$LINUX_PATH_COUNTER"
|
||||
LINUX_PATH_COUNTER="$(find "${FIRMWARE_PATH_CHECK}" "${EXCL_FIND[@]}" -xdev -type d -iname bin -o -type f -iname busybox -o -type f -name shadow -o -type f -name passwd -o -type d -iname sbin -o -type d -iname etc 2> /dev/null | wc -l)"
|
||||
backup_var "LINUX_PATH_COUNTER" "${LINUX_PATH_COUNTER}"
|
||||
}
|
||||
|
||||
wait_for_extractor() {
|
||||
export OUTPUT_DIR="$FIRMWARE_PATH_CP"
|
||||
export OUTPUT_DIR="${FIRMWARE_PATH_CP}"
|
||||
local SEARCHER=""
|
||||
SEARCHER=$(basename "$FIRMWARE_PATH")
|
||||
SEARCHER=$(basename "${FIRMWARE_PATH}")
|
||||
|
||||
# this is not solid and we probably have to adjust it in the future
|
||||
# but for now it works
|
||||
SEARCHER="$(safe_echo "$SEARCHER" | tr "(" "." | tr ")" ".")"
|
||||
SEARCHER="$(safe_echo "${SEARCHER}" | tr "(" "." | tr ")" ".")"
|
||||
|
||||
for PID in "${WAIT_PIDS[@]}"; do
|
||||
local running=1
|
||||
while [[ $running -eq 1 ]]; do
|
||||
while [[ ${running} -eq 1 ]]; do
|
||||
print_dot
|
||||
if ! pgrep -v grep | grep -q "$PID"; then
|
||||
if ! pgrep -v grep | grep -q "${PID}"; then
|
||||
running=0
|
||||
fi
|
||||
disk_space_protection "$SEARCHER"
|
||||
disk_space_protection "${SEARCHER}"
|
||||
sleep 1
|
||||
done
|
||||
done
|
||||
|
||||
@@ -28,58 +28,58 @@ P65_package_extractor() {
|
||||
export FILES_PRE_PACKAGE=0
|
||||
local FILES_POST_PACKAGE=0
|
||||
|
||||
if [[ "${#ROOT_PATH[@]}" -gt 0 && "$RTOS" -eq 0 ]]; then
|
||||
FILES_PRE_PACKAGE=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
if [[ "$DISK_SPACE_CRIT" -ne 1 ]]; then
|
||||
if [[ "${#ROOT_PATH[@]}" -gt 0 && "${RTOS}" -eq 0 ]]; then
|
||||
FILES_PRE_PACKAGE=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
if [[ "${DISK_SPACE_CRIT}" -ne 1 ]]; then
|
||||
deb_extractor
|
||||
else
|
||||
print_output "[!] $(date) - Extractor needs too much disk space $DISK_SPACE" "main"
|
||||
print_output "[!] $(date) - Extractor needs too much disk space ${DISK_SPACE}" "main"
|
||||
print_output "[!] $(date) - Ending extraction processes - no deb extraction performed" "main"
|
||||
DISK_SPACE_CRIT=1
|
||||
fi
|
||||
if [[ "$DISK_SPACE_CRIT" -ne 1 ]]; then
|
||||
if [[ "${DISK_SPACE_CRIT}" -ne 1 ]]; then
|
||||
ipk_extractor
|
||||
else
|
||||
print_output "[!] $(date) - Extractor needs too much disk space $DISK_SPACE" "main"
|
||||
print_output "[!] $(date) - Extractor needs too much disk space ${DISK_SPACE}" "main"
|
||||
print_output "[!] $(date) - Ending extraction processes - no ipk extraction performed" "main"
|
||||
DISK_SPACE_CRIT=1
|
||||
fi
|
||||
if [[ "$DISK_SPACE_CRIT" -ne 1 ]]; then
|
||||
if [[ "${DISK_SPACE_CRIT}" -ne 1 ]]; then
|
||||
apk_extractor
|
||||
else
|
||||
print_output "[!] $(date) - Extractor needs too much disk space $DISK_SPACE" "main"
|
||||
print_output "[!] $(date) - Extractor needs too much disk space ${DISK_SPACE}" "main"
|
||||
print_output "[!] $(date) - Ending extraction processes - apk extraction performed" "main"
|
||||
DISK_SPACE_CRIT=1
|
||||
fi
|
||||
|
||||
FILES_POST_PACKAGE=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
FILES_POST_PACKAGE=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
|
||||
if [[ "$FILES_POST_PACKAGE" -gt "$FILES_PRE_PACKAGE" ]]; then
|
||||
if [[ "${FILES_POST_PACKAGE}" -gt "${FILES_PRE_PACKAGE}" ]]; then
|
||||
# we need to update these numbers:
|
||||
FILES_EXT=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES=$(find "$FIRMWARE_PATH_CP" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT=$(find "$FIRMWARE_PATH_CP" -xdev -type d | wc -l )
|
||||
BINS=$(find "$FIRMWARE_PATH_CP" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
FILES_EXT=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES=$(find "${FIRMWARE_PATH_CP}" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT=$(find "${FIRMWARE_PATH_CP}" -xdev -type d | wc -l )
|
||||
BINS=$(find "${FIRMWARE_PATH_CP}" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
|
||||
if [[ "$BINS" -gt 0 || "$UNIQUE_FILES" -gt 0 ]]; then
|
||||
if [[ "${BINS}" -gt 0 || "${UNIQUE_FILES}" -gt 0 ]]; then
|
||||
sub_module_title "Firmware package extraction details"
|
||||
linux_basic_identification_helper "$FIRMWARE_PATH_CP"
|
||||
linux_basic_identification_helper "${FIRMWARE_PATH_CP}"
|
||||
print_ln
|
||||
print_output "[*] Found $ORANGE$FILES_EXT$NC files ($ORANGE$UNIQUE_FILES$NC unique files) and $ORANGE$DIRS_EXT$NC directories at all."
|
||||
print_output "[*] Found $ORANGE$BINS$NC binaries."
|
||||
print_output "[*] Additionally the Linux path counter is $ORANGE$LINUX_PATH_COUNTER$NC."
|
||||
print_output "[*] Found ${ORANGE}${FILES_EXT}${NC} files (${ORANGE}${UNIQUE_FILES}${NC} unique files) and ${ORANGE}${DIRS_EXT}${NC} directories at all."
|
||||
print_output "[*] Found ${ORANGE}${BINS}${NC} binaries."
|
||||
print_output "[*] Additionally the Linux path counter is ${ORANGE}${LINUX_PATH_COUNTER}${NC}."
|
||||
print_ln
|
||||
tree -csh "$FIRMWARE_PATH_CP" | tee -a "$LOG_FILE"
|
||||
print_output "[*] Before package extraction we had $ORANGE$FILES_PRE_PACKAGE$NC files, after package extraction we have now $ORANGE$FILES_POST_PACKAGE$NC files extracted."
|
||||
tree -csh "${FIRMWARE_PATH_CP}" | tee -a "${LOG_FILE}"
|
||||
print_output "[*] Before package extraction we had ${ORANGE}${FILES_PRE_PACKAGE}${NC} files, after package extraction we have now ${ORANGE}${FILES_POST_PACKAGE}${NC} files extracted."
|
||||
NEG_LOG=1
|
||||
fi
|
||||
backup_var "FILES_EXT" "$FILES_EXT"
|
||||
backup_var "FILES_EXT" "${FILES_EXT}"
|
||||
fi
|
||||
else
|
||||
print_output "[*] As there is no root directory detected it is not possible to process package archives"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
apk_extractor() {
|
||||
@@ -94,22 +94,22 @@ apk_extractor() {
|
||||
wait_for_extractor
|
||||
WAIT_PIDS=( )
|
||||
|
||||
if [[ -f "$TMP_DIR"/apk_db.txt ]] ; then
|
||||
APK_ARCHIVES=$(wc -l "$TMP_DIR"/apk_db.txt | awk '{print $1}')
|
||||
if [[ "$APK_ARCHIVES" -gt 0 ]]; then
|
||||
print_output "[*] Found $ORANGE$APK_ARCHIVES$NC APK archives - extracting them to the root directories ..."
|
||||
if [[ -f "${TMP_DIR}"/apk_db.txt ]] ; then
|
||||
APK_ARCHIVES=$(wc -l "${TMP_DIR}"/apk_db.txt | awk '{print $1}')
|
||||
if [[ "${APK_ARCHIVES}" -gt 0 ]]; then
|
||||
print_output "[*] Found ${ORANGE}${APK_ARCHIVES}${NC} APK archives - extracting them to the root directories ..."
|
||||
for R_PATH in "${ROOT_PATH[@]}"; do
|
||||
while read -r APK; do
|
||||
APK_NAME=$(basename "$APK")
|
||||
print_output "[*] Extracting $ORANGE$APK_NAME$NC package to the root directory $ORANGE$R_PATH$NC."
|
||||
# tar xpf "$APK" --directory "$R_PATH" || true
|
||||
unzip -o -d "$R_PATH" "$APK" || true
|
||||
done < "$TMP_DIR"/apk_db.txt
|
||||
APK_NAME=$(basename "${APK}")
|
||||
print_output "[*] Extracting ${ORANGE}${APK_NAME}${NC} package to the root directory ${ORANGE}${R_PATH}${NC}."
|
||||
# tar xpf "${APK}" --directory "${R_PATH}" || true
|
||||
unzip -o -d "${R_PATH}" "${APK}" || true
|
||||
done < "${TMP_DIR}"/apk_db.txt
|
||||
done
|
||||
|
||||
FILES_AFTER_APK=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
FILES_AFTER_APK=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
print_ln "no_log"
|
||||
print_output "[*] Before apk extraction we had $ORANGE$FILES_PRE_PACKAGE$NC files, after deep extraction we have $ORANGE$FILES_AFTER_APK$NC files extracted."
|
||||
print_output "[*] Before apk extraction we had ${ORANGE}${FILES_PRE_PACKAGE}${NC} files, after deep extraction we have ${ORANGE}${FILES_AFTER_APK}${NC} files extracted."
|
||||
fi
|
||||
check_disk_space
|
||||
else
|
||||
@@ -129,34 +129,34 @@ ipk_extractor() {
|
||||
wait_for_extractor
|
||||
WAIT_PIDS=( )
|
||||
|
||||
if [[ -f "$TMP_DIR"/ipk_db.txt ]] ; then
|
||||
IPK_ARCHIVES=$(wc -l "$TMP_DIR"/ipk_db.txt | awk '{print $1}')
|
||||
if [[ "$IPK_ARCHIVES" -gt 0 ]]; then
|
||||
print_output "[*] Found $ORANGE$IPK_ARCHIVES$NC IPK archives - extracting them to the root directories ..."
|
||||
mkdir "$LOG_DIR"/ipk_tmp
|
||||
if [[ -f "${TMP_DIR}"/ipk_db.txt ]] ; then
|
||||
IPK_ARCHIVES=$(wc -l "${TMP_DIR}"/ipk_db.txt | awk '{print $1}')
|
||||
if [[ "${IPK_ARCHIVES}" -gt 0 ]]; then
|
||||
print_output "[*] Found ${ORANGE}${IPK_ARCHIVES}${NC} IPK archives - extracting them to the root directories ..."
|
||||
mkdir "${LOG_DIR}"/ipk_tmp
|
||||
for R_PATH in "${ROOT_PATH[@]}"; do
|
||||
while read -r IPK; do
|
||||
IPK_NAME=$(basename "$IPK")
|
||||
IPK_NAME=$(basename "${IPK}")
|
||||
if [[ $(file "${IPK}") == *"gzip"* ]]; then
|
||||
print_output "[*] Extracting $ORANGE$IPK_NAME$NC package to the root directory $ORANGE$R_PATH$NC."
|
||||
tar zxpf "$IPK" --directory "$LOG_DIR"/ipk_tmp || true
|
||||
print_output "[*] Extracting ${ORANGE}${IPK_NAME}${NC} package to the root directory ${ORANGE}${R_PATH}${NC}."
|
||||
tar zxpf "${IPK}" --directory "${LOG_DIR}"/ipk_tmp || true
|
||||
else
|
||||
print_output "[-] Is ${ORANGE}${IPK_NAME}${NC} a valid ipk (tgz) archive?"
|
||||
fi
|
||||
if [[ -f "$LOG_DIR"/ipk_tmp/data.tar.gz ]]; then
|
||||
tar xzf "$LOG_DIR"/ipk_tmp/data.tar.gz --directory "$R_PATH" || true
|
||||
if [[ -f "${LOG_DIR}"/ipk_tmp/data.tar.gz ]]; then
|
||||
tar xzf "${LOG_DIR}"/ipk_tmp/data.tar.gz --directory "${R_PATH}" || true
|
||||
fi
|
||||
if [[ -d "$LOG_DIR"/ipk_tmp/ ]]; then
|
||||
rm -r "$LOG_DIR"/ipk_tmp/* 2>/dev/null || true
|
||||
if [[ -d "${LOG_DIR}"/ipk_tmp/ ]]; then
|
||||
rm -r "${LOG_DIR}"/ipk_tmp/* 2>/dev/null || true
|
||||
fi
|
||||
done < "$TMP_DIR"/ipk_db.txt
|
||||
done < "${TMP_DIR}"/ipk_db.txt
|
||||
done
|
||||
|
||||
FILES_AFTER_IPK=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
FILES_AFTER_IPK=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
print_ln "no_log"
|
||||
print_output "[*] Before ipk extraction we had $ORANGE$FILES_PRE_PACKAGE$NC files, after deep extraction we have $ORANGE$FILES_AFTER_IPK$NC files extracted."
|
||||
if [[ -d "$LOG_DIR"/ipk_tmp/ ]]; then
|
||||
rm -r "$LOG_DIR"/ipk_tmp/* 2>/dev/null || true
|
||||
print_output "[*] Before ipk extraction we had ${ORANGE}${FILES_PRE_PACKAGE}${NC} files, after deep extraction we have ${ORANGE}${FILES_AFTER_IPK}${NC} files extracted."
|
||||
if [[ -d "${LOG_DIR}"/ipk_tmp/ ]]; then
|
||||
rm -r "${LOG_DIR}"/ipk_tmp/* 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
check_disk_space
|
||||
@@ -176,26 +176,26 @@ deb_extractor() {
|
||||
wait_for_extractor
|
||||
WAIT_PIDS=( )
|
||||
|
||||
if [[ -f "$TMP_DIR"/deb_db.txt ]] ; then
|
||||
DEB_ARCHIVES=$(wc -l "$TMP_DIR"/deb_db.txt | awk '{print $1}')
|
||||
if [[ "$DEB_ARCHIVES" -gt 0 ]]; then
|
||||
print_output "[*] Found $ORANGE$DEB_ARCHIVES$NC debian archives - extracting them to the root directories ..."
|
||||
if [[ -f "${TMP_DIR}"/deb_db.txt ]] ; then
|
||||
DEB_ARCHIVES=$(wc -l "${TMP_DIR}"/deb_db.txt | awk '{print $1}')
|
||||
if [[ "${DEB_ARCHIVES}" -gt 0 ]]; then
|
||||
print_output "[*] Found ${ORANGE}${DEB_ARCHIVES}${NC} debian archives - extracting them to the root directories ..."
|
||||
for R_PATH in "${ROOT_PATH[@]}"; do
|
||||
while read -r DEB; do
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
extract_deb_extractor_helper "$DEB" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
extract_deb_extractor_helper "${DEB}" &
|
||||
WAIT_PIDS_P20+=( "$!" )
|
||||
else
|
||||
extract_deb_extractor_helper "$DEB"
|
||||
extract_deb_extractor_helper "${DEB}"
|
||||
fi
|
||||
done < "$TMP_DIR"/deb_db.txt
|
||||
done < "${TMP_DIR}"/deb_db.txt
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_P20[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_P20[@]}"
|
||||
|
||||
FILES_AFTER_DEB=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
|
||||
FILES_AFTER_DEB=$(find "${FIRMWARE_PATH_CP}" -xdev -type f | wc -l )
|
||||
print_ln "no_log"
|
||||
print_output "[*] Before deb extraction we had $ORANGE$FILES_PRE_PACKAGE$NC files, after deep extraction we have $ORANGE$FILES_AFTER_DEB$NC files extracted."
|
||||
print_output "[*] Before deb extraction we had ${ORANGE}${FILES_PRE_PACKAGE}${NC} files, after deep extraction we have ${ORANGE}${FILES_AFTER_DEB}${NC} files extracted."
|
||||
fi
|
||||
check_disk_space
|
||||
else
|
||||
@@ -204,22 +204,22 @@ deb_extractor() {
|
||||
}
|
||||
|
||||
extract_ipk_helper() {
|
||||
find "$FIRMWARE_PATH_CP" -xdev -type f -name "*.ipk" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 >> "$TMP_DIR"/ipk_db.txt
|
||||
find "${FIRMWARE_PATH_CP}" -xdev -type f -name "*.ipk" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 >> "${TMP_DIR}"/ipk_db.txt
|
||||
}
|
||||
|
||||
extract_apk_helper() {
|
||||
find "$FIRMWARE_PATH_CP" -xdev -type f -name "*.apk" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 >> "$TMP_DIR"/apk_db.txt
|
||||
find "${FIRMWARE_PATH_CP}" -xdev -type f -name "*.apk" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 >> "${TMP_DIR}"/apk_db.txt
|
||||
}
|
||||
|
||||
extract_deb_helper() {
|
||||
find "$FIRMWARE_PATH_CP" -xdev -type f \( -name "*.deb" -o -name "*.udeb" \) -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 >> "$TMP_DIR"/deb_db.txt
|
||||
find "${FIRMWARE_PATH_CP}" -xdev -type f \( -name "*.deb" -o -name "*.udeb" \) -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 >> "${TMP_DIR}"/deb_db.txt
|
||||
}
|
||||
|
||||
extract_deb_extractor_helper(){
|
||||
local DEB="${1:-}"
|
||||
local DEB_NAME
|
||||
DEB_NAME=$(basename "$DEB")
|
||||
print_output "[*] Extracting $ORANGE$DEB_NAME$NC package to the root directory $ORANGE$R_PATH$NC."
|
||||
dpkg-deb --extract "$DEB" "$R_PATH" || true
|
||||
DEB_NAME=$(basename "${DEB}")
|
||||
print_output "[*] Extracting ${ORANGE}${DEB_NAME}${NC} package to the root directory ${ORANGE}${R_PATH}${NC}."
|
||||
dpkg-deb --extract "${DEB}" "${R_PATH}" || true
|
||||
}
|
||||
|
||||
|
||||
@@ -26,61 +26,61 @@ export PRE_THREAD_ENA=0
|
||||
P99_prepare_analyzer() {
|
||||
|
||||
# this module is the latest in the preparation phase. So, wait for all the others
|
||||
[[ $THREADED -eq 1 ]] && wait_for_pid "${WAIT_PIDS[@]}"
|
||||
[[ ${THREADED} -eq 1 ]] && wait_for_pid "${WAIT_PIDS[@]}"
|
||||
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Analysis preparation"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
LINUX_PATH_COUNTER="$(find "$LOG_DIR"/firmware "${EXCL_FIND[@]}" -xdev -type d -iname bin -o -type f -iname busybox -o -type f -name shadow -o -type f -name passwd -o -type d -iname sbin -o -type d -iname etc 2> /dev/null | wc -l)"
|
||||
LINUX_PATH_COUNTER="$(find "${LOG_DIR}"/firmware "${EXCL_FIND[@]}" -xdev -type d -iname bin -o -type f -iname busybox -o -type f -name shadow -o -type f -name passwd -o -type d -iname sbin -o -type d -iname etc 2> /dev/null | wc -l)"
|
||||
|
||||
# we have a linux:
|
||||
if [[ $LINUX_PATH_COUNTER -gt 0 || ${#ROOT_PATH[@]} -gt 1 ]] ; then
|
||||
if [[ ${LINUX_PATH_COUNTER} -gt 0 || ${#ROOT_PATH[@]} -gt 1 ]] ; then
|
||||
export FIRMWARE=1
|
||||
export FIRMWARE_PATH
|
||||
# FIRMWARE_PATH="$(abs_path "$OUTPUT_DIR")"
|
||||
FIRMWARE_PATH="$LOG_DIR"/firmware
|
||||
backup_var "FIRMWARE_PATH" "$FIRMWARE_PATH"
|
||||
# FIRMWARE_PATH="$(abs_path "${OUTPUT_DIR}")"
|
||||
FIRMWARE_PATH="${LOG_DIR}"/firmware
|
||||
backup_var "FIRMWARE_PATH" "${FIRMWARE_PATH}"
|
||||
fi
|
||||
|
||||
print_output "[*] Quick check if it is a real Linux system"
|
||||
check_firmware
|
||||
print_ln
|
||||
|
||||
prepare_file_arr "$FIRMWARE_PATH"
|
||||
prepare_file_arr "${FIRMWARE_PATH}"
|
||||
print_ln
|
||||
prepare_binary_arr "$FIRMWARE_PATH"
|
||||
prepare_binary_arr "${FIRMWARE_PATH}"
|
||||
print_ln
|
||||
|
||||
if [[ $KERNEL -eq 0 ]] ; then
|
||||
if [[ ${KERNEL} -eq 0 ]] ; then
|
||||
architecture_check "${FIRMWARE_PATH}"
|
||||
architecture_dep_check
|
||||
fi
|
||||
|
||||
if [[ "${#ROOT_PATH[@]}" -eq 0 ]]; then
|
||||
detect_root_dir_helper "$FIRMWARE_PATH" "main"
|
||||
detect_root_dir_helper "${FIRMWARE_PATH}" "main"
|
||||
fi
|
||||
|
||||
set_etc_paths
|
||||
print_ln "no_log"
|
||||
if [[ "$RTOS" -eq 1 ]] && [[ "$UEFI_DETECTED" -eq 1 ]]; then
|
||||
if [[ "${RTOS}" -eq 1 ]] && [[ "${UEFI_DETECTED}" -eq 1 ]]; then
|
||||
print_output "[*] Possible UEFI firmware detected"
|
||||
elif [[ "$RTOS" -eq 1 ]]; then
|
||||
elif [[ "${RTOS}" -eq 1 ]]; then
|
||||
print_output "[*] RTOS system detected"
|
||||
fi
|
||||
|
||||
if [[ "${#ROOT_PATH[@]}" -gt 0 ]] && ! [[ -f "$CSV_DIR"/p99_prepare_analyzer.csv ]]; then
|
||||
if [[ "${#ROOT_PATH[@]}" -gt 0 ]] && ! [[ -f "${CSV_DIR}"/p99_prepare_analyzer.csv ]]; then
|
||||
write_csv_log "FILES" "UNIQUE_FILES" "DIRS" "Binaries" "LINUX_PATH_COUNTER" "Root PATH detected" "architecture" "endianess"
|
||||
for R_PATH in "${ROOT_PATH[@]}"; do
|
||||
FILES_EXT=$(find "$ROOT_PATH" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES=$(find "$ROOT_PATH" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT=$(find "$ROOT_PATH" -xdev -type d | wc -l )
|
||||
BINS=$(find "$ROOT_PATH" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
write_csv_log "$FILES_EXT" "$UNIQUE_FILES" "$DIRS_EXT" "$BINS" "$LINUX_PATH_COUNTER" "$R_PATH" "$ARCH" "$D_END"
|
||||
FILES_EXT=$(find "${ROOT_PATH}" -xdev -type f | wc -l )
|
||||
UNIQUE_FILES=$(find "${ROOT_PATH}" "${EXCL_FIND[@]}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l )
|
||||
DIRS_EXT=$(find "${ROOT_PATH}" -xdev -type d | wc -l )
|
||||
BINS=$(find "${ROOT_PATH}" "${EXCL_FIND[@]}" -xdev -type f -exec file {} \; | grep -c "ELF" || true)
|
||||
write_csv_log "${FILES_EXT}" "${UNIQUE_FILES}" "${DIRS_EXT}" "${BINS}" "${LINUX_PATH_COUNTER}" "${R_PATH}" "${ARCH}" "${D_END}"
|
||||
done
|
||||
fi
|
||||
|
||||
local NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ ask_chatgpt() {
|
||||
# remove the LOG_DIR
|
||||
# shellcheck disable=SC2001
|
||||
SCRIPT_PATH_TMP_="$(echo "${SCRIPT_PATH_TMP_}" | sed 's#'"${LOG_DIR}"'##')"
|
||||
print_output "[*] Stripped path $SCRIPT_PATH_TMP_" "no_log"
|
||||
print_output "[*] Stripped path ${SCRIPT_PATH_TMP_}" "no_log"
|
||||
fi
|
||||
# dirty fix - Todo: use array in future
|
||||
SCRIPT_PATH_TMP_="$(find "${LOG_DIR}/firmware" -wholename "*${SCRIPT_PATH_TMP_}" | head -1)"
|
||||
|
||||
+36
-36
@@ -29,45 +29,45 @@ S02_UEFI_FwHunt() {
|
||||
local MAX_MOD_THREADS=$((MAX_MOD_THREADS/2))
|
||||
local EXTRACTED_FILE=""
|
||||
|
||||
if [[ "$RTOS" -eq 1 ]] && [[ "$UEFI_DETECTED" -eq 1 ]] && [[ -v FILE_ARR_LIMITED ]]; then
|
||||
if [[ "${RTOS}" -eq 1 ]] && [[ "${UEFI_DETECTED}" -eq 1 ]] && [[ -v FILE_ARR_LIMITED ]]; then
|
||||
print_output "[*] Starting FwHunter UEFI firmware vulnerability detection"
|
||||
for EXTRACTED_FILE in "${FILE_ARR_LIMITED[@]}"; do
|
||||
if [[ $THREADED -eq 1 ]]; then
|
||||
fwhunter "$EXTRACTED_FILE" &
|
||||
if [[ ${THREADED} -eq 1 ]]; then
|
||||
fwhunter "${EXTRACTED_FILE}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S02+=( "$TMP_PID" )
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S02[@]}"
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S02+=( "${TMP_PID}" )
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S02[@]}"
|
||||
else
|
||||
fwhunter "$EXTRACTED_FILE"
|
||||
fwhunter "${EXTRACTED_FILE}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
[[ $THREADED -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S02[@]}"
|
||||
[[ ${THREADED} -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S02[@]}"
|
||||
|
||||
fwhunter_logging
|
||||
|
||||
[[ "${#FWHUNTER_RESULTS[@]}" -gt 0 ]] && NEG_LOG=1
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
fwhunter() {
|
||||
local FWHUNTER_CHECK_FILE="${1:-}"
|
||||
local FWHUNTER_CHECK_FILE_NAME=""
|
||||
FWHUNTER_CHECK_FILE_NAME=$(basename "$FWHUNTER_CHECK_FILE")
|
||||
local MEM_LIMIT=$(( "$TOTAL_MEMORY"*80/100 ))
|
||||
FWHUNTER_CHECK_FILE_NAME=$(basename "${FWHUNTER_CHECK_FILE}")
|
||||
local MEM_LIMIT=$(( "${TOTAL_MEMORY}"*80/100 ))
|
||||
|
||||
print_output "[*] Running FwHunt on $ORANGE$FWHUNTER_CHECK_FILE$NC" "" "$LOG_PATH_MODULE""/fwhunt_scan_$FWHUNTER_CHECK_FILE_NAME.txt"
|
||||
ulimit -Sv "$MEM_LIMIT"
|
||||
write_log "[*] Running FwHunt on $ORANGE$FWHUNTER_CHECK_FILE$NC" "$LOG_PATH_MODULE""/fwhunt_scan_$FWHUNTER_CHECK_FILE_NAME.txt"
|
||||
timeout --preserve-status --signal SIGINT 600 python3 "$EXT_DIR"/fwhunt-scan/fwhunt_scan_analyzer.py scan-firmware "$FWHUNTER_CHECK_FILE" --rules_dir "$EXT_DIR"/fwhunt-scan/rules/ | tee -a "$LOG_PATH_MODULE""/fwhunt_scan_$FWHUNTER_CHECK_FILE_NAME.txt" || true
|
||||
print_output "[*] Running FwHunt on ${ORANGE}${FWHUNTER_CHECK_FILE}${NC}" "" "${LOG_PATH_MODULE}""/fwhunt_scan_${FWHUNTER_CHECK_FILE_NAME}.txt"
|
||||
ulimit -Sv "${MEM_LIMIT}"
|
||||
write_log "[*] Running FwHunt on ${ORANGE}${FWHUNTER_CHECK_FILE}${NC}" "${LOG_PATH_MODULE}""/fwhunt_scan_${FWHUNTER_CHECK_FILE_NAME}.txt"
|
||||
timeout --preserve-status --signal SIGINT 600 python3 "${EXT_DIR}"/fwhunt-scan/fwhunt_scan_analyzer.py scan-firmware "${FWHUNTER_CHECK_FILE}" --rules_dir "${EXT_DIR}"/fwhunt-scan/rules/ | tee -a "${LOG_PATH_MODULE}""/fwhunt_scan_${FWHUNTER_CHECK_FILE_NAME}.txt" || true
|
||||
ulimit -Sv unlimited
|
||||
|
||||
# delete empty log files
|
||||
if [[ $(wc -l "$LOG_PATH_MODULE""/fwhunt_scan_$FWHUNTER_CHECK_FILE_NAME.txt" | awk '{print $1}') -eq 1 ]]; then
|
||||
rm "$LOG_PATH_MODULE""/fwhunt_scan_$FWHUNTER_CHECK_FILE_NAME.txt" || true
|
||||
if [[ $(wc -l "${LOG_PATH_MODULE}""/fwhunt_scan_${FWHUNTER_CHECK_FILE_NAME}.txt" | awk '{print $1}') -eq 1 ]]; then
|
||||
rm "${LOG_PATH_MODULE}""/fwhunt_scan_${FWHUNTER_CHECK_FILE_NAME}.txt" || true
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ fwhunter_logging() {
|
||||
local CVE_RESULTS_BINARLY=()
|
||||
local FWHUNTER_CVEs=""
|
||||
|
||||
mapfile -t FWHUNTER_RESULTS < <(find "$LOG_PATH_MODULE" -type f -exec grep -H "Scanner result.*FwHunt rule has been triggered" {} \;)
|
||||
mapfile -t FWHUNTER_RESULTS < <(find "${LOG_PATH_MODULE}" -type f -exec grep -H "Scanner result.*FwHunt rule has been triggered" {} \;)
|
||||
if ! [[ "${#FWHUNTER_RESULTS[@]}" -gt 0 ]]; then
|
||||
return
|
||||
fi
|
||||
@@ -92,48 +92,48 @@ fwhunter_logging() {
|
||||
for FWHUNTER_RESULT in "${FWHUNTER_RESULTS[@]}"; do
|
||||
local CVE_RESULTS_BINARLY=()
|
||||
|
||||
FWHUNTER_RESULT_FILE=$(echo "$FWHUNTER_RESULT" | cut -d: -f1)
|
||||
FWHUNTER_BINARLY_ID=$(echo "$FWHUNTER_RESULT" | sed 's/.*\ BRLY-/BRLY-/' | sed 's/\ .variant:\ .*//g')
|
||||
mapfile -t FWHUNTER_BINARLY_ID_FILES < <(find "$EXT_DIR"/fwhunt-scan/rules -iname "$FWHUNTER_BINARLY_ID*")
|
||||
FWHUNTER_RESULT_FILE=$(echo "${FWHUNTER_RESULT}" | cut -d: -f1)
|
||||
FWHUNTER_BINARLY_ID=$(echo "${FWHUNTER_RESULT}" | sed 's/.*\ BRLY-/BRLY-/' | sed 's/\ .variant:\ .*//g')
|
||||
mapfile -t FWHUNTER_BINARLY_ID_FILES < <(find "${EXT_DIR}"/fwhunt-scan/rules -iname "${FWHUNTER_BINARLY_ID}*")
|
||||
for BINARLY_ID_FILE in "${FWHUNTER_BINARLY_ID_FILES[@]}"; do
|
||||
# extract possible CVE information from the binarly scan rule:
|
||||
mapfile -t CVE_RESULTS_BINARLY_ < <(grep "CVE number:" "$BINARLY_ID_FILE" | cut -d: -f2 | tr ',' '\n' | awk '{print $1}')
|
||||
mapfile -t CVE_RESULTS_BINARLY_ < <(grep "CVE number:" "${BINARLY_ID_FILE}" | cut -d: -f2 | tr ',' '\n' | awk '{print $1}')
|
||||
CVE_RESULTS_BINARLY+=("${CVE_RESULTS_BINARLY_[@]}")
|
||||
done
|
||||
FWHUNTER_BINARY_MATCH=$(basename "$(grep "Running FwHunt on" "$FWHUNTER_RESULT_FILE" | cut -d\ -f5-)")
|
||||
FWHUNTER_RESULT=$(echo "$FWHUNTER_RESULT" | cut -d: -f2-)
|
||||
BINARLY_RULE=$(echo "$FWHUNTER_RESULT" | sed -e 's/.*\ BRLY/BRLY/' | sed -e 's/\ .variant\:\ .*//')
|
||||
if [[ "$FWHUNTER_RESULT" == *"rule has been triggered and threat detected"* ]]; then
|
||||
FWHUNTER_BINARY_MATCH=$(basename "$(grep "Running FwHunt on" "${FWHUNTER_RESULT_FILE}" | cut -d\ -f5-)")
|
||||
FWHUNTER_RESULT=$(echo "${FWHUNTER_RESULT}" | cut -d: -f2-)
|
||||
BINARLY_RULE=$(echo "${FWHUNTER_RESULT}" | sed -e 's/.*\ BRLY/BRLY/' | sed -e 's/\ .variant\:\ .*//')
|
||||
if [[ "${FWHUNTER_RESULT}" == *"rule has been triggered and threat detected"* ]]; then
|
||||
if [[ "${#CVE_RESULTS_BINARLY[@]}" -gt 0 ]]; then
|
||||
for BINARLY_ID_CVE in "${CVE_RESULTS_BINARLY[@]}"; do
|
||||
# if we have CVE details we include it into our reporting
|
||||
print_output "[+] $FWHUNTER_BINARY_MATCH $ORANGE:$GREEN $FWHUNTER_RESULT$GREEN - CVE: $ORANGE$BINARLY_ID_CVE$NC" "" "https://binarly.io/advisories/$BINARLY_RULE"
|
||||
write_csv_log "$FWHUNTER_BINARY_MATCH" "unknown" "$BINARLY_ID_CVE" "unknown" "$BINARLY_RULE"
|
||||
print_output "[+] ${FWHUNTER_BINARY_MATCH} ${ORANGE}:${GREEN} ${FWHUNTER_RESULT}${GREEN} - CVE: ${ORANGE}${BINARLY_ID_CVE}${NC}" "" "https://binarly.io/advisories/${BINARLY_RULE}"
|
||||
write_csv_log "${FWHUNTER_BINARY_MATCH}" "unknown" "${BINARLY_ID_CVE}" "unknown" "${BINARLY_RULE}"
|
||||
done
|
||||
else
|
||||
# if we do not have CVE details we can't include it into our reporting
|
||||
print_output "[+] $FWHUNTER_BINARY_MATCH $ORANGE:$GREEN $FWHUNTER_RESULT$NC" "" "https://binarly.io/advisories/$BINARLY_RULE"
|
||||
write_csv_log "$FWHUNTER_BINARY_MATCH" "unknown" "NA" "unknown" "$BINARLY_RULE"
|
||||
print_output "[+] ${FWHUNTER_BINARY_MATCH} ${ORANGE}:${GREEN} ${FWHUNTER_RESULT}${NC}" "" "https://binarly.io/advisories/${BINARLY_RULE}"
|
||||
write_csv_log "${FWHUNTER_BINARY_MATCH}" "unknown" "NA" "unknown" "${BINARLY_RULE}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
mapfile -t FWHUNTER_CVEs < <(grep "CVE" "$LOG_FILE" | cut -d: -f4 | sort -u || true)
|
||||
mapfile -t FWHUNTER_BINARLY_IDs < <(grep "FwHunt rule has been triggered and threat detected" "$LOG_PATH_MODULE"/* | sed 's/.*BRLY-/BRLY-/' | sed 's/\ .variant:\ .*//g' | sort -u || true)
|
||||
mapfile -t FWHUNTER_CVEs < <(grep "CVE" "${LOG_FILE}" | cut -d: -f4 | sort -u || true)
|
||||
mapfile -t FWHUNTER_BINARLY_IDs < <(grep "FwHunt rule has been triggered and threat detected" "${LOG_PATH_MODULE}"/* | sed 's/.*BRLY-/BRLY-/' | sed 's/\ .variant:\ .*//g' | sort -u || true)
|
||||
|
||||
print_ln
|
||||
print_ln
|
||||
# default: output of CVE data
|
||||
# backup: output of binarly IDs
|
||||
if [[ "${#FWHUNTER_CVEs[@]}" -gt 0 ]]; then
|
||||
print_output "[*] Detected $ORANGE${#FWHUNTER_CVEs[@]}$NC firmware issues in UEFI firmware:"
|
||||
print_output "[*] Detected ${ORANGE}${#FWHUNTER_CVEs[@]}${NC} firmware issues in UEFI firmware:"
|
||||
for BINARLY_CVE in "${FWHUNTER_CVEs[@]}"; do
|
||||
print_output "$(indent "$(orange "$BINARLY_CVE")")"
|
||||
print_output "$(indent "$(orange "${BINARLY_CVE}")")"
|
||||
done
|
||||
elif [[ "${#FWHUNTER_BINARLY_IDs[@]}" -gt 0 ]]; then
|
||||
print_output "[*] Detected $ORANGE${#FWHUNTER_BINARLY_IDs[@]}$NC firmware issues in UEFI firmware:"
|
||||
print_output "[*] Detected ${ORANGE}${#FWHUNTER_BINARLY_IDs[@]}${NC} firmware issues in UEFI firmware:"
|
||||
for BINARLY_ID in "${FWHUNTER_BINARLY_IDs[@]}"; do
|
||||
print_output "$(indent "$(orange "$BINARLY_ID")")"
|
||||
print_output "$(indent "$(orange "${BINARLY_ID}")")"
|
||||
done
|
||||
fi
|
||||
print_ln
|
||||
|
||||
@@ -29,42 +29,42 @@ S03_firmware_bin_base_analyzer() {
|
||||
local NEG_LOG=0
|
||||
local WAIT_PIDS_S03=()
|
||||
|
||||
if [[ -d "$FIRMWARE_PATH_CP" ]] ; then
|
||||
export OUTPUT_DIR="$FIRMWARE_PATH_CP"
|
||||
if [[ $THREADED -eq 1 ]]; then
|
||||
if [[ -d "${FIRMWARE_PATH_CP}" ]] ; then
|
||||
export OUTPUT_DIR="${FIRMWARE_PATH_CP}"
|
||||
if [[ ${THREADED} -eq 1 ]]; then
|
||||
os_identification &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S03+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S03+=( "${TMP_PID}" )
|
||||
else
|
||||
os_identification
|
||||
fi
|
||||
fi
|
||||
|
||||
# we only do this if we have not found a Linux filesystem
|
||||
if [[ -f "$FIRMWARE_PATH_BAK" ]]; then
|
||||
if [[ -f "${FIRMWARE_PATH_BAK}" ]]; then
|
||||
export PRE_ARCH_Y=()
|
||||
export PRE_ARCH_A=()
|
||||
export PRE_ARCH_CPU_REC=""
|
||||
if [[ $RTOS -eq 1 ]] ; then
|
||||
if [[ $THREADED -eq 1 ]]; then
|
||||
binary_architecture_detection "$FIRMWARE_PATH_BAK" &
|
||||
if [[ ${RTOS} -eq 1 ]] ; then
|
||||
if [[ ${THREADED} -eq 1 ]]; then
|
||||
binary_architecture_detection "${FIRMWARE_PATH_BAK}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S03+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S03+=( "${TMP_PID}" )
|
||||
else
|
||||
binary_architecture_detection "$FIRMWARE_PATH_BAK"
|
||||
binary_architecture_detection "${FIRMWARE_PATH_BAK}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ $THREADED -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S03[@]}"
|
||||
[[ ${THREADED} -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S03[@]}"
|
||||
|
||||
[[ -f "$TMP_DIR"/s03_arch.tmp ]] && binary_architecture_reporter
|
||||
[[ -f "${TMP_DIR}"/s03_arch.tmp ]] && binary_architecture_reporter
|
||||
|
||||
[[ "$(wc -l "$TMP_DIR"/s03.tmp | awk '{print $1}')" -gt 0 ]] && NEG_LOG=1
|
||||
[[ "$(wc -l "${TMP_DIR}"/s03.tmp | awk '{print $1}')" -gt 0 ]] && NEG_LOG=1
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
os_identification() {
|
||||
@@ -82,26 +82,26 @@ os_identification() {
|
||||
declare -A OS_COUNTER=()
|
||||
local WAIT_PIDS_S03_1=()
|
||||
|
||||
if [[ ${#ROOT_PATH[@]} -gt 1 || $LINUX_PATH_COUNTER -gt 2 ]] ; then
|
||||
safe_echo "${#ROOT_PATH[@]}" >> "$TMP_DIR"/s03.tmp
|
||||
safe_echo "$LINUX_PATH_COUNTER" >> "$TMP_DIR"/s03.tmp
|
||||
if [[ ${#ROOT_PATH[@]} -gt 1 || ${LINUX_PATH_COUNTER} -gt 2 ]] ; then
|
||||
safe_echo "${#ROOT_PATH[@]}" >> "${TMP_DIR}"/s03.tmp
|
||||
safe_echo "${LINUX_PATH_COUNTER}" >> "${TMP_DIR}"/s03.tmp
|
||||
fi
|
||||
|
||||
print_ln
|
||||
print_output "$(indent "$(orange "Operating system detection:")")"
|
||||
|
||||
for OS in "${OS_SEARCHER[@]}"; do
|
||||
if [[ $THREADED -eq 1 ]]; then
|
||||
os_detection_thread_per_os "$OS" &
|
||||
if [[ ${THREADED} -eq 1 ]]; then
|
||||
os_detection_thread_per_os "${OS}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S03_1+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S03_1+=( "${TMP_PID}" )
|
||||
else
|
||||
os_detection_thread_per_os "$OS"
|
||||
os_detection_thread_per_os "${OS}"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ $THREADED -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S03_1[@]}"
|
||||
[[ ${THREADED} -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S03_1[@]}"
|
||||
}
|
||||
|
||||
os_detection_thread_per_os() {
|
||||
@@ -109,103 +109,103 @@ os_detection_thread_per_os() {
|
||||
local DETECTED=0
|
||||
local OS_=""
|
||||
|
||||
OS_COUNTER[$OS]=0
|
||||
OS_COUNTER[$OS]=$(("${OS_COUNTER[$OS]}"+"$(find "$OUTPUT_DIR" -xdev -type f -exec strings {} \; | grep -i -c "$OS" 2> /dev/null || true)"))
|
||||
if [[ -f "$LOG_DIR"/p60_firmware_bin_extractor.txt ]]; then
|
||||
OS_COUNTER[$OS]=$(("${OS_COUNTER[$OS]}"+"$(find "$LOG_DIR" -maxdepth 1 -xdev -type f -name "p60_firmware_bin_extractor.txt" -exec grep -i -c "$OS" {} \; 2> /dev/null || true)" ))
|
||||
OS_COUNTER[${OS}]=0
|
||||
OS_COUNTER[${OS}]=$(("${OS_COUNTER[${OS}]}"+"$(find "${OUTPUT_DIR}" -xdev -type f -exec strings {} \; | grep -i -c "${OS}" 2> /dev/null || true)"))
|
||||
if [[ -f "${LOG_DIR}"/p60_firmware_bin_extractor.txt ]]; then
|
||||
OS_COUNTER[${OS}]=$(("${OS_COUNTER[${OS}]}"+"$(find "${LOG_DIR}" -maxdepth 1 -xdev -type f -name "p60_firmware_bin_extractor.txt" -exec grep -i -c "${OS}" {} \; 2> /dev/null || true)" ))
|
||||
fi
|
||||
OS_COUNTER[$OS]=$(("${OS_COUNTER[$OS]}"+"$(strings "$FIRMWARE_PATH" 2>/dev/null | grep -i -c "$OS" || true)" ))
|
||||
OS_COUNTER[${OS}]=$(("${OS_COUNTER[${OS}]}"+"$(strings "${FIRMWARE_PATH}" 2>/dev/null | grep -i -c "${OS}" || true)" ))
|
||||
|
||||
if [[ $OS == "VxWorks\|Wind" ]]; then
|
||||
OS_COUNTER_VxWorks="${OS_COUNTER[$OS]}"
|
||||
if [[ ${OS} == "VxWorks\|Wind" ]]; then
|
||||
OS_COUNTER_VxWorks="${OS_COUNTER[${OS}]}"
|
||||
fi
|
||||
if [[ $OS == *"CPU "* || $OS == "ADONIS" || $OS == "CP443" ]]; then
|
||||
OS_COUNTER[$OS]=$(("${OS_COUNTER[$OS]}"+"$(strings "$FIRMWARE_PATH" 2>/dev/null | grep -i -c "Original Siemens Equipment" || true)" ))
|
||||
if [[ ${OS} == *"CPU "* || ${OS} == "ADONIS" || ${OS} == "CP443" ]]; then
|
||||
OS_COUNTER[${OS}]=$(("${OS_COUNTER[${OS}]}"+"$(strings "${FIRMWARE_PATH}" 2>/dev/null | grep -i -c "Original Siemens Equipment" || true)" ))
|
||||
fi
|
||||
|
||||
if [[ $OS == "Linux" && ${OS_COUNTER[$OS]} -gt 5 && ${#ROOT_PATH[@]} -gt 1 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified Linux operating system detected (root filesystem)${NC}\n" "$OS detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS" "${OS_COUNTER[$OS]}" "verified" "${#ROOT_PATH[@]}"
|
||||
if [[ ${OS} == "Linux" && ${OS_COUNTER[${OS}]} -gt 5 && ${#ROOT_PATH[@]} -gt 1 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified Linux operating system detected (root filesystem)${NC}\n" "${OS} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS}" "${OS_COUNTER[${OS}]}" "verified" "${#ROOT_PATH[@]}"
|
||||
DETECTED=1
|
||||
elif [[ $OS == "Linux" && ${OS_COUNTER[$OS]} -gt 5 && $LINUX_PATH_COUNTER -gt 2 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified Linux operating system detected (root filesystem)${NC}\n" "$OS detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS" "${OS_COUNTER[$OS]}" "verified" "${#ROOT_PATH[@]}"
|
||||
elif [[ ${OS} == "Linux" && ${OS_COUNTER[${OS}]} -gt 5 && ${LINUX_PATH_COUNTER} -gt 2 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified Linux operating system detected (root filesystem)${NC}\n" "${OS} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS}" "${OS_COUNTER[${OS}]}" "verified" "${#ROOT_PATH[@]}"
|
||||
DETECTED=1
|
||||
elif [[ $OS == "Linux" && ${OS_COUNTER[$OS]} -gt 5 ]] ; then
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "$OS detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS" "${OS_COUNTER[$OS]}" "not verified" "${#ROOT_PATH[@]}"
|
||||
elif [[ ${OS} == "Linux" && ${OS_COUNTER[${OS}]} -gt 5 ]] ; then
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "${OS} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS}" "${OS_COUNTER[${OS}]}" "not verified" "${#ROOT_PATH[@]}"
|
||||
DETECTED=1
|
||||
fi
|
||||
|
||||
if [[ $OS == "SIPROTEC" && ${OS_COUNTER[$OS]} -gt 100 && $OS_COUNTER_VxWorks -gt 20 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified SIPROTEC system detected${NC}\n" "$OS detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS" "${OS_COUNTER[$OS]}" "verified" "NA"
|
||||
if [[ ${OS} == "SIPROTEC" && ${OS_COUNTER[${OS}]} -gt 100 && ${OS_COUNTER_VxWorks} -gt 20 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified SIPROTEC system detected${NC}\n" "${OS} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS}" "${OS_COUNTER[${OS}]}" "verified" "NA"
|
||||
DETECTED=1
|
||||
elif [[ $OS == "SIPROTEC" && ${OS_COUNTER[$OS]} -gt 10 ]] ; then
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "SIPROTEC detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS" "${OS_COUNTER[$OS]}" "not verified" "NA"
|
||||
elif [[ ${OS} == "SIPROTEC" && ${OS_COUNTER[${OS}]} -gt 10 ]] ; then
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "SIPROTEC detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS}" "${OS_COUNTER[${OS}]}" "not verified" "NA"
|
||||
DETECTED=1
|
||||
fi
|
||||
if [[ $OS == "CP443" && ${OS_COUNTER[$OS]} -gt 100 && $OS_COUNTER_VxWorks -gt 20 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified S7-CP443 system detected${NC}\n" "$OS detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS" "${OS_COUNTER[$OS]}" "verified" "NA"
|
||||
if [[ ${OS} == "CP443" && ${OS_COUNTER[${OS}]} -gt 100 && ${OS_COUNTER_VxWorks} -gt 20 ]] ; then
|
||||
printf "${GREEN}\t%-20.20s\t:\t%-15s\t:\tverified S7-CP443 system detected${NC}\n" "${OS} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS}" "${OS_COUNTER[${OS}]}" "verified" "NA"
|
||||
DETECTED=1
|
||||
elif [[ $OS == "CP443" && ${OS_COUNTER[$OS]} -gt 10 ]] ; then
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "S7-CP443 detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS" "${OS_COUNTER[$OS]}" "not verified" "NA"
|
||||
elif [[ ${OS} == "CP443" && ${OS_COUNTER[${OS}]} -gt 10 ]] ; then
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "S7-CP443 detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS}" "${OS_COUNTER[${OS}]}" "not verified" "NA"
|
||||
DETECTED=1
|
||||
fi
|
||||
|
||||
if [[ ${OS_COUNTER[$OS]} -gt 5 ]] ; then
|
||||
if [[ $OS == "VxWorks\|Wind" ]]; then
|
||||
if [[ ${OS_COUNTER[${OS}]} -gt 5 ]] ; then
|
||||
if [[ ${OS} == "VxWorks\|Wind" ]]; then
|
||||
OS_="VxWorks"
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "$OS_ detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS_" "${OS_COUNTER[$OS]}" "not verified" "NA"
|
||||
elif [[ $OS == "CPU\ [34][12][0-9]-[0-9]" ]]; then
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "${OS_} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS_}" "${OS_COUNTER[${OS}]}" "not verified" "NA"
|
||||
elif [[ ${OS} == "CPU\ [34][12][0-9]-[0-9]" ]]; then
|
||||
OS_="S7-CPU400"
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "$OS_ detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS_" "${OS_COUNTER[$OS]}" "not verified" "NA"
|
||||
elif [[ $DETECTED -eq 0 ]]; then
|
||||
OS_="$OS"
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "$OS_ detected" "${OS_COUNTER[$OS]}" | tee -a "$LOG_FILE"
|
||||
write_csv_log "$OS_" "${OS_COUNTER[$OS]}" "not verified" "NA"
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "${OS_} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS_}" "${OS_COUNTER[${OS}]}" "not verified" "NA"
|
||||
elif [[ ${DETECTED} -eq 0 ]]; then
|
||||
OS_="${OS}"
|
||||
printf "${ORANGE}\t%-20.20s\t:\t%-15s${NC}\n" "${OS_} detected" "${OS_COUNTER[${OS}]}" | tee -a "${LOG_FILE}"
|
||||
write_csv_log "${OS_}" "${OS_COUNTER[${OS}]}" "not verified" "NA"
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ "${OS_COUNTER[$OS]}" -gt 0 ]] && safe_echo "${OS_COUNTER[$OS]}" >> "$TMP_DIR"/s03.tmp
|
||||
[[ "${OS_COUNTER[${OS}]}" -gt 0 ]] && safe_echo "${OS_COUNTER[${OS}]}" >> "${TMP_DIR}"/s03.tmp
|
||||
}
|
||||
|
||||
binary_architecture_detection() {
|
||||
# sub_module_title "Architecture detection for RTOS based systems"
|
||||
|
||||
local FILE_TO_CHECK="${1:-}"
|
||||
if ! [[ -f "$FILE_TO_CHECK" ]]; then
|
||||
if ! [[ -f "${FILE_TO_CHECK}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
print_output "[*] Architecture detection running on ""$FILE_TO_CHECK"
|
||||
print_output "[*] Architecture detection running on ""${FILE_TO_CHECK}"
|
||||
|
||||
|
||||
# as Thumb is usually false positive we remove it from the results
|
||||
mapfile -t PRE_ARCH_Y < <(binwalk -Y "$FILE_TO_CHECK" | grep "valid\ instructions" | grep -v "Thumb" | \
|
||||
mapfile -t PRE_ARCH_Y < <(binwalk -Y "${FILE_TO_CHECK}" | grep "valid\ instructions" | grep -v "Thumb" | \
|
||||
awk '{print $3}' | sort -u || true)
|
||||
mapfile -t PRE_ARCH_A < <(binwalk -A "$FILE_TO_CHECK" | grep "\ instructions," | awk '{print $3}' | \
|
||||
mapfile -t PRE_ARCH_A < <(binwalk -A "${FILE_TO_CHECK}" | grep "\ instructions," | awk '{print $3}' | \
|
||||
uniq -c | sort -n | tail -1 | awk '{print $2}' || true)
|
||||
|
||||
if [[ -f "$HOME"/.config/binwalk/modules/cpu_rec.py ]]; then
|
||||
if [[ -f "${HOME}"/.config/binwalk/modules/cpu_rec.py ]]; then
|
||||
# entropy=0.9xxx is typically encrypted or compressed -> we just remove these entries:
|
||||
PRE_ARCH_CPU_REC=$(binwalk -% "$FILE_TO_CHECK" | grep -v "DESCRIPTION\|None\|-----------" | grep -v "entropy=0.9" \
|
||||
PRE_ARCH_CPU_REC=$(binwalk -% "${FILE_TO_CHECK}" | grep -v "DESCRIPTION\|None\|-----------" | grep -v "entropy=0.9" \
|
||||
| awk '{print $3}' | grep -v -e "^$" | sort | uniq -c | head -1 | awk '{print $2}' || true)
|
||||
fi
|
||||
|
||||
for PRE_ARCH_ in "${PRE_ARCH_Y[@]}"; do
|
||||
echo "binwalk -Y;$PRE_ARCH_" >> "$TMP_DIR"/s03_arch.tmp
|
||||
echo "binwalk -Y;${PRE_ARCH_}" >> "${TMP_DIR}"/s03_arch.tmp
|
||||
done
|
||||
for PRE_ARCH_ in "${PRE_ARCH_A[@]}"; do
|
||||
echo "binwalk -A;$PRE_ARCH_" >> "$TMP_DIR"/s03_arch.tmp
|
||||
echo "binwalk -A;${PRE_ARCH_}" >> "${TMP_DIR}"/s03_arch.tmp
|
||||
done
|
||||
if [[ -n "$PRE_ARCH_CPU_REC" ]]; then
|
||||
echo "cpu_rec;$PRE_ARCH_CPU_REC" >> "$TMP_DIR"/s03_arch.tmp
|
||||
if [[ -n "${PRE_ARCH_CPU_REC}" ]]; then
|
||||
echo "cpu_rec;${PRE_ARCH_CPU_REC}" >> "${TMP_DIR}"/s03_arch.tmp
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -213,10 +213,10 @@ binary_architecture_reporter() {
|
||||
sub_module_title "Architecture detection for RTOS based systems"
|
||||
local PRE_ARCH_=""
|
||||
while read -r PRE_ARCH_; do
|
||||
SOURCE=$(echo "$PRE_ARCH_" | cut -d\; -f1)
|
||||
PRE_ARCH_=$(echo "$PRE_ARCH_" | cut -d\; -f2)
|
||||
SOURCE=$(echo "${PRE_ARCH_}" | cut -d\; -f1)
|
||||
PRE_ARCH_=$(echo "${PRE_ARCH_}" | cut -d\; -f2)
|
||||
print_ln
|
||||
print_output "[+] Possible architecture details found ($ORANGE$SOURCE$GREEN): $ORANGE$PRE_ARCH_$NC"
|
||||
echo "$PRE_ARCH_" >> "$TMP_DIR"/s03.tmp
|
||||
done < "$TMP_DIR"/s03_arch.tmp
|
||||
print_output "[+] Possible architecture details found (${ORANGE}${SOURCE}${GREEN}): ${ORANGE}${PRE_ARCH_}${NC}"
|
||||
echo "${PRE_ARCH_}" >> "${TMP_DIR}"/s03.tmp
|
||||
done < "${TMP_DIR}"/s03_arch.tmp
|
||||
}
|
||||
|
||||
@@ -26,21 +26,21 @@ S05_firmware_details()
|
||||
local DETECTED_DIR
|
||||
|
||||
# we use the file FILE_ARR from helpers module
|
||||
if [[ $RTOS -eq 0 ]]; then
|
||||
if [[ ${RTOS} -eq 0 ]]; then
|
||||
# Linux:
|
||||
DETECTED_DIR=$(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -type d 2>/dev/null | wc -l)
|
||||
DETECTED_DIR=$(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -type d 2>/dev/null | wc -l)
|
||||
else
|
||||
# RTOS:
|
||||
DETECTED_DIR=$(find "$OUTPUT_DIR" -xdev -type d 2>/dev/null | wc -l)
|
||||
DETECTED_DIR=$(find "${OUTPUT_DIR}" -xdev -type d 2>/dev/null | wc -l)
|
||||
fi
|
||||
|
||||
print_output "[*] $ORANGE${#FILE_ARR[@]}$NC files and $ORANGE$DETECTED_DIR$NC directories detected."
|
||||
print_output "[*] ${ORANGE}${#FILE_ARR[@]}${NC} files and ${ORANGE}${DETECTED_DIR}${NC} directories detected."
|
||||
|
||||
release_info
|
||||
filesystem_tree
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:${#FILE_ARR[@]}:$DETECTED_DIR"
|
||||
write_log "[*] Statistics:${#FILE_ARR[@]}:${DETECTED_DIR}"
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "${#FILE_ARR[@]}"
|
||||
}
|
||||
@@ -48,23 +48,23 @@ S05_firmware_details()
|
||||
filesystem_tree() {
|
||||
sub_module_title "Filesystem information"
|
||||
write_anchor "file_dirs"
|
||||
if [[ $RTOS -eq 0 ]]; then
|
||||
local LPATH="$FIRMWARE_PATH"
|
||||
if [[ ${RTOS} -eq 0 ]]; then
|
||||
local LPATH="${FIRMWARE_PATH}"
|
||||
else
|
||||
local LPATH="$OUTPUT_DIR"
|
||||
local LPATH="${OUTPUT_DIR}"
|
||||
fi
|
||||
# excluded paths will be also printed
|
||||
if command -v tree > /dev/null 2>&1 ; then
|
||||
if [[ $FORMAT_LOG -eq 1 ]] ; then
|
||||
tree -p -s -a -C "$LPATH" >> "$LOG_FILE" || true
|
||||
if [[ ${FORMAT_LOG} -eq 1 ]] ; then
|
||||
tree -p -s -a -C "${LPATH}" >> "${LOG_FILE}" || true
|
||||
else
|
||||
tree -p -s -a -n "$LPATH" >> "$LOG_FILE" || true
|
||||
tree -p -s -a -n "${LPATH}" >> "${LOG_FILE}" || true
|
||||
fi
|
||||
else
|
||||
if [[ $FORMAT_LOG -eq 1 ]] ; then
|
||||
ls -laR "$LPATH" >> "$LOG_FILE"
|
||||
if [[ ${FORMAT_LOG} -eq 1 ]] ; then
|
||||
ls -laR "${LPATH}" >> "${LOG_FILE}"
|
||||
else
|
||||
ls -laR --color=never "$LPATH" >> "$LOG_FILE"
|
||||
ls -laR --color=never "${LPATH}" >> "${LOG_FILE}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -76,22 +76,22 @@ release_info() {
|
||||
local RELEASE=""
|
||||
|
||||
declare -a RELEASE_STUFF=()
|
||||
mapfile -t RELEASE_STUFF < <(config_find "$CONFIG_DIR""/release_files.cfg")
|
||||
mapfile -t RELEASE_STUFF < <(config_find "${CONFIG_DIR}""/release_files.cfg")
|
||||
if [[ "${RELEASE_STUFF[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#RELEASE_STUFF[@]}" -gt 0 ]] ; then
|
||||
print_output "[+] Specific release/version information of target:"
|
||||
for R_INFO in "${RELEASE_STUFF[@]}" ; do
|
||||
if [[ -f "$R_INFO" ]] ; then
|
||||
if file "$R_INFO" | grep -a -q text; then
|
||||
print_output "\\n""$( print_path "$R_INFO")"
|
||||
RELEASE="$( cat "$R_INFO" )"
|
||||
if [[ "$RELEASE" ]] ; then
|
||||
if [[ -f "${R_INFO}" ]] ; then
|
||||
if file "${R_INFO}" | grep -a -q text; then
|
||||
print_output "\\n""$( print_path "${R_INFO}")"
|
||||
RELEASE="$( cat "${R_INFO}" )"
|
||||
if [[ "${RELEASE}" ]] ; then
|
||||
print_ln
|
||||
print_output "$(indent "$(magenta "$RELEASE")")"
|
||||
print_output "$(indent "$(magenta "${RELEASE}")")"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
print_output "\\n""$(magenta "Directory:")"" ""$( print_path "$R_INFO")""\\n"
|
||||
print_output "\\n""$(magenta "Directory:")"" ""$( print_path "${R_INFO}")""\\n"
|
||||
fi
|
||||
done
|
||||
else
|
||||
|
||||
@@ -37,75 +37,75 @@ S06_distribution_identification()
|
||||
write_csv_log "file" "type" "identifier" "csv_rule"
|
||||
|
||||
while read -r CONFIG; do
|
||||
if safe_echo "$CONFIG" | grep -q "^[^#*/;]"; then
|
||||
SEARCH_FILE="$(safe_echo "$CONFIG" | cut -d\; -f2)"
|
||||
mapfile -t FOUND_FILES < <(find "$FIRMWARE_PATH" -xdev -iwholename "*$SEARCH_FILE" || true)
|
||||
if safe_echo "${CONFIG}" | grep -q "^[^#*/;]"; then
|
||||
SEARCH_FILE="$(safe_echo "${CONFIG}" | cut -d\; -f2)"
|
||||
mapfile -t FOUND_FILES < <(find "${FIRMWARE_PATH}" -xdev -iwholename "*${SEARCH_FILE}" || true)
|
||||
for FILE in "${FOUND_FILES[@]}"; do
|
||||
if [[ -f "$FILE" ]]; then
|
||||
PATTERN="$(safe_echo "$CONFIG" | cut -d\; -f3)"
|
||||
if [[ -f "${FILE}" ]]; then
|
||||
PATTERN="$(safe_echo "${CONFIG}" | cut -d\; -f3)"
|
||||
# do not use safe_echo for SED_COMMAND
|
||||
SED_COMMAND="$(echo "$CONFIG" | cut -d\; -f4)"
|
||||
FILE_QUOTED=$(escape_echo "$FILE")
|
||||
OUT1="$(eval "$PATTERN" "$FILE_QUOTED" || true)"
|
||||
SED_COMMAND="$(echo "${CONFIG}" | cut -d\; -f4)"
|
||||
FILE_QUOTED=$(escape_echo "${FILE}")
|
||||
OUT1="$(eval "${PATTERN}" "${FILE_QUOTED}" || true)"
|
||||
# echo "PATTERN: $PATTERN"
|
||||
# echo "SED command: $SED_COMMAND"
|
||||
# echo "identified: $OUT1"
|
||||
# echo "FILE: $FILE_QUOTED"
|
||||
IDENTIFIER=$(echo "$OUT1" | eval "$SED_COMMAND" | sed 's/ \+/ /g' | sed 's/ $//' || true)
|
||||
IDENTIFIER=$(echo "${OUT1}" | eval "${SED_COMMAND}" | sed 's/ \+/ /g' | sed 's/ $//' || true)
|
||||
|
||||
if [[ $(basename "$FILE") == "image_sign" ]]; then
|
||||
if [[ $(basename "${FILE}") == "image_sign" ]]; then
|
||||
# dlink image_sign file handling
|
||||
dlink_image_sign
|
||||
fi
|
||||
|
||||
# check if not zero and not only spaces
|
||||
if [[ -n "${IDENTIFIER// }" ]] && [[ "$IDENTIFIER" == *[0-9]* ]]; then
|
||||
if [[ -n "$DLINK_FW_VER" ]]; then
|
||||
print_output "[+] Version information found $ORANGE$IDENTIFIER$GREEN in file $ORANGE$(print_path "$FILE")$GREEN for D-Link device."
|
||||
get_csv_rule_distri "$IDENTIFIER"
|
||||
write_csv_log "$FILE" "dlink" "$IDENTIFIER" "$CSV_RULE"
|
||||
if [[ -n "${IDENTIFIER// }" ]] && [[ "${IDENTIFIER}" == *[0-9]* ]]; then
|
||||
if [[ -n "${DLINK_FW_VER}" ]]; then
|
||||
print_output "[+] Version information found ${ORANGE}${IDENTIFIER}${GREEN} in file ${ORANGE}$(print_path "${FILE}")${GREEN} for D-Link device."
|
||||
get_csv_rule_distri "${IDENTIFIER}"
|
||||
write_csv_log "${FILE}" "dlink" "${IDENTIFIER}" "${CSV_RULE}"
|
||||
else
|
||||
print_output "[+] Version information found $ORANGE$IDENTIFIER$GREEN in file $ORANGE$(print_path "$FILE")$GREEN with Linux distribution detection"
|
||||
get_csv_rule_distri "$IDENTIFIER"
|
||||
write_csv_log "$FILE" "Linux" "$IDENTIFIER" "$CSV_RULE"
|
||||
print_output "[+] Version information found ${ORANGE}${IDENTIFIER}${GREEN} in file ${ORANGE}$(print_path "${FILE}")${GREEN} with Linux distribution detection"
|
||||
get_csv_rule_distri "${IDENTIFIER}"
|
||||
write_csv_log "${FILE}" "Linux" "${IDENTIFIER}" "${CSV_RULE}"
|
||||
fi
|
||||
OUTPUT=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done < "$CONFIG_DIR"/distri_id.cfg
|
||||
done < "${CONFIG_DIR}"/distri_id.cfg
|
||||
|
||||
write_log ""
|
||||
module_end_log "${FUNCNAME[0]}" "$OUTPUT"
|
||||
module_end_log "${FUNCNAME[0]}" "${OUTPUT}"
|
||||
}
|
||||
|
||||
dlink_image_sign() {
|
||||
# the firmware version can be found in /config/buildver
|
||||
local DLINK_BUILDVER=()
|
||||
mapfile -t DLINK_BUILDVER < <(find "$FIRMWARE_PATH" -xdev -path "*config/buildver")
|
||||
mapfile -t DLINK_BUILDVER < <(find "${FIRMWARE_PATH}" -xdev -path "*config/buildver")
|
||||
for DLINK_BVER in "${DLINK_BUILDVER[@]}"; do
|
||||
DLINK_FW_VER=$(grep -E "[0-9]+\.[0-9]+" "$DLINK_BVER")
|
||||
if ! [[ "$DLINK_FW_VER" =~ ^v.* ]]; then
|
||||
DLINK_FW_VER="v$DLINK_FW_VER"
|
||||
DLINK_FW_VER=$(grep -E "[0-9]+\.[0-9]+" "${DLINK_BVER}")
|
||||
if ! [[ "${DLINK_FW_VER}" =~ ^v.* ]]; then
|
||||
DLINK_FW_VER="v${DLINK_FW_VER}"
|
||||
fi
|
||||
# -> v2.14
|
||||
done
|
||||
|
||||
local DLINK_BUILDREV=()
|
||||
# probably we can use this in the future. Currently there is no need for it:
|
||||
mapfile -t DLINK_BUILDREV < <(find "$FIRMWARE_PATH" -xdev -path "*config/buildrev")
|
||||
mapfile -t DLINK_BUILDREV < <(find "${FIRMWARE_PATH}" -xdev -path "*config/buildrev")
|
||||
for DLINK_BREV in "${DLINK_BUILDREV[@]}"; do
|
||||
DLINK_FW_VERx=$(grep -E "^[A-Z][0-9]+" "$DLINK_BREV" || true)
|
||||
DLINK_FW_VERx=$(grep -E "^[A-Z][0-9]+" "${DLINK_BREV}" || true)
|
||||
# -> B01
|
||||
DLINK_FW_VER="$DLINK_FW_VER""$DLINK_FW_VERx"
|
||||
DLINK_FW_VER="${DLINK_FW_VER}""${DLINK_FW_VERx}"
|
||||
# -> v2.14B01
|
||||
# if we have multiple files we only take the first one - this usually happens if we have some packed firmware
|
||||
break
|
||||
done
|
||||
|
||||
if [[ -n "$DLINK_FW_VER" ]]; then
|
||||
IDENTIFIER="D-Link $IDENTIFIER"" $DLINK_FW_VER"
|
||||
if [[ -n "${DLINK_FW_VER}" ]]; then
|
||||
IDENTIFIER="D-Link ${IDENTIFIER}"" ${DLINK_FW_VER}"
|
||||
# -> D-Link dir-300 v2.14B01
|
||||
fi
|
||||
}
|
||||
@@ -113,44 +113,44 @@ dlink_image_sign() {
|
||||
get_csv_rule_distri() {
|
||||
# this is a temp solution. If this list grows we are going to solve it via a configuration file
|
||||
local VERSION_IDENTIFIER="${1:-}"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | tr '[:upper:]' '[:lower:]' | tr -dc '[:print:]')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | tr '[:upper:]' '[:lower:]' | tr -dc '[:print:]')"
|
||||
|
||||
### handle versions of linux distributions:
|
||||
# debian 9 (stretch) - installer build 20170615+deb9u5
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/(debian) [0-9]+\ \([a-z]+\)\ -\ installer\ build\ [0-9]+\+deb([0-9]+)u([0-9])/\1:\1_linux:\2\.\3/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/(debian) [0-9]+\ \([a-z]+\)\ -\ installer\ build\ [0-9]+\+deb([0-9]+)u([0-9])/\1:\1_linux:\2\.\3/')"
|
||||
# Fedora 17 (Beefy Miracle)
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/(fedora)\ ([0-9]+).*/\1project:\1:\2/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/(fedora)\ ([0-9]+).*/\1project:\1:\2/')"
|
||||
# CentOS
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/centos\ linux\ ([0-9]+(\.[0-9]+)+?).*/centos:centos:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/centos\ linux\ ([0-9]+(\.[0-9]+)+?).*/centos:centos:\1/')"
|
||||
# Ubuntu
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/(ubuntu)\ ([0-9]+\,[0-9]+).*/\1_linux:\1:\2/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/(ubuntu)\ ([0-9]+\,[0-9]+).*/\1_linux:\1:\2/')"
|
||||
# OpenWRT KAMIKAZE r18* -> 8.09.2
|
||||
# see also: https://openwrt.org/about/history
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/(openwrt)\ (kamikaze)\ r1[4-8][0-9][0-9][0-9].*/\1:\2:8.09/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/(openwrt)\ (backfire)\ r2[0-9][0-9][0-9][0-9].*/\1:\2:10.03/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/(openwrt)\ (kamikaze)\ r1[4-8][0-9][0-9][0-9].*/\1:\2:8.09/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/(openwrt)\ (backfire)\ r2[0-9][0-9][0-9][0-9].*/\1:\2:10.03/')"
|
||||
# OpenWrt 18.06.2 r7676-cddd7b4c77
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/(openwrt)\ ([0-9]+\.[0-9]+\.[0-9]+)\ (r[0-9]+\-[a-z0-9]+).*/openwrt:\2:\3/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/lede\ ([0-9]+\.[0-9]+\.[0-9]+)(-)?(rc[0-9])?.*/openwrt:\1:\3/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/openwrt\ ([0-9]+\.[0-9]+)/openwrt:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/(openwrt)\ ([0-9]+\.[0-9]+\.[0-9]+)\ (r[0-9]+\-[a-z0-9]+).*/openwrt:\2:\3/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/lede\ ([0-9]+\.[0-9]+\.[0-9]+)(-)?(rc[0-9])?.*/openwrt:\1:\3/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/openwrt\ ([0-9]+\.[0-9]+)/openwrt:\1/')"
|
||||
# OpenWrt Attitude Adjustment r7549 -> 12.09
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/openwrt\ attitude\ adjustment\ r([0-9]+).*/openwrt:12\.09/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/openwrt\ attitude\ adjustment\ r([0-9]+).*/openwrt:12\.09/')"
|
||||
# d-link dir-300 v2.14b01
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/d-link\ (.*)\ v([0-9].[0-9]+[a-z][0-9]+)/dlink:\1_firmware:\2/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/d-link\ (.*)\ v([0-9].[0-9]+)/dlink:\1_firmware:\2/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/d-link\ (.*)\ v([0-9].[0-9]+[a-z][0-9]+)/dlink:\1_firmware:\2/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/d-link\ (.*)\ v([0-9].[0-9]+)/dlink:\1_firmware:\2/')"
|
||||
# dd-wrt v24-sp2
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/dd-wrt\ v([0-9]+)-?(sp[0-9])?.*/dd-wrt:dd-wrt:\1:\2/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/dd-wrt\ \#([0-9]+).*/dd-wrt:dd-wrt:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/dd-wrt\ v([0-9]+)-?(sp[0-9])?.*/dd-wrt:dd-wrt:\1:\2/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/dd-wrt\ \#([0-9]+).*/dd-wrt:dd-wrt:\1/')"
|
||||
# iotgoat v1.0
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/iotgoat\ v([0-9]\.[0-9]+)/iotgoat:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/iotgoat\ v([0-9]\.[0-9]+)/iotgoat:\1/')"
|
||||
# F5 BigIP
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/big-ip\ ltm\ ([0-9]+(\.[0-9]+)+?)/f5:big-ip_local_traffic_manager:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/big-ip\ asm\ ([0-9]+(\.[0-9]+)+?)/f5:big-ip_application_security_manager:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/big-ip\ ltm\ ([0-9]+(\.[0-9]+)+?)/f5:big-ip_local_traffic_manager:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/big-ip\ asm\ ([0-9]+(\.[0-9]+)+?)/f5:big-ip_application_security_manager:\1/')"
|
||||
# Yocto linux - e.g.: poky:(yocto:project:reference:distro):2.2:(morty)
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/.*\(yocto:project:reference:distro\):([0-9]+(\.[0-9]+)+?):\(.*\)$/yoctoproject:yocto:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/.*\(yocto:project:reference:distro\):([0-9]+(\.[0-9]+)+?):\(.*\)$/yoctoproject:yocto:\1/')"
|
||||
# Buildroot 2022.01.01
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/buildroot\ ([0-9]+(\.[0-9]+)+?)/buildroot:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/buildroot\ ([0-9]+(\.[0-9]+)+?)/buildroot:\1/')"
|
||||
# MikroTik routerOS V2.4 (c) 1999-2001 http://mikrotik.com/
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_IDENTIFIER" | sed -r 's/.*mikrotik\ routeros\ v([0-9]\.[0-9]+).*/mikrotik:routeros:\1/')"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_IDENTIFIER}" | sed -r 's/.*mikrotik\ routeros\ v([0-9]\.[0-9]+).*/mikrotik:routeros:\1/')"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER// /:}"
|
||||
CSV_RULE="$(safe_echo "$VERSION_IDENTIFIER" | tr -dc '[:print:]')"
|
||||
CSV_RULE="$(safe_echo "${VERSION_IDENTIFIER}" | tr -dc '[:print:]')"
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ S07_bootloader_check()
|
||||
find_boot_files
|
||||
find_runlevel
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$STARTUP_FINDS"
|
||||
module_end_log "${FUNCNAME[0]}" "${STARTUP_FINDS}"
|
||||
}
|
||||
|
||||
check_dtb()
|
||||
@@ -39,15 +39,15 @@ check_dtb()
|
||||
local DTB_ARR=()
|
||||
local DTB_FILE=""
|
||||
|
||||
readarray -t DTB_ARR < <( find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -iname "*.dtb" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 || true)
|
||||
readarray -t DTB_ARR < <( find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -iname "*.dtb" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 || true)
|
||||
|
||||
if [[ ${#DTB_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Device tree blobs found - output of fdtdump into log, could take a moment"
|
||||
for DTB_FILE in "${DTB_ARR[@]}" ; do
|
||||
print_output "$(indent "$DTB_FILE")"
|
||||
if [[ $DTBDUMP -eq 1 ]] ; then
|
||||
write_log "$(fdtdump "$DTB_FILE" 2> /dev/null || true)" "$LOG_PATH_MODULE""/""$(basename "$DTB_FILE" .dtb)""-DUMP.txt" "g"
|
||||
write_link "$LOG_PATH_MODULE""/""$(basename "$DTB_FILE" .dtb)""-DUMP.txt"
|
||||
print_output "$(indent "${DTB_FILE}")"
|
||||
if [[ ${DTBDUMP} -eq 1 ]] ; then
|
||||
write_log "$(fdtdump "${DTB_FILE}" 2> /dev/null || true)" "${LOG_PATH_MODULE}""/""$(basename "${DTB_FILE}" .dtb)""-DUMP.txt" "g"
|
||||
write_link "${LOG_PATH_MODULE}""/""$(basename "${DTB_FILE}" .dtb)""-DUMP.txt"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
@@ -66,16 +66,16 @@ check_bootloader()
|
||||
# Syslinux
|
||||
local SYSLINUX_PATHS=()
|
||||
local SYSLINUX_FILE=""
|
||||
mapfile -t SYSLINUX_PATHS < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/syslinux/syslinux.cfg" || true)
|
||||
mapfile -t SYSLINUX_PATHS < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/syslinux/syslinux.cfg" || true)
|
||||
for SYSLINUX_FILE in "${SYSLINUX_PATHS[@]}" ; do
|
||||
if [[ -f "$SYSLINUX_FILE" ]] ; then
|
||||
if [[ -f "${SYSLINUX_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found Syslinux config: ""$(print_path "$SYSLINUX_FILE")"
|
||||
print_output "[+] Found Syslinux config: ""$(print_path "${SYSLINUX_FILE}")"
|
||||
BOOTLOADER="Syslinux"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No Syslinux configuration file found"
|
||||
fi
|
||||
|
||||
@@ -83,53 +83,53 @@ check_bootloader()
|
||||
CHECK=0
|
||||
local GRUB_PATHS=()
|
||||
local GRUB_FILE=""
|
||||
mapfile -t GRUB_PATHS < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/grub/grub.conf" || true)
|
||||
mapfile -t GRUB_PATHS < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/grub/grub.conf" || true)
|
||||
for GRUB_FILE in "${GRUB_PATHS[@]}" ; do
|
||||
if [[ -f "$GRUB_FILE" ]] ; then
|
||||
if [[ -f "${GRUB_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found Grub config: ""$(print_path "$GRUB_FILE")"
|
||||
GRUB="$GRUB_FILE"
|
||||
print_output "[+] Found Grub config: ""$(print_path "${GRUB_FILE}")"
|
||||
GRUB="${GRUB_FILE}"
|
||||
BOOTLOADER="Grub"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
mapfile -t GRUB_PATHS < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/grub/menu.lst" || true)
|
||||
mapfile -t GRUB_PATHS < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/grub/menu.lst" || true)
|
||||
for GRUB_FILE in "${GRUB_PATHS[@]}" ; do
|
||||
if [[ -f "$GRUB_FILE" ]] ; then
|
||||
if [[ -f "${GRUB_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found Grub config: ""$(print_path "$GRUB_FILE")"
|
||||
GRUB="$GRUB_FILE"
|
||||
print_output "[+] Found Grub config: ""$(print_path "${GRUB_FILE}")"
|
||||
GRUB="${GRUB_FILE}"
|
||||
BOOTLOADER="Grub"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No Grub configuration file found"
|
||||
fi
|
||||
|
||||
# Grub2
|
||||
CHECK=0
|
||||
mapfile -t GRUB_PATHS < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/grub/grub.cfg" || true)
|
||||
mapfile -t GRUB_PATHS < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/grub/grub.cfg" || true)
|
||||
for GRUB_FILE in "${GRUB_PATHS[@]}" ; do
|
||||
if [[ -f "$GRUB_FILE" ]] ; then
|
||||
if [[ -f "${GRUB_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found Grub2 config: ""$(print_path "$GRUB_FILE")"
|
||||
GRUB="$GRUB_FILE"
|
||||
print_output "[+] Found Grub2 config: ""$(print_path "${GRUB_FILE}")"
|
||||
GRUB="${GRUB_FILE}"
|
||||
BOOTLOADER="Grub2"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
mapfile -t GRUB_PATHS < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/grub/grub.conf" || true)
|
||||
mapfile -t GRUB_PATHS < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/grub/grub.conf" || true)
|
||||
for GRUB_FILE in "${GRUB_PATHS[@]}" ; do
|
||||
if [[ -f "$GRUB_FILE" ]] ; then
|
||||
if [[ -f "${GRUB_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found Grub2 config: ""$(print_path "$GRUB_FILE")"
|
||||
GRUB="$GRUB_FILE"
|
||||
print_output "[+] Found Grub2 config: ""$(print_path "${GRUB_FILE}")"
|
||||
GRUB="${GRUB_FILE}"
|
||||
BOOTLOADER="Grub2"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No Grub configuration file found"
|
||||
fi
|
||||
|
||||
@@ -141,12 +141,12 @@ check_bootloader()
|
||||
local FIND5=""
|
||||
local FOUND=0
|
||||
if [[ -n "${GRUB:-}" ]] ; then
|
||||
print_output "[*] Check Grub config: ""$(print_path "$GRUB")"
|
||||
FIND=$(grep 'password --md5' "$GRUB"| grep -v '^#' || true)
|
||||
FIND2=$(grep 'password --encrypted' "$GRUB"| grep -v '^#' || true)
|
||||
FIND3=$(grep 'set superusers' "$GRUB"| grep -v '^#' || true)
|
||||
FIND4=$(grep 'password_pbkdf2' "$GRUB"| grep -v '^#' || true)
|
||||
FIND5=$(grep 'grub.pbkdf2' "$GRUB"| grep -v '^#' || true)
|
||||
print_output "[*] Check Grub config: ""$(print_path "${GRUB}")"
|
||||
FIND=$(grep 'password --md5' "${GRUB}"| grep -v '^#' || true)
|
||||
FIND2=$(grep 'password --encrypted' "${GRUB}"| grep -v '^#' || true)
|
||||
FIND3=$(grep 'set superusers' "${GRUB}"| grep -v '^#' || true)
|
||||
FIND4=$(grep 'password_pbkdf2' "${GRUB}"| grep -v '^#' || true)
|
||||
FIND5=$(grep 'grub.pbkdf2' "${GRUB}"| grep -v '^#' || true)
|
||||
# GRUB1: Password should be set (MD5 or SHA1)
|
||||
if [[ -n "${FIND}" ]] || [[ -n "${FIND2}" ]] ; then
|
||||
FOUND=1
|
||||
@@ -157,7 +157,7 @@ check_bootloader()
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
fi
|
||||
if [[ $FOUND -eq 1 ]] ; then
|
||||
if [[ ${FOUND} -eq 1 ]] ; then
|
||||
print_output "[+] GRUB has password protection"
|
||||
else
|
||||
print_output "[-] No hashed password line in GRUB boot file"
|
||||
@@ -170,25 +170,25 @@ check_bootloader()
|
||||
CHECK=0
|
||||
local BOOT1 BOOT2 BOOTL
|
||||
# mapfile -t BOOT1 < <(mod_path "/boot/boot1")
|
||||
mapfile -t BOOT1 < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/boot1" || true)
|
||||
mapfile -t BOOT1 < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/boot1" || true)
|
||||
# mapfile -t BOOT2 < <(mod_path "/boot/boot2")
|
||||
mapfile -t BOOT2 < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/boot2" || true)
|
||||
mapfile -t BOOT2 < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/boot2" || true)
|
||||
# mapfile -t BOOTL < <(mod_path "/boot/loader")
|
||||
mapfile -t BOOTL < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot/loader" || true)
|
||||
mapfile -t BOOTL < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot/loader" || true)
|
||||
|
||||
for B1 in "${BOOT1[@]}" ; do
|
||||
for B2 in "${BOOT2[@]}" ; do
|
||||
for BL in "${BOOTL[@]}" ; do
|
||||
if [[ -f "$B1" ]] && [[ -f "$B2" ]] && [[ -f "$BL" ]] ; then
|
||||
if [[ -f "${B1}" ]] && [[ -f "${B2}" ]] && [[ -f "${BL}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found ""$(print_path "$B1")"", ""$(print_path "$B2")"" and ""$(print_path "$BL")"" (FreeBSD or DragonFly)"
|
||||
print_output "[+] Found ""$(print_path "${B1}")"", ""$(print_path "${B2}")"" and ""$(print_path "${BL}")"" (FreeBSD or DragonFly)"
|
||||
BOOTLOADER="FreeBSD / DragonFly"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No FreeBSD or DragonFly bootloader files found"
|
||||
fi
|
||||
|
||||
@@ -198,10 +198,10 @@ check_bootloader()
|
||||
local LILO_FILE
|
||||
mapfile -t LILO_PATH < <(mod_path "/ETC_PATHS/lilo.conf")
|
||||
for LILO_FILE in "${LILO_PATH[@]}" ; do
|
||||
if [[ -f "$LILO_FILE" ]] ; then
|
||||
if [[ -f "${LILO_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found lilo.conf: ""$(print_path "$LILO_FILE")"" (LILO)"
|
||||
FIND=$(grep 'password[[:space:]]?=' "$LILO_FILE" | grep -v "^#" || true)
|
||||
print_output "[+] Found lilo.conf: ""$(print_path "${LILO_FILE}")"" (LILO)"
|
||||
FIND=$(grep 'password[[:space:]]?=' "${LILO_FILE}" | grep -v "^#" || true)
|
||||
if [[ -z "${FIND}" ]] ; then
|
||||
print_output "[+] LILO has password protection"
|
||||
((STARTUP_FINDS+=1))
|
||||
@@ -209,7 +209,7 @@ check_bootloader()
|
||||
BOOTLOADER="LILO"
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No LILO configuration file found"
|
||||
fi
|
||||
|
||||
@@ -219,14 +219,14 @@ check_bootloader()
|
||||
local SILO_FILE=""
|
||||
mapfile -t SILO_PATH < <(mod_path "/ETC_PATHS/silo.conf")
|
||||
for SILO_FILE in "${SILO_PATH[@]}" ; do
|
||||
if [[ -f "$SILO_FILE" ]] ; then
|
||||
if [[ -f "${SILO_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found silo.conf: ""$(print_path "$SILO_FILE")"" (SILO)"
|
||||
print_output "[+] Found silo.conf: ""$(print_path "${SILO_FILE}")"" (SILO)"
|
||||
BOOTLOADER="SILO"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No SILO configuration file found"
|
||||
fi
|
||||
|
||||
@@ -236,14 +236,14 @@ check_bootloader()
|
||||
local YABOOT_FILE=""
|
||||
mapfile -t YABOOT_PATH < <(mod_path "/ETC_PATHS/yaboot.conf")
|
||||
for YABOOT_FILE in "${YABOOT_PATH[@]}" ; do
|
||||
if [[ -f "$YABOOT_FILE" ]] ; then
|
||||
if [[ -f "${YABOOT_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found yaboot.conf: ""$(print_path "$YABOOT_FILE")"" (YABOOT)"
|
||||
print_output "[+] Found yaboot.conf: ""$(print_path "${YABOOT_FILE}")"" (YABOOT)"
|
||||
BOOTLOADER="Yaboot"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No YABOOT configuration file found"
|
||||
fi
|
||||
|
||||
@@ -253,20 +253,20 @@ check_bootloader()
|
||||
local OBSD_FILE1=""
|
||||
local OBSD_FILE2=""
|
||||
# mapfile -t OBSD_PATH1 < <(mod_path "/usr/mdec/biosboot")
|
||||
mapfile -t OBSD_PATH1 < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/usr/mdec/biosboot" || true)
|
||||
mapfile -t OBSD_PATH1 < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/usr/mdec/biosboot" || true)
|
||||
# mapfile -t OBSD_PATH2 < <(mod_path "/boot")
|
||||
mapfile -t OBSD_PATH2 < <(find "$FIRMWARE_PATH" -xdev -type f -iwholename "/boot" || true)
|
||||
mapfile -t OBSD_PATH2 < <(find "${FIRMWARE_PATH}" -xdev -type f -iwholename "/boot" || true)
|
||||
for OBSD_FILE1 in "${OBSD_PATH1[@]}" ; do
|
||||
for OBSD_FILE2 in "${OBSD_PATH2[@]}" ; do
|
||||
if [[ -f "$OBSD_FILE2" ]] && [[ -f "OBSD_FILE2" ]] ; then
|
||||
if [[ -f "${OBSD_FILE2}" ]] && [[ -f "OBSD_FILE2" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found first and second stage bootstrap in ""$(print_path "$OBSD_FILE1")"" and ""$(print_path "$OBSD_FILE2")"" (OpenBSD)"
|
||||
print_output "[+] Found first and second stage bootstrap in ""$(print_path "${OBSD_FILE1}")"" and ""$(print_path "${OBSD_FILE2}")"" (OpenBSD)"
|
||||
BOOTLOADER="OpenBSD"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No OpenBSD/bootstrap files found"
|
||||
fi
|
||||
|
||||
@@ -278,40 +278,40 @@ check_bootloader()
|
||||
local OPENBSD2=""
|
||||
mapfile -t OPENBSD_PATH < <(mod_path "/ETC_PATHS/boot.conf")
|
||||
for OPENBSD in "${OPENBSD_PATH[@]}" ; do
|
||||
if [[ -f "$OPENBSD" ]] ; then
|
||||
if [[ -f "${OPENBSD}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found ""$(print_path "$OPENBSD")"" (OpenBSD)"
|
||||
FIND=$(grep '^boot' "$OPENBSD" || true)
|
||||
print_output "[+] Found ""$(print_path "${OPENBSD}")"" (OpenBSD)"
|
||||
FIND=$(grep '^boot' "${OPENBSD}" || true)
|
||||
if [[ -z "${FIND}" ]] ; then
|
||||
print_output "[+] System can be booted into single user mode without password"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
mapfile -t OPENBSD_PATH2 < <(mod_path "/ETC_PATHS/rc.conf")
|
||||
for OPENBSD2 in "${OPENBSD_PATH2[@]}" ; do
|
||||
if [[ -e "$OPENBSD2" ]] ; then
|
||||
FIND=$(grep -v -i '^#|none' "$OPENBSD2" | grep-i '_enable.*(yes|on|1)' || true| sort | awk -F= '{ print $1 }' | sed 's/_enable//')
|
||||
print_output "[+] Found OpenBSD boot services ""$(print_path "$OPENBSD2")"
|
||||
if [[ -z "$FIND" ]] ; then
|
||||
print_output "$(indent "$(orange "$FIND")")"
|
||||
if [[ -e "${OPENBSD2}" ]] ; then
|
||||
FIND=$(grep -v -i '^#|none' "${OPENBSD2}" | grep-i '_enable.*(yes|on|1)' || true| sort | awk -F= '{ print $1 }' | sed 's/_enable//')
|
||||
print_output "[+] Found OpenBSD boot services ""$(print_path "${OPENBSD2}")"
|
||||
if [[ -z "${FIND}" ]] ; then
|
||||
print_output "$(indent "$(orange "${FIND}")")"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No OpenBSD configuration file found"
|
||||
fi
|
||||
|
||||
# U-Boot quick check on firmware file
|
||||
CHECK=0
|
||||
if [[ "$UBOOT_IMAGE" -eq 1 ]]; then
|
||||
if [[ "${UBOOT_IMAGE}" -eq 1 ]]; then
|
||||
CHECK=1
|
||||
print_output "[+] Found uboot image: ""$(print_path "$FIRMWARE_PATH")"" (U-BOOT)"
|
||||
print_output "[+] Found uboot image: ""$(print_path "${FIRMWARE_PATH}")"" (U-BOOT)"
|
||||
BOOTLOADER="U-Boot"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No U-Boot image found"
|
||||
fi
|
||||
|
||||
@@ -326,15 +326,15 @@ find_boot_files()
|
||||
|
||||
local BOOT_FILES=()
|
||||
local LINE=""
|
||||
mapfile -t BOOT_FILES < <(config_find "$CONFIG_DIR""/boot_files.cfg")
|
||||
mapfile -t BOOT_FILES < <(config_find "${CONFIG_DIR}""/boot_files.cfg")
|
||||
|
||||
if [[ "${BOOT_FILES[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#BOOT_FILES[@]}" -ne 0 ]] ; then
|
||||
print_output "[+] Found ""${#BOOT_FILES[@]}"" startup files:"
|
||||
for LINE in "${BOOT_FILES[@]}" ; do
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")"
|
||||
if [[ "$(basename "$LINE")" == "inittab" ]] ; then
|
||||
INITTAB_V=("${INITTAB_V[@]}" "$LINE")
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")"
|
||||
if [[ "$(basename "${LINE}")" == "inittab" ]] ; then
|
||||
INITTAB_V=("${INITTAB_V[@]}" "${LINE}")
|
||||
fi
|
||||
((STARTUP_FINDS+=1))
|
||||
done
|
||||
@@ -355,20 +355,20 @@ find_runlevel()
|
||||
|
||||
mapfile -t SYSTEMD_PATH < <(mod_path "/ETC_PATHS/systemd")
|
||||
for SYSTEMD_P in "${SYSTEMD_PATH[@]}" ; do
|
||||
if [[ -d "$SYSTEMD_P" ]] ; then
|
||||
print_output "[*] Check runlevel in systemd directory: ""$(print_path "$SYSTEMD_P")"
|
||||
DEFAULT_TARGET_PATH="$SYSTEMD_P""/system/default.target"
|
||||
if [[ -L "$DEFAULT_TARGET_PATH" ]] ; then
|
||||
FIND="$( read -r "$DEFAULT_TARGET_PATH"'' | grep "runlevel" || true)"
|
||||
if [[ -z "$FIND" ]] ; then
|
||||
if [[ -d "${SYSTEMD_P}" ]] ; then
|
||||
print_output "[*] Check runlevel in systemd directory: ""$(print_path "${SYSTEMD_P}")"
|
||||
DEFAULT_TARGET_PATH="${SYSTEMD_P}""/system/default.target"
|
||||
if [[ -L "${DEFAULT_TARGET_PATH}" ]] ; then
|
||||
FIND="$( read -r "${DEFAULT_TARGET_PATH}"'' | grep "runlevel" || true)"
|
||||
if [[ -z "${FIND}" ]] ; then
|
||||
print_output "[+] systemd run level information:"
|
||||
print_output "$(indent "$FIND")"
|
||||
print_output "$(indent "${FIND}")"
|
||||
((STARTUP_FINDS+=1))
|
||||
else
|
||||
print_output "[-] No run level in ""$(print_path "$DEFAULT_TARGET_PATH")"" found"
|
||||
print_output "[-] No run level in ""$(print_path "${DEFAULT_TARGET_PATH}")"" found"
|
||||
fi
|
||||
else
|
||||
print_output "[-] ""$(print_path "$DEFAULT_TARGET_PATH")"" not found"
|
||||
print_output "[-] ""$(print_path "${DEFAULT_TARGET_PATH}")"" not found"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -376,12 +376,12 @@ find_runlevel()
|
||||
if [[ -v INITTAB_V[@] ]] ; then
|
||||
if [[ ${#INITTAB_V[@]} -gt 0 ]] ; then
|
||||
for INIT_TAB_F in "${INITTAB_V[@]}" ; do
|
||||
print_output "[*] Check runlevel in ""$(print_path "$INIT_TAB_F")"
|
||||
FIND=$(awk -F: '/^id/ { print $2; }' "$INIT_TAB_F" | head -n 1)
|
||||
if [[ -z "$FIND" ]] ; then
|
||||
print_output "[-] No default run level ""$(print_path "$INIT_TAB_F")"" found"
|
||||
print_output "[*] Check runlevel in ""$(print_path "${INIT_TAB_F}")"
|
||||
FIND=$(awk -F: '/^id/ { print $2; }' "${INIT_TAB_F}" | head -n 1)
|
||||
if [[ -z "${FIND}" ]] ; then
|
||||
print_output "[-] No default run level ""$(print_path "${INIT_TAB_F}")"" found"
|
||||
else
|
||||
print_output "[+] Found default run level: ""$(orange "$FIND")"
|
||||
print_output "[+] Found default run level: ""$(orange "${FIND}")"
|
||||
((STARTUP_FINDS+=1))
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -29,7 +29,7 @@ S08_package_mgmt_extractor()
|
||||
rpm_package_files_search
|
||||
|
||||
[[ "${#DEBIAN_MGMT_STATUS[@]}" -gt 0 || "${#OPENWRT_MGMT_CONTROL[@]}" -gt 0 || "${#RPM_PACKAGES[@]}" -gt 0 ]] && NEG_LOG=1
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
debian_status_files_search() {
|
||||
@@ -42,32 +42,32 @@ debian_status_files_search() {
|
||||
local PACKAGE=""
|
||||
local VERSION=""
|
||||
|
||||
mapfile -t DEBIAN_MGMT_STATUS < <(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -path "*dpkg/status" -type f)
|
||||
mapfile -t DEBIAN_MGMT_STATUS < <(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -path "*dpkg/status" -type f)
|
||||
|
||||
if [[ -v DEBIAN_MGMT_STATUS[@] ]] ; then
|
||||
write_csv_log "Packaging system" "package file" "package" "original version" "stripped version"
|
||||
print_output "[*] Found $ORANGE${#DEBIAN_MGMT_STATUS[@]}$NC debian package management files:"
|
||||
print_output "[*] Found ${ORANGE}${#DEBIAN_MGMT_STATUS[@]}${NC} debian package management files:"
|
||||
for PACKAGE_FILE in "${DEBIAN_MGMT_STATUS[@]}" ; do
|
||||
print_output "$(indent "$(orange "$(print_path "$PACKAGE_FILE")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${PACKAGE_FILE}")")")"
|
||||
done
|
||||
for PACKAGE_FILE in "${DEBIAN_MGMT_STATUS[@]}" ; do
|
||||
if grep -q "Package: " "$PACKAGE_FILE"; then
|
||||
mapfile -t DEBIAN_PACKAGES < <(grep "^Package: \|^Status: \|^Version: " "$PACKAGE_FILE" | sed -z 's/\nVersion: / - Version: /g' | sed -z 's/\nStatus: / - Status: /g')
|
||||
if grep -q "Package: " "${PACKAGE_FILE}"; then
|
||||
mapfile -t DEBIAN_PACKAGES < <(grep "^Package: \|^Status: \|^Version: " "${PACKAGE_FILE}" | sed -z 's/\nVersion: / - Version: /g' | sed -z 's/\nStatus: / - Status: /g')
|
||||
print_ln
|
||||
print_output "[*] Found debian package details:"
|
||||
for PACKAGE_VERSION in "${DEBIAN_PACKAGES[@]}" ; do
|
||||
# Package: xxd - Status: install ok installed - 2:8.2.3995-1+b3
|
||||
PACKAGE=$(safe_echo "$PACKAGE_VERSION" | awk '{print $2}' | tr -dc '[:print:]')
|
||||
PACKAGE=$(safe_echo "${PACKAGE_VERSION}" | awk '{print $2}' | tr -dc '[:print:]')
|
||||
VERSION=${PACKAGE_VERSION/*Version:\ /}
|
||||
# What is the state in an offline firmware image? Is it installed or not?
|
||||
# Futher investigation needed!
|
||||
# if ! echo "$PACKAGE_VERSION" | grep -q "installed"; then
|
||||
# if ! echo "${PACKAGE_VERSION}" | grep -q "installed"; then
|
||||
# # a not installed package - skip it
|
||||
# continue
|
||||
# fi
|
||||
clean_package_versions "$VERSION"
|
||||
print_output "[*] Debian package details: $ORANGE$PACKAGE_FILE$NC - $ORANGE$PACKAGE$NC - $ORANGE$VERSION$NC"
|
||||
write_csv_log "$PACKAGING_SYSTEM" "$PACKAGE_FILE" "$PACKAGE" "$VERSION" "$STRIPPED_VERSION"
|
||||
clean_package_versions "${VERSION}"
|
||||
print_output "[*] Debian package details: ${ORANGE}${PACKAGE_FILE}${NC} - ${ORANGE}${PACKAGE}${NC} - ${ORANGE}${VERSION}${NC}"
|
||||
write_csv_log "${PACKAGING_SYSTEM}" "${PACKAGE_FILE}" "${PACKAGE}" "${VERSION}" "${STRIPPED_VERSION}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
@@ -86,23 +86,23 @@ openwrt_control_files_search() {
|
||||
local PACKAGE=""
|
||||
local VERSION=""
|
||||
|
||||
mapfile -t OPENWRT_MGMT_CONTROL < <(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -path "*opkg/info/*.control" -type f)
|
||||
mapfile -t OPENWRT_MGMT_CONTROL < <(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -path "*opkg/info/*.control" -type f)
|
||||
|
||||
if [[ -v OPENWRT_MGMT_CONTROL[@] ]] ; then
|
||||
write_csv_log "Packaging system" "package file" "package" "version"
|
||||
print_output "[*] Found $ORANGE${#OPENWRT_MGMT_CONTROL[@]}$NC OpenWRT package management files."
|
||||
print_output "[*] Found ${ORANGE}${#OPENWRT_MGMT_CONTROL[@]}${NC} OpenWRT package management files."
|
||||
for PACKAGE_FILE in "${OPENWRT_MGMT_CONTROL[@]}" ; do
|
||||
if grep -q "Package: " "$PACKAGE_FILE"; then
|
||||
mapfile -t OPENWRT_PACKAGES < <(grep "^Package: \|^Version: " "$PACKAGE_FILE" | sed -z 's/\nVersion: / - Version: /g')
|
||||
if grep -q "Package: " "${PACKAGE_FILE}"; then
|
||||
mapfile -t OPENWRT_PACKAGES < <(grep "^Package: \|^Version: " "${PACKAGE_FILE}" | sed -z 's/\nVersion: / - Version: /g')
|
||||
print_ln
|
||||
for PACKAGE_VERSION in "${OPENWRT_PACKAGES[@]}" ; do
|
||||
PACKAGE=$(safe_echo "$PACKAGE_VERSION" | awk '{print $2}' | tr -dc '[:print:]')
|
||||
PACKAGE=$(safe_echo "${PACKAGE_VERSION}" | awk '{print $2}' | tr -dc '[:print:]')
|
||||
VERSION=${PACKAGE_VERSION/*Version:\ /}
|
||||
# What is the state in an offline firmware image? Is it installed or not?
|
||||
# Futher investigation needed!
|
||||
clean_package_versions "$VERSION"
|
||||
print_output "[*] OpenWRT package details: $ORANGE$PACKAGE_FILE$NC - $ORANGE$PACKAGE$NC - $ORANGE$VERSION$NC"
|
||||
write_csv_log "$PACKAGING_SYSTEM" "$PACKAGE_FILE" "$PACKAGE" "$VERSION" "$STRIPPED_VERSION"
|
||||
clean_package_versions "${VERSION}"
|
||||
print_output "[*] OpenWRT package details: ${ORANGE}${PACKAGE_FILE}${NC} - ${ORANGE}${PACKAGE}${NC} - ${ORANGE}${VERSION}${NC}"
|
||||
write_csv_log "${PACKAGING_SYSTEM}" "${PACKAGE_FILE}" "${PACKAGE}" "${VERSION}" "${STRIPPED_VERSION}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
@@ -127,21 +127,21 @@ rpm_package_files_search() {
|
||||
local PACKAGE_VERSION=""
|
||||
local PACKAGE_NAME=""
|
||||
|
||||
mapfile -t RPM_PACKAGE_DBS < <(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -path "*rpm/Packages" -type f)
|
||||
mapfile -t RPM_PACKAGE_DBS < <(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -path "*rpm/Packages" -type f)
|
||||
|
||||
if [[ -v RPM_PACKAGE_DBS[@] ]] ; then
|
||||
write_csv_log "Packaging system" "package dir" "package" "version"
|
||||
print_output "[*] Found $ORANGE${#RPM_PACKAGE_DBS[@]}$NC RPM package management directories."
|
||||
print_output "[*] Found ${ORANGE}${#RPM_PACKAGE_DBS[@]}${NC} RPM package management directories."
|
||||
for PACKAGE_FILE in "${RPM_PACKAGE_DBS[@]}" ; do
|
||||
RPM_DIR="$(dirname "$PACKAGE_FILE")"
|
||||
RPM_DIR="$(dirname "${PACKAGE_FILE}")"
|
||||
# not sure this works on an offline system - we need further tests on this:
|
||||
mapfile -t RPM_PACKAGES < <(rpm -qa --dbpath "$RPM_DIR" || true)
|
||||
mapfile -t RPM_PACKAGES < <(rpm -qa --dbpath "${RPM_DIR}" || true)
|
||||
print_ln
|
||||
for PACKAGE_AND_VERSION in "${RPM_PACKAGES[@]}" ; do
|
||||
PACKAGE_VERSION=$(rpm -qi --dbpath "$RPM_DIR" "$PACKAGE_AND_VERSION" | grep Version | awk '{print $3}' || true)
|
||||
PACKAGE_NAME=$(rpm -qi --dbpath "$RPM_DIR" "$PACKAGE_AND_VERSION" | grep Version | awk '{print $1}' || true)
|
||||
print_output "[*] RPM package details: $ORANGE$PACKAGE_NAME$NC - $ORANGE$PACKAGE_VERSION$NC"
|
||||
write_csv_log "$PACKAGING_SYSTEM" "$RPM_DIR" "$PACKAGE_NAME" "$PACKAGE_VERSION"
|
||||
PACKAGE_VERSION=$(rpm -qi --dbpath "${RPM_DIR}" "${PACKAGE_AND_VERSION}" | grep Version | awk '{print $3}' || true)
|
||||
PACKAGE_NAME=$(rpm -qi --dbpath "${RPM_DIR}" "${PACKAGE_AND_VERSION}" | grep Version | awk '{print $1}' || true)
|
||||
print_output "[*] RPM package details: ${ORANGE}${PACKAGE_NAME}${NC} - ${ORANGE}${PACKAGE_VERSION}${NC}"
|
||||
write_csv_log "${PACKAGING_SYSTEM}" "${RPM_DIR}" "${PACKAGE_NAME}" "${PACKAGE_VERSION}"
|
||||
done
|
||||
done
|
||||
else
|
||||
@@ -156,14 +156,14 @@ clean_package_versions() {
|
||||
# usually we get a version like 1.2.3-4 or 1.2.3-0kali1bla or 1.2.3-unknown
|
||||
# this is a quick approach to clean this version identifier
|
||||
# there is a lot of room for future improvement
|
||||
STRIPPED_VERSION=$(safe_echo "$VERSION_" | sed -r 's/-[0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/-unknown$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/-[0-9]+kali[0-9]+.*$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/-[0-9]+ubuntu[0-9]+.*$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/-[0-9]+build[0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/-[0-9]+\.[0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/-[0-9]+\.[a-d][0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/:[0-9]:/:/g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | sed -r 's/^[0-9]://g')
|
||||
STRIPPED_VERSION=$(safe_echo "$STRIPPED_VERSION" | tr -dc '[:print:]')
|
||||
STRIPPED_VERSION=$(safe_echo "${VERSION_}" | sed -r 's/-[0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/-unknown$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/-[0-9]+kali[0-9]+.*$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/-[0-9]+ubuntu[0-9]+.*$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/-[0-9]+build[0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/-[0-9]+\.[0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/-[0-9]+\.[a-d][0-9]+$//g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/:[0-9]:/:/g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | sed -r 's/^[0-9]://g')
|
||||
STRIPPED_VERSION=$(safe_echo "${STRIPPED_VERSION}" | tr -dc '[:print:]')
|
||||
}
|
||||
|
||||
@@ -29,77 +29,77 @@ S09_firmware_base_version_check() {
|
||||
module_title "Static binary firmware versions detection"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
EXTRACTOR_LOG="$LOG_DIR"/p60_firmware_bin_extractor.txt
|
||||
EXTRACTOR_LOG="${LOG_DIR}"/p60_firmware_bin_extractor.txt
|
||||
|
||||
print_output "[*] Static version detection running ..." "no_log" | tr -d "\n"
|
||||
write_csv_log "binary/file" "version_rule" "version_detected" "csv_rule" "license" "static/emulation"
|
||||
TYPE="static"
|
||||
|
||||
while read -r VERSION_LINE; do
|
||||
if safe_echo "$VERSION_LINE" | grep -v -q "^[^#*/;]"; then
|
||||
if safe_echo "${VERSION_LINE}" | grep -v -q "^[^#*/;]"; then
|
||||
continue
|
||||
fi
|
||||
if safe_echo "$VERSION_LINE" | grep -q ";no_static;"; then
|
||||
if safe_echo "${VERSION_LINE}" | grep -q ";no_static;"; then
|
||||
continue
|
||||
fi
|
||||
if safe_echo "$VERSION_LINE" | grep -q ";live;"; then
|
||||
if safe_echo "${VERSION_LINE}" | grep -q ";live;"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
print_dot
|
||||
|
||||
STRICT="$(safe_echo "$VERSION_LINE" | cut -d\; -f2)"
|
||||
LIC="$(safe_echo "$VERSION_LINE" | cut -d\; -f3)"
|
||||
BIN_NAME="$(safe_echo "$VERSION_LINE" | cut -d\; -f1)"
|
||||
CSV_REGEX="$(echo "$VERSION_LINE" | cut -d\; -f5)"
|
||||
STRICT="$(safe_echo "${VERSION_LINE}" | cut -d\; -f2)"
|
||||
LIC="$(safe_echo "${VERSION_LINE}" | cut -d\; -f3)"
|
||||
BIN_NAME="$(safe_echo "${VERSION_LINE}" | cut -d\; -f1)"
|
||||
CSV_REGEX="$(echo "${VERSION_LINE}" | cut -d\; -f5)"
|
||||
|
||||
# VERSION_IDENTIFIER="$(echo "$VERSION_LINE" | cut -d\; -f4 | sed s/^\"// | sed s/\"$//)"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_LINE" | cut -d\; -f4)"
|
||||
# VERSION_IDENTIFIER="$(echo "${VERSION_LINE}" | cut -d\; -f4 | sed s/^\"// | sed s/\"$//)"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_LINE}" | cut -d\; -f4)"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER/\"}"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER%\"}"
|
||||
|
||||
if [[ "$STRICT" == *"strict"* ]]; then
|
||||
if [[ "${STRICT}" == *"strict"* ]]; then
|
||||
|
||||
# strict mode
|
||||
# use the defined regex only on a binary called BIN_NAME (field 1)
|
||||
|
||||
[[ "$RTOS" -eq 1 ]] && continue
|
||||
[[ "${RTOS}" -eq 1 ]] && continue
|
||||
|
||||
mapfile -t STRICT_BINS < <(find "$OUTPUT_DIR" -xdev -executable -type f -name "$BIN_NAME" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3)
|
||||
mapfile -t STRICT_BINS < <(find "${OUTPUT_DIR}" -xdev -executable -type f -name "${BIN_NAME}" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3)
|
||||
for BIN in "${STRICT_BINS[@]}"; do
|
||||
# as the STRICT_BINS array could also include executable scripts we have to check for ELF files now:
|
||||
if file "$BIN" | grep -q ELF ; then
|
||||
VERSION_FINDER=$(strings "$BIN" | grep -E "$VERSION_IDENTIFIER" | sort -u || true)
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
if file "${BIN}" | grep -q ELF ; then
|
||||
VERSION_FINDER=$(strings "${BIN}" | grep -E "${VERSION_IDENTIFIER}" | sort -u || true)
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}$BIN_NAME $VERSION_FINDER${NC}${GREEN} in binary $ORANGE$(print_path "$BIN")$GREEN (license: $ORANGE$LIC$GREEN) (${ORANGE}static - strict$GREEN)."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
write_csv_log "$BIN" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
print_output "[+] Version information found ${RED}${BIN_NAME} ${VERSION_FINDER}${NC}${GREEN} in binary ${ORANGE}$(print_path "${BIN}")${GREEN} (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static - strict${GREEN})."
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
write_csv_log "${BIN}" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
done
|
||||
print_dot
|
||||
|
||||
elif [[ "$STRICT" == "zgrep" ]]; then
|
||||
elif [[ "${STRICT}" == "zgrep" ]]; then
|
||||
|
||||
# zgrep mode:
|
||||
# search for files with identifier in field 1
|
||||
# use regex (VERSION_IDENTIFIER) via zgrep on these files
|
||||
# use csv-regex to get the csv-search string for csv lookup
|
||||
|
||||
mapfile -t SPECIAL_FINDS < <(find "$FIRMWARE_PATH" -xdev -type f -name "$BIN_NAME" -exec zgrep -H "$VERSION_IDENTIFIER" {} \; || true)
|
||||
mapfile -t SPECIAL_FINDS < <(find "${FIRMWARE_PATH}" -xdev -type f -name "${BIN_NAME}" -exec zgrep -H "${VERSION_IDENTIFIER}" {} \; || true)
|
||||
for SFILE in "${SPECIAL_FINDS[@]}"; do
|
||||
BIN_PATH=$(safe_echo "$SFILE" | cut -d ":" -f1)
|
||||
BIN_NAME="$(basename "$(safe_echo "$SFILE" | cut -d ":" -f1)")"
|
||||
# CSV_REGEX=$(echo "$VERSION_LINE" | cut -d\; -f5 | sed s/^\"// | sed s/\"$//)
|
||||
CSV_REGEX="$(echo "$VERSION_LINE" | cut -d\; -f5)"
|
||||
BIN_PATH=$(safe_echo "${SFILE}" | cut -d ":" -f1)
|
||||
BIN_NAME="$(basename "$(safe_echo "${SFILE}" | cut -d ":" -f1)")"
|
||||
# CSV_REGEX=$(echo "${VERSION_LINE}" | cut -d\; -f5 | sed s/^\"// | sed s/\"$//)
|
||||
CSV_REGEX="$(echo "${VERSION_LINE}" | cut -d\; -f5)"
|
||||
CSV_REGEX="${CSV_REGEX/\"}"
|
||||
CSV_REGEX="${CSV_REGEX%\"}"
|
||||
VERSION_FINDER=$(safe_echo "$SFILE" | cut -d ":" -f2-3 | tr -dc '[:print:]')
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
print_output "[+] Version information found ${RED}""$VERSION_FINDER""${NC}${GREEN} in binary $ORANGE$(print_path "$BIN_PATH")$GREEN (license: $ORANGE$LIC$GREEN) (${ORANGE}static - zgrep$GREEN)."
|
||||
write_csv_log "$BIN_PATH" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
VERSION_FINDER=$(safe_echo "${SFILE}" | cut -d ":" -f2-3 | tr -dc '[:print:]')
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
print_output "[+] Version information found ${RED}""${VERSION_FINDER}""${NC}${GREEN} in binary ${ORANGE}$(print_path "${BIN_PATH}")${GREEN} (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static - zgrep${GREEN})."
|
||||
write_csv_log "${BIN_PATH}" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
done
|
||||
print_dot
|
||||
|
||||
@@ -108,46 +108,46 @@ S09_firmware_base_version_check() {
|
||||
# This is default mode!
|
||||
|
||||
# check binwalk files sometimes we can find kernel version information or something else in it
|
||||
VERSION_FINDER=$(grep -o -a -E "$VERSION_IDENTIFIER" "$EXTRACTOR_LOG" 2>/dev/null | head -1 2>/dev/null || true)
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
VERSION_FINDER=$(grep -o -a -E "${VERSION_IDENTIFIER}" "${EXTRACTOR_LOG}" 2>/dev/null | head -1 2>/dev/null || true)
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}""$VERSION_FINDER""${NC}${GREEN} in binwalk logs (license: $ORANGE$LIC$GREEN) (${ORANGE}static$GREEN)."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
write_csv_log "binwalk logs" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
print_output "[+] Version information found ${RED}""${VERSION_FINDER}""${NC}${GREEN} in binwalk logs (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
write_csv_log "binwalk logs" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
print_dot
|
||||
fi
|
||||
|
||||
print_dot
|
||||
|
||||
if [[ $FIRMWARE -eq 0 || -f $FIRMWARE_PATH ]]; then
|
||||
VERSION_FINDER=$(find "$FIRMWARE_PATH" -xdev -type f -print0 2>/dev/null | xargs -0 strings | grep -o -a -E "$VERSION_IDENTIFIER" | head -1 2>/dev/null || true)
|
||||
if [[ ${FIRMWARE} -eq 0 || -f ${FIRMWARE_PATH} ]]; then
|
||||
VERSION_FINDER=$(find "${FIRMWARE_PATH}" -xdev -type f -print0 2>/dev/null | xargs -0 strings | grep -o -a -E "${VERSION_IDENTIFIER}" | head -1 2>/dev/null || true)
|
||||
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}""$VERSION_FINDER""${NC}${GREEN} in original firmware file (license: $ORANGE$LIC$GREEN) (${ORANGE}static$GREEN)."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
write_csv_log "firmware" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
print_output "[+] Version information found ${RED}""${VERSION_FINDER}""${NC}${GREEN} in original firmware file (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
write_csv_log "firmware" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
fi
|
||||
print_dot
|
||||
fi
|
||||
|
||||
if [[ $RTOS -eq 1 ]]; then
|
||||
if [[ ${RTOS} -eq 1 ]]; then
|
||||
# in RTOS mode we also test the original firmware file
|
||||
VERSION_FINDER=$(find "${FIRMWARE_PATH_BAK}" -xdev -type f -print0 2>/dev/null | xargs -0 strings | grep -o -a -E "${VERSION_IDENTIFIER}" | head -1 2>/dev/null || true)
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}""${VERSION_FINDER}""${NC}${GREEN} in original firmware file (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
write_csv_log "firmware" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
write_csv_log "firmware" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
# this will burn the CPU but in most cases the time of testing is cut into half
|
||||
bin_string_checker &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S09+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S09+=( "${TMP_PID}" )
|
||||
else
|
||||
bin_string_checker
|
||||
fi
|
||||
@@ -156,62 +156,62 @@ S09_firmware_base_version_check() {
|
||||
|
||||
fi
|
||||
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
if [[ "${#WAIT_PIDS_S09[@]}" -gt "$MAX_MOD_THREADS" ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
if [[ "${#WAIT_PIDS_S09[@]}" -gt "${MAX_MOD_THREADS}" ]]; then
|
||||
recover_wait_pids "${WAIT_PIDS_S09[@]}"
|
||||
if [[ "${#WAIT_PIDS_S09[@]}" -gt "$MAX_MOD_THREADS" ]]; then
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S09[@]}"
|
||||
if [[ "${#WAIT_PIDS_S09[@]}" -gt "${MAX_MOD_THREADS}" ]]; then
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S09[@]}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
done < "$CONFIG_DIR"/bin_version_strings.cfg
|
||||
done < "${CONFIG_DIR}"/bin_version_strings.cfg
|
||||
|
||||
print_dot
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S09[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S09[@]}"
|
||||
|
||||
VERSIONS_DETECTED=$(grep -c "Version information found" "$LOG_FILE" || true)
|
||||
VERSIONS_DETECTED=$(grep -c "Version information found" "${LOG_FILE}" || true)
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$VERSIONS_DETECTED"
|
||||
module_end_log "${FUNCNAME[0]}" "${VERSIONS_DETECTED}"
|
||||
}
|
||||
|
||||
bin_string_checker() {
|
||||
for BIN in "${FILE_ARR[@]}"; do
|
||||
if [[ $RTOS -eq 0 ]]; then
|
||||
BIN_FILE=$(file "$BIN" || true)
|
||||
if [[ ${RTOS} -eq 0 ]]; then
|
||||
BIN_FILE=$(file "${BIN}" || true)
|
||||
# as the FILE_ARR array also includes non binary stuff we have to check for relevant files now:
|
||||
if ! [[ "$BIN_FILE" == *uImage* || "$BIN_FILE" == *Kernel\ Image* || "$BIN_FILE" == *ELF* ]] ; then
|
||||
if ! [[ "${BIN_FILE}" == *uImage* || "${BIN_FILE}" == *Kernel\ Image* || "${BIN_FILE}" == *ELF* ]] ; then
|
||||
continue
|
||||
fi
|
||||
if [[ "$BIN_FILE" == *ELF* ]] ; then
|
||||
VERSION_FINDER=$(strings "$BIN" | grep -o -a -E "$VERSION_IDENTIFIER" | head -1 2> /dev/null || true)
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
if [[ "${BIN_FILE}" == *ELF* ]] ; then
|
||||
VERSION_FINDER=$(strings "${BIN}" | grep -o -a -E "${VERSION_IDENTIFIER}" | head -1 2> /dev/null || true)
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}$VERSION_FINDER${NC}${GREEN} in binary $ORANGE$(print_path "$BIN")$GREEN (license: $ORANGE$LIC$GREEN) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
write_csv_log "$BIN" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
print_output "[+] Version information found ${RED}${VERSION_FINDER}${NC}${GREEN} in binary ${ORANGE}$(print_path "${BIN}")${GREEN} (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
write_csv_log "${BIN}" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
continue
|
||||
fi
|
||||
elif [[ "$BIN_FILE" == *uImage* || "$BIN_FILE" == *Kernel\ Image* ]] ; then
|
||||
VERSION_FINDER=$(strings "$BIN" | grep -o -a -E "$VERSION_IDENTIFIER" | head -1 2> /dev/null || true)
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
elif [[ "${BIN_FILE}" == *uImage* || "${BIN_FILE}" == *Kernel\ Image* ]] ; then
|
||||
VERSION_FINDER=$(strings "${BIN}" | grep -o -a -E "${VERSION_IDENTIFIER}" | head -1 2> /dev/null || true)
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}$VERSION_FINDER${NC}${GREEN} in kernel image $ORANGE$(print_path "$BIN")$GREEN (license: $ORANGE$LIC$GREEN) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
write_csv_log "$BIN" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
print_output "[+] Version information found ${RED}${VERSION_FINDER}${NC}${GREEN} in kernel image ${ORANGE}$(print_path "${BIN}")${GREEN} (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
write_csv_log "${BIN}" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# this is RTOS mode
|
||||
# echo "Testing $BIN - $VERSION_IDENTIFIER"
|
||||
VERSION_FINDER="$(strings "$BIN" | grep -o -a -E "$VERSION_IDENTIFIER" | head -1 2> /dev/null || true)"
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
VERSION_FINDER="$(strings "${BIN}" | grep -o -a -E "${VERSION_IDENTIFIER}" | head -1 2> /dev/null || true)"
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}$VERSION_FINDER${NC}${GREEN} in binary $ORANGE$(print_path "$BIN")$GREEN (license: $ORANGE$LIC$GREEN) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
write_csv_log "$BIN" "$BIN_NAME" "$VERSION_FINDER" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
print_output "[+] Version information found ${RED}${VERSION_FINDER}${NC}${GREEN} in binary ${ORANGE}$(print_path "${BIN}")${GREEN} (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
write_csv_log "${BIN}" "${BIN_NAME}" "${VERSION_FINDER}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
@@ -224,8 +224,8 @@ recover_wait_pids() {
|
||||
# check for really running PIDs and re-create the array
|
||||
for PID in "${WAIT_PIDS_S09[@]}"; do
|
||||
# print_output "[*] max pid protection: ${#WAIT_PIDS[@]}"
|
||||
if [[ -e /proc/"$PID" ]]; then
|
||||
TEMP_PIDS+=( "$PID" )
|
||||
if [[ -e /proc/"${PID}" ]]; then
|
||||
TEMP_PIDS+=( "${PID}" )
|
||||
fi
|
||||
done
|
||||
# print_output "[!] S09 - really running pids: ${#TEMP_PIDS[@]}"
|
||||
|
||||
@@ -22,7 +22,7 @@ S100_command_inj_check()
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
local CMD_INJ_DIRS
|
||||
mapfile -t CMD_INJ_DIRS < <(config_find "$CONFIG_DIR""/check_command_inj_dirs.cfg")
|
||||
mapfile -t CMD_INJ_DIRS < <(config_find "${CONFIG_DIR}""/check_command_inj_dirs.cfg")
|
||||
local DIR=""
|
||||
local FILE_ARRX=()
|
||||
local FILE_S=""
|
||||
@@ -33,25 +33,25 @@ S100_command_inj_check()
|
||||
elif [[ "${#CMD_INJ_DIRS[@]}" -ne 0 ]] ; then
|
||||
print_output "[+] Found directories and files used for web scripts:"
|
||||
for DIR in "${CMD_INJ_DIRS[@]}" ; do
|
||||
if [[ -d "$DIR" ]] ; then
|
||||
print_output "$(indent "$(print_path "$DIR")")"
|
||||
mapfile -t FILE_ARRX < <( find "$DIR" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
if [[ -d "${DIR}" ]] ; then
|
||||
print_output "$(indent "$(print_path "${DIR}")")"
|
||||
mapfile -t FILE_ARRX < <( find "${DIR}" -xdev -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
|
||||
for FILE_S in "${FILE_ARRX[@]}" ; do
|
||||
if file "$FILE_S" | grep -q -E "script.*executable" ; then
|
||||
print_output "$( indent "$(orange "$(print_path "$FILE_S")"" -> Executable script")")"
|
||||
if file "${FILE_S}" | grep -q -E "script.*executable" ; then
|
||||
print_output "$( indent "$(orange "$(print_path "${FILE_S}")"" -> Executable script")")"
|
||||
|
||||
local QUERY_L
|
||||
mapfile -t QUERY_L < <(config_list "$CONFIG_DIR""/check_command_injections.cfg" "")
|
||||
mapfile -t QUERY_L < <(config_list "${CONFIG_DIR}""/check_command_injections.cfg" "")
|
||||
for QUERY in "${QUERY_L[@]}" ; do
|
||||
# without this check we always have an empty search string and get every file as result
|
||||
if [[ -n "$QUERY" ]]; then
|
||||
mapfile -t CHECK < <(grep -H -h "$QUERY" "$FILE_S" | sort -u || true)
|
||||
if [[ -n "${QUERY}" ]]; then
|
||||
mapfile -t CHECK < <(grep -H -h "${QUERY}" "${FILE_S}" | sort -u || true)
|
||||
if [[ "${#CHECK[@]}" -gt 0 ]] ; then
|
||||
print_ln
|
||||
print_output "$(indent "[$GREEN+$NC]$GREEN Found ""$QUERY"" in ""$(print_path "$FILE_S")$NC")"
|
||||
print_output "$(indent "[${GREEN}+${NC}]${GREEN} Found ""${QUERY}"" in ""$(print_path "${FILE_S}")${NC}")"
|
||||
for CHECK_ in "${CHECK[@]}" ; do
|
||||
print_output "$(indent "[$GREEN+$NC]$GREEN $CHECK_$NC")"
|
||||
print_output "$(indent "[${GREEN}+${NC}]${GREEN} ${CHECK_}${NC}")"
|
||||
done
|
||||
print_ln
|
||||
fi
|
||||
|
||||
@@ -23,12 +23,12 @@ S106_deep_key_search()
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
local PATTERNS
|
||||
PATTERNS="$(config_list "$CONFIG_DIR""/deep_key_search.cfg" "")"
|
||||
PATTERNS="$(config_list "${CONFIG_DIR}""/deep_key_search.cfg" "")"
|
||||
|
||||
readarray -t PATTERN_LIST < <(printf '%s' "$PATTERNS")
|
||||
readarray -t PATTERN_LIST < <(printf '%s' "${PATTERNS}")
|
||||
|
||||
for PATTERN in "${PATTERN_LIST[@]}";do
|
||||
print_output "[*] Pattern: $PATTERN"
|
||||
print_output "[*] Pattern: ${PATTERN}"
|
||||
done
|
||||
|
||||
SORTED_OCC_LIST=()
|
||||
@@ -47,36 +47,36 @@ deep_key_search() {
|
||||
local FILE_NAME=""
|
||||
|
||||
for PATTERN in "${PATTERN_LIST[@]}" ; do
|
||||
GREP_PATTERN_COMMAND=( "${GREP_PATTERN_COMMAND[@]}" "-e" ".{0,15}""$PATTERN"".{0,15}" )
|
||||
GREP_PATTERN_COMMAND=( "${GREP_PATTERN_COMMAND[@]}" "-e" ".{0,15}""${PATTERN}"".{0,15}" )
|
||||
done
|
||||
print_ln
|
||||
readarray -t MATCH_FILES < <(grep -E -l -R "${GREP_PATTERN_COMMAND[@]}" -D skip "$LOG_DIR"/firmware 2>/dev/null || true)
|
||||
readarray -t MATCH_FILES < <(grep -E -l -R "${GREP_PATTERN_COMMAND[@]}" -D skip "${LOG_DIR}"/firmware 2>/dev/null || true)
|
||||
if [[ ${#MATCH_FILES[@]} -gt 0 ]] ; then
|
||||
for MATCH_FILE in "${MATCH_FILES[@]}" ; do
|
||||
if ! [[ -f "$MATCH_FILE" ]]; then
|
||||
if ! [[ -f "${MATCH_FILE}" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
FILE_NAME=$(basename "$MATCH_FILE")
|
||||
FILE_NAME=$(basename "${MATCH_FILE}")
|
||||
# we just write the FILE_PATH in the beginning to the file (e.g., the log file is not available -> we create it)
|
||||
if ! [[ -f "$LOG_PATH_MODULE"/deep_key_search_"$FILE_NAME".txt ]]; then
|
||||
write_log "[*] FILE_PATH: $(print_path "$MATCH_FILE")" "$LOG_PATH_MODULE/deep_key_search_$FILE_NAME.txt"
|
||||
write_log "" "$LOG_PATH_MODULE/deep_key_search_$FILE_NAME.txt"
|
||||
if ! [[ -f "${LOG_PATH_MODULE}"/deep_key_search_"${FILE_NAME}".txt ]]; then
|
||||
write_log "[*] FILE_PATH: $(print_path "${MATCH_FILE}")" "${LOG_PATH_MODULE}/deep_key_search_${FILE_NAME}.txt"
|
||||
write_log "" "${LOG_PATH_MODULE}/deep_key_search_${FILE_NAME}.txt"
|
||||
fi
|
||||
grep -A 2 --no-group-separator -E -n -a -h "${GREP_PATTERN_COMMAND[@]}" -D skip "$MATCH_FILE" 2>/dev/null | tr -d '\0' >> "$LOG_PATH_MODULE"/deep_key_search_"$FILE_NAME".txt || true
|
||||
print_output "[+] $(print_path "$MATCH_FILE")"
|
||||
write_link "$LOG_PATH_MODULE""/deep_key_search_""$FILE_NAME"".txt"
|
||||
grep -A 2 --no-group-separator -E -n -a -h "${GREP_PATTERN_COMMAND[@]}" -D skip "${MATCH_FILE}" 2>/dev/null | tr -d '\0' >> "${LOG_PATH_MODULE}"/deep_key_search_"${FILE_NAME}".txt || true
|
||||
print_output "[+] $(print_path "${MATCH_FILE}")"
|
||||
write_link "${LOG_PATH_MODULE}""/deep_key_search_""${FILE_NAME}"".txt"
|
||||
local D_S_FINDINGS=""
|
||||
for PATTERN in "${PATTERN_LIST[@]}" ; do
|
||||
F_COUNT=$(grep -c "$PATTERN" "$LOG_PATH_MODULE"/deep_key_search_"$FILE_NAME"".txt" || true)
|
||||
if [[ $F_COUNT -gt 0 ]] ; then
|
||||
D_S_FINDINGS="$D_S_FINDINGS"" ""$F_COUNT""\t:\t""$PATTERN""\n"
|
||||
F_COUNT=$(grep -c "${PATTERN}" "${LOG_PATH_MODULE}"/deep_key_search_"${FILE_NAME}"".txt" || true)
|
||||
if [[ ${F_COUNT} -gt 0 ]] ; then
|
||||
D_S_FINDINGS="${D_S_FINDINGS}"" ""${F_COUNT}""\t:\t""${PATTERN}""\n"
|
||||
fi
|
||||
done
|
||||
print_output "$D_S_FINDINGS"
|
||||
write_log "" "$LOG_PATH_MODULE/deep_key_search_$FILE_NAME.txt"
|
||||
write_log "[*] Deep search results:" "$LOG_PATH_MODULE/deep_key_search_$FILE_NAME.txt"
|
||||
write_log "$D_S_FINDINGS" "$LOG_PATH_MODULE/deep_key_search_$FILE_NAME.txt"
|
||||
print_output "${D_S_FINDINGS}"
|
||||
write_log "" "${LOG_PATH_MODULE}/deep_key_search_${FILE_NAME}.txt"
|
||||
write_log "[*] Deep search results:" "${LOG_PATH_MODULE}/deep_key_search_${FILE_NAME}.txt"
|
||||
write_log "${D_S_FINDINGS}" "${LOG_PATH_MODULE}/deep_key_search_${FILE_NAME}.txt"
|
||||
done
|
||||
fi
|
||||
}
|
||||
@@ -84,9 +84,9 @@ deep_key_search() {
|
||||
deep_key_reporter() {
|
||||
OCC_LIST=()
|
||||
for PATTERN in "${PATTERN_LIST[@]}" ; do
|
||||
P_COUNT=$(grep -c "$PATTERN" "$LOG_PATH_MODULE"/deep_key_search_* 2>/dev/null | cut -d: -f2 | awk '{ SUM += $1} END { print SUM }' || true )
|
||||
if [[ "$P_COUNT" -gt 0 ]]; then
|
||||
OCC_LIST=( "${OCC_LIST[@]}" "$P_COUNT"": ""$PATTERN" )
|
||||
P_COUNT=$(grep -c "${PATTERN}" "${LOG_PATH_MODULE}"/deep_key_search_* 2>/dev/null | cut -d: -f2 | awk '{ SUM += $1} END { print SUM }' || true )
|
||||
if [[ "${P_COUNT}" -gt 0 ]]; then
|
||||
OCC_LIST=( "${OCC_LIST[@]}" "${P_COUNT}"": ""${PATTERN}" )
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -97,7 +97,7 @@ deep_key_reporter() {
|
||||
SORTED_OCC_LIST=("$(printf '%s\n' "${OCC_LIST[@]}" | sort -r --version-sort)")
|
||||
if [[ "${#SORTED_OCC_LIST[@]}" -gt 0 ]]; then
|
||||
for OCC in "${SORTED_OCC_LIST[@]}"; do
|
||||
print_output "$( indent "$(orange "$OCC" )")""\n"
|
||||
print_output "$( indent "$(orange "${OCC}" )")""\n"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -20,32 +20,32 @@ S107_deep_password_search()
|
||||
module_title "Deep analysis of files for password hashes"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
local PW_HASH_CONFIG="$CONFIG_DIR"/password_regex.cfg
|
||||
local PW_HASH_CONFIG="${CONFIG_DIR}"/password_regex.cfg
|
||||
local PW_COUNTER=0
|
||||
local PW_PATH=""
|
||||
local PW_HASHES=()
|
||||
local PW_HASH=""
|
||||
|
||||
find "$FIRMWARE_PATH" -xdev -type f -exec grep --color -n -a -E -H -f "$PW_HASH_CONFIG" {} \; > "$TMP_DIR"/pw_hashes.txt
|
||||
find "${FIRMWARE_PATH}" -xdev -type f -exec grep --color -n -a -E -H -f "${PW_HASH_CONFIG}" {} \; > "${TMP_DIR}"/pw_hashes.txt
|
||||
|
||||
if [[ $(wc -l "$TMP_DIR"/pw_hashes.txt | awk '{print $1}') -gt 0 ]]; then
|
||||
if [[ $(wc -l "${TMP_DIR}"/pw_hashes.txt | awk '{print $1}') -gt 0 ]]; then
|
||||
print_output "[+] Found the following password hash values:"
|
||||
write_csv_log "PW_PATH" "PW_HASH"
|
||||
while read -r PW_HASH; do
|
||||
PW_PATH=$(echo "$PW_HASH" | cut -d: -f1)
|
||||
mapfile -t PW_HASHES < <(strings "$PW_PATH" | grep --color -a -E -f "$PW_HASH_CONFIG")
|
||||
PW_PATH=$(echo "${PW_HASH}" | cut -d: -f1)
|
||||
mapfile -t PW_HASHES < <(strings "${PW_PATH}" | grep --color -a -E -f "${PW_HASH_CONFIG}")
|
||||
for PW_HASH in "${PW_HASHES[@]}"; do
|
||||
print_output "[+] PATH: $ORANGE$(print_path "$PW_PATH")$GREEN\t-\tHash: $ORANGE$PW_HASH$GREEN."
|
||||
write_csv_log "NA" "$PW_PATH" "$PW_HASH"
|
||||
print_output "[+] PATH: ${ORANGE}$(print_path "${PW_PATH}")${GREEN}\t-\tHash: ${ORANGE}${PW_HASH}${GREEN}."
|
||||
write_csv_log "NA" "${PW_PATH}" "${PW_HASH}"
|
||||
((PW_COUNTER+=1))
|
||||
done
|
||||
done < "$TMP_DIR"/pw_hashes.txt
|
||||
done < "${TMP_DIR}"/pw_hashes.txt
|
||||
|
||||
print_ln
|
||||
print_output "[*] Found $ORANGE$PW_COUNTER$NC password hashes."
|
||||
print_output "[*] Found ${ORANGE}${PW_COUNTER}${NC} password hashes."
|
||||
fi
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$PW_COUNTER"
|
||||
write_log "[*] Statistics:${PW_COUNTER}"
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$PW_COUNTER"
|
||||
module_end_log "${FUNCNAME[0]}" "${PW_COUNTER}"
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ S108_stacs_password_search()
|
||||
module_title "Stacs analysis of firmware for password hashes"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
local STACS_RULES_DIR="$EXT_DIR"/stacs-rules
|
||||
local STACS_LOG_FILE="$LOG_PATH_MODULE"/stacs_pw_hashes.json
|
||||
local STACS_RULES_DIR="${EXT_DIR}"/stacs-rules
|
||||
local STACS_LOG_FILE="${LOG_PATH_MODULE}"/stacs_pw_hashes.json
|
||||
local ELEMENTS=0
|
||||
local ELEMENTS_=0
|
||||
local PW_PATH=""
|
||||
@@ -32,40 +32,40 @@ S108_stacs_password_search()
|
||||
local MESSAGE=""
|
||||
|
||||
if command -v stacs > /dev/null ; then
|
||||
stacs --debug --skip-unprocessable --rule-pack "$STACS_RULES_DIR"/credential.json "$FIRMWARE_PATH" 2> "$TMP_DIR"/stacs.err 1> "$STACS_LOG_FILE" || true
|
||||
stacs --debug --skip-unprocessable --rule-pack "${STACS_RULES_DIR}"/credential.json "${FIRMWARE_PATH}" 2> "${TMP_DIR}"/stacs.err 1> "${STACS_LOG_FILE}" || true
|
||||
|
||||
if [[ -f "$TMP_DIR"/stacs.err ]]; then
|
||||
if [[ -f "${TMP_DIR}"/stacs.err ]]; then
|
||||
print_ln
|
||||
print_output "[*] STACS log:"
|
||||
tee -a "$LOG_FILE" < "$TMP_DIR"/stacs.err || true
|
||||
tee -a "${LOG_FILE}" < "${TMP_DIR}"/stacs.err || true
|
||||
fi
|
||||
|
||||
if [[ -f "$STACS_LOG_FILE" && $(jq ".runs[0] .results[] | .message[]" "$STACS_LOG_FILE" | wc -l) -gt 0 ]]; then
|
||||
if [[ -f "${STACS_LOG_FILE}" && $(jq ".runs[0] .results[] | .message[]" "${STACS_LOG_FILE}" | wc -l) -gt 0 ]]; then
|
||||
print_ln
|
||||
ELEMENTS_="$(jq ".runs[0] .results[] .message.text" "$STACS_LOG_FILE" | wc -l)"
|
||||
print_output "[+] Found $ORANGE$ELEMENTS_$GREEN credential areas:"
|
||||
ELEMENTS_="$(jq ".runs[0] .results[] .message.text" "${STACS_LOG_FILE}" | wc -l)"
|
||||
print_output "[+] Found ${ORANGE}${ELEMENTS_}${GREEN} credential areas:"
|
||||
write_csv_log "Message" "PW_PATH" "PW_HASH" "PW_HASH_real"
|
||||
ELEMENTS=$((ELEMENTS_-1))
|
||||
|
||||
for ELEMENT in $(seq 0 "$ELEMENTS"); do
|
||||
MESSAGE=$(jq ".runs[0] .results[$ELEMENT] .message.text" "$STACS_LOG_FILE" | grep -v null || true)
|
||||
PW_PATH=$(jq ".runs[0] .results[$ELEMENT] .locations[] .physicalLocation[].uri" "$STACS_LOG_FILE" \
|
||||
for ELEMENT in $(seq 0 "${ELEMENTS}"); do
|
||||
MESSAGE=$(jq ".runs[0] .results[${ELEMENT}] .message.text" "${STACS_LOG_FILE}" | grep -v null || true)
|
||||
PW_PATH=$(jq ".runs[0] .results[${ELEMENT}] .locations[] .physicalLocation[].uri" "${STACS_LOG_FILE}" \
|
||||
| grep -v null | sed 's/^"//' | sed 's/"$//' || true)
|
||||
PW_HASH=$(jq ".runs[0] .results[$ELEMENT] .locations[] .physicalLocation[].snippet" "$STACS_LOG_FILE" \
|
||||
PW_HASH=$(jq ".runs[0] .results[${ELEMENT}] .locations[] .physicalLocation[].snippet" "${STACS_LOG_FILE}" \
|
||||
| grep -v null | grep "text\|binary" | head -1 | cut -d: -f2- | sed 's/\\n//g' | tr -d '[:blank:]' || true)
|
||||
PW_HASH_REAL=$(jq ".runs[0] .results[$ELEMENT] .locations[] .physicalLocation[].snippet.text" "$STACS_LOG_FILE" \
|
||||
PW_HASH_REAL=$(jq ".runs[0] .results[${ELEMENT}] .locations[] .physicalLocation[].snippet.text" "${STACS_LOG_FILE}" \
|
||||
| grep -v null | head -2 | tail -1 | sed 's/\\n//g' | tr -d '[:blank:]' || true)
|
||||
|
||||
print_output "[+] PATH: $ORANGE/$PW_PATH$GREEN\t-\tHash: $ORANGE$PW_HASH$GREEN."
|
||||
write_csv_log "$MESSAGE" "/$PW_PATH" "$PW_HASH" "$PW_HASH_REAL"
|
||||
print_output "[+] PATH: ${ORANGE}/${PW_PATH}${GREEN}\t-\tHash: ${ORANGE}${PW_HASH}${GREEN}."
|
||||
write_csv_log "${MESSAGE}" "/${PW_PATH}" "${PW_HASH}" "${PW_HASH_REAL}"
|
||||
done
|
||||
|
||||
print_ln
|
||||
print_output "[*] Found $ORANGE$ELEMENTS_$NC password hashes."
|
||||
print_output "[*] Found ${ORANGE}${ELEMENTS_}${NC} password hashes."
|
||||
fi
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$ELEMENTS_"
|
||||
write_log "[*] Statistics:${ELEMENTS_}"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$ELEMENTS_"
|
||||
module_end_log "${FUNCNAME[0]}" "${ELEMENTS_}"
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ S109_jtr_local_pw_cracking()
|
||||
{
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
|
||||
local PW_FILE="$CSV_DIR"/s108_stacs_password_search.csv
|
||||
local PW_FILE_S107="$CSV_DIR"/s107_deep_password_search.csv
|
||||
local PW_FILE="${CSV_DIR}"/s108_stacs_password_search.csv
|
||||
local PW_FILE_S107="${CSV_DIR}"/s107_deep_password_search.csv
|
||||
local NEG_LOG=0
|
||||
local HASHES_S107=()
|
||||
local HASHES_S108=()
|
||||
@@ -34,7 +34,7 @@ S109_jtr_local_pw_cracking()
|
||||
local CRACKED=0
|
||||
local JTR_TIMEOUT="3600"
|
||||
# optional wordlist for JTR - if no wordlist is there JTR runs in default mode
|
||||
local JTR_WORDLIST="$CONFIG_DIR/jtr_wordlist.txt"
|
||||
local JTR_WORDLIST="${CONFIG_DIR}/jtr_wordlist.txt"
|
||||
|
||||
# This module waits for S108_stacs_password_search and S107_deep_password_search
|
||||
# check emba.log for S108_stacs_password_search starting
|
||||
@@ -44,56 +44,56 @@ S109_jtr_local_pw_cracking()
|
||||
module_title "Cracking identified password hashes"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
if [[ -f "$PW_FILE_S107" ]]; then
|
||||
mapfile -t HASHES_S107 < <(cut -d\; -f1,2,3 "$PW_FILE_S107" | grep -v "PW_HASH" | sort -k 2 -t \; -u)
|
||||
if [[ -f "${PW_FILE_S107}" ]]; then
|
||||
mapfile -t HASHES_S107 < <(cut -d\; -f1,2,3 "${PW_FILE_S107}" | grep -v "PW_HASH" | sort -k 2 -t \; -u)
|
||||
fi
|
||||
|
||||
if [[ -f "$PW_FILE" ]]; then
|
||||
mapfile -t HASHES_S108 < <(cut -d\; -f1,2,3 "$PW_FILE" | grep -v "PW_PATH;PW_HASH" | sort -k 2 -t \; -u)
|
||||
if [[ -f "${PW_FILE}" ]]; then
|
||||
mapfile -t HASHES_S108 < <(cut -d\; -f1,2,3 "${PW_FILE}" | grep -v "PW_PATH;PW_HASH" | sort -k 2 -t \; -u)
|
||||
|
||||
HASHES=("${HASHES_S107[@]}" "${HASHES_S108[@]}")
|
||||
|
||||
for HASH in "${HASHES[@]}"; do
|
||||
HASH_DESCRIPTION=$(basename "$(echo "$HASH" | cut -d\; -f1)")
|
||||
HASH_SOURCE=$(basename "$(echo "$HASH" | cut -d\; -f2)")
|
||||
HASH=$(echo "$HASH" | cut -d\; -f3 | tr -d \")
|
||||
HASH_DESCRIPTION=$(basename "$(echo "${HASH}" | cut -d\; -f1)")
|
||||
HASH_SOURCE=$(basename "$(echo "${HASH}" | cut -d\; -f2)")
|
||||
HASH=$(echo "${HASH}" | cut -d\; -f3 | tr -d \")
|
||||
|
||||
[[ "$HASH" == *"BEGIN"*"KEY"* ]] && continue
|
||||
[[ "$HASH_DESCRIPTION" == *"private key found"* ]] && continue
|
||||
[[ "${HASH}" == *"BEGIN"*"KEY"* ]] && continue
|
||||
[[ "${HASH_DESCRIPTION}" == *"private key found"* ]] && continue
|
||||
|
||||
if echo "$HASH" | cut -d: -f1-3 | grep -q "::[0-9]"; then
|
||||
if echo "${HASH}" | cut -d: -f1-3 | grep -q "::[0-9]"; then
|
||||
# nosemgrep
|
||||
# removing entries: root::0:0:99999:7:::
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE"/jtr_hashes.txt ]]; then
|
||||
if ! grep -q "$HASH" "$LOG_PATH_MODULE"/jtr_hashes.txt; then
|
||||
print_output "[*] Found password data $ORANGE$HASH$NC for further processing in $ORANGE$HASH_SOURCE$NC"
|
||||
echo "$HASH" >> "$LOG_PATH_MODULE"/jtr_hashes.txt
|
||||
if [[ -f "${LOG_PATH_MODULE}"/jtr_hashes.txt ]]; then
|
||||
if ! grep -q "${HASH}" "${LOG_PATH_MODULE}"/jtr_hashes.txt; then
|
||||
print_output "[*] Found password data ${ORANGE}${HASH}${NC} for further processing in ${ORANGE}${HASH_SOURCE}${NC}"
|
||||
echo "${HASH}" >> "${LOG_PATH_MODULE}"/jtr_hashes.txt
|
||||
fi
|
||||
else
|
||||
print_output "[*] Found password data $ORANGE$HASH$NC for further processing in $ORANGE$HASH_SOURCE$NC"
|
||||
echo "$HASH" >> "$LOG_PATH_MODULE"/jtr_hashes.txt
|
||||
print_output "[*] Found password data ${ORANGE}${HASH}${NC} for further processing in ${ORANGE}${HASH_SOURCE}${NC}"
|
||||
echo "${HASH}" >> "${LOG_PATH_MODULE}"/jtr_hashes.txt
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE"/jtr_hashes.txt ]]; then
|
||||
print_output "[*] Starting jtr with a runtime of $ORANGE$JTR_TIMEOUT$NC on the following data:"
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/jtr_hashes.txt
|
||||
if [[ -f "${LOG_PATH_MODULE}"/jtr_hashes.txt ]]; then
|
||||
print_output "[*] Starting jtr with a runtime of ${ORANGE}${JTR_TIMEOUT}${NC} on the following data:"
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/jtr_hashes.txt
|
||||
print_ln
|
||||
if [[ -f "$JTR_WORDLIST" ]]; then
|
||||
print_output "[*] Starting jtr with the following wordlist: $ORANGE$JTR_WORDLIST$NC with $ORANGE$(wc -l "$JTR_WORDLIST" | awk '{print $1}')$NC entries."
|
||||
john --progress-every=120 --wordlist="$JTR_WORDLIST" "$LOG_PATH_MODULE"/jtr_hashes.txt 2>&1 | tee -a "$LOG_FILE" || true &
|
||||
if [[ -f "${JTR_WORDLIST}" ]]; then
|
||||
print_output "[*] Starting jtr with the following wordlist: ${ORANGE}${JTR_WORDLIST}${NC} with ${ORANGE}$(wc -l "${JTR_WORDLIST}" | awk '{print $1}')${NC} entries."
|
||||
john --progress-every=120 --wordlist="${JTR_WORDLIST}" "${LOG_PATH_MODULE}"/jtr_hashes.txt 2>&1 | tee -a "${LOG_FILE}" || true &
|
||||
PID="$!"
|
||||
else
|
||||
john --progress-every=120 "$LOG_PATH_MODULE"/jtr_hashes.txt 2>&1 | tee -a "$LOG_FILE" || true &
|
||||
john --progress-every=120 "${LOG_PATH_MODULE}"/jtr_hashes.txt 2>&1 | tee -a "${LOG_FILE}" || true &
|
||||
PID="$!"
|
||||
fi
|
||||
sleep 5
|
||||
|
||||
COUNT=0
|
||||
while [[ "$COUNT" -le "$JTR_TIMEOUT" ]];do
|
||||
while [[ "${COUNT}" -le "${JTR_TIMEOUT}" ]];do
|
||||
((COUNT+=1))
|
||||
if ! pgrep john > /dev/null; then
|
||||
# if no john process is running it means we are finished with cracking passwords
|
||||
@@ -102,36 +102,36 @@ S109_jtr_local_pw_cracking()
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
kill "$PID" || true
|
||||
kill "${PID}" || true
|
||||
|
||||
# lets check our log if we can find further hashes
|
||||
mapfile -t JTR_FORMATS < <(grep "option to force loading hashes of that type instead" "$LOG_FILE" || true)
|
||||
mapfile -t JTR_FORMATS < <(grep "option to force loading hashes of that type instead" "${LOG_FILE}" || true)
|
||||
|
||||
# if we have further hashes we are processing these now
|
||||
if [[ "${#JTR_FORMATS[@]}" -gt 0 ]] && [[ "$COUNT" -lt "$JTR_TIMEOUT" ]] ; then
|
||||
if [[ "${#JTR_FORMATS[@]}" -gt 0 ]] && [[ "${COUNT}" -lt "${JTR_TIMEOUT}" ]] ; then
|
||||
print_ln
|
||||
print_output "[*] Further password hashes detected:"
|
||||
for JTR_FORMAT in "${JTR_FORMATS[@]}"; do
|
||||
JTR_FORMAT="$(echo "$JTR_FORMAT" | cut -d '=' -f2 | awk '{print $1}' | tr -d '"' )"
|
||||
print_output "$(indent "$(orange "Detected hash type: $JTR_FORMAT")")"
|
||||
JTR_FORMAT="$(echo "${JTR_FORMAT}" | cut -d '=' -f2 | awk '{print $1}' | tr -d '"' )"
|
||||
print_output "$(indent "$(orange "Detected hash type: ${JTR_FORMAT}")")"
|
||||
done
|
||||
|
||||
for JTR_FORMAT in "${JTR_FORMATS[@]}"; do
|
||||
print_ln
|
||||
JTR_FORMAT="$(echo "$JTR_FORMAT" | cut -d '=' -f2 | awk '{print $1}' | tr -d '"' )"
|
||||
print_output "[*] Testing password hash types $ORANGE$JTR_FORMAT$NC"
|
||||
if [[ -f "$JTR_WORDLIST" ]]; then
|
||||
print_output "[*] Starting jtr with the following wordlist: $ORANGE$JTR_WORDLIST$NC with $ORANGE$(wc -l "$JTR_WORDLIST" | awk '{print $1}')$NC entries."
|
||||
find "$JTR_WORDLIST" | tee -a "$LOG_FILE"
|
||||
john --format="$JTR_FORMAT" --progress-every=120 --wordlist="$JTR_WORDLIST" "$LOG_PATH_MODULE"/jtr_hashes.txt 2>&1 | tee -a "$LOG_FILE" || true &
|
||||
JTR_FORMAT="$(echo "${JTR_FORMAT}" | cut -d '=' -f2 | awk '{print $1}' | tr -d '"' )"
|
||||
print_output "[*] Testing password hash types ${ORANGE}${JTR_FORMAT}${NC}"
|
||||
if [[ -f "${JTR_WORDLIST}" ]]; then
|
||||
print_output "[*] Starting jtr with the following wordlist: ${ORANGE}${JTR_WORDLIST}${NC} with ${ORANGE}$(wc -l "${JTR_WORDLIST}" | awk '{print $1}')${NC} entries."
|
||||
find "${JTR_WORDLIST}" | tee -a "${LOG_FILE}"
|
||||
john --format="${JTR_FORMAT}" --progress-every=120 --wordlist="${JTR_WORDLIST}" "${LOG_PATH_MODULE}"/jtr_hashes.txt 2>&1 | tee -a "${LOG_FILE}" || true &
|
||||
PID="$!"
|
||||
else
|
||||
john --format="$JTR_FORMAT" --progress-every=120 "$LOG_PATH_MODULE"/jtr_hashes.txt 2>&1 | tee -a "$LOG_FILE" || true &
|
||||
john --format="${JTR_FORMAT}" --progress-every=120 "${LOG_PATH_MODULE}"/jtr_hashes.txt 2>&1 | tee -a "${LOG_FILE}" || true &
|
||||
PID="$!"
|
||||
fi
|
||||
sleep 5
|
||||
|
||||
while [[ "$COUNT" -le "$JTR_TIMEOUT" ]];do
|
||||
while [[ "${COUNT}" -le "${JTR_TIMEOUT}" ]];do
|
||||
((COUNT+=1))
|
||||
if ! pgrep john > /dev/null; then
|
||||
# if no john process is running it means we are finished with cracking passwords
|
||||
@@ -140,29 +140,29 @@ S109_jtr_local_pw_cracking()
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
kill "$PID" || true
|
||||
kill "${PID}" || true
|
||||
done
|
||||
fi
|
||||
print_ln
|
||||
NEG_LOG=1
|
||||
|
||||
mapfile -t CRACKED_HASHES < <(john --show "$LOG_PATH_MODULE"/jtr_hashes.txt | grep -v "password hash\(es\)\? cracked" | grep -v "^$" || true)
|
||||
JTR_FINAL_STAT=$(john --show "$LOG_PATH_MODULE"/jtr_hashes.txt | grep "password hash\(es\)\? cracked\|No password hashes loaded" || true)
|
||||
CRACKED=$(echo "$JTR_FINAL_STAT" | awk '{print $1}')
|
||||
if [[ -n "$JTR_FINAL_STAT" ]]; then
|
||||
print_output "[*] John the ripper final status: $ORANGE$JTR_FINAL_STAT$NC"
|
||||
mapfile -t CRACKED_HASHES < <(john --show "${LOG_PATH_MODULE}"/jtr_hashes.txt | grep -v "password hash\(es\)\? cracked" | grep -v "^$" || true)
|
||||
JTR_FINAL_STAT=$(john --show "${LOG_PATH_MODULE}"/jtr_hashes.txt | grep "password hash\(es\)\? cracked\|No password hashes loaded" || true)
|
||||
CRACKED=$(echo "${JTR_FINAL_STAT}" | awk '{print $1}')
|
||||
if [[ -n "${JTR_FINAL_STAT}" ]]; then
|
||||
print_output "[*] John the ripper final status: ${ORANGE}${JTR_FINAL_STAT}${NC}"
|
||||
NEG_LOG=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CRACKED" -gt 0 ]]; then
|
||||
if [[ "${CRACKED}" -gt 0 ]]; then
|
||||
for CRACKED_HASH in "${CRACKED_HASHES[@]}"; do
|
||||
print_output "[+] Password hash cracked: $ORANGE$CRACKED_HASH$NC"
|
||||
print_output "[+] Password hash cracked: ${ORANGE}${CRACKED_HASH}${NC}"
|
||||
NEG_LOG=1
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
write_log "[*] Statistics:$CRACKED"
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
write_log "[*] Statistics:${CRACKED}"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
@@ -29,31 +29,31 @@ S10_binaries_basic_check()
|
||||
local VUL_FUNC_RESULT=()
|
||||
local VUL_FUNC=""
|
||||
|
||||
VULNERABLE_FUNCTIONS="$(config_list "$CONFIG_DIR""/functions.cfg")"
|
||||
IFS=" " read -r -a VUL_FUNC_GREP <<<"$( echo -e "$VULNERABLE_FUNCTIONS" | sed ':a;N;$!ba;s/\n/ -e /g')"
|
||||
VULNERABLE_FUNCTIONS="$(config_list "${CONFIG_DIR}""/functions.cfg")"
|
||||
IFS=" " read -r -a VUL_FUNC_GREP <<<"$( echo -e "${VULNERABLE_FUNCTIONS}" | sed ':a;N;$!ba;s/\n/ -e /g')"
|
||||
|
||||
if [[ "$VULNERABLE_FUNCTIONS" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ -n "$VULNERABLE_FUNCTIONS" ]] ; then
|
||||
print_output "[*] Interesting functions: ""$( echo -e "$VULNERABLE_FUNCTIONS" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
if [[ "${VULNERABLE_FUNCTIONS}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ -n "${VULNERABLE_FUNCTIONS}" ]] ; then
|
||||
print_output "[*] Interesting functions: ""$( echo -e "${VULNERABLE_FUNCTIONS}" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
for BINARY in "${BINARIES[@]}" ; do
|
||||
if ( file "$BINARY" | grep -q "ELF" ) ; then
|
||||
if ( file "${BINARY}" | grep -q "ELF" ) ; then
|
||||
BIN_COUNT=$((BIN_COUNT+1))
|
||||
mapfile -t VUL_FUNC_RESULT < <(readelf -s --use-dynamic "$BINARY" 2> /dev/null | grep -we "${VUL_FUNC_GREP[@]}" | grep -v "file format" || true)
|
||||
mapfile -t VUL_FUNC_RESULT < <(readelf -s --use-dynamic "${BINARY}" 2> /dev/null | grep -we "${VUL_FUNC_GREP[@]}" | grep -v "file format" || true)
|
||||
if [[ "${#VUL_FUNC_RESULT[@]}" -ne 0 ]] ; then
|
||||
print_ln
|
||||
print_output "[+] Interesting function in ""$(print_path "$BINARY")"" found:"
|
||||
print_output "[+] Interesting function in ""$(print_path "${BINARY}")"" found:"
|
||||
for VUL_FUNC in "${VUL_FUNC_RESULT[@]}" ; do
|
||||
# shellcheck disable=SC2001
|
||||
VUL_FUNC="$(echo "$VUL_FUNC" | sed -e 's/[[:space:]]\+/\t/g')"
|
||||
print_output "$(indent "$VUL_FUNC")"
|
||||
VUL_FUNC="$(echo "${VUL_FUNC}" | sed -e 's/[[:space:]]\+/\t/g')"
|
||||
print_output "$(indent "${VUL_FUNC}")"
|
||||
done
|
||||
COUNTER=$((COUNTER+1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
print_ln
|
||||
print_output "[*] Found ""$ORANGE$COUNTER$NC"" binaries with interesting functions in ""$ORANGE$BIN_COUNT$NC"" files (vulnerable functions: ""$( echo -e "$VULNERABLE_FUNCTIONS" | sed ':a;N;$!ba;s/\n/ /g' )"")"
|
||||
print_output "[*] Found ""${ORANGE}${COUNTER}${NC}"" binaries with interesting functions in ""${ORANGE}${BIN_COUNT}${NC}"" files (vulnerable functions: ""$( echo -e "${VULNERABLE_FUNCTIONS}" | sed ':a;N;$!ba;s/\n/ /g' )"")"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$COUNTER"
|
||||
module_end_log "${FUNCNAME[0]}" "${COUNTER}"
|
||||
}
|
||||
|
||||
+23
-23
@@ -23,55 +23,55 @@ S110_yara_check()
|
||||
module_title "Check for code patterns with yara"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
local DIR_COMB_YARA="$TMP_DIR""/dir-combined.yara"
|
||||
local DIR_COMB_YARA="${TMP_DIR}""/dir-combined.yara"
|
||||
local COUNTING=0
|
||||
local YRULE=""
|
||||
local MATCH_FILE=""
|
||||
local MATCH_FILE_NAME=""
|
||||
local MAX_MOD_THREADS=$((MAX_MOD_THREADS/2))
|
||||
local MEM_LIMIT=$(( "$TOTAL_MEMORY"*80/100 ))
|
||||
local MEM_LIMIT=$(( "${TOTAL_MEMORY}"*80/100 ))
|
||||
|
||||
if [[ $YARA -eq 1 ]] ; then
|
||||
if [[ ${YARA} -eq 1 ]] ; then
|
||||
# if multiple instances are running we can't overwrite it
|
||||
# after updating yara rules we should remove this file and it gets regenerated
|
||||
if [[ ! -f "$DIR_COMB_YARA" ]]; then
|
||||
find "$EXT_DIR""/yara" -xdev -iname '*.yar' -exec realpath {} \; | xargs printf 'include "%s"\n'| sort -n > "$DIR_COMB_YARA"
|
||||
if [[ ! -f "${DIR_COMB_YARA}" ]]; then
|
||||
find "${EXT_DIR}""/yara" -xdev -iname '*.yar' -exec realpath {} \; | xargs printf 'include "%s"\n'| sort -n > "${DIR_COMB_YARA}"
|
||||
fi
|
||||
|
||||
ulimit -Sv "$MEM_LIMIT"
|
||||
yara -p "$MAX_MOD_THREADS" -r -w -s -m -L -g "$DIR_COMB_YARA" "$LOG_DIR"/firmware > "$LOG_PATH_MODULE"/yara_complete_output.txt || true
|
||||
ulimit -Sv "${MEM_LIMIT}"
|
||||
yara -p "${MAX_MOD_THREADS}" -r -w -s -m -L -g "${DIR_COMB_YARA}" "${LOG_DIR}"/firmware > "${LOG_PATH_MODULE}"/yara_complete_output.txt || true
|
||||
ulimit -Sv unlimited
|
||||
|
||||
while read -r YARA_OUT_LINE; do
|
||||
local AUTHOR_STRING=" [] [author="
|
||||
if [[ "${YARA_OUT_LINE}" == *"${AUTHOR_STRING}"* ]]; then
|
||||
YRULE=$(echo "$YARA_OUT_LINE" | awk '{print $1}')
|
||||
MATCH_FILE=$(echo "$YARA_OUT_LINE" | grep "\ \[\]\ \[author=\"" | rev | awk '{print $1}' | rev)
|
||||
MATCH_FILE_NAME=$(basename "$MATCH_FILE")
|
||||
YRULE=$(echo "${YARA_OUT_LINE}" | awk '{print $1}')
|
||||
MATCH_FILE=$(echo "${YARA_OUT_LINE}" | grep "\ \[\]\ \[author=\"" | rev | awk '{print $1}' | rev)
|
||||
MATCH_FILE_NAME=$(basename "${MATCH_FILE}")
|
||||
# this rule does not help us a lot ... remove it from results
|
||||
[[ "$YRULE" =~ .*IsSuspicious.* ]] && continue
|
||||
if ! [[ -f "$LOG_PATH_MODULE"/"$MATCH_FILE_NAME" ]]; then
|
||||
print_output "[+] Yara rule $ORANGE$YRULE$GREEN matched in $ORANGE$MATCH_FILE$NC" "" "$LOG_PATH_MODULE/$MATCH_FILE_NAME".txt
|
||||
write_log "" "$LOG_PATH_MODULE/$MATCH_FILE_NAME".txt
|
||||
write_log "[+] Yara rule $ORANGE$YRULE$GREEN matched in $ORANGE$MATCH_FILE$NC" "$LOG_PATH_MODULE/$MATCH_FILE_NAME".txt
|
||||
echo "" >> "$LOG_PATH_MODULE/$MATCH_FILE_NAME".txt
|
||||
[[ "${YRULE}" =~ .*IsSuspicious.* ]] && continue
|
||||
if ! [[ -f "${LOG_PATH_MODULE}"/"${MATCH_FILE_NAME}" ]]; then
|
||||
print_output "[+] Yara rule ${ORANGE}${YRULE}${GREEN} matched in ${ORANGE}${MATCH_FILE}${NC}" "" "${LOG_PATH_MODULE}/${MATCH_FILE_NAME}".txt
|
||||
write_log "" "${LOG_PATH_MODULE}/${MATCH_FILE_NAME}".txt
|
||||
write_log "[+] Yara rule ${ORANGE}${YRULE}${GREEN} matched in ${ORANGE}${MATCH_FILE}${NC}" "${LOG_PATH_MODULE}/${MATCH_FILE_NAME}".txt
|
||||
echo "" >> "${LOG_PATH_MODULE}/${MATCH_FILE_NAME}".txt
|
||||
COUNTING=$((COUNTING+1))
|
||||
fi
|
||||
fi
|
||||
[[ -v MATCH_FILE_NAME ]] && echo "$YARA_OUT_LINE" >> "$LOG_PATH_MODULE"/"$MATCH_FILE_NAME".txt
|
||||
done < "$LOG_PATH_MODULE"/yara_complete_output.txt
|
||||
[[ -v MATCH_FILE_NAME ]] && echo "${YARA_OUT_LINE}" >> "${LOG_PATH_MODULE}"/"${MATCH_FILE_NAME}".txt
|
||||
done < "${LOG_PATH_MODULE}"/yara_complete_output.txt
|
||||
|
||||
print_ln
|
||||
print_ln
|
||||
print_output "[*] Found $ORANGE$COUNTING$NC yara rule matches in $ORANGE${#FILE_ARR[@]}$NC files."
|
||||
print_output "[*] Found ${ORANGE}${COUNTING}${NC} yara rule matches in ${ORANGE}${#FILE_ARR[@]}${NC} files."
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$COUNTING"
|
||||
write_log "[*] Statistics:${COUNTING}"
|
||||
|
||||
[[ "$COUNTING" -eq 0 ]] && print_output "[-] No code patterns found with yara."
|
||||
[[ -f "$DIR_COMB_YARA" ]] && rm "$DIR_COMB_YARA"
|
||||
[[ "${COUNTING}" -eq 0 ]] && print_output "[-] No code patterns found with yara."
|
||||
[[ -f "${DIR_COMB_YARA}" ]] && rm "${DIR_COMB_YARA}"
|
||||
else
|
||||
print_output "[!] Check with yara not possible, because it isn't installed!"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$COUNTING"
|
||||
module_end_log "${FUNCNAME[0]}" "${COUNTING}"
|
||||
}
|
||||
|
||||
+401
-401
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ S116_qemu_version_detection() {
|
||||
local NEG_LOG=0
|
||||
local VERSION_LINE=""
|
||||
|
||||
if [[ "$RTOS" -eq 0 ]]; then
|
||||
if [[ "${RTOS}" -eq 0 ]]; then
|
||||
module_title "Identified software components - via usermode emulation."
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
@@ -27,54 +27,54 @@ S116_qemu_version_detection() {
|
||||
# check emba.log for S115_usermode_emulator
|
||||
module_wait "S115_usermode_emulator"
|
||||
|
||||
LOG_PATH_S115="$LOG_DIR"/s115_usermode_emulator.txt
|
||||
if [[ -f "$LOG_PATH_S115" && -d "$LOG_DIR/s115_usermode_emulator" ]]; then
|
||||
LOG_PATH_MODULE_S115="$LOG_DIR"/s115_usermode_emulator/
|
||||
LOG_PATH_S115="${LOG_DIR}"/s115_usermode_emulator.txt
|
||||
if [[ -f "${LOG_PATH_S115}" && -d "${LOG_DIR}/s115_usermode_emulator" ]]; then
|
||||
LOG_PATH_MODULE_S115="${LOG_DIR}"/s115_usermode_emulator/
|
||||
|
||||
write_csv_log "binary/file" "version_rule" "version_detected" "csv_rule" "license" "static/emulation"
|
||||
TYPE="emulation"
|
||||
|
||||
while read -r VERSION_LINE; do
|
||||
if echo "$VERSION_LINE" | grep -v -q "^[^#*/;]"; then
|
||||
if echo "${VERSION_LINE}" | grep -v -q "^[^#*/;]"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ $THREADED -eq 1 ]]; then
|
||||
version_detection_thread "$VERSION_LINE" &
|
||||
if [[ ${THREADED} -eq 1 ]]; then
|
||||
version_detection_thread "${VERSION_LINE}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S116+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S116+=( "${TMP_PID}" )
|
||||
else
|
||||
version_detection_thread "$VERSION_LINE"
|
||||
version_detection_thread "${VERSION_LINE}"
|
||||
fi
|
||||
done < "$CONFIG_DIR"/bin_version_strings.cfg
|
||||
done < "${CONFIG_DIR}"/bin_version_strings.cfg
|
||||
print_ln "no_log"
|
||||
|
||||
[[ $THREADED -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S116[@]}"
|
||||
if [[ $(wc -l "$CSV_DIR"/s116_qemu_version_detection.csv | awk '{print $1}' ) -gt 1 ]]; then
|
||||
[[ ${THREADED} -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S116[@]}"
|
||||
if [[ $(wc -l "${CSV_DIR}"/s116_qemu_version_detection.csv | awk '{print $1}' ) -gt 1 ]]; then
|
||||
NEG_LOG=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
version_detection_thread() {
|
||||
local VERSION_LINE="${1:-}"
|
||||
|
||||
local BINARY=""
|
||||
BINARY="$(echo "$VERSION_LINE" | cut -d\; -f1)"
|
||||
BINARY="$(echo "${VERSION_LINE}" | cut -d\; -f1)"
|
||||
local STRICT=""
|
||||
STRICT="$(echo "$VERSION_LINE" | cut -d\; -f2)"
|
||||
STRICT="$(echo "${VERSION_LINE}" | cut -d\; -f2)"
|
||||
local LIC=""
|
||||
LIC="$(echo "$VERSION_LINE" | cut -d\; -f3)"
|
||||
LIC="$(echo "${VERSION_LINE}" | cut -d\; -f3)"
|
||||
local CSV_REGEX=""
|
||||
CSV_REGEX="$(echo "$VERSION_LINE" | cut -d\; -f5)"
|
||||
CSV_REGEX="$(echo "${VERSION_LINE}" | cut -d\; -f5)"
|
||||
|
||||
local VERSION_IDENTIFIER=""
|
||||
# VERSION_IDENTIFIER="$(echo "$VERSION_LINE" | cut -d\; -f4 | sed s/^\"// | sed s/\"$//)"
|
||||
VERSION_IDENTIFIER="$(echo "$VERSION_LINE" | cut -d\; -f4)"
|
||||
# VERSION_IDENTIFIER="$(echo "${VERSION_LINE}" | cut -d\; -f4 | sed s/^\"// | sed s/\"$//)"
|
||||
VERSION_IDENTIFIER="$(echo "${VERSION_LINE}" | cut -d\; -f4)"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER/\"}"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER%\"}"
|
||||
|
||||
@@ -83,27 +83,27 @@ version_detection_thread() {
|
||||
local LOG_PATH_=""
|
||||
|
||||
# if we have the key strict this version identifier only works for the defined binary and is not generic!
|
||||
if [[ $STRICT == "strict" ]]; then
|
||||
if [[ -f "$LOG_PATH_MODULE_S115"/qemu_tmp_"$BINARY".txt ]]; then
|
||||
mapfile -t VERSIONS_DETECTED < <(grep -a -o -E "$VERSION_IDENTIFIER" "$LOG_PATH_MODULE_S115"/qemu_tmp_"$BINARY".txt | sort -u 2>/dev/null || true)
|
||||
mapfile -t BINARY_PATHS < <(strip_color_codes "$(grep -a "Emulating binary:" "$LOG_PATH_MODULE_S115"/qemu_tmp_"$BINARY".txt | cut -d: -f2 | sed -e 's/^\ //' | sort -u 2>/dev/null || true)")
|
||||
if [[ ${STRICT} == "strict" ]]; then
|
||||
if [[ -f "${LOG_PATH_MODULE_S115}"/qemu_tmp_"${BINARY}".txt ]]; then
|
||||
mapfile -t VERSIONS_DETECTED < <(grep -a -o -E "${VERSION_IDENTIFIER}" "${LOG_PATH_MODULE_S115}"/qemu_tmp_"${BINARY}".txt | sort -u 2>/dev/null || true)
|
||||
mapfile -t BINARY_PATHS < <(strip_color_codes "$(grep -a "Emulating binary:" "${LOG_PATH_MODULE_S115}"/qemu_tmp_"${BINARY}".txt | cut -d: -f2 | sed -e 's/^\ //' | sort -u 2>/dev/null || true)")
|
||||
TYPE="emulation/strict"
|
||||
fi
|
||||
else
|
||||
if [[ $(find "$LOG_PATH_MODULE_S115" -name "qemu_tmp*" | wc -l) -gt 0 ]]; then
|
||||
readarray -t VERSIONS_DETECTED < <(grep -a -o -H -E "$VERSION_IDENTIFIER" "$LOG_PATH_MODULE_S115"/qemu_tmp*.txt | sort -u 2>/dev/null || true)
|
||||
if [[ $(find "${LOG_PATH_MODULE_S115}" -name "qemu_tmp*" | wc -l) -gt 0 ]]; then
|
||||
readarray -t VERSIONS_DETECTED < <(grep -a -o -H -E "${VERSION_IDENTIFIER}" "${LOG_PATH_MODULE_S115}"/qemu_tmp*.txt | sort -u 2>/dev/null || true)
|
||||
# VERSIONS_DETECTED:
|
||||
# path_to_logfile:Version Identifier
|
||||
# └─$ grep -a -o -H -E "Version: 1.8" /home/m1k3/firmware/emba_logs_manual/test_dir300/s115_usermode_emulator/qemu_tmp_radvd.txt 130 ⨯
|
||||
# /home/m1k3/firmware/emba_logs_manual/test_dir300/s115_usermode_emulator/qemu_tmp_radvd.txt:Version: 1.8
|
||||
# /home/m1k3/firmware/emba_logs_manual/test_dir300/s115_usermode_emulator/qemu_tmp_radvd.txt:Version: 1.8
|
||||
for VERSION_DETECTED in "${VERSIONS_DETECTED[@]}"; do
|
||||
mapfile -t LOG_PATHS < <(strip_color_codes "$(echo "$VERSION_DETECTED" | cut -d: -f1 | sort -u || true)")
|
||||
mapfile -t LOG_PATHS < <(strip_color_codes "$(echo "${VERSION_DETECTED}" | cut -d: -f1 | sort -u || true)")
|
||||
for LOG_PATH_ in "${LOG_PATHS[@]}"; do
|
||||
mapfile -t BINARY_PATHS_ < <(strip_color_codes "$(grep -a "Emulating binary:" "$LOG_PATH_" 2>/dev/null | cut -d: -f2 | sed -e 's/^\ //' | sort -u 2>/dev/null || true)")
|
||||
mapfile -t BINARY_PATHS_ < <(strip_color_codes "$(grep -a "Emulating binary:" "${LOG_PATH_}" 2>/dev/null | cut -d: -f2 | sed -e 's/^\ //' | sort -u 2>/dev/null || true)")
|
||||
for BINARY_PATH_ in "${BINARY_PATHS_[@]}"; do
|
||||
# BINARY_PATH is the final array which we are using further
|
||||
BINARY_PATHS+=( "$BINARY_PATH_" )
|
||||
BINARY_PATHS+=( "${BINARY_PATH_}" )
|
||||
done
|
||||
done
|
||||
done
|
||||
@@ -112,16 +112,16 @@ version_detection_thread() {
|
||||
fi
|
||||
|
||||
for VERSION_DETECTED in "${VERSIONS_DETECTED[@]}"; do
|
||||
LOG_PATH_="$(strip_color_codes "$(echo "$VERSION_DETECTED" | cut -d: -f1 | sort -u || true)")"
|
||||
if [[ $STRICT != "strict" ]]; then
|
||||
VERSION_DETECTED="$(echo "$VERSION_DETECTED" | cut -d: -f2- | sort -u)"
|
||||
LOG_PATH_="$(strip_color_codes "$(echo "${VERSION_DETECTED}" | cut -d: -f1 | sort -u || true)")"
|
||||
if [[ ${STRICT} != "strict" ]]; then
|
||||
VERSION_DETECTED="$(echo "${VERSION_DETECTED}" | cut -d: -f2- | sort -u)"
|
||||
fi
|
||||
|
||||
get_csv_rule "$VERSION_DETECTED" "$CSV_REGEX"
|
||||
get_csv_rule "${VERSION_DETECTED}" "${CSV_REGEX}"
|
||||
|
||||
for BINARY_PATH in "${BINARY_PATHS[@]}"; do
|
||||
print_output "[+] Version information found ${RED}""$VERSION_DETECTED""${NC}${GREEN} in binary $ORANGE$BINARY_PATH$GREEN (license: $ORANGE$LIC$GREEN) (${ORANGE}$TYPE$GREEN)." "" "$LOG_PATH_"
|
||||
write_csv_log "$BINARY_PATH" "$BINARY" "$VERSION_DETECTED" "$CSV_RULE" "$LIC" "$TYPE"
|
||||
print_output "[+] Version information found ${RED}""${VERSION_DETECTED}""${NC}${GREEN} in binary ${ORANGE}${BINARY_PATH}${GREEN} (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}${TYPE}${GREEN})." "" "${LOG_PATH_}"
|
||||
write_csv_log "${BINARY_PATH}" "${BINARY}" "${VERSION_DETECTED}" "${CSV_RULE}" "${LIC}" "${TYPE}"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
+59
-59
@@ -24,25 +24,25 @@ export THREAD_PRIO=1
|
||||
|
||||
S120_cwe_checker()
|
||||
{
|
||||
if [[ $CWE_CHECKER -eq 1 ]] ; then
|
||||
if [[ ${CWE_CHECKER} -eq 1 ]] ; then
|
||||
module_log_init "${FUNCNAME[0]}"
|
||||
module_title "Check binaries with cwe-checker"
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
local CWE_CNT_=0
|
||||
|
||||
[[ "$IN_DOCKER" -eq 1 ]] && cwe_container_prepare
|
||||
[[ "${IN_DOCKER}" -eq 1 ]] && cwe_container_prepare
|
||||
|
||||
cwe_check
|
||||
|
||||
if [[ -f "$TMP_DIR"/CWE_CNT.tmp ]]; then
|
||||
CWE_CNT_=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/CWE_CNT.tmp || true)
|
||||
if [[ -f "${TMP_DIR}"/CWE_CNT.tmp ]]; then
|
||||
CWE_CNT_=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/CWE_CNT.tmp || true)
|
||||
fi
|
||||
|
||||
final_cwe_log "$CWE_CNT_"
|
||||
final_cwe_log "${CWE_CNT_}"
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$CWE_CNT_"
|
||||
module_end_log "${FUNCNAME[0]}" "$CWE_CNT_"
|
||||
write_log "[*] Statistics:${CWE_CNT_}"
|
||||
module_end_log "${FUNCNAME[0]}" "${CWE_CNT_}"
|
||||
else
|
||||
print_output "[!] Check with cwe-checker is disabled!"
|
||||
print_output "[!] Enable it with the -c switch."
|
||||
@@ -53,61 +53,61 @@ cwe_container_prepare() {
|
||||
# as we are in a read only docker environment we need to trick a bit:
|
||||
# /root is mounted as a writable tempfs. With this we need to set it up
|
||||
# on every run from scratch:
|
||||
if [[ -d "$EXT_DIR"/cwe_checker/.config ]]; then
|
||||
if [[ -d "${EXT_DIR}"/cwe_checker/.config ]]; then
|
||||
print_output "[*] Restoring config directory in read-only container" "no_log"
|
||||
if ! [[ -d "$HOME"/.config/ ]]; then
|
||||
mkdir -p "$HOME"/.config
|
||||
if ! [[ -d "${HOME}"/.config/ ]]; then
|
||||
mkdir -p "${HOME}"/.config
|
||||
fi
|
||||
cp -pr "$EXT_DIR"/cwe_checker/.config/cwe_checker "$HOME"/.config/
|
||||
cp -pr "$EXT_DIR"/cwe_checker/.local/share "$HOME"/.local/
|
||||
cp -pr "${EXT_DIR}"/cwe_checker/.config/cwe_checker "${HOME}"/.config/
|
||||
cp -pr "${EXT_DIR}"/cwe_checker/.local/share "${HOME}"/.local/
|
||||
fi
|
||||
if ! [[ -d "$HOME"/.cargo ]]; then
|
||||
mkdir -p "$HOME"/.cargo/bin
|
||||
if ! [[ -d "${HOME}"/.cargo ]]; then
|
||||
mkdir -p "${HOME}"/.cargo/bin
|
||||
fi
|
||||
if [[ -d "$EXT_DIR"/cwe_checker/bin ]]; then
|
||||
if [[ -d "${EXT_DIR}"/cwe_checker/bin ]]; then
|
||||
print_output "[*] Restoring cargo bin directory in read-only container" "no_log"
|
||||
cp -pr "$EXT_DIR"/cwe_checker/bin/* "$HOME"/.cargo/bin/
|
||||
cp -pr "${EXT_DIR}"/cwe_checker/bin/* "${HOME}"/.cargo/bin/
|
||||
else
|
||||
print_output "[!] CWE checker installation broken ... please check it manually!"
|
||||
return
|
||||
fi
|
||||
# Todo: move this to dependency check
|
||||
export PATH=$PATH:"$HOME"/.cargo/bin/:"$EXT_DIR"/jdk/bin/
|
||||
export PATH=${PATH}:"${HOME}"/.cargo/bin/:"${EXT_DIR}"/jdk/bin/
|
||||
}
|
||||
|
||||
cwe_check() {
|
||||
local BINARY=""
|
||||
|
||||
if [[ -d "$HOME"/.cargo/bin ]]; then
|
||||
export PATH="$PATH":"$HOME"/.cargo/bin
|
||||
if [[ -d "${HOME}"/.cargo/bin ]]; then
|
||||
export PATH="${PATH}":"${HOME}"/.cargo/bin
|
||||
else
|
||||
print_output "[!] CWE checker installation broken ... please check it manually!"
|
||||
return
|
||||
fi
|
||||
|
||||
for BINARY in "${BINARIES[@]}" ; do
|
||||
if ( file "$BINARY" | grep -q ELF ) ; then
|
||||
if ( file "${BINARY}" | grep -q ELF ) ; then
|
||||
# do not try to analyze kernel modules:
|
||||
[[ "$BINARY" == *".ko" ]] && continue
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
[[ "${BINARY}" == *".ko" ]] && continue
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
local MAX_MOD_THREADS=$(("$(grep -c ^processor /proc/cpuinfo || true)" / 3))
|
||||
if [[ $(grep -i -c S09_ "$LOG_DIR"/"$MAIN_LOG_FILE" || true) -eq 1 ]]; then
|
||||
if [[ $(grep -i -c S09_ "${LOG_DIR}"/"${MAIN_LOG_FILE}" || true) -eq 1 ]]; then
|
||||
local MAX_MOD_THREADS=1
|
||||
fi
|
||||
|
||||
cwe_checker_threaded "$BINARY" &
|
||||
cwe_checker_threaded "${BINARY}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S120+=( "$TMP_PID" )
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S120[@]}"
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S120+=( "${TMP_PID}" )
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S120[@]}"
|
||||
continue
|
||||
else
|
||||
cwe_checker_threaded "$BINARY"
|
||||
cwe_checker_threaded "${BINARY}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
[[ $THREADED -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S120[@]}"
|
||||
[[ ${THREADED} -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S120[@]}"
|
||||
}
|
||||
|
||||
cwe_checker_threaded () {
|
||||
@@ -118,47 +118,47 @@ cwe_checker_threaded () {
|
||||
local CWE=""
|
||||
local CWE_DESC=""
|
||||
local CWE_CNT=0
|
||||
local MEM_LIMIT=$(( "$TOTAL_MEMORY"/2 ))
|
||||
local MEM_LIMIT=$(( "${TOTAL_MEMORY}"/2 ))
|
||||
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_")
|
||||
local OLD_LOG_FILE="$LOG_FILE"
|
||||
local LOG_FILE="$LOG_PATH_MODULE""/cwe_check_""$NAME"".txt"
|
||||
BINARY_=$(readlink -f "$BINARY_")
|
||||
NAME=$(basename "${BINARY_}")
|
||||
local OLD_LOG_FILE="${LOG_FILE}"
|
||||
local LOG_FILE="${LOG_PATH_MODULE}""/cwe_check_""${NAME}"".txt"
|
||||
BINARY_=$(readlink -f "${BINARY_}")
|
||||
|
||||
ulimit -Sv "$MEM_LIMIT"
|
||||
"$HOME"/.cargo/bin/cwe_checker "$BINARY" --json --out "$LOG_PATH_MODULE"/cwe_"$NAME".log 2>/dev/null|| true
|
||||
ulimit -Sv "${MEM_LIMIT}"
|
||||
"${HOME}"/.cargo/bin/cwe_checker "${BINARY}" --json --out "${LOG_PATH_MODULE}"/cwe_"${NAME}".log 2>/dev/null|| true
|
||||
ulimit -Sv unlimited
|
||||
print_output "[*] Tested $ORANGE""$(print_path "$BINARY_")""$NC"
|
||||
print_output "[*] Tested ${ORANGE}""$(print_path "${BINARY_}")""${NC}"
|
||||
|
||||
if [[ -s "$LOG_PATH_MODULE"/cwe_"$NAME".log ]]; then
|
||||
jq -r '.[] | "\(.name) - \(.description)"' "$LOG_PATH_MODULE"/cwe_"$NAME".log | sort -u || true
|
||||
mapfile -t CWE_OUT < <( jq -r '.[] | "\(.name) \(.description)"' "$LOG_PATH_MODULE"/cwe_"$NAME".log | cut -d\) -f1 | tr -d '(' | sort -u|| true)
|
||||
if [[ -s "${LOG_PATH_MODULE}"/cwe_"${NAME}".log ]]; then
|
||||
jq -r '.[] | "\(.name) - \(.description)"' "${LOG_PATH_MODULE}"/cwe_"${NAME}".log | sort -u || true
|
||||
mapfile -t CWE_OUT < <( jq -r '.[] | "\(.name) \(.description)"' "${LOG_PATH_MODULE}"/cwe_"${NAME}".log | cut -d\) -f1 | tr -d '(' | sort -u|| true)
|
||||
# this is the logging after every tested file
|
||||
if [[ ${#CWE_OUT[@]} -ne 0 ]] ; then
|
||||
print_ln
|
||||
print_output "[+] cwe-checker found ""$ORANGE""${#CWE_OUT[@]}""$GREEN"" different security issues in ""$ORANGE""$NAME""$GREEN"":" "" "$LOG_PATH_MODULE"/cwe_"$NAME".log
|
||||
print_output "[+] cwe-checker found ""${ORANGE}""${#CWE_OUT[@]}""${GREEN}"" different security issues in ""${ORANGE}""${NAME}""${GREEN}"":" "" "${LOG_PATH_MODULE}"/cwe_"${NAME}".log
|
||||
for CWE_LINE in "${CWE_OUT[@]}"; do
|
||||
CWE="$(echo "$CWE_LINE" | awk '{print $1}')"
|
||||
CWE_DESC="$(echo "$CWE_LINE" | cut -d\ -f2-)"
|
||||
CWE_CNT="$(grep -c "$CWE" "$LOG_PATH_MODULE"/cwe_"$NAME".log 2>/dev/null || true)"
|
||||
echo "$CWE_CNT" >> "$TMP_DIR"/CWE_CNT.tmp
|
||||
print_output "$(indent "$(orange "$CWE""$GREEN"" - ""$CWE_DESC"" - ""$ORANGE""$CWE_CNT"" times.")")"
|
||||
CWE="$(echo "${CWE_LINE}" | awk '{print $1}')"
|
||||
CWE_DESC="$(echo "${CWE_LINE}" | cut -d\ -f2-)"
|
||||
CWE_CNT="$(grep -c "${CWE}" "${LOG_PATH_MODULE}"/cwe_"${NAME}".log 2>/dev/null || true)"
|
||||
echo "${CWE_CNT}" >> "${TMP_DIR}"/CWE_CNT.tmp
|
||||
print_output "$(indent "$(orange "${CWE}""${GREEN}"" - ""${CWE_DESC}"" - ""${ORANGE}""${CWE_CNT}"" times.")")"
|
||||
done
|
||||
print_ln
|
||||
else
|
||||
print_ln
|
||||
print_output "[-] Nothing found in ""$ORANGE""$NAME""$NC""\\n"
|
||||
rm "$LOG_PATH_MODULE"/cwe_"$NAME".log
|
||||
print_output "[-] Nothing found in ""${ORANGE}""${NAME}""${NC}""\\n"
|
||||
rm "${LOG_PATH_MODULE}"/cwe_"${NAME}".log
|
||||
fi
|
||||
fi
|
||||
[[ ${#TEST_OUTPUT[@]} -ne 0 ]] && print_ln
|
||||
|
||||
if [[ -f "$LOG_FILE" ]]; then
|
||||
cat "$LOG_FILE" >> "$OLD_LOG_FILE"
|
||||
rm "$LOG_FILE" 2> /dev/null
|
||||
if [[ -f "${LOG_FILE}" ]]; then
|
||||
cat "${LOG_FILE}" >> "${OLD_LOG_FILE}"
|
||||
rm "${LOG_FILE}" 2> /dev/null
|
||||
fi
|
||||
LOG_FILE="$OLD_LOG_FILE"
|
||||
LOG_FILE="${OLD_LOG_FILE}"
|
||||
}
|
||||
|
||||
final_cwe_log() {
|
||||
@@ -169,19 +169,19 @@ final_cwe_log() {
|
||||
local CWE_DESC=""
|
||||
local CWE_CNT=""
|
||||
|
||||
if [[ -d "$LOG_PATH_MODULE" ]]; then
|
||||
mapfile -t CWE_OUT < <( jq -r '.[] | "\(.name) \(.description)"' "$LOG_PATH_MODULE"/cwe_*.log | cut -d\) -f1 | tr -d '(' | sort -u|| true)
|
||||
if [[ -d "${LOG_PATH_MODULE}" ]]; then
|
||||
mapfile -t CWE_OUT < <( jq -r '.[] | "\(.name) \(.description)"' "${LOG_PATH_MODULE}"/cwe_*.log | cut -d\) -f1 | tr -d '(' | sort -u|| true)
|
||||
print_ln
|
||||
if [[ ${#CWE_OUT[@]} -gt 0 ]] ; then
|
||||
print_bar
|
||||
print_output "[+] cwe-checker found a total of ""$ORANGE""$TOTAL_CWE_CNT""$GREEN"" of the following security issues:"
|
||||
print_output "[+] cwe-checker found a total of ""${ORANGE}""${TOTAL_CWE_CNT}""${GREEN}"" of the following security issues:"
|
||||
for CWE_LINE in "${CWE_OUT[@]}"; do
|
||||
CWE="$(echo "$CWE_LINE" | awk '{print $1}')"
|
||||
CWE_DESC="$(echo "$CWE_LINE" | cut -d\ -f2-)"
|
||||
CWE="$(echo "${CWE_LINE}" | awk '{print $1}')"
|
||||
CWE_DESC="$(echo "${CWE_LINE}" | cut -d\ -f2-)"
|
||||
# do not change this to grep -c!
|
||||
# shellcheck disable=SC2126
|
||||
CWE_CNT="$(grep "$CWE" "$LOG_PATH_MODULE"/cwe_*.log 2>/dev/null | wc -l || true)"
|
||||
print_output "$(indent "$(orange "$CWE""$GREEN"" - ""$CWE_DESC"" - ""$ORANGE""$CWE_CNT"" times.")")"
|
||||
CWE_CNT="$(grep "${CWE}" "${LOG_PATH_MODULE}"/cwe_*.log 2>/dev/null | wc -l || true)"
|
||||
print_output "$(indent "$(orange "${CWE}""${GREEN}"" - ""${CWE_DESC}"" - ""${ORANGE}""${CWE_CNT}"" times.")")"
|
||||
done
|
||||
print_bar
|
||||
print_ln
|
||||
|
||||
@@ -26,86 +26,86 @@ S12_binary_protection()
|
||||
local BIN_PROT_COUNTER=0
|
||||
local CSV_LOG
|
||||
CSV_LOG="${LOG_FILE_NAME/\.txt/\.csv}"
|
||||
CSV_LOG="$CSV_DIR""/""$CSV_LOG"
|
||||
CSV_LOG="${CSV_DIR}""/""${CSV_LOG}"
|
||||
local BINARY=""
|
||||
|
||||
if [[ -f "$EXT_DIR"/checksec ]] ; then
|
||||
echo "RELRO;STACK CANARY;NX;PIE;RPATH;RUNPATH;Symbols;FORTIFY;Fortified;Fortifiable;FILE" >> "$CSV_LOG"
|
||||
if [[ -f "${EXT_DIR}"/checksec ]] ; then
|
||||
echo "RELRO;STACK CANARY;NX;PIE;RPATH;RUNPATH;Symbols;FORTIFY;Fortified;Fortifiable;FILE" >> "${CSV_LOG}"
|
||||
printf "\t%-13.13s %-16.16s %-11.11s %-8.8s %-11.11s %-11.11s %-11.11s %-5.5s %s\n" \
|
||||
"RELRO" "CANARY" "NX" "PIE" "RPATH" "RUNPATH" "SYMBOLS" "FORTIFY" "FILE" | tee -a "$TMP_DIR"/s12.tmp
|
||||
"RELRO" "CANARY" "NX" "PIE" "RPATH" "RUNPATH" "SYMBOLS" "FORTIFY" "FILE" | tee -a "${TMP_DIR}"/s12.tmp
|
||||
|
||||
for BINARY in "${BINARIES[@]}" ; do
|
||||
if ( file "$BINARY" | grep -q ELF ) ; then
|
||||
CSV_BIN_OUT=$("$EXT_DIR"/checksec --format=csv --file="$BINARY")
|
||||
if ( file "${BINARY}" | grep -q ELF ) ; then
|
||||
CSV_BIN_OUT=$("${EXT_DIR}"/checksec --format=csv --file="${BINARY}")
|
||||
|
||||
# we usually use ; instead of , for csv ...
|
||||
CSV_BIN_OUT=${CSV_BIN_OUT//,/\;}
|
||||
echo "$CSV_BIN_OUT" >> "$CSV_LOG"
|
||||
echo "${CSV_BIN_OUT}" >> "${CSV_LOG}"
|
||||
|
||||
# coloring the output from csv
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(No\ RELRO)/${RED_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(Partial\ RELRO)/${ORANGE_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(Full\ RELRO)/${GREEN_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(No\ RELRO)/${RED_}&${NC_}/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(Partial\ RELRO)/${ORANGE_}&${NC_}/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(Full\ RELRO)/${GREEN_}&${NC_}/g")
|
||||
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(DSO)/${ORANGE_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(DSO)/${ORANGE_}&${NC_}/g")
|
||||
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(NX\ enabled)/${GREEN_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(NX\ disabled)/${RED_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(NX\ enabled)/${GREEN_}&${NC_}/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(NX\ disabled)/${RED_}&${NC_}/g")
|
||||
|
||||
if [[ "$CSV_BIN_OUT" == *"No PIE"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(No\ PIE)/${RED_}&$NC_/g")
|
||||
elif [[ "$CSV_BIN_OUT" == *"PIE enabled"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(PIE\ enabled)/${GREEN_}&$NC_/g")
|
||||
elif [[ "$(echo "$CSV_BIN_OUT" | cut -d\; -f4)" == "REL" ]]; then
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | awk -F ';' -v repl="${ORANGE_}REL$NC_" '$4 == "REL"{OFS = ";"; $4=repl}1')
|
||||
if [[ "${CSV_BIN_OUT}" == *"No PIE"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(No\ PIE)/${RED_}&${NC_}/g")
|
||||
elif [[ "${CSV_BIN_OUT}" == *"PIE enabled"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(PIE\ enabled)/${GREEN_}&${NC_}/g")
|
||||
elif [[ "$(echo "${CSV_BIN_OUT}" | cut -d\; -f4)" == "REL" ]]; then
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | awk -F ';' -v repl="${ORANGE_}REL${NC_}" '$4 == "REL"{OFS = ";"; $4=repl}1')
|
||||
fi
|
||||
|
||||
if [[ "$CSV_BIN_OUT" == *"No Canary found"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(No\ Canary\ found)/${RED_}&$NC_/g")
|
||||
if [[ "${CSV_BIN_OUT}" == *"No Canary found"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(No\ Canary\ found)/${RED_}&${NC_}/g")
|
||||
else
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(Canary\ found)/${GREEN_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(Canary\ found)/${GREEN_}&${NC_}/g")
|
||||
fi
|
||||
|
||||
if [[ "$CSV_BIN_OUT" == *"No RPATH"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(No\ RPATH)/${GREEN_}&$NC_/g")
|
||||
if [[ "${CSV_BIN_OUT}" == *"No RPATH"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(No\ RPATH)/${GREEN_}&${NC_}/g")
|
||||
else
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(RPATH)/${RED_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(RPATH)/${RED_}&${NC_}/g")
|
||||
fi
|
||||
|
||||
if [[ "$CSV_BIN_OUT" == *"No RUNPATH"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(No\ RUNPATH)/${GREEN_}&$NC_/g")
|
||||
if [[ "${CSV_BIN_OUT}" == *"No RUNPATH"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(No\ RUNPATH)/${GREEN_}&${NC_}/g")
|
||||
else
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(RUNPATH)/${RED_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(RUNPATH)/${RED_}&${NC_}/g")
|
||||
fi
|
||||
|
||||
if [[ "$CSV_BIN_OUT" == *"No Symbols"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(No\ Symbols)/${GREEN_}&$NC_/g")
|
||||
if [[ "${CSV_BIN_OUT}" == *"No Symbols"* ]]; then
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(No\ Symbols)/${GREEN_}&${NC_}/g")
|
||||
else
|
||||
CSV_BIN_OUT=$(echo "$CSV_BIN_OUT" | sed -r "s/(Symbols)/${RED_}&$NC_/g")
|
||||
CSV_BIN_OUT=$(echo "${CSV_BIN_OUT}" | sed -r "s/(Symbols)/${RED_}&${NC_}/g")
|
||||
fi
|
||||
|
||||
RELRO=$(echo "$CSV_BIN_OUT" | cut -d\; -f1)
|
||||
CANARY=$(echo "$CSV_BIN_OUT" | cut -d\; -f2)
|
||||
NX=$(echo "$CSV_BIN_OUT" | cut -d\; -f3)
|
||||
PIE=$(echo "$CSV_BIN_OUT" | cut -d\; -f4)
|
||||
RPATH=$(echo "$CSV_BIN_OUT" | cut -d\; -f5)
|
||||
RUNPATH=$(echo "$CSV_BIN_OUT" | cut -d\; -f6)
|
||||
SYMBOLS=$(echo "$CSV_BIN_OUT" | cut -d\; -f7)
|
||||
FORTIFY=$(echo "$CSV_BIN_OUT" | cut -d\; -f8)
|
||||
FILE=$(echo "$CSV_BIN_OUT" | cut -d\; -f11)
|
||||
FILE=$(print_path "$FILE")
|
||||
RELRO=$(echo "${CSV_BIN_OUT}" | cut -d\; -f1)
|
||||
CANARY=$(echo "${CSV_BIN_OUT}" | cut -d\; -f2)
|
||||
NX=$(echo "${CSV_BIN_OUT}" | cut -d\; -f3)
|
||||
PIE=$(echo "${CSV_BIN_OUT}" | cut -d\; -f4)
|
||||
RPATH=$(echo "${CSV_BIN_OUT}" | cut -d\; -f5)
|
||||
RUNPATH=$(echo "${CSV_BIN_OUT}" | cut -d\; -f6)
|
||||
SYMBOLS=$(echo "${CSV_BIN_OUT}" | cut -d\; -f7)
|
||||
FORTIFY=$(echo "${CSV_BIN_OUT}" | cut -d\; -f8)
|
||||
FILE=$(echo "${CSV_BIN_OUT}" | cut -d\; -f11)
|
||||
FILE=$(print_path "${FILE}")
|
||||
|
||||
printf "\t%-22.22s %-25.25s %-20.20s %-20.20s %-20.20s %-20.20s %-20.20s %-5.5s %s\n" \
|
||||
"$RELRO" "$CANARY" "$NX" "$PIE" "$RPATH" "$RUNPATH" "$SYMBOLS" "$FORTIFY" "$FILE" | tee -a "$TMP_DIR"/s12.tmp || true
|
||||
"${RELRO}" "${CANARY}" "${NX}" "${PIE}" "${RPATH}" "${RUNPATH}" "${SYMBOLS}" "${FORTIFY}" "${FILE}" | tee -a "${TMP_DIR}"/s12.tmp || true
|
||||
BIN_PROT_COUNTER=$((BIN_PROT_COUNTER+1))
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -f "$TMP_DIR"/s12.tmp ]] && cat "$TMP_DIR"/s12.tmp >> "$LOG_FILE"
|
||||
[[ -f "${TMP_DIR}"/s12.tmp ]] && cat "${TMP_DIR}"/s12.tmp >> "${LOG_FILE}"
|
||||
else
|
||||
print_output "[-] Binary protection analyzer $ORANGE$EXT_DIR/checksec$NC not found - check your installation."
|
||||
print_output "[-] Binary protection analyzer ${ORANGE}${EXT_DIR}/checksec${NC} not found - check your installation."
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$BIN_PROT_COUNTER"
|
||||
module_end_log "${FUNCNAME[0]}" "${BIN_PROT_COUNTER}"
|
||||
}
|
||||
|
||||
|
||||
+264
-264
@@ -33,128 +33,128 @@ S13_weak_func_check()
|
||||
local VULNERABLE_FUNCTIONS_VAR=""
|
||||
local ERR_PRINTED=0
|
||||
|
||||
if [[ -n "$ARCH" ]] ; then
|
||||
if [[ -n "${ARCH}" ]] ; then
|
||||
# This module waits for S12 - binary protections
|
||||
# check emba.log for S12_binary_protection starting
|
||||
module_wait "S12_binary_protection"
|
||||
|
||||
if ! [[ -d "$TMP_DIR" ]]; then
|
||||
mkdir "$TMP_DIR"
|
||||
if ! [[ -d "${TMP_DIR}" ]]; then
|
||||
mkdir "${TMP_DIR}"
|
||||
fi
|
||||
|
||||
# OBJDMP_ARCH, READELF are set in dependency check
|
||||
# Test source: https://security.web.cern.ch/security/recommendations/en/codetools/c.shtml
|
||||
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "$CONFIG_DIR""/functions.cfg")"
|
||||
print_output "[*] Vulnerable functions: ""$( echo -e "$VULNERABLE_FUNCTIONS_VAR" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "$VULNERABLE_FUNCTIONS_VAR" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "${CONFIG_DIR}""/functions.cfg")"
|
||||
print_output "[*] Vulnerable functions: ""$( echo -e "${VULNERABLE_FUNCTIONS_VAR}" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "${VULNERABLE_FUNCTIONS_VAR}" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
|
||||
write_csv_log "binary" "function" "function count" "common linux file" "networking"
|
||||
|
||||
for BINARY in "${BINARIES[@]}" ; do
|
||||
if ( file "$BINARY" | grep -q ELF ) ; then
|
||||
NAME=$(basename "$BINARY" 2> /dev/null)
|
||||
if ( file "${BINARY}" | grep -q ELF ) ; then
|
||||
NAME=$(basename "${BINARY}" 2> /dev/null)
|
||||
|
||||
if ( file "$BINARY" | grep -q "x86-64" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
function_check_x86_64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
if ( file "${BINARY}" | grep -q "x86-64" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
function_check_x86_64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S13+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S13+=( "${TMP_PID}" )
|
||||
else
|
||||
function_check_x86_64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
function_check_x86_64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "Intel 80386" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
function_check_x86 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "Intel 80386" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
function_check_x86 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S13+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S13+=( "${TMP_PID}" )
|
||||
else
|
||||
function_check_x86 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
function_check_x86 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "32-bit.*ARM" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
function_check_ARM32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "32-bit.*ARM" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
function_check_ARM32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S13+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S13+=( "${TMP_PID}" )
|
||||
else
|
||||
function_check_ARM32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
function_check_ARM32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "64-bit.*ARM" ) ; then
|
||||
elif ( file "${BINARY}" | grep -q "64-bit.*ARM" ) ; then
|
||||
# ARM 64 code is in alpha state and nearly not tested!
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
function_check_ARM64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
function_check_ARM64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S13+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S13+=( "${TMP_PID}" )
|
||||
else
|
||||
function_check_ARM64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
function_check_ARM64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "MIPS" ) ; then
|
||||
elif ( file "${BINARY}" | grep -q "MIPS" ) ; then
|
||||
# MIPS32 and MIPS64
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
function_check_MIPS "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
function_check_MIPS "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S13+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S13+=( "${TMP_PID}" )
|
||||
else
|
||||
function_check_MIPS "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
function_check_MIPS "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "PowerPC" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
function_check_PPC32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "PowerPC" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
function_check_PPC32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S13+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S13+=( "${TMP_PID}" )
|
||||
else
|
||||
function_check_PPC32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
function_check_PPC32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "Altera Nios II" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
function_check_NIOS2 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "Altera Nios II" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
function_check_NIOS2 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S13+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S13+=( "${TMP_PID}" )
|
||||
else
|
||||
function_check_NIOS2 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
function_check_NIOS2 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "QUALCOMM DSP6" ) ; then
|
||||
if [[ "$ERR_PRINTED" -eq 0 ]]; then
|
||||
elif ( file "${BINARY}" | grep -q "QUALCOMM DSP6" ) ; then
|
||||
if [[ "${ERR_PRINTED}" -eq 0 ]]; then
|
||||
print_output "[-] Qualcom DSP6 is currently not supported from objdump"
|
||||
print_output "[-] The binaries will be analysed from radare2 module s14"
|
||||
ERR_PRINTED=1
|
||||
fi
|
||||
else
|
||||
print_output "[-] Something went wrong ... no supported architecture available"
|
||||
print_output "[-] Tested binary: $ORANGE$BINARY$NC"
|
||||
print_output "[-] Tested binary: ${ORANGE}${BINARY}${NC}"
|
||||
print_output "[-] Please open an issue at https://github.com/e-m-b-a/emba/issues"
|
||||
fi
|
||||
fi
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S13[@]}"
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S13[@]}"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S13[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S13[@]}"
|
||||
|
||||
# ensure that we do not have result files without real results:
|
||||
find "$LOG_DIR"/s13_weak_func_check/vul_func_0*.txt -exec rm {} \; 2>/dev/null || true
|
||||
find "${LOG_DIR}"/s13_weak_func_check/vul_func_0*.txt -exec rm {} \; 2>/dev/null || true
|
||||
|
||||
print_top10_statistics "${VULNERABLE_FUNCTIONS[@]}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/S13_STRCPY_CNT.tmp ]]; then
|
||||
STRCPY_CNT=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S13_STRCPY_CNT.tmp)
|
||||
if [[ -f "${TMP_DIR}"/S13_STRCPY_CNT.tmp ]]; then
|
||||
STRCPY_CNT=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S13_STRCPY_CNT.tmp)
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$STRCPY_CNT"
|
||||
write_log "[*] Statistics:${STRCPY_CNT}"
|
||||
write_log ""
|
||||
write_log "[*] Statistics1:$ARCH"
|
||||
write_log "[*] Statistics1:${ARCH}"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$STRCPY_CNT"
|
||||
module_end_log "${FUNCNAME[0]}" "${STRCPY_CNT}"
|
||||
}
|
||||
|
||||
function_check_NIOS2(){
|
||||
@@ -163,46 +163,46 @@ function_check_NIOS2(){
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
local STRCPY_CNT=0
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -r "$BINARY_" --use-dynamic | awk '{print $5}' | grep -E -q "^$FUNCTION" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
FUNC_ADDR=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E \ "$FUNCTION" | grep -m1 UND | cut -d: -f2 | awk '{print $1}' | sed -e 's/^[0]*//' 2> /dev/null || true)
|
||||
if [[ -z "$FUNC_ADDR" ]] || [[ "$FUNC_ADDR" == "00000000" ]]; then
|
||||
if ( readelf -r "${BINARY_}" --use-dynamic | awk '{print $5}' | grep -E -q "^${FUNCTION}" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
FUNC_ADDR=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E \ "${FUNCTION}" | grep -m1 UND | cut -d: -f2 | awk '{print $1}' | sed -e 's/^[0]*//' 2> /dev/null || true)
|
||||
if [[ -z "${FUNC_ADDR}" ]] || [[ "${FUNC_ADDR}" == "00000000" ]]; then
|
||||
continue
|
||||
fi
|
||||
STRLEN_ADDR=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E \ "strlen" | grep -m1 UND | cut -d: -f2 | awk '{print $1}' | sed -e 's/^[0]*//' 2> /dev/null || true)
|
||||
STRLEN_ADDR=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E \ "strlen" | grep -m1 UND | cut -d: -f2 | awk '{print $1}' | sed -e 's/^[0]*//' 2> /dev/null || true)
|
||||
|
||||
log_bin_hardening "$NAME"
|
||||
log_func_header "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
log_bin_hardening "${NAME}"
|
||||
log_func_header "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 20 "call.*$FUNC_ADDR" | sed s/-"$FUNC_ADDR"\(gp\)/"$FUNCTION"/ 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 20 "call.*${FUNC_ADDR}" | sed s/-"${FUNC_ADDR}"\(gp\)/"${FUNCTION}"/ 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 2 -B 20 "call.*$FUNC_ADDR" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 2 -B 20 "call.*${FUNC_ADDR}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*($FUNC_ADDR).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" || true
|
||||
COUNT_FUNC="$(grep -c "call.*""$FUNC_ADDR" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*$STRLEN_ADDR" "$FUNC_LOG" 2> /dev/null || true)
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*(${FUNC_ADDR}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" || true
|
||||
COUNT_FUNC="$(grep -c "call.*""${FUNC_ADDR}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*${STRLEN_ADDR}" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# COUNT_MMAP_OK=$(grep -c "cmpwi.*,r.*,-1" "$FUNC_LOG" 2> /dev/null || true)
|
||||
# COUNT_MMAP_OK=$(grep -c "cmpwi.*,r.*,-1" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK="NA"
|
||||
fi
|
||||
log_func_footer "$NAME" "$FUNCTION"
|
||||
output_function_details "$BINARY_" "$FUNCTION"
|
||||
log_func_footer "${NAME}" "${FUNCTION}"
|
||||
output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S13_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S13_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
function_check_PPC32(){
|
||||
@@ -210,40 +210,40 @@ function_check_PPC32(){
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -r "$BINARY_" --use-dynamic | awk '{print $5}' | grep -E -q "^$FUNCTION" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
log_bin_hardening "$NAME"
|
||||
log_func_header "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if ( readelf -r "${BINARY_}" --use-dynamic | awk '{print $5}' | grep -E -q "^${FUNCTION}" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
log_bin_hardening "${NAME}"
|
||||
log_func_header "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 20 "bl.*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 20 "bl.*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 2 -B 20 "bl.*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 2 -B 20 "bl.*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*($FUNCTION).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" || true
|
||||
COUNT_FUNC="$(grep -c "bl.*""$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*(${FUNCTION}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" || true
|
||||
COUNT_FUNC="$(grep -c "bl.*""${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
COUNT_MMAP_OK=$(grep -c "cmpwi.*,r.*,-1" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c "cmpwi.*,r.*,-1" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
log_func_footer "$NAME" "$FUNCTION"
|
||||
output_function_details "$BINARY_" "$FUNCTION"
|
||||
log_func_footer "${NAME}" "${FUNCTION}"
|
||||
output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S13_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S13_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
function_check_MIPS() {
|
||||
@@ -251,46 +251,46 @@ function_check_MIPS() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
FUNC_ADDR=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E \ "$FUNCTION" | grep gp | grep -m1 UND | cut -d\ -f4 | sed s/\(gp\)// | sed s/-// 2> /dev/null || true)
|
||||
if [[ -z "$FUNC_ADDR" ]] || [[ "$FUNC_ADDR" == "00000000" ]]; then
|
||||
FUNC_ADDR=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E \ "${FUNCTION}" | grep gp | grep -m1 UND | cut -d\ -f4 | sed s/\(gp\)// | sed s/-// 2> /dev/null || true)
|
||||
if [[ -z "${FUNC_ADDR}" ]] || [[ "${FUNC_ADDR}" == "00000000" ]]; then
|
||||
continue
|
||||
fi
|
||||
STRLEN_ADDR=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E \ "strlen" | grep gp | grep -m1 UND | cut -d\ -f4 | sed s/\(gp\)// | sed s/-// 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
if [[ -n "$FUNC_ADDR" ]] ; then
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
log_bin_hardening "$NAME"
|
||||
log_func_header "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
STRLEN_ADDR=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E \ "strlen" | grep gp | grep -m1 UND | cut -d\ -f4 | sed s/\(gp\)// | sed s/-// 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
if [[ -n "${FUNC_ADDR}" ]] ; then
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
log_bin_hardening "${NAME}"
|
||||
log_func_header "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -A 20 "$FUNC_ADDR""(gp)" | sed s/-"$FUNC_ADDR"\(gp\)/"$FUNCTION"/ >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -A 20 "${FUNC_ADDR}""(gp)" | sed s/-"${FUNC_ADDR}"\(gp\)/"${FUNCTION}"/ >> "${FUNC_LOG}" || true
|
||||
else
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -A 2 -B 25 "$FUNC_ADDR""(gp)" | sed s/-"$FUNC_ADDR"\(gp\)/"$FUNCTION"/ | sed s/-"$STRLEN_ADDR"\(gp\)/strlen/ >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -A 2 -B 25 "${FUNC_ADDR}""(gp)" | sed s/-"${FUNC_ADDR}"\(gp\)/"${FUNCTION}"/ | sed s/-"${STRLEN_ADDR}"\(gp\)/strlen/ >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*($FUNCTION).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" || true
|
||||
COUNT_FUNC="$(grep -c "l[wd].*""$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "l[wd].*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*(${FUNCTION}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" || true
|
||||
COUNT_FUNC="$(grep -c "l[wd].*""${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "l[wd].*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# Check this. This test is very rough:
|
||||
COUNT_MMAP_OK=$(grep -c ",-1$" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c ",-1$" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
log_func_footer "$NAME" "$FUNCTION"
|
||||
output_function_details "$BINARY_" "$FUNCTION"
|
||||
log_func_footer "${NAME}" "${FUNCTION}"
|
||||
output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S13_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S13_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
function_check_ARM64() {
|
||||
@@ -298,39 +298,39 @@ function_check_ARM64() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
log_bin_hardening "$NAME"
|
||||
log_func_header "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -A 20 "[[:blank:]]bl[[:blank:]].*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
log_bin_hardening "${NAME}"
|
||||
log_func_header "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -A 20 "[[:blank:]]bl[[:blank:]].*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -A 2 -B 20 "[[:blank:]]bl[[:blank:]].*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -A 2 -B 20 "[[:blank:]]bl[[:blank:]].*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*($FUNCTION).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" || true
|
||||
COUNT_FUNC="$(grep -c "[[:blank:]]bl[[:blank:]].*<$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "[[:blank:]]bl[[:blank:]].*<strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*(${FUNCTION}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" || true
|
||||
COUNT_FUNC="$(grep -c "[[:blank:]]bl[[:blank:]].*<${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "[[:blank:]]bl[[:blank:]].*<strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# Test not implemented on ARM64
|
||||
# COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "$FUNC_LOG" 2> /dev/null)
|
||||
# COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "${FUNC_LOG}" 2> /dev/null)
|
||||
COUNT_MMAP_OK="NA"
|
||||
fi
|
||||
log_func_footer "$NAME" "$FUNCTION"
|
||||
output_function_details "$BINARY_" "$FUNCTION"
|
||||
log_func_footer "${NAME}" "${FUNCTION}"
|
||||
output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S13_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S13_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
function_check_ARM32() {
|
||||
@@ -338,38 +338,38 @@ function_check_ARM32() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
log_bin_hardening "$NAME"
|
||||
log_func_header "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -A 20 "[[:blank:]]bl[[:blank:]].*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
log_bin_hardening "${NAME}"
|
||||
log_func_header "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -A 20 "[[:blank:]]bl[[:blank:]].*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -A 2 -B 20 "[[:blank:]]bl[[:blank:]].*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -A 2 -B 20 "[[:blank:]]bl[[:blank:]].*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*($FUNCTION).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" || true
|
||||
COUNT_FUNC="$(grep -c "[[:blank:]]bl[[:blank:]].*<$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "[[:blank:]]bl[[:blank:]].*<strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*(${FUNCTION}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" || true
|
||||
COUNT_FUNC="$(grep -c "[[:blank:]]bl[[:blank:]].*<${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "[[:blank:]]bl[[:blank:]].*<strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# Check this testcase. Not sure if it works in all cases!
|
||||
COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
log_func_footer "$NAME" "$FUNCTION"
|
||||
output_function_details "$BINARY_" "$FUNCTION"
|
||||
log_func_footer "${NAME}" "${FUNCTION}"
|
||||
output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S13_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S13_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
function_check_x86() {
|
||||
@@ -377,40 +377,40 @@ function_check_x86() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -r --use-dynamic "$BINARY_" | awk '{print $5}' | grep -E -q "^$FUNCTION" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
log_bin_hardening "$NAME"
|
||||
log_func_header "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if ( readelf -r --use-dynamic "${BINARY_}" | awk '{print $5}' | grep -E -q "^${FUNCTION}" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
log_bin_hardening "${NAME}"
|
||||
log_func_header "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 20 "call.*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 20 "call.*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 2 -B 20 "call.*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 2 -B 20 "call.*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*($FUNCTION).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" || true
|
||||
COUNT_FUNC="$(grep -c -e "call.*$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*(${FUNCTION}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" || true
|
||||
COUNT_FUNC="$(grep -c -e "call.*${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffff" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffff" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
log_func_footer "$NAME" "$FUNCTION"
|
||||
output_function_details "$BINARY_" "$FUNCTION"
|
||||
log_func_footer "${NAME}" "${FUNCTION}"
|
||||
output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S13_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S13_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
function_check_x86_64() {
|
||||
@@ -418,40 +418,40 @@ function_check_x86_64() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -r --use-dynamic "$BINARY_" | awk '{print $5}' | grep -E -q "^$FUNCTION" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
log_bin_hardening "$NAME"
|
||||
log_func_header "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if ( readelf -r --use-dynamic "${BINARY_}" | awk '{print $5}' | grep -E -q "^${FUNCTION}" 2> /dev/null ) ; then
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
log_bin_hardening "${NAME}"
|
||||
log_func_header "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 20 "call.*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 20 "call.*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
"$OBJDUMP" -d "$BINARY_" | grep -E -A 2 -B 20 "call.*<$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
"${OBJDUMP}" -d "${BINARY_}" | grep -E -A 2 -B 20 "call.*<${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*($FUNCTION).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" || true
|
||||
COUNT_FUNC="$(grep -c -e "call.*$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
sed -i -r "s/^.*:.*(${FUNCTION}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" || true
|
||||
COUNT_FUNC="$(grep -c -e "call.*${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffffffffffff" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffffffffffff" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
log_func_footer "$NAME" "$FUNCTION"
|
||||
output_function_details "$BINARY_" "$FUNCTION"
|
||||
log_func_footer "${NAME}" "${FUNCTION}"
|
||||
output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S13_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S13_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
print_top10_statistics() {
|
||||
@@ -462,36 +462,36 @@ print_top10_statistics() {
|
||||
|
||||
sub_module_title "Top 10 legacy C functions - Objdump disasm mode"
|
||||
|
||||
if [[ "$(find "$LOG_PATH_MODULE" -xdev -iname "vul_func_*_*-*.txt" | wc -l)" -gt 0 ]]; then
|
||||
if [[ "$(find "${LOG_PATH_MODULE}" -xdev -iname "vul_func_*_*-*.txt" | wc -l)" -gt 0 ]]; then
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
local SEARCH_TERM=""
|
||||
local F_COUNTER=0
|
||||
readarray -t RESULTS < <( find "$LOG_PATH_MODULE" -xdev -iname "vul_func_*_""$FUNCTION""-*.txt" 2> /dev/null | sed "s/.*vul_func_//" | sort -g -r | head -10 | sed "s/_""$FUNCTION""-/ /" | sed "s/\.txt//" 2> /dev/null || true)
|
||||
readarray -t RESULTS < <( find "${LOG_PATH_MODULE}" -xdev -iname "vul_func_*_""${FUNCTION}""-*.txt" 2> /dev/null | sed "s/.*vul_func_//" | sort -g -r | head -10 | sed "s/_""${FUNCTION}""-/ /" | sed "s/\.txt//" 2> /dev/null || true)
|
||||
|
||||
if [[ "${#RESULTS[@]}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] ""$FUNCTION"" - top 10 results:"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
print_output "[+] ""${FUNCTION}"" - top 10 results:"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
write_anchor "strcpysummary"
|
||||
elif [[ "$FUNCTION" == "system" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "system" ]] ; then
|
||||
write_anchor "systemsummary"
|
||||
fi
|
||||
for BINARY in "${RESULTS[@]}" ; do
|
||||
SEARCH_TERM="$(echo "$BINARY" | awk '{print $2}')"
|
||||
F_COUNTER="$(echo "$BINARY" | awk '{print $1}')"
|
||||
[[ "$F_COUNTER" -eq 0 ]] && continue
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
SEARCH_TERM="$(echo "${BINARY}" | awk '{print $2}')"
|
||||
F_COUNTER="$(echo "${BINARY}" | awk '{print $1}')"
|
||||
[[ "${F_COUNTER}" -eq 0 ]] && continue
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
# if we have the base linux config file we are checking it:
|
||||
if grep -E -q "^$SEARCH_TERM$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
printf "${GREEN}\t%-5.5s : %-15.15s : common linux file: yes${NC}\n" "$F_COUNTER" "$SEARCH_TERM" | tee -a "$LOG_FILE" || true
|
||||
if grep -E -q "^${SEARCH_TERM}$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
printf "${GREEN}\t%-5.5s : %-15.15s : common linux file: yes${NC}\n" "${F_COUNTER}" "${SEARCH_TERM}" | tee -a "${LOG_FILE}" || true
|
||||
else
|
||||
printf "${ORANGE}\t%-5.5s : %-15.15s : common linux file: no${NC}\n" "$F_COUNTER" "$SEARCH_TERM" | tee -a "$LOG_FILE" || true
|
||||
printf "${ORANGE}\t%-5.5s : %-15.15s : common linux file: no${NC}\n" "${F_COUNTER}" "${SEARCH_TERM}" | tee -a "${LOG_FILE}" || true
|
||||
fi
|
||||
else
|
||||
print_output "$(indent "$(orange "$F_COUNTER""\t:\t""$SEARCH_TERM")")"
|
||||
print_output "$(indent "$(orange "${F_COUNTER}""\t:\t""${SEARCH_TERM}")")"
|
||||
fi
|
||||
if [[ -f "$LOG_PATH_MODULE""/vul_func_""$F_COUNTER""_""$FUNCTION"-"$SEARCH_TERM"".txt" ]]; then
|
||||
write_link "$LOG_PATH_MODULE""/vul_func_""$F_COUNTER""_""$FUNCTION"-"$SEARCH_TERM"".txt"
|
||||
if [[ -f "${LOG_PATH_MODULE}""/vul_func_""${F_COUNTER}""_""${FUNCTION}"-"${SEARCH_TERM}"".txt" ]]; then
|
||||
write_link "${LOG_PATH_MODULE}""/vul_func_""${F_COUNTER}""_""${FUNCTION}"-"${SEARCH_TERM}"".txt"
|
||||
fi
|
||||
done
|
||||
print_ln
|
||||
@@ -507,16 +507,16 @@ log_bin_hardening() {
|
||||
local HEAD_BIN_PROT=""
|
||||
local BIN_PROT=""
|
||||
|
||||
if [[ -f "$LOG_DIR"/s12_binary_protection.txt ]]; then
|
||||
write_log "[*] Binary protection state of $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
if [[ -f "${LOG_DIR}"/s12_binary_protection.txt ]]; then
|
||||
write_log "[*] Binary protection state of ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
# get headline:
|
||||
HEAD_BIN_PROT=$(grep "FORTIFY Fortified" "$LOG_DIR"/s12_binary_protection.txt | sed 's/FORTIFY.*//'| sort -u || true)
|
||||
write_log " $HEAD_BIN_PROT" "$FUNC_LOG"
|
||||
HEAD_BIN_PROT=$(grep "FORTIFY Fortified" "${LOG_DIR}"/s12_binary_protection.txt | sed 's/FORTIFY.*//'| sort -u || true)
|
||||
write_log " ${HEAD_BIN_PROT}" "${FUNC_LOG}"
|
||||
# get binary entry
|
||||
BIN_PROT=$(grep '/'"$NAME"' ' "$LOG_DIR"/s12_binary_protection.txt | sed 's/Symbols.*/Symbols/' | sort -u || true)
|
||||
write_log " $BIN_PROT$NC" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
BIN_PROT=$(grep '/'"${NAME}"' ' "${LOG_DIR}"/s12_binary_protection.txt | sed 's/Symbols.*/Symbols/' | sort -u || true)
|
||||
write_log " ${BIN_PROT}${NC}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -524,57 +524,57 @@ log_func_header() {
|
||||
local NAME="${1:-}"
|
||||
local FUNCTION="${2:-}"
|
||||
|
||||
write_log "$NC" "$FUNC_LOG"
|
||||
write_log "[*] Function $ORANGE$FUNCTION$NC tear down of $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
write_log "${NC}" "${FUNC_LOG}"
|
||||
write_log "[*] Function ${ORANGE}${FUNCTION}${NC} tear down of ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
}
|
||||
|
||||
log_func_footer() {
|
||||
local NAME="${1:-}"
|
||||
local FUNCTION="${2:-}"
|
||||
|
||||
write_log "\n$NC" "$FUNC_LOG"
|
||||
write_log "[*] Function $ORANGE$FUNCTION$NC used $ORANGE$COUNT_FUNC$NC times $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
write_log "\n${NC}" "${FUNC_LOG}"
|
||||
write_log "[*] Function ${ORANGE}${FUNCTION}${NC} used ${ORANGE}${COUNT_FUNC}${NC} times ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
}
|
||||
|
||||
output_function_details()
|
||||
{
|
||||
write_s13_log()
|
||||
{
|
||||
OLD_LOG_FILE="$LOG_FILE"
|
||||
LOG_FILE="$3"
|
||||
print_output "$1"
|
||||
write_link "$2"
|
||||
if [[ -f "$LOG_FILE" ]]; then
|
||||
cat "$LOG_FILE" >> "$OLD_LOG_FILE"
|
||||
rm "$LOG_FILE" 2> /dev/null || true
|
||||
OLD_LOG_FILE="${LOG_FILE}"
|
||||
LOG_FILE="${3}"
|
||||
print_output "${1}"
|
||||
write_link "${2}"
|
||||
if [[ -f "${LOG_FILE}" ]]; then
|
||||
cat "${LOG_FILE}" >> "${OLD_LOG_FILE}"
|
||||
rm "${LOG_FILE}" 2> /dev/null || true
|
||||
fi
|
||||
LOG_FILE="$OLD_LOG_FILE"
|
||||
LOG_FILE="${OLD_LOG_FILE}"
|
||||
}
|
||||
|
||||
local BINARY_="${1:-}"
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
local FUNCTION="${2:-}"
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_")
|
||||
NAME=$(basename "${BINARY_}")
|
||||
|
||||
local LOG_FILE_LOC
|
||||
LOG_FILE_LOC="$LOG_PATH_MODULE"/vul_func_"$FUNCTION"-"$NAME".txt
|
||||
LOG_FILE_LOC="${LOG_PATH_MODULE}"/vul_func_"${FUNCTION}"-"${NAME}".txt
|
||||
|
||||
# check if this is common linux file:
|
||||
local COMMON_FILES_FOUND
|
||||
local SEARCH_TERM
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
SEARCH_TERM=$(basename "$BINARY_")
|
||||
if grep -q "^$SEARCH_TERM\$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
SEARCH_TERM=$(basename "${BINARY_}")
|
||||
if grep -q "^${SEARCH_TERM}\$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
COMMON_FILES_FOUND="${CYAN}"" - common linux file: yes - "
|
||||
write_log "[+] File $(print_path "$BINARY_") found in default Linux file dictionary" "$LOG_PATH_MODULE/common_linux_files.txt"
|
||||
write_log "[+] File $(print_path "${BINARY_}") found in default Linux file dictionary" "${LOG_PATH_MODULE}/common_linux_files.txt"
|
||||
CFF_CSV="true"
|
||||
else
|
||||
write_log "[+] File $(print_path "$BINARY_") not found in default Linux file dictionary" "$LOG_PATH_MODULE/common_linux_files.txt"
|
||||
write_log "[+] File $(print_path "${BINARY_}") not found in default Linux file dictionary" "${LOG_PATH_MODULE}/common_linux_files.txt"
|
||||
COMMON_FILES_FOUND="${RED}"" - common linux file: no -"
|
||||
CFF_CSV="false"
|
||||
fi
|
||||
@@ -582,14 +582,14 @@ output_function_details()
|
||||
COMMON_FILES_FOUND=" -"
|
||||
fi
|
||||
|
||||
LOG_FILE_LOC_OLD="$LOG_FILE_LOC"
|
||||
LOG_FILE_LOC="$LOG_PATH_MODULE"/vul_func_"$COUNT_FUNC"_"$FUNCTION"-"$NAME".txt
|
||||
LOG_FILE_LOC_OLD="${LOG_FILE_LOC}"
|
||||
LOG_FILE_LOC="${LOG_PATH_MODULE}"/vul_func_"${COUNT_FUNC}"_"${FUNCTION}"-"${NAME}".txt
|
||||
|
||||
if [[ -f "$LOG_FILE_LOC_OLD" ]]; then
|
||||
mv "$LOG_FILE_LOC_OLD" "$LOG_FILE_LOC" 2> /dev/null || true
|
||||
if [[ -f "${LOG_FILE_LOC_OLD}" ]]; then
|
||||
mv "${LOG_FILE_LOC_OLD}" "${LOG_FILE_LOC}" 2> /dev/null || true
|
||||
fi
|
||||
|
||||
if [[ "$NETWORKING" -gt 1 ]]; then
|
||||
if [[ "${NETWORKING}" -gt 1 ]]; then
|
||||
NETWORKING_="${ORANGE}networking: yes${NC}"
|
||||
NW_CSV="yes"
|
||||
else
|
||||
@@ -597,16 +597,16 @@ output_function_details()
|
||||
NW_CSV="no"
|
||||
fi
|
||||
|
||||
if [[ $COUNT_FUNC -ne 0 ]] ; then
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""${ORANGE}""strlen: ""$COUNT_STRLEN"" ""${NC}""/ ""$NETWORKING_""${NC}""\\n"
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""${ORANGE}""Correct error handling: ""$COUNT_MMAP_OK"" ""${NC}""\\n"
|
||||
if [[ ${COUNT_FUNC} -ne 0 ]] ; then
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${ORANGE}""strlen: ""${COUNT_STRLEN}"" ""${NC}""/ ""${NETWORKING_}""${NC}""\\n"
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${ORANGE}""Correct error handling: ""${COUNT_MMAP_OK}"" ""${NC}""\\n"
|
||||
else
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""$NETWORKING_""${NC}""\\n"
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${NETWORKING_}""${NC}""\\n"
|
||||
fi
|
||||
write_s13_log "$OUTPUT" "$LOG_FILE_LOC" "$LOG_PATH_MODULE""/vul_func_tmp_""$FUNCTION"-"$NAME"".txt"
|
||||
write_csv_log "$(print_path "$BINARY_")" "$FUNCTION" "$COUNT_FUNC" "$CFF_CSV" "$NW_CSV"
|
||||
write_s13_log "${OUTPUT}" "${LOG_FILE_LOC}" "${LOG_PATH_MODULE}""/vul_func_tmp_""${FUNCTION}"-"${NAME}"".txt"
|
||||
write_csv_log "$(print_path "${BINARY_}")" "${FUNCTION}" "${COUNT_FUNC}" "${CFF_CSV}" "${NW_CSV}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ S14_weak_func_radare_check()
|
||||
local STRCPY_CNT=0
|
||||
local FCT_CNT=0
|
||||
|
||||
if [[ -n "$ARCH" ]] ; then
|
||||
if [[ -n "${ARCH}" ]] ; then
|
||||
# as this module is slow we only run it in case the objdump method from s13 was not working as expected
|
||||
# This module waits for S12 - binary protections and s13
|
||||
# check emba.log for S12_binary_protection starting
|
||||
@@ -42,118 +42,118 @@ S14_weak_func_radare_check()
|
||||
local VULNERABLE_FUNCTIONS=()
|
||||
local VULNERABLE_FUNCTIONS_VAR=""
|
||||
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "$CONFIG_DIR""/functions.cfg")"
|
||||
print_output "[*] Vulnerable functions: ""$( echo -e "$VULNERABLE_FUNCTIONS_VAR" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "$VULNERABLE_FUNCTIONS_VAR" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "${CONFIG_DIR}""/functions.cfg")"
|
||||
print_output "[*] Vulnerable functions: ""$( echo -e "${VULNERABLE_FUNCTIONS_VAR}" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "${VULNERABLE_FUNCTIONS_VAR}" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
|
||||
write_csv_log "binary" "function" "function count" "common linux file" "networking"
|
||||
|
||||
for BINARY in "${BINARIES[@]}" ; do
|
||||
# we run throught the bins and check if the bin was already analysed via objdump:
|
||||
if [[ "$(find "$LOG_DIR"/s13_weak_func_check/vul_func_*"$(basename "$BINARY")".txt 2>/dev/null | wc -l)" -gt 0 ]]; then
|
||||
if [[ "$(find "${LOG_DIR}"/s13_weak_func_check/vul_func_*"$(basename "${BINARY}")".txt 2>/dev/null | wc -l)" -gt 0 ]]; then
|
||||
continue
|
||||
fi
|
||||
if ( file "$BINARY" | grep -q ELF ) ; then
|
||||
NAME=$(basename "$BINARY" 2> /dev/null)
|
||||
if ( file "${BINARY}" | grep -q ELF ) ; then
|
||||
NAME=$(basename "${BINARY}" 2> /dev/null)
|
||||
|
||||
if ( file "$BINARY" | grep -q "x86-64" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_function_check_x86_64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
if ( file "${BINARY}" | grep -q "x86-64" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_function_check_x86_64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_function_check_x86_64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
radare_function_check_x86_64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "Intel 80386" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_function_check_x86 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "Intel 80386" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_function_check_x86 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_function_check_x86
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "32-bit.*ARM" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_function_check_ARM32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "32-bit.*ARM" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_function_check_ARM32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_function_check_ARM32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
radare_function_check_ARM32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "64-bit.*ARM" ) ; then
|
||||
elif ( file "${BINARY}" | grep -q "64-bit.*ARM" ) ; then
|
||||
# ARM 64 code is in alpha state and nearly not tested!
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_function_check_ARM64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_function_check_ARM64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_function_check_ARM64 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
radare_function_check_ARM64 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "MIPS" ) ; then
|
||||
elif ( file "${BINARY}" | grep -q "MIPS" ) ; then
|
||||
# MIPS32 and MIPS64
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_function_check_MIPS "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_function_check_MIPS "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_function_check_MIPS "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
radare_function_check_MIPS "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "PowerPC" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_function_check_PPC32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "PowerPC" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_function_check_PPC32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_function_check_PPC32 "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
radare_function_check_PPC32 "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
elif ( file "$BINARY" | grep -q "QUALCOMM DSP6" ) ; then
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_function_check_hexagon "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
elif ( file "${BINARY}" | grep -q "QUALCOMM DSP6" ) ; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_function_check_hexagon "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_function_check_hexagon "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
radare_function_check_hexagon "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
|
||||
else
|
||||
print_output "[-] Something went wrong ... no supported architecture available"
|
||||
print_output "[-] Tested binary: $ORANGE$BINARY$NC"
|
||||
print_output "[-] Tested binary: ${ORANGE}${BINARY}${NC}"
|
||||
print_output "[-] Please open an issue at https://github.com/e-m-b-a/emba/issues"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S14[@]}"
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S14[@]}"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S14[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S14[@]}"
|
||||
|
||||
radare_print_top10_statistics "${VULNERABLE_FUNCTIONS[@]}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/S14_STRCPY_CNT.tmp ]]; then
|
||||
STRCPY_CNT=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S14_STRCPY_CNT.tmp)
|
||||
if [[ -f "${TMP_DIR}"/S14_STRCPY_CNT.tmp ]]; then
|
||||
STRCPY_CNT=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S14_STRCPY_CNT.tmp)
|
||||
FCT_CNT="${STRCPY_CNT}"
|
||||
fi
|
||||
if [[ "$FCT_CNT" -eq 0 ]] && [[ -f "$TMP_DIR"/S14_FCT_CNT.tmp ]]; then
|
||||
if [[ "${FCT_CNT}" -eq 0 ]] && [[ -f "${TMP_DIR}"/S14_FCT_CNT.tmp ]]; then
|
||||
# FCT_CNT respects also other functions
|
||||
FCT_CNT=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S14_FCT_CNT.tmp)
|
||||
FCT_CNT=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S14_FCT_CNT.tmp)
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:${STRCPY_CNT}"
|
||||
write_log ""
|
||||
write_log "[*] Statistics1:$ARCH"
|
||||
write_log "[*] Statistics1:${ARCH}"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$FCT_CNT"
|
||||
module_end_log "${FUNCNAME[0]}" "${FCT_CNT}"
|
||||
}
|
||||
|
||||
radare_function_check_PPC32(){
|
||||
@@ -161,40 +161,40 @@ radare_function_check_PPC32(){
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -r "$BINARY_" | awk '{print $5}' | grep -E -q "^$FUNCTION" 2> /dev/null ) ; then
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if ( readelf -r "${BINARY_}" | awk '{print $5}' | grep -E -q "^${FUNCTION}" 2> /dev/null ) ; then
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 20 "bl.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 20 "bl.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 2 -B 20 "bl.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 2 -B 20 "bl.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "${FUNCTION}"
|
||||
|
||||
COUNT_FUNC="$(grep -c "bl.*""$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c "bl.*""${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
COUNT_MMAP_OK=$(grep -c "cmpwi.*,r.*,-1" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c "cmpwi.*,r.*,-1" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S14_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S14_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_function_check_MIPS() {
|
||||
@@ -202,41 +202,41 @@ radare_function_check_MIPS() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $ss' "$BINARY_" 2>/dev/null | grep -A 20 "^l[wd] .*$FUNCTION""(gp)" >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $ss' "${BINARY_}" 2>/dev/null | grep -A 20 "^l[wd] .*${FUNCTION}""(gp)" >> "${FUNC_LOG}" || true
|
||||
else
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $ss' "$BINARY_" 2>/dev/null | grep -A 20 -B 25 "^l[wd] .*$FUNCTION""(gp)" >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $ss' "${BINARY_}" 2>/dev/null | grep -A 20 -B 25 "^l[wd] .*${FUNCTION}""(gp)" >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "${FUNCTION}"
|
||||
|
||||
COUNT_FUNC="$(grep -c "l[wd].*""$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "l[wd].*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c "l[wd].*""${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "l[wd].*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# Check this. This test is very rough:
|
||||
# TODO: check this in radare2
|
||||
# COUNT_MMAP_OK=$(grep -c ",-1$" "$FUNC_LOG" 2> /dev/null)
|
||||
# COUNT_MMAP_OK=$(grep -c ",-1$" "${FUNC_LOG}" 2> /dev/null)
|
||||
COUNT_MMAP_OK="NA"
|
||||
fi
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S14_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S14_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_function_check_ARM64() {
|
||||
@@ -244,40 +244,40 @@ radare_function_check_ARM64() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -A 20 "bl.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -A 20 "bl.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -A 2 -B 20 "bl.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -A 2 -B 20 "bl.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "${FUNCTION}"
|
||||
|
||||
COUNT_FUNC="$(grep -c "bl.*$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c "bl.*${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# Test not implemented on ARM64
|
||||
# TODO: check this in radare2
|
||||
# COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "$FUNC_LOG" 2> /dev/null)
|
||||
# COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "${FUNC_LOG}" 2> /dev/null)
|
||||
COUNT_MMAP_OK="NA"
|
||||
fi
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S14_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S14_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_function_check_ARM32() {
|
||||
@@ -285,40 +285,40 @@ radare_function_check_ARM32() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -A 20 "bl.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -A 20 "bl.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -A 2 -B 20 "bl.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -A 2 -B 20 "bl.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "${FUNCTION}"
|
||||
|
||||
COUNT_FUNC="$(grep -c "bl.*$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c "bl.*${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "bl.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# Check this testcase. Not sure if it works in all cases!
|
||||
# TODO: check this in radare2
|
||||
# COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "$FUNC_LOG" 2> /dev/null)
|
||||
# COUNT_MMAP_OK=$(grep -c "cm.*r.*,\ \#[01]" "${FUNC_LOG}" 2> /dev/null)
|
||||
COUNT_MMAP_OK="NA"
|
||||
fi
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S14_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S14_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_function_check_hexagon() {
|
||||
@@ -326,41 +326,41 @@ radare_function_check_hexagon() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -s --use-dynamic "$BINARY_" | grep -q "$FUNCTION" 2> /dev/null ) ; then
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if ( readelf -s --use-dynamic "${BINARY_}" | grep -q "${FUNCTION}" 2> /dev/null ) ; then
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 20 "call.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 20 "call.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 2 -B 20 "call.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 2 -B 20 "call.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "${FUNCTION}"
|
||||
|
||||
COUNT_FUNC="$(grep -c -e "call.*$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c -e "call.*${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# TODO: check this in radare2
|
||||
COUNT_MMAP_OK="NA"
|
||||
fi
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S14_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S14_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_function_check_x86() {
|
||||
@@ -368,41 +368,41 @@ radare_function_check_x86() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -r --use-dynamic "$BINARY_" | awk '{print $5}' | grep -E -q "^$FUNCTION" 2> /dev/null ) ; then
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if ( readelf -r --use-dynamic "${BINARY_}" | awk '{print $5}' | grep -E -q "^${FUNCTION}" 2> /dev/null ) ; then
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 20 "call.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 20 "call.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 2 -B 20 "call.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 2 -B 20 "call.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "${FUNCTION}"
|
||||
|
||||
COUNT_FUNC="$(grep -c -e "call.*$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c -e "call.*${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
# TODO: check this in radare2
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffff" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffff" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S14_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S14_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_function_check_x86_64() {
|
||||
@@ -410,40 +410,40 @@ radare_function_check_x86_64() {
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
if ( readelf -r --use-dynamic "$BINARY_" | awk '{print $5}' | grep -E -q "^$FUNCTION" 2> /dev/null ) ; then
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
if [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if ( readelf -r --use-dynamic "${BINARY_}" | awk '{print $5}' | grep -E -q "^${FUNCTION}" 2> /dev/null ) ; then
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
if [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# For the mmap check we need the disasm after the call
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 20 "call.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 20 "call.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
else
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "$BINARY_" | grep -E -A 2 -B 20 "call.*$FUNCTION" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
r2 -e io.cache=true -e scr.color=false -q -c 'pI $s' "${BINARY_}" | grep -E -A 2 -B 20 "call.*${FUNCTION}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
fi
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 0 ]] ; then
|
||||
radare_color_output "${FUNCTION}"
|
||||
|
||||
COUNT_FUNC="$(grep -c -e "call.*$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c -e "call.*${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "call.*strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
# Test source: https://www.golem.de/news/mmap-codeanalyse-mit-sechs-zeilen-bash-2006-148878-2.html
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffffffffffff" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_MMAP_OK=$(grep -c "cmp.*0xffffffffffffffff" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
fi
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S14_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S14_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_print_top10_statistics() {
|
||||
@@ -454,39 +454,39 @@ radare_print_top10_statistics() {
|
||||
|
||||
sub_module_title "Top 10 legacy C functions - Radare2 disasm mode"
|
||||
|
||||
if [[ "$(find "$LOG_PATH_MODULE" -xdev -iname "vul_func_*_*-*.txt" | wc -l)" -gt 0 ]]; then
|
||||
if [[ "$(find "${LOG_PATH_MODULE}" -xdev -iname "vul_func_*_*-*.txt" | wc -l)" -gt 0 ]]; then
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
local SEARCH_TERM=""
|
||||
local F_COUNTER=0
|
||||
readarray -t RESULTS < <( find "$LOG_PATH_MODULE" -xdev -iname "vul_func_*_""$FUNCTION""-*.txt" 2> /dev/null | sed "s/.*vul_func_//" | sort -g -r | head -10 | sed "s/_""$FUNCTION""-/ /" | sed "s/\.txt//" 2> /dev/null || true)
|
||||
readarray -t RESULTS < <( find "${LOG_PATH_MODULE}" -xdev -iname "vul_func_*_""${FUNCTION}""-*.txt" 2> /dev/null | sed "s/.*vul_func_//" | sort -g -r | head -10 | sed "s/_""${FUNCTION}""-/ /" | sed "s/\.txt//" 2> /dev/null || true)
|
||||
|
||||
if [[ "${#RESULTS[@]}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] ""$FUNCTION"" - top 10 results:"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
print_output "[+] ""${FUNCTION}"" - top 10 results:"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
write_anchor "strcpysummary"
|
||||
fi
|
||||
for BINARY in "${RESULTS[@]}" ; do
|
||||
SEARCH_TERM="$(echo "$BINARY" | awk '{print $2}')"
|
||||
F_COUNTER="$(echo "$BINARY" | awk '{print $1}')"
|
||||
[[ "$F_COUNTER" -eq 0 ]] && continue
|
||||
SEARCH_TERM="$(echo "${BINARY}" | awk '{print $2}')"
|
||||
F_COUNTER="$(echo "${BINARY}" | awk '{print $1}')"
|
||||
[[ "${F_COUNTER}" -eq 0 ]] && continue
|
||||
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
# if we have the base linux config file we are checking it:
|
||||
if grep -E -q "^$SEARCH_TERM$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
printf "${GREEN}\t%-5.5s : %-15.15s : common linux file: yes${NC}\n" "$F_COUNTER" "$SEARCH_TERM" | tee -a "$LOG_FILE" || true
|
||||
if grep -E -q "^${SEARCH_TERM}$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
printf "${GREEN}\t%-5.5s : %-15.15s : common linux file: yes${NC}\n" "${F_COUNTER}" "${SEARCH_TERM}" | tee -a "${LOG_FILE}" || true
|
||||
else
|
||||
printf "${ORANGE}\t%-5.5s : %-15.15s : common linux file: no${NC}\n" "$F_COUNTER" "$SEARCH_TERM" | tee -a "$LOG_FILE" || true
|
||||
printf "${ORANGE}\t%-5.5s : %-15.15s : common linux file: no${NC}\n" "${F_COUNTER}" "${SEARCH_TERM}" | tee -a "${LOG_FILE}" || true
|
||||
fi
|
||||
else
|
||||
print_output "$(indent "$(orange "$F_COUNTER""\t:\t""$SEARCH_TERM")")"
|
||||
print_output "$(indent "$(orange "${F_COUNTER}""\t:\t""${SEARCH_TERM}")")"
|
||||
fi
|
||||
if [[ -f "$LOG_PATH_MODULE""/vul_func_""$F_COUNTER""_""$FUNCTION"-"$SEARCH_TERM"".txt" ]]; then
|
||||
write_link "$LOG_PATH_MODULE""/vul_func_""$F_COUNTER""_""$FUNCTION"-"$SEARCH_TERM"".txt"
|
||||
if [[ -f "${LOG_PATH_MODULE}""/vul_func_""${F_COUNTER}""_""${FUNCTION}"-"${SEARCH_TERM}"".txt" ]]; then
|
||||
write_link "${LOG_PATH_MODULE}""/vul_func_""${F_COUNTER}""_""${FUNCTION}"-"${SEARCH_TERM}"".txt"
|
||||
fi
|
||||
done
|
||||
print_ln
|
||||
echo "${#RESULTS[@]}" >> "$TMP_DIR"/S14_FCT_CNT.tmp
|
||||
echo "${#RESULTS[@]}" >> "${TMP_DIR}"/S14_FCT_CNT.tmp
|
||||
fi
|
||||
done
|
||||
else
|
||||
@@ -496,77 +496,77 @@ radare_print_top10_statistics() {
|
||||
|
||||
radare_color_output() {
|
||||
local FUNCTION="${1:-}"
|
||||
sed -i -r "s/^[[:alnum:]].*($FUNCTION).*/\x1b[31m&\x1b[0m/" "$FUNC_LOG" 2>/dev/null || true
|
||||
sed -i -r "s/^[[:alnum:]].*(${FUNCTION}).*/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
radare_log_bin_hardening() {
|
||||
local NAME="${1:-}"
|
||||
local FUNCTION="${2:-}"
|
||||
|
||||
if [[ -f "$LOG_DIR"/s12_binary_protection.txt ]]; then
|
||||
write_log "[*] Binary protection state of $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
write_link "$LOG_DIR/s12_binary_protection.txt" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
if [[ -f "${LOG_DIR}"/s12_binary_protection.txt ]]; then
|
||||
write_log "[*] Binary protection state of ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
write_link "${LOG_DIR}/s12_binary_protection.txt" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
# get headline:
|
||||
HEAD_BIN_PROT=$(grep "FORTIFY Fortified" "$LOG_DIR"/s12_binary_protection.txt | sed 's/FORTIFY.*//'| sort -u || true)
|
||||
write_log " $HEAD_BIN_PROT" "$FUNC_LOG"
|
||||
HEAD_BIN_PROT=$(grep "FORTIFY Fortified" "${LOG_DIR}"/s12_binary_protection.txt | sed 's/FORTIFY.*//'| sort -u || true)
|
||||
write_log " ${HEAD_BIN_PROT}" "${FUNC_LOG}"
|
||||
# get binary entry
|
||||
BIN_PROT=$(grep '/'"$NAME"' ' "$LOG_DIR"/s12_binary_protection.txt | sed 's/Symbols.*/Symbols/' | sort -u || true)
|
||||
write_log " $BIN_PROT" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
BIN_PROT=$(grep '/'"${NAME}"' ' "${LOG_DIR}"/s12_binary_protection.txt | sed 's/Symbols.*/Symbols/' | sort -u || true)
|
||||
write_log " ${BIN_PROT}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
fi
|
||||
|
||||
write_log "$NC" "$FUNC_LOG"
|
||||
write_log "[*] Function $ORANGE$FUNCTION$NC tear down of $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
write_log "${NC}" "${FUNC_LOG}"
|
||||
write_log "[*] Function ${ORANGE}${FUNCTION}${NC} tear down of ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
}
|
||||
|
||||
radare_log_func_footer() {
|
||||
local NAME="${1:-}"
|
||||
local FUNCTION="${2:-}"
|
||||
|
||||
write_log "" "$FUNC_LOG"
|
||||
write_log "[*] Function $ORANGE$FUNCTION$NC used $ORANGE$COUNT_FUNC$NC times $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
write_log "[*] Function ${ORANGE}${FUNCTION}${NC} used ${ORANGE}${COUNT_FUNC}${NC} times ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
}
|
||||
|
||||
radare_output_function_details()
|
||||
{
|
||||
write_s14_log()
|
||||
{
|
||||
OLD_LOG_FILE="$LOG_FILE"
|
||||
LOG_FILE="$3"
|
||||
print_output "$1"
|
||||
write_link "$2"
|
||||
if [[ -f "$LOG_FILE" ]]; then
|
||||
cat "$LOG_FILE" >> "$OLD_LOG_FILE" || true
|
||||
rm "$LOG_FILE" 2> /dev/null || true
|
||||
OLD_LOG_FILE="${LOG_FILE}"
|
||||
LOG_FILE="${3}"
|
||||
print_output "${1}"
|
||||
write_link "${2}"
|
||||
if [[ -f "${LOG_FILE}" ]]; then
|
||||
cat "${LOG_FILE}" >> "${OLD_LOG_FILE}" || true
|
||||
rm "${LOG_FILE}" 2> /dev/null || true
|
||||
fi
|
||||
LOG_FILE="$OLD_LOG_FILE"
|
||||
LOG_FILE="${OLD_LOG_FILE}"
|
||||
}
|
||||
|
||||
local BINARY_="${1:-}"
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
local FUNCTION="${2:-}"
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_")
|
||||
NAME=$(basename "${BINARY_}")
|
||||
|
||||
local LOG_FILE_LOC
|
||||
LOG_FILE_LOC="$LOG_PATH_MODULE"/vul_func_"$FUNCTION"-"$NAME".txt
|
||||
LOG_FILE_LOC="${LOG_PATH_MODULE}"/vul_func_"${FUNCTION}"-"${NAME}".txt
|
||||
|
||||
# check if this is common linux file:
|
||||
local COMMON_FILES_FOUND
|
||||
local SEARCH_TERM
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
SEARCH_TERM=$(basename "$BINARY_")
|
||||
if grep -q "^$SEARCH_TERM\$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
SEARCH_TERM=$(basename "${BINARY_}")
|
||||
if grep -q "^${SEARCH_TERM}\$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
COMMON_FILES_FOUND="${CYAN}"" - common linux file: yes - "
|
||||
write_log "[+] File $(print_path "$BINARY_") found in default Linux file dictionary" "$LOG_PATH_MODULE/common_linux_files.txt"
|
||||
write_log "[+] File $(print_path "${BINARY_}") found in default Linux file dictionary" "${LOG_PATH_MODULE}/common_linux_files.txt"
|
||||
CFF_CSV="true"
|
||||
else
|
||||
write_log "[+] File $(print_path "$BINARY_") not found in default Linux file dictionary" "$LOG_PATH_MODULE/common_linux_files.txt"
|
||||
write_log "[+] File $(print_path "${BINARY_}") not found in default Linux file dictionary" "${LOG_PATH_MODULE}/common_linux_files.txt"
|
||||
COMMON_FILES_FOUND="${RED}"" - common linux file: no -"
|
||||
CFF_CSV="false"
|
||||
fi
|
||||
@@ -574,14 +574,14 @@ radare_output_function_details()
|
||||
COMMON_FILES_FOUND=" -"
|
||||
fi
|
||||
|
||||
local LOG_FILE_LOC_OLD="$LOG_FILE_LOC"
|
||||
local LOG_FILE_LOC="$LOG_PATH_MODULE"/vul_func_"$COUNT_FUNC"_"$FUNCTION"-"$NAME".txt
|
||||
local LOG_FILE_LOC_OLD="${LOG_FILE_LOC}"
|
||||
local LOG_FILE_LOC="${LOG_PATH_MODULE}"/vul_func_"${COUNT_FUNC}"_"${FUNCTION}"-"${NAME}".txt
|
||||
|
||||
if [[ -f "$LOG_FILE_LOC_OLD" ]]; then
|
||||
mv "$LOG_FILE_LOC_OLD" "$LOG_FILE_LOC" 2> /dev/null || true
|
||||
if [[ -f "${LOG_FILE_LOC_OLD}" ]]; then
|
||||
mv "${LOG_FILE_LOC_OLD}" "${LOG_FILE_LOC}" 2> /dev/null || true
|
||||
fi
|
||||
|
||||
if [[ "$NETWORKING" -gt 1 ]]; then
|
||||
if [[ "${NETWORKING}" -gt 1 ]]; then
|
||||
NETWORKING_="${ORANGE}networking: yes${NC}"
|
||||
NW_CSV="yes"
|
||||
else
|
||||
@@ -589,15 +589,15 @@ radare_output_function_details()
|
||||
NW_CSV="no"
|
||||
fi
|
||||
|
||||
if [[ $COUNT_FUNC -ne 0 ]] ; then
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""${ORANGE}""strlen: ""$COUNT_STRLEN"" ""${NC}""/ ""$NETWORKING_""${NC}""\\n"
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""${ORANGE}""Correct error handling: ""$COUNT_MMAP_OK"" ""${NC}""\\n"
|
||||
if [[ ${COUNT_FUNC} -ne 0 ]] ; then
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${ORANGE}""strlen: ""${COUNT_STRLEN}"" ""${NC}""/ ""${NETWORKING_}""${NC}""\\n"
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${ORANGE}""Correct error handling: ""${COUNT_MMAP_OK}"" ""${NC}""\\n"
|
||||
else
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""$NETWORKING_""${NC}""\\n"
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${NETWORKING_}""${NC}""\\n"
|
||||
fi
|
||||
write_s14_log "$OUTPUT" "$LOG_FILE_LOC" "$LOG_PATH_MODULE""/vul_func_tmp_""$FUNCTION"-"$NAME"".txt"
|
||||
write_csv_log "$(print_path "$BINARY_")" "$FUNCTION" "$COUNT_FUNC" "$CFF_CSV" "$NW_CSV"
|
||||
write_s14_log "${OUTPUT}" "${LOG_FILE_LOC}" "${LOG_PATH_MODULE}""/vul_func_tmp_""${FUNCTION}"-"${NAME}"".txt"
|
||||
write_csv_log "$(print_path "${BINARY_}")" "${FUNCTION}" "${COUNT_FUNC}" "${CFF_CSV}" "${NW_CSV}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ S15_radare_decompile_checks()
|
||||
|
||||
local STRCPY_CNT=0
|
||||
|
||||
if [[ -n "$ARCH" ]] ; then
|
||||
if [[ -n "${ARCH}" ]] ; then
|
||||
# as this module is slow we only run it in case the objdump method from s13 was not working as expected
|
||||
# This module waits for S12 - binary protections and s13
|
||||
# check emba.log for S12_binary_protection starting
|
||||
@@ -40,46 +40,46 @@ S15_radare_decompile_checks()
|
||||
local VULNERABLE_FUNCTIONS=()
|
||||
local VULNERABLE_FUNCTIONS_VAR=""
|
||||
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "$CONFIG_DIR""/functions.cfg")"
|
||||
print_output "[*] Vulnerable functions: ""$( echo -e "$VULNERABLE_FUNCTIONS_VAR" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "$VULNERABLE_FUNCTIONS_VAR" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "${CONFIG_DIR}""/functions.cfg")"
|
||||
print_output "[*] Vulnerable functions: ""$( echo -e "${VULNERABLE_FUNCTIONS_VAR}" | sed ':a;N;$!ba;s/\n/ /g' )""\\n"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "${VULNERABLE_FUNCTIONS_VAR}" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
|
||||
write_csv_log "binary" "function" "function count" "common linux file" "networking"
|
||||
|
||||
for BINARY in "${BINARIES[@]}" ; do
|
||||
if ( file "$BINARY" | grep -q ELF ) ; then
|
||||
NAME=$(basename "$BINARY" 2> /dev/null)
|
||||
if ( file "${BINARY}" | grep -q ELF ) ; then
|
||||
NAME=$(basename "${BINARY}" 2> /dev/null)
|
||||
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
radare_decompilation "$BINARY" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
radare_decompilation "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S14+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S14+=( "${TMP_PID}" )
|
||||
else
|
||||
radare_decompilation "$BINARY" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
radare_decompilation "${BINARY}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S14[@]}"
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S14[@]}"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S14[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S14[@]}"
|
||||
|
||||
radare_decomp_print_top10_statistics "${VULNERABLE_FUNCTIONS[@]}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/S15_STRCPY_CNT.tmp ]]; then
|
||||
STRCPY_CNT=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S15_STRCPY_CNT.tmp)
|
||||
if [[ -f "${TMP_DIR}"/S15_STRCPY_CNT.tmp ]]; then
|
||||
STRCPY_CNT=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S15_STRCPY_CNT.tmp)
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$STRCPY_CNT"
|
||||
write_log "[*] Statistics:${STRCPY_CNT}"
|
||||
write_log ""
|
||||
write_log "[*] Statistics1:$ARCH"
|
||||
write_log "[*] Statistics1:${ARCH}"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$STRCPY_CNT"
|
||||
module_end_log "${FUNCNAME[0]}" "${STRCPY_CNT}"
|
||||
}
|
||||
|
||||
radare_decompilation(){
|
||||
@@ -87,70 +87,70 @@ radare_decompilation(){
|
||||
shift 1
|
||||
local VULNERABLE_FUNCTIONS=("$@")
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_" 2> /dev/null)
|
||||
NAME=$(basename "${BINARY_}" 2> /dev/null)
|
||||
local STRCPY_CNT=0
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
NETWORKING=$(readelf -a "$BINARY_" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
NETWORKING=$(readelf -a "${BINARY_}" --use-dynamic 2> /dev/null | grep -E "FUNC[[:space:]]+UND" | grep -c "\ bind\|\ socket\|\ accept\|\ recvfrom\|\ listen" 2> /dev/null || true)
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
FUNC_LOG="$LOG_PATH_MODULE""/decompilation_vul_func_""$FUNCTION""-""$NAME"".txt"
|
||||
radare_decomp_log_bin_hardening "$NAME" "$FUNCTION"
|
||||
FUNC_LOG="${LOG_PATH_MODULE}""/decompilation_vul_func_""${FUNCTION}""-""${NAME}"".txt"
|
||||
radare_decomp_log_bin_hardening "${NAME}" "${FUNCTION}"
|
||||
# with axt we are looking for function usages and store this in $FUNCTION_usage
|
||||
# pdd is for decompilation - with @@ we are working through all the identified functions
|
||||
# We analyse only 200 functions per binary
|
||||
timeout --preserve-status --signal SIGINT 3600 r2 -e io.cache=true -e scr.color=false -q -A -c \
|
||||
'axt `is~'"${FUNCTION}"'[2]`~[0] | tail -n +2 | grep -v "nofunc" | sort -u | tail -n 200 > '"${LOG_PATH_MODULE}""/""${FUNCTION}""_""${NAME}""_usage"'; pdd --assembly @@ `cat '"${LOG_PATH_MODULE}""/""${FUNCTION}""_""${NAME}"'_usage`' "$BINARY" 2> /dev/null >> "$FUNC_LOG" || true
|
||||
'axt `is~'"${FUNCTION}"'[2]`~[0] | tail -n +2 | grep -v "nofunc" | sort -u | tail -n 200 > '"${LOG_PATH_MODULE}""/""${FUNCTION}""_""${NAME}""_usage"'; pdd --assembly @@ `cat '"${LOG_PATH_MODULE}""/""${FUNCTION}""_""${NAME}"'_usage`' "${BINARY}" 2> /dev/null >> "${FUNC_LOG}" || true
|
||||
|
||||
if [[ -f "$FUNC_LOG" ]] && [[ $(wc -l "$FUNC_LOG" | awk '{print $1}') -gt 3 ]] ; then
|
||||
radare_decomp_color_output "$FUNCTION"
|
||||
if [[ -f "${FUNC_LOG}" ]] && [[ $(wc -l "${FUNC_LOG}" | awk '{print $1}') -gt 3 ]] ; then
|
||||
radare_decomp_color_output "${FUNCTION}"
|
||||
|
||||
# Todo: check this with other architectures
|
||||
COUNT_FUNC="$(grep -c "$FUNCTION" "$FUNC_LOG" 2> /dev/null || true)"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "strlen" "$FUNC_LOG" 2> /dev/null || true)
|
||||
COUNT_FUNC="$(grep -c "${FUNCTION}" "${FUNC_LOG}" 2> /dev/null || true)"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
COUNT_STRLEN=$(grep -c "strlen" "${FUNC_LOG}" 2> /dev/null || true)
|
||||
STRCPY_CNT=$((STRCPY_CNT+COUNT_FUNC))
|
||||
fi
|
||||
|
||||
radare_log_func_footer "$NAME" "$FUNCTION"
|
||||
radare_decomp_output_function_details "$BINARY_" "$FUNCTION"
|
||||
radare_log_func_footer "${NAME}" "${FUNCTION}"
|
||||
radare_decomp_output_function_details "${BINARY_}" "${FUNCTION}"
|
||||
else
|
||||
rm "$FUNC_LOG" || true
|
||||
rm "${FUNC_LOG}" || true
|
||||
fi
|
||||
done
|
||||
echo "$STRCPY_CNT" >> "$TMP_DIR"/S15_STRCPY_CNT.tmp
|
||||
echo "${STRCPY_CNT}" >> "${TMP_DIR}"/S15_STRCPY_CNT.tmp
|
||||
}
|
||||
|
||||
radare_decomp_log_bin_hardening() {
|
||||
local NAME="${1:-}"
|
||||
local FUNCTION="${2:-}"
|
||||
|
||||
if [[ -f "$LOG_DIR"/s12_binary_protection.txt ]]; then
|
||||
write_log "[*] Binary protection state of $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
# write_link "$LOG_DIR/s12_binary_protection.txt" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
if [[ -f "${LOG_DIR}"/s12_binary_protection.txt ]]; then
|
||||
write_log "[*] Binary protection state of ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
# write_link "$LOG_DIR/s12_binary_protection.txt" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
# get headline:
|
||||
HEAD_BIN_PROT=$(grep "FORTIFY Fortified" "$LOG_DIR"/s12_binary_protection.txt | sed 's/FORTIFY.*//'| sort -u || true)
|
||||
write_log " $HEAD_BIN_PROT" "$FUNC_LOG"
|
||||
HEAD_BIN_PROT=$(grep "FORTIFY Fortified" "${LOG_DIR}"/s12_binary_protection.txt | sed 's/FORTIFY.*//'| sort -u || true)
|
||||
write_log " ${HEAD_BIN_PROT}" "${FUNC_LOG}"
|
||||
# get binary entry
|
||||
BIN_PROT=$(grep '/'"$NAME"' ' "$LOG_DIR"/s12_binary_protection.txt | sed 's/Symbols.*/Symbols/' | sort -u || true)
|
||||
write_log " $BIN_PROT" "$FUNC_LOG"
|
||||
write_log "" "$FUNC_LOG"
|
||||
BIN_PROT=$(grep '/'"${NAME}"' ' "${LOG_DIR}"/s12_binary_protection.txt | sed 's/Symbols.*/Symbols/' | sort -u || true)
|
||||
write_log " ${BIN_PROT}" "${FUNC_LOG}"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
fi
|
||||
|
||||
write_log "$NC" "$FUNC_LOG"
|
||||
write_log "${NC}" "${FUNC_LOG}"
|
||||
# not working - check this:
|
||||
# if [[ -d "$LOG_DIR"/s14_weak_func_radare_check/ ]] && [[ "$(find "$LOG_DIR"/s14_weak_func_radare_check/ -name "vul_func_*""$FUNCTION""-""$NAME"".txt" | wc -l | awk '{print $1}')" -gt 0 ]]; then
|
||||
# write_log "[*] Function $ORANGE$FUNCTION$NC tear down of $ORANGE$NAME$NC / Switch to Radare2 disasm$NC" "$FUNC_LOG"
|
||||
# write_link "$(find "$LOG_DIR"/s14_weak_func_radare_check/ -name "vul_func_*""$FUNCTION""-""$NAME"".txt")" "$FUNC_LOG"
|
||||
# elif [[ -d "$LOG_DIR"/s13_weak_func_check/ ]] && [[ "$(find "$LOG_DIR"/s13_weak_func_check/ -name "vul_func_*""$FUNCTION""-""$NAME"".txt" | wc -l | awk '{print $1}')" -gt 0 ]]; then
|
||||
# write_log "[*] Function $ORANGE$FUNCTION$NC tear down of $ORANGE$NAME$NC / Switch to Objdump disasm$NC" "$FUNC_LOG"
|
||||
# write_link "$(find "$LOG_DIR"/s13_weak_func_check/ -name "vul_func_*""$FUNCTION""-""$NAME"".txt")" "$FUNC_LOG"
|
||||
# if [[ -d "${LOG_DIR}"/s14_weak_func_radare_check/ ]] && [[ "$(find "${LOG_DIR}"/s14_weak_func_radare_check/ -name "vul_func_*""${FUNCTION}""-""${NAME}"".txt" | wc -l | awk '{print $1}')" -gt 0 ]]; then
|
||||
# write_log "[*] Function $ORANGE$FUNCTION$NC tear down of $ORANGE$NAME$NC / Switch to Radare2 disasm$NC" "${FUNC_LOG}"
|
||||
# write_link "$(find "${LOG_DIR}"/s14_weak_func_radare_check/ -name "vul_func_*""${FUNCTION}""-""${NAME}"".txt")" "${FUNC_LOG}"
|
||||
# elif [[ -d "${LOG_DIR}"/s13_weak_func_check/ ]] && [[ "$(find "${LOG_DIR}"/s13_weak_func_check/ -name "vul_func_*""${FUNCTION}""-""${NAME}"".txt" | wc -l | awk '{print $1}')" -gt 0 ]]; then
|
||||
# write_log "[*] Function $ORANGE$FUNCTION$NC tear down of $ORANGE$NAME$NC / Switch to Objdump disasm$NC" "${FUNC_LOG}"
|
||||
# write_link "$(find "${LOG_DIR}"/s13_weak_func_check/ -name "vul_func_*""${FUNCTION}""-""${NAME}"".txt")" "${FUNC_LOG}"
|
||||
# else
|
||||
write_log "[*] Function $ORANGE$FUNCTION$NC tear down of $ORANGE$NAME$NC" "$FUNC_LOG"
|
||||
write_log "[*] Function ${ORANGE}${FUNCTION}${NC} tear down of ${ORANGE}${NAME}${NC}" "${FUNC_LOG}"
|
||||
# fi
|
||||
write_log "" "$FUNC_LOG"
|
||||
write_log "" "${FUNC_LOG}"
|
||||
}
|
||||
|
||||
radare_decomp_print_top10_statistics() {
|
||||
@@ -163,40 +163,40 @@ radare_decomp_print_top10_statistics() {
|
||||
|
||||
sub_module_title "Top 10 legacy C functions - Radare2 decompilation mode"
|
||||
|
||||
if [[ "$(find "$LOG_PATH_MODULE" -xdev -iname "vul_func_*_*-*.txt" | wc -l)" -gt 0 ]]; then
|
||||
if [[ "$(find "${LOG_PATH_MODULE}" -xdev -iname "vul_func_*_*-*.txt" | wc -l)" -gt 0 ]]; then
|
||||
for FUNCTION in "${VULNERABLE_FUNCTIONS[@]}" ; do
|
||||
local SEARCH_TERM=""
|
||||
local F_COUNTER=0
|
||||
readarray -t RESULTS < <( find "$LOG_PATH_MODULE" -xdev -iname "vul_func_*_""$FUNCTION""-*.txt" 2> /dev/null | sed "s/.*vul_func_//" | sort -g -r | head -10 | sed "s/_""$FUNCTION""-/ /" | sed "s/\.txt//" 2> /dev/null || true)
|
||||
readarray -t RESULTS < <( find "${LOG_PATH_MODULE}" -xdev -iname "vul_func_*_""${FUNCTION}""-*.txt" 2> /dev/null | sed "s/.*vul_func_//" | sort -g -r | head -10 | sed "s/_""${FUNCTION}""-/ /" | sed "s/\.txt//" 2> /dev/null || true)
|
||||
|
||||
if [[ "${#RESULTS[@]}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] ""$FUNCTION"" - top 10 results:"
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
print_output "[+] ""${FUNCTION}"" - top 10 results:"
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
write_anchor "strcpysummary"
|
||||
fi
|
||||
for BINARY in "${RESULTS[@]}" ; do
|
||||
SEARCH_TERM="$(echo "$BINARY" | awk '{print $2}')"
|
||||
F_COUNTER="$(echo "$BINARY" | awk '{print $1}')"
|
||||
[[ "$F_COUNTER" -eq 0 ]] && continue
|
||||
SEARCH_TERM="$(echo "${BINARY}" | awk '{print $2}')"
|
||||
F_COUNTER="$(echo "${BINARY}" | awk '{print $1}')"
|
||||
[[ "${F_COUNTER}" -eq 0 ]] && continue
|
||||
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
# if we have the base linux config file we are checking it:
|
||||
if grep -E -q "^$SEARCH_TERM$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
printf "${GREEN}\t%-5.5s : %-15.15s : common linux file: yes${NC}\n" "$F_COUNTER" "$SEARCH_TERM" | tee -a "$LOG_FILE" || true
|
||||
if grep -E -q "^${SEARCH_TERM}$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
printf "${GREEN}\t%-5.5s : %-15.15s : common linux file: yes${NC}\n" "${F_COUNTER}" "${SEARCH_TERM}" | tee -a "${LOG_FILE}" || true
|
||||
else
|
||||
printf "${ORANGE}\t%-5.5s : %-15.15s : common linux file: no${NC}\n" "$F_COUNTER" "$SEARCH_TERM" | tee -a "$LOG_FILE" || true
|
||||
printf "${ORANGE}\t%-5.5s : %-15.15s : common linux file: no${NC}\n" "${F_COUNTER}" "${SEARCH_TERM}" | tee -a "${LOG_FILE}" || true
|
||||
fi
|
||||
else
|
||||
print_output "$(indent "$(orange "$F_COUNTER""\t:\t""$SEARCH_TERM")")"
|
||||
print_output "$(indent "$(orange "${F_COUNTER}""\t:\t""${SEARCH_TERM}")")"
|
||||
fi
|
||||
if [[ -f "$LOG_PATH_MODULE""/vul_func_""$F_COUNTER""_""$FUNCTION"-"$SEARCH_TERM"".txt" ]]; then
|
||||
write_link "$LOG_PATH_MODULE""/vul_func_""$F_COUNTER""_""$FUNCTION"-"$SEARCH_TERM"".txt"
|
||||
if [[ -f "${LOG_PATH_MODULE}""/vul_func_""${F_COUNTER}""_""${FUNCTION}"-"${SEARCH_TERM}"".txt" ]]; then
|
||||
write_link "${LOG_PATH_MODULE}""/vul_func_""${F_COUNTER}""_""${FUNCTION}"-"${SEARCH_TERM}"".txt"
|
||||
# FIXME
|
||||
if [[ "${GPT_OPTION}" -gt 0 ]]; then
|
||||
print_output "[*] Asking OpenAI chatbot about ${LOG_PATH_MODULE}/vul_func_${F_COUNTER}_${FUNCTION}-${SEARCH_TERM}.txt"
|
||||
GPT_ANCHOR_="$(openssl rand -hex 8)"
|
||||
# "${GPT_INPUT_FILE_}" "$GPT_ANCHOR_" "$GPT_PRIO_" "$GPT_QUESTION_" "$GPT_OUTPUT_FILE_" "cost=$GPT_TOKENS_" "$GPT_RESPONSE_"
|
||||
# "${GPT_INPUT_FILE_}" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION_}" "${GPT_OUTPUT_FILE_}" "cost=$GPT_TOKENS_" "${GPT_RESPONSE_}"
|
||||
write_csv_gpt_tmp "${LOG_PATH_MODULE}/vul_func_${F_COUNTER}_${FUNCTION}-${SEARCH_TERM}.txt" "${GPT_ANCHOR}" "${GPT_PRIO}" "Can you give me a side by side desciption of the following code in a table, where on the left is the code and on the right the desciption. And please use proper spacing and | to make it terminal friendly:" "${LOG_PATH_MODULE}/vul_func_${F_COUNTER}_${FUNCTION}-${SEARCH_TERM}.txt" "" ""
|
||||
# add ChatGPT link
|
||||
printf '%s\n\n' "" >> "${LOG_PATH_MODULE}/vul_func_${F_COUNTER}_${FUNCTION}-${SEARCH_TERM}.txt"
|
||||
@@ -214,45 +214,45 @@ radare_decomp_print_top10_statistics() {
|
||||
|
||||
radare_decomp_color_output() {
|
||||
local FUNCTION="${1:-}"
|
||||
sed -i -r "s/.* \| .*($FUNCTION).*$/\x1b[31m&\x1b[0m/" "$FUNC_LOG" 2>/dev/null || true
|
||||
sed -i -r "s/.* \| .*(${FUNCTION}).*$/\x1b[31m&\x1b[0m/" "${FUNC_LOG}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
radare_decomp_output_function_details() {
|
||||
write_s15_log()
|
||||
{
|
||||
OLD_LOG_FILE="$LOG_FILE"
|
||||
LOG_FILE="$3"
|
||||
print_output "$1"
|
||||
write_link "$2"
|
||||
if [[ -f "$LOG_FILE" ]]; then
|
||||
cat "$LOG_FILE" >> "$OLD_LOG_FILE" || true
|
||||
rm "$LOG_FILE" 2> /dev/null || true
|
||||
OLD_LOG_FILE="${LOG_FILE}"
|
||||
LOG_FILE="${3}"
|
||||
print_output "${1}"
|
||||
write_link "${2}"
|
||||
if [[ -f "${LOG_FILE}" ]]; then
|
||||
cat "${LOG_FILE}" >> "${OLD_LOG_FILE}" || true
|
||||
rm "${LOG_FILE}" 2> /dev/null || true
|
||||
fi
|
||||
LOG_FILE="$OLD_LOG_FILE"
|
||||
LOG_FILE="${OLD_LOG_FILE}"
|
||||
}
|
||||
|
||||
local BINARY_="${1:-}"
|
||||
if ! [[ -f "$BINARY_" ]]; then
|
||||
if ! [[ -f "${BINARY_}" ]]; then
|
||||
return
|
||||
fi
|
||||
local FUNCTION="${2:-}"
|
||||
local NAME=""
|
||||
NAME=$(basename "$BINARY_")
|
||||
NAME=$(basename "${BINARY_}")
|
||||
|
||||
local LOG_FILE_LOC
|
||||
LOG_FILE_LOC="$LOG_PATH_MODULE"/decompilation_vul_func_"$FUNCTION"-"$NAME".txt
|
||||
LOG_FILE_LOC="${LOG_PATH_MODULE}"/decompilation_vul_func_"${FUNCTION}"-"${NAME}".txt
|
||||
|
||||
# check if this is common linux file:
|
||||
local COMMON_FILES_FOUND
|
||||
local SEARCH_TERM
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
SEARCH_TERM=$(basename "$BINARY_")
|
||||
if grep -q "^$SEARCH_TERM\$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
SEARCH_TERM=$(basename "${BINARY_}")
|
||||
if grep -q "^${SEARCH_TERM}\$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
COMMON_FILES_FOUND="${CYAN}"" - common linux file: yes - "
|
||||
write_log "[+] File $(print_path "$BINARY_") found in default Linux file dictionary" "$LOG_PATH_MODULE/common_linux_files.txt"
|
||||
write_log "[+] File $(print_path "${BINARY_}") found in default Linux file dictionary" "${LOG_PATH_MODULE}/common_linux_files.txt"
|
||||
CFF_CSV="true"
|
||||
else
|
||||
write_log "[+] File $(print_path "$BINARY_") not found in default Linux file dictionary" "$LOG_PATH_MODULE/common_linux_files.txt"
|
||||
write_log "[+] File $(print_path "${BINARY_}") not found in default Linux file dictionary" "${LOG_PATH_MODULE}/common_linux_files.txt"
|
||||
COMMON_FILES_FOUND="${RED}"" - common linux file: no -"
|
||||
CFF_CSV="false"
|
||||
fi
|
||||
@@ -260,14 +260,14 @@ radare_decomp_output_function_details() {
|
||||
COMMON_FILES_FOUND=" -"
|
||||
fi
|
||||
|
||||
local LOG_FILE_LOC_OLD="$LOG_FILE_LOC"
|
||||
local LOG_FILE_LOC="$LOG_PATH_MODULE"/vul_func_"$COUNT_FUNC"_"$FUNCTION"-"$NAME".txt
|
||||
local LOG_FILE_LOC_OLD="${LOG_FILE_LOC}"
|
||||
local LOG_FILE_LOC="${LOG_PATH_MODULE}"/vul_func_"${COUNT_FUNC}"_"${FUNCTION}"-"${NAME}".txt
|
||||
|
||||
if [[ -f "$LOG_FILE_LOC_OLD" ]]; then
|
||||
mv "$LOG_FILE_LOC_OLD" "$LOG_FILE_LOC" 2> /dev/null || true
|
||||
if [[ -f "${LOG_FILE_LOC_OLD}" ]]; then
|
||||
mv "${LOG_FILE_LOC_OLD}" "${LOG_FILE_LOC}" 2> /dev/null || true
|
||||
fi
|
||||
|
||||
if [[ "$NETWORKING" -gt 1 ]]; then
|
||||
if [[ "${NETWORKING}" -gt 1 ]]; then
|
||||
local NW_CSV="yes"
|
||||
local NETWORKING_="${ORANGE}networking: ${NW_CSV}${NC}"
|
||||
else
|
||||
@@ -275,16 +275,16 @@ radare_decomp_output_function_details() {
|
||||
local NETWORKING_="${GREEN}networking: ${NW_CSV}${NC}"
|
||||
fi
|
||||
|
||||
if [[ $COUNT_FUNC -ne 0 ]] ; then
|
||||
if [[ "$FUNCTION" == "strcpy" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""${ORANGE}""strlen: ""$COUNT_STRLEN"" ""${NC}""/ ""$NETWORKING_""${NC}""\\n"
|
||||
elif [[ "$FUNCTION" == "mmap" ]] ; then
|
||||
if [[ ${COUNT_FUNC} -ne 0 ]] ; then
|
||||
if [[ "${FUNCTION}" == "strcpy" ]] ; then
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${ORANGE}""strlen: ""${COUNT_STRLEN}"" ""${NC}""/ ""${NETWORKING_}""${NC}""\\n"
|
||||
elif [[ "${FUNCTION}" == "mmap" ]] ; then
|
||||
local COUNT_MMAP_OK="NA"
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""${ORANGE}""Correct error handling: ""$COUNT_MMAP_OK"" ""${NC}""\\n"
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${ORANGE}""Correct error handling: ""${COUNT_MMAP_OK}"" ""${NC}""\\n"
|
||||
else
|
||||
OUTPUT="[+] ""$(print_path "$BINARY_")""$COMMON_FILES_FOUND""${NC}"" Vulnerable function: ""${CYAN}""$FUNCTION"" ""${NC}""/ ""${RED}""Function count: ""$COUNT_FUNC"" ""${NC}""/ ""$NETWORKING_""${NC}""\\n"
|
||||
OUTPUT="[+] ""$(print_path "${BINARY_}")""${COMMON_FILES_FOUND}""${NC}"" Vulnerable function: ""${CYAN}""${FUNCTION}"" ""${NC}""/ ""${RED}""Function count: ""${COUNT_FUNC}"" ""${NC}""/ ""${NETWORKING_}""${NC}""\\n"
|
||||
fi
|
||||
write_s15_log "$OUTPUT" "$LOG_FILE_LOC" "$LOG_PATH_MODULE""/decompilation_vul_func_""$FUNCTION"-"$NAME"".txt"
|
||||
write_csv_log "$(print_path "$BINARY_")" "$FUNCTION" "$COUNT_FUNC" "$CFF_CSV" "$NW_CSV"
|
||||
write_s15_log "${OUTPUT}" "${LOG_FILE_LOC}" "${LOG_PATH_MODULE}""/decompilation_vul_func_""${FUNCTION}"-"${NAME}"".txt"
|
||||
write_csv_log "$(print_path "${BINARY_}")" "${FUNCTION}" "${COUNT_FUNC}" "${CFF_CSV}" "${NW_CSV}"
|
||||
fi
|
||||
}
|
||||
|
||||
+30
-30
@@ -31,67 +31,67 @@ apk_identifier() {
|
||||
export APK_ARR=()
|
||||
local APK=""
|
||||
|
||||
mapfile -t APK_ARR < <(find "$FIRMWARE_PATH" -type f -name "*.apk")
|
||||
mapfile -t APK_ARR < <(find "${FIRMWARE_PATH}" -type f -name "*.apk")
|
||||
for APK in "${APK_ARR[@]}"; do
|
||||
print_output "[+] Found Android apk - $ORANGE$(print_path "$APK")$NC"
|
||||
print_output "[+] Found Android apk - ${ORANGE}$(print_path "${APK}")${NC}"
|
||||
done
|
||||
}
|
||||
|
||||
apk_checker() {
|
||||
sub_module_title "Android apk analysis"
|
||||
local APK=""
|
||||
if ! [[ -d "$EXT_DIR"/APKHunt ]]; then
|
||||
if ! [[ -d "${EXT_DIR}"/APKHunt ]]; then
|
||||
print_output "[-] APKHunt installation missing."
|
||||
return
|
||||
fi
|
||||
|
||||
export GOTMPDIR="$TMP_DIR"/apkhunt
|
||||
mkdir "$GOTMPDIR"
|
||||
export GOTMPDIR="${TMP_DIR}"/apkhunt
|
||||
mkdir "${GOTMPDIR}"
|
||||
|
||||
write_csv_log "APK" "Identified issues" "log path"
|
||||
|
||||
for APK in "${APK_ARR[@]}"; do
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
apk_checker_helper "$APK" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
apk_checker_helper "${APK}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S17+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S17+=( "${TMP_PID}" )
|
||||
else
|
||||
apk_checker_helper "$APK"
|
||||
apk_checker_helper "${APK}"
|
||||
fi
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S17[@]}"
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S17[@]}"
|
||||
fi
|
||||
done
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S17[@]}"
|
||||
[[ -d "$GOTMPDIR" ]] && rm -rf "$GOTMPDIR"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S17[@]}"
|
||||
[[ -d "${GOTMPDIR}" ]] && rm -rf "${GOTMPDIR}"
|
||||
}
|
||||
|
||||
apk_checker_helper() {
|
||||
local APK="${1:-}"
|
||||
! [[ -f "$APK" ]] && return
|
||||
! [[ -f "${APK}" ]] && return
|
||||
local APK_ISSUES=0
|
||||
|
||||
print_output "[*] Testing Android apk with APKHunt - $ORANGE$(print_path "$APK")$NC"
|
||||
go run "$EXT_DIR"/APKHunt/apkhunt.go -p "$APK" -l 2>&1 | tee -a "$LOG_PATH_MODULE/APKHunt-$(basename -s .apk "$APK").txt"
|
||||
print_output "[*] Testing Android apk with APKHunt - ${ORANGE}$(print_path "${APK}")${NC}"
|
||||
go run "${EXT_DIR}"/APKHunt/apkhunt.go -p "${APK}" -l 2>&1 | tee -a "${LOG_PATH_MODULE}/APKHunt-$(basename -s .apk "${APK}").txt"
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE/APKHunt-$(basename -s .apk "$APK").txt" ]]; then
|
||||
APK_ISSUES=$(grep -c -E "^[0-9]+:" "$LOG_PATH_MODULE/APKHunt-$(basename -s .apk "$APK").txt" || true)
|
||||
if [[ "$APK_ISSUES" -gt 0 ]]; then
|
||||
print_output "[+] APKHunt found $ORANGE$APK_ISSUES$GREEN areas of interest in $ORANGE$(print_path "$APK")$NC" "" "$LOG_PATH_MODULE/APKHunt-$(basename -s .apk "$APK").txt"
|
||||
if [[ -f "${LOG_PATH_MODULE}/APKHunt-$(basename -s .apk "${APK}").txt" ]]; then
|
||||
APK_ISSUES=$(grep -c -E "^[0-9]+:" "${LOG_PATH_MODULE}/APKHunt-$(basename -s .apk "${APK}").txt" || true)
|
||||
if [[ "${APK_ISSUES}" -gt 0 ]]; then
|
||||
print_output "[+] APKHunt found ${ORANGE}${APK_ISSUES}${GREEN} areas of interest in ${ORANGE}$(print_path "${APK}")${NC}" "" "${LOG_PATH_MODULE}/APKHunt-$(basename -s .apk "${APK}").txt"
|
||||
else
|
||||
print_output "[*] APKHunt results for $ORANGE$(print_path "$APK")$NC" "" "$LOG_PATH_MODULE/APKHunt-$(basename -s .apk "$APK").txt"
|
||||
print_output "[*] APKHunt results for ${ORANGE}$(print_path "${APK}")${NC}" "" "${LOG_PATH_MODULE}/APKHunt-$(basename -s .apk "${APK}").txt"
|
||||
fi
|
||||
|
||||
write_csv_log "$APK" "$APK_ISSUES" "$LOG_PATH_MODULE/APKHunt-$(basename -s .apk "$APK").txt"
|
||||
write_csv_log "${APK}" "${APK_ISSUES}" "${LOG_PATH_MODULE}/APKHunt-$(basename -s .apk "${APK}").txt"
|
||||
else
|
||||
print_output "[-] No APKHunt Android apk analysis results available - $(print_path "$APK")"
|
||||
write_csv_log "$APK" "$APK_ISSUES" "NA"
|
||||
print_output "[-] No APKHunt Android apk analysis results available - $(print_path "${APK}")"
|
||||
write_csv_log "${APK}" "${APK_ISSUES}" "NA"
|
||||
fi
|
||||
|
||||
APK_DIR_NAME=$(dirname "$APK")
|
||||
APK_STACS_DIR=$(grep "APK Static Analysis Path" "$APK_DIR_NAME"/APKHunt_"$(basename -s .apk "$APK")"*.txt)
|
||||
APK_JAR="$APK_DIR_NAME"/"$(basename -s .apk "$APK")".jar
|
||||
[[ -d "$APK_STACS_DIR" ]] && rm -rf "$APK_STACS_DIR"
|
||||
[[ -f "$APK_JAR" ]] && rm -rf "$APK_JAR"
|
||||
APK_DIR_NAME=$(dirname "${APK}")
|
||||
APK_STACS_DIR=$(grep "APK Static Analysis Path" "${APK_DIR_NAME}"/APKHunt_"$(basename -s .apk "${APK}")"*.txt)
|
||||
APK_JAR="${APK_DIR_NAME}"/"$(basename -s .apk "${APK}")".jar
|
||||
[[ -d "${APK_STACS_DIR}" ]] && rm -rf "${APK_STACS_DIR}"
|
||||
[[ -f "${APK_JAR}" ]] && rm -rf "${APK_JAR}"
|
||||
}
|
||||
|
||||
+51
-51
@@ -30,86 +30,86 @@ S20_shell_check()
|
||||
local SEMGREP=1
|
||||
local NEG_LOG=0
|
||||
|
||||
mapfile -t SH_SCRIPTS < <( find "$FIRMWARE_PATH" -xdev -type f -type f -exec file {} \; | grep "shell script, ASCII text executable" 2>/dev/null | cut -d: -f1 | sort -u || true )
|
||||
mapfile -t SH_SCRIPTS < <( find "${FIRMWARE_PATH}" -xdev -type f -type f -exec file {} \; | grep "shell script, ASCII text executable" 2>/dev/null | cut -d: -f1 | sort -u || true )
|
||||
write_csv_log "Script path" "Shell issues detected" "common linux file" "shellcheck/semgrep"
|
||||
|
||||
if [[ $SHELLCHECK -eq 1 ]] ; then
|
||||
if [[ ${SHELLCHECK} -eq 1 ]] ; then
|
||||
sub_module_title "Check scripts with shellcheck"
|
||||
for SH_SCRIPT in "${SH_SCRIPTS[@]}" ; do
|
||||
if ( file "$SH_SCRIPT" | grep -q "shell script" ) ; then
|
||||
if ( file "${SH_SCRIPT}" | grep -q "shell script" ) ; then
|
||||
((S20_SCRIPTS+=1))
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
s20_script_check "$SH_SCRIPT" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
s20_script_check "${SH_SCRIPT}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S20+=( "$TMP_PID" )
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S20[@]}"
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S20+=( "${TMP_PID}" )
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S20[@]}"
|
||||
continue
|
||||
else
|
||||
s20_script_check "$SH_SCRIPT"
|
||||
s20_script_check "${SH_SCRIPT}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S20[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S20[@]}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/S20_VULNS.tmp ]]; then
|
||||
S20_SHELL_VULNS=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S20_VULNS.tmp)
|
||||
rm "$TMP_DIR"/S20_VULNS.tmp
|
||||
if [[ -f "${TMP_DIR}"/S20_VULNS.tmp ]]; then
|
||||
S20_SHELL_VULNS=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S20_VULNS.tmp)
|
||||
rm "${TMP_DIR}"/S20_VULNS.tmp
|
||||
fi
|
||||
[[ "$S20_SHELL_VULNS" -gt 0 ]] && NEG_LOG=1
|
||||
[[ "${S20_SHELL_VULNS}" -gt 0 ]] && NEG_LOG=1
|
||||
|
||||
print_ln
|
||||
if [[ "$S20_SHELL_VULNS" -gt 0 ]]; then
|
||||
if [[ "${S20_SHELL_VULNS}" -gt 0 ]]; then
|
||||
sub_module_title "Summary of shell issues (shellcheck)"
|
||||
print_output "[+] Found ""$ORANGE""$S20_SHELL_VULNS"" issues""$GREEN"" in ""$ORANGE""$S20_SCRIPTS""$GREEN"" shell scripts""$NC""\\n"
|
||||
print_output "[+] Found ""${ORANGE}""${S20_SHELL_VULNS}"" issues""${GREEN}"" in ""${ORANGE}""${S20_SCRIPTS}""${GREEN}"" shell scripts""${NC}""\\n"
|
||||
fi
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$S20_SHELL_VULNS:$S20_SCRIPTS"
|
||||
write_log "[*] Statistics:${S20_SHELL_VULNS}:${S20_SCRIPTS}"
|
||||
|
||||
mapfile -t S20_VULN_TYPES < <(grep "\^--\ SC[0-9]" "$LOG_PATH_MODULE"/shellchecker_* 2>/dev/null | cut -d: -f2- | sed -e 's/\ \+\^--\ //g' | sed -e 's/\^--\ //g' | sort -u -t: -k1,1 || true)
|
||||
mapfile -t S20_VULN_TYPES < <(grep "\^--\ SC[0-9]" "${LOG_PATH_MODULE}"/shellchecker_* 2>/dev/null | cut -d: -f2- | sed -e 's/\ \+\^--\ //g' | sed -e 's/\^--\ //g' | sort -u -t: -k1,1 || true)
|
||||
for VTYPE in "${S20_VULN_TYPES[@]}" ; do
|
||||
print_output "$(indent "$NC""[""$GREEN""+""$NC""]""$GREEN"" ""$VTYPE""$NC")"
|
||||
print_output "$(indent "${NC}""[""${GREEN}""+""${NC}""]""${GREEN}"" ""${VTYPE}""${NC}")"
|
||||
done
|
||||
|
||||
else
|
||||
print_output "[-] Shellchecker is disabled ... no tests performed"
|
||||
fi
|
||||
|
||||
if [[ $SEMGREP -eq 1 ]] ; then
|
||||
if [[ ${SEMGREP} -eq 1 ]] ; then
|
||||
sub_module_title "Check scripts with semgrep"
|
||||
local S20_SEMGREP_SCRIPTS=0
|
||||
local S20_SEMGREP_VULNS=0
|
||||
local SHELL_LOG="$LOG_PATH_MODULE"/semgrep.log
|
||||
local SHELL_LOG="${LOG_PATH_MODULE}"/semgrep.log
|
||||
|
||||
semgrep --disable-version-check --config "$EXT_DIR"/semgrep-rules/bash "$LOG_DIR"/firmware/ > "$SHELL_LOG" 2>&1 || true
|
||||
semgrep --disable-version-check --config "${EXT_DIR}"/semgrep-rules/bash "${LOG_DIR}"/firmware/ > "${SHELL_LOG}" 2>&1 || true
|
||||
|
||||
if [[ -f "$SHELL_LOG" ]]; then
|
||||
S20_SEMGREP_ISSUES=$(grep "\ findings\." "$SHELL_LOG" | cut -d: -f2 | awk '{print $1}' || true)
|
||||
S20_SEMGREP_VULNS=$(grep -c "semgrep-rules.bash.lang.security" "$SHELL_LOG" || true)
|
||||
S20_SEMGREP_SCRIPTS=$(grep "\ findings\." "$SHELL_LOG" | awk '{print $5}' || true)
|
||||
if [[ -f "${SHELL_LOG}" ]]; then
|
||||
S20_SEMGREP_ISSUES=$(grep "\ findings\." "${SHELL_LOG}" | cut -d: -f2 | awk '{print $1}' || true)
|
||||
S20_SEMGREP_VULNS=$(grep -c "semgrep-rules.bash.lang.security" "${SHELL_LOG}" || true)
|
||||
S20_SEMGREP_SCRIPTS=$(grep "\ findings\." "${SHELL_LOG}" | awk '{print $5}' || true)
|
||||
print_ln
|
||||
sub_module_title "Summary of shell issues (semgrep)"
|
||||
if [[ "$S20_SEMGREP_VULNS" -gt 0 ]]; then
|
||||
print_output "[+] Found ""$ORANGE""$S20_SEMGREP_ISSUES"" issues""$GREEN"" (""$ORANGE""$S20_SEMGREP_VULNS"" vulnerabilites${GREEN}) in ""$ORANGE""$S20_SEMGREP_SCRIPTS""$GREEN"" shell scripts""$NC" "" "$SHELL_LOG"
|
||||
elif [[ "$S20_SEMGREP_ISSUES" -gt 0 ]]; then
|
||||
print_output "[+] Found ""$ORANGE""$S20_SEMGREP_ISSUES"" issues""$GREEN"" in ""$ORANGE""$S20_SEMGREP_SCRIPTS""$GREEN"" shell scripts""$NC" "" "$SHELL_LOG"
|
||||
if [[ "${S20_SEMGREP_VULNS}" -gt 0 ]]; then
|
||||
print_output "[+] Found ""${ORANGE}""${S20_SEMGREP_ISSUES}"" issues""${GREEN}"" (""${ORANGE}""${S20_SEMGREP_VULNS}"" vulnerabilites${GREEN}) in ""${ORANGE}""${S20_SEMGREP_SCRIPTS}""${GREEN}"" shell scripts""${NC}" "" "${SHELL_LOG}"
|
||||
elif [[ "${S20_SEMGREP_ISSUES}" -gt 0 ]]; then
|
||||
print_output "[+] Found ""${ORANGE}""${S20_SEMGREP_ISSUES}"" issues""${GREEN}"" in ""${ORANGE}""${S20_SEMGREP_SCRIPTS}""${GREEN}"" shell scripts""${NC}" "" "${SHELL_LOG}"
|
||||
fi
|
||||
# highlight security findings in semgrep log:
|
||||
sed -i -r "s/.*external\.semgrep-rules\.bash\.lang\.security.*/\x1b[32m&\x1b[0m/" "$SHELL_LOG"
|
||||
sed -i -r "s/.*external\.semgrep-rules\.bash\.lang\.security.*/\x1b[32m&\x1b[0m/" "${SHELL_LOG}"
|
||||
fi
|
||||
|
||||
[[ "$S20_SEMGREP_ISSUES" -gt 0 ]] && NEG_LOG=1
|
||||
[[ "${S20_SEMGREP_ISSUES}" -gt 0 ]] && NEG_LOG=1
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics1:$S20_SEMGREP_ISSUES:$S20_SEMGREP_SCRIPTS"
|
||||
write_log "[*] Statistics1:${S20_SEMGREP_ISSUES}:${S20_SEMGREP_SCRIPTS}"
|
||||
else
|
||||
print_output "[-] Semgrepper is disabled ... no tests performed"
|
||||
fi
|
||||
|
||||
s20_eval_script_check "${SH_SCRIPTS[@]}"
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
s20_eval_script_check() {
|
||||
@@ -124,15 +124,15 @@ s20_eval_script_check() {
|
||||
print_output "[*] Testing ${ORANGE}${SH_SCRIPT}${NC} for eval usage" "no_log"
|
||||
if grep "eval " "${SH_SCRIPT}" | grep -q -v "^#.*"; then
|
||||
SH_SCRIPT_NAME="$(basename "${SH_SCRIPT}")"
|
||||
local SHELL_LOG="$LOG_PATH_MODULE"/sh_eval_sources/"${SH_SCRIPT_NAME}".log
|
||||
! [[ -d "$LOG_PATH_MODULE"/sh_eval_sources/ ]] && mkdir "$LOG_PATH_MODULE"/sh_eval_sources/
|
||||
local SHELL_LOG="${LOG_PATH_MODULE}"/sh_eval_sources/"${SH_SCRIPT_NAME}".log
|
||||
! [[ -d "${LOG_PATH_MODULE}"/sh_eval_sources/ ]] && mkdir "${LOG_PATH_MODULE}"/sh_eval_sources/
|
||||
[[ -f "${SH_SCRIPT}" ]] && cp "${SH_SCRIPT}" "${SHELL_LOG}"
|
||||
sed -i -r "s/.*eval\ .*/\x1b[32m&\x1b[0m/" "${SHELL_LOG}"
|
||||
print_output "[+] Found ${ORANGE}eval${GREEN} usage in ${ORANGE}${SH_SCRIPT_NAME}${NC}" "" "${SHELL_LOG}"
|
||||
|
||||
if [[ "${GPT_OPTION}" -gt 0 ]]; then
|
||||
GPT_ANCHOR_="$(openssl rand -hex 8)"
|
||||
# "${GPT_INPUT_FILE_}" "$GPT_ANCHOR_" "GPT-Prio-$GPT_PRIO_" "$GPT_QUESTION_" "$GPT_OUTPUT_FILE_" "cost=$GPT_TOKENS_" "$GPT_RESPONSE_"
|
||||
# "${GPT_INPUT_FILE_}" "${GPT_ANCHOR_}" "GPT-Prio-$GPT_PRIO_" "${GPT_QUESTION_}" "${GPT_OUTPUT_FILE_}" "cost=$GPT_TOKENS_" "${GPT_RESPONSE_}"
|
||||
write_csv_gpt_tmp "$(cut_path "${SH_SCRIPT}")" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION}" "${SHELL_LOG}" "" ""
|
||||
# add ChatGPT link
|
||||
printf '%s\n\n' "" >> "${SHELL_LOG}"
|
||||
@@ -149,12 +149,12 @@ s20_script_check() {
|
||||
local SHELL_LOG=""
|
||||
local VULNS=""
|
||||
|
||||
NAME=$(basename "$SH_SCRIPT_" 2> /dev/null | sed -e 's/:/_/g')
|
||||
SHELL_LOG="$LOG_PATH_MODULE""/shellchecker_""$NAME"".txt"
|
||||
shellcheck -C "$SH_SCRIPT_" > "$SHELL_LOG" 2> /dev/null || true
|
||||
VULNS=$(grep -c "\\^-- SC" "$SHELL_LOG" 2> /dev/null || true)
|
||||
NAME=$(basename "${SH_SCRIPT_}" 2> /dev/null | sed -e 's/:/_/g')
|
||||
SHELL_LOG="${LOG_PATH_MODULE}""/shellchecker_""${NAME}"".txt"
|
||||
shellcheck -C "${SH_SCRIPT_}" > "${SHELL_LOG}" 2> /dev/null || true
|
||||
VULNS=$(grep -c "\\^-- SC" "${SHELL_LOG}" 2> /dev/null || true)
|
||||
|
||||
s20_reporter "$VULNS" "$SH_SCRIPT_" "$SHELL_LOG"
|
||||
s20_reporter "${VULNS}" "${SH_SCRIPT_}" "${SHELL_LOG}"
|
||||
}
|
||||
|
||||
s20_reporter() {
|
||||
@@ -164,13 +164,13 @@ s20_reporter() {
|
||||
local GPT_PRIO_=2
|
||||
local GPT_ANCHOR_=""
|
||||
|
||||
if [[ "$VULNS" -ne 0 ]] ; then
|
||||
if [[ "${VULNS}" -ne 0 ]] ; then
|
||||
# check if this is common linux file:
|
||||
local COMMON_FILES_FOUND
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
COMMON_FILES_FOUND="(""${RED}""common linux file: no""${GREEN}"")"
|
||||
CFF="no"
|
||||
if grep -q "^$NAME\$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
if grep -q "^${NAME}\$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
COMMON_FILES_FOUND="(""${CYAN}""common linux file: yes""${GREEN}"")"
|
||||
CFF="yes"
|
||||
fi
|
||||
@@ -178,23 +178,23 @@ s20_reporter() {
|
||||
COMMON_FILES_FOUND=""
|
||||
fi
|
||||
|
||||
if [[ "$VULNS" -gt 20 ]] ; then
|
||||
print_output "[+] Found ""$RED""$VULNS"" issues""$GREEN"" in script ""$COMMON_FILES_FOUND"":""$NC"" ""$(print_path "$SH_SCRIPT")" "" "$SHELL_LOG"
|
||||
if [[ "${VULNS}" -gt 20 ]] ; then
|
||||
print_output "[+] Found ""${RED}""${VULNS}"" issues""${GREEN}"" in script ""${COMMON_FILES_FOUND}"":""${NC}"" ""$(print_path "${SH_SCRIPT}")" "" "${SHELL_LOG}"
|
||||
GPT_PRIO_=1
|
||||
else
|
||||
print_output "[+] Found ""$ORANGE""$VULNS"" issues""$GREEN"" in script ""$COMMON_FILES_FOUND"":""$NC"" ""$(print_path "$SH_SCRIPT")" "" "$SHELL_LOG"
|
||||
print_output "[+] Found ""${ORANGE}""${VULNS}"" issues""${GREEN}"" in script ""${COMMON_FILES_FOUND}"":""${NC}"" ""$(print_path "${SH_SCRIPT}")" "" "${SHELL_LOG}"
|
||||
fi
|
||||
write_csv_log "$(print_path "$SH_SCRIPT")" "$VULNS" "$CFF" "NA"
|
||||
write_csv_log "$(print_path "${SH_SCRIPT}")" "${VULNS}" "${CFF}" "NA"
|
||||
|
||||
if [[ "${GPT_OPTION}" -gt 0 ]]; then
|
||||
GPT_ANCHOR_="$(openssl rand -hex 8)"
|
||||
# "${GPT_INPUT_FILE_}" "$GPT_ANCHOR_" "GPT-Prio-$GPT_PRIO_" "$GPT_QUESTION_" "$GPT_OUTPUT_FILE_" "cost=$GPT_TOKENS_" "$GPT_RESPONSE_"
|
||||
# "${GPT_INPUT_FILE_}" "${GPT_ANCHOR_}" "GPT-Prio-$GPT_PRIO_" "${GPT_QUESTION_}" "${GPT_OUTPUT_FILE_}" "cost=$GPT_TOKENS_" "${GPT_RESPONSE_}"
|
||||
write_csv_gpt_tmp "$(cut_path "${SH_SCRIPT}")" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION}" "${SHELL_LOG}" "" ""
|
||||
# add ChatGPT link
|
||||
printf '%s\n\n' "" >> "${SHELL_LOG}"
|
||||
write_anchor_gpt "${GPT_ANCHOR_}" "${SHELL_LOG}"
|
||||
fi
|
||||
|
||||
echo "$VULNS" >> "$TMP_DIR"/S20_VULNS.tmp
|
||||
echo "${VULNS}" >> "${TMP_DIR}"/S20_VULNS.tmp
|
||||
fi
|
||||
}
|
||||
|
||||
+31
-31
@@ -28,48 +28,48 @@ S21_python_check()
|
||||
local S21_VULN_TYPES=()
|
||||
local VTYPE=""
|
||||
|
||||
if [[ $PYTHON_CHECK -eq 1 ]] ; then
|
||||
if [[ ${PYTHON_CHECK} -eq 1 ]] ; then
|
||||
write_csv_log "Script path" "Python issues detected" "common linux file"
|
||||
mapfile -t PYTHON_SCRIPTS < <(find "$FIRMWARE_PATH" -xdev -type f -iname "*.py" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
mapfile -t PYTHON_SCRIPTS < <(find "${FIRMWARE_PATH}" -xdev -type f -iname "*.py" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
for PY_SCRIPT in "${PYTHON_SCRIPTS[@]}" ; do
|
||||
if ( file "$PY_SCRIPT" | grep -q "Python script.*executable" ) ; then
|
||||
if ( file "${PY_SCRIPT}" | grep -q "Python script.*executable" ) ; then
|
||||
((S21_PY_SCRIPTS+=1))
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
s21_script_bandit "$PY_SCRIPT" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
s21_script_bandit "${PY_SCRIPT}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S21+=( "$TMP_PID" )
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S21[@]}"
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S21+=( "${TMP_PID}" )
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S21[@]}"
|
||||
continue
|
||||
else
|
||||
s21_script_bandit "$PY_SCRIPT"
|
||||
s21_script_bandit "${PY_SCRIPT}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S21[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S21[@]}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/S21_VULNS.tmp ]]; then
|
||||
S21_PY_VULNS=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S21_VULNS.tmp)
|
||||
if [[ -f "${TMP_DIR}"/S21_VULNS.tmp ]]; then
|
||||
S21_PY_VULNS=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S21_VULNS.tmp)
|
||||
fi
|
||||
|
||||
if [[ "$S21_PY_VULNS" -gt 0 ]]; then
|
||||
if [[ "${S21_PY_VULNS}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] Found ""$ORANGE""$S21_PY_VULNS"" vulnerabilities""$GREEN"" in ""$ORANGE""$S21_PY_SCRIPTS""$GREEN"" python files:""$NC""\\n"
|
||||
print_output "[+] Found ""${ORANGE}""${S21_PY_VULNS}"" vulnerabilities""${GREEN}"" in ""${ORANGE}""${S21_PY_SCRIPTS}""${GREEN}"" python files:""${NC}""\\n"
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$S21_PY_VULNS:$S21_PY_SCRIPTS"
|
||||
write_log "[*] Statistics:${S21_PY_VULNS}:${S21_PY_SCRIPTS}"
|
||||
|
||||
# we just print one issue per issue type:
|
||||
mapfile -t S21_VULN_TYPES < <(grep "[A-Z][0-9][0-9][0-9]" "$LOG_PATH_MODULE"/bandit_* 2>/dev/null | grep Issue | cut -d: -f3- | tr -d '[' | tr ']' ':' | sort -u || true)
|
||||
mapfile -t S21_VULN_TYPES < <(grep "[A-Z][0-9][0-9][0-9]" "${LOG_PATH_MODULE}"/bandit_* 2>/dev/null | grep Issue | cut -d: -f3- | tr -d '[' | tr ']' ':' | sort -u || true)
|
||||
for VTYPE in "${S21_VULN_TYPES[@]}" ; do
|
||||
print_output "$(indent "$NC""[""$GREEN""+""$NC""]""$GREEN"" ""$VTYPE""$GREEN")"
|
||||
print_output "$(indent "${NC}""[""${GREEN}""+""${NC}""]""${GREEN}"" ""${VTYPE}""${GREEN}")"
|
||||
done
|
||||
else
|
||||
print_output "[-] Python check is disabled ... no tests performed"
|
||||
fi
|
||||
module_end_log "${FUNCNAME[0]}" "$S21_PY_VULNS"
|
||||
module_end_log "${FUNCNAME[0]}" "${S21_PY_VULNS}"
|
||||
}
|
||||
|
||||
s21_script_bandit() {
|
||||
@@ -80,19 +80,19 @@ s21_script_bandit() {
|
||||
local GPT_PRIO_=2
|
||||
local GPT_ANCHOR_=""
|
||||
|
||||
NAME=$(basename "$PY_SCRIPT_" 2> /dev/null | sed -e 's/:/_/g')
|
||||
PY_LOG="$LOG_PATH_MODULE""/bandit_""$NAME"".txt"
|
||||
bandit -r "$PY_SCRIPT_" > "$PY_LOG" 2> /dev/null || true
|
||||
NAME=$(basename "${PY_SCRIPT_}" 2> /dev/null | sed -e 's/:/_/g')
|
||||
PY_LOG="${LOG_PATH_MODULE}""/bandit_""${NAME}"".txt"
|
||||
bandit -r "${PY_SCRIPT_}" > "${PY_LOG}" 2> /dev/null || true
|
||||
|
||||
VULNS=$(grep -c ">> Issue: " "$PY_LOG" 2> /dev/null || true)
|
||||
if [[ "$VULNS" -ne 0 ]] ; then
|
||||
VULNS=$(grep -c ">> Issue: " "${PY_LOG}" 2> /dev/null || true)
|
||||
if [[ "${VULNS}" -ne 0 ]] ; then
|
||||
# check if this is common linux file:
|
||||
local COMMON_FILES_FOUND
|
||||
local CFF
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
COMMON_FILES_FOUND="(""${RED}""common linux file: no""${GREEN}"")"
|
||||
CFF="no"
|
||||
if grep -q "^$NAME\$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
if grep -q "^${NAME}\$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
COMMON_FILES_FOUND="(""${CYAN}""common linux file: yes""${GREEN}"")"
|
||||
CFF="yes"
|
||||
fi
|
||||
@@ -100,22 +100,22 @@ s21_script_bandit() {
|
||||
COMMON_FILES_FOUND=""
|
||||
CFF="NA"
|
||||
fi
|
||||
if [[ "$VULNS" -gt 20 ]] ; then
|
||||
print_output "[+] Found ""$RED""$VULNS"" issues""$GREEN"" in script ""$COMMON_FILES_FOUND"":""$NC"" ""$(print_path "$PY_SCRIPT_")" "" "$PY_LOG"
|
||||
if [[ "${VULNS}" -gt 20 ]] ; then
|
||||
print_output "[+] Found ""${RED}""${VULNS}"" issues""${GREEN}"" in script ""${COMMON_FILES_FOUND}"":""${NC}"" ""$(print_path "${PY_SCRIPT_}")" "" "${PY_LOG}"
|
||||
GPT_PRIO_=2
|
||||
else
|
||||
print_output "[+] Found ""$ORANGE""$VULNS"" issues""$GREEN"" in script ""$COMMON_FILES_FOUND"":""$NC"" ""$(print_path "$PY_SCRIPT_")" "" "$PY_LOG"
|
||||
print_output "[+] Found ""${ORANGE}""${VULNS}"" issues""${GREEN}"" in script ""${COMMON_FILES_FOUND}"":""${NC}"" ""$(print_path "${PY_SCRIPT_}")" "" "${PY_LOG}"
|
||||
fi
|
||||
|
||||
write_csv_log "$(print_path "$PY_SCRIPT_")" "$VULNS" "$CFF" "NA"
|
||||
write_csv_log "$(print_path "${PY_SCRIPT_}")" "${VULNS}" "${CFF}" "NA"
|
||||
if [[ "${GPT_OPTION}" -gt 0 ]]; then
|
||||
GPT_ANCHOR_="$(openssl rand -hex 8)"
|
||||
# "${GPT_INPUT_FILE_}" "$GPT_ANCHOR_" "$GPT_PRIO_" "$GPT_QUESTION_" "$GPT_OUTPUT_FILE_" "cost=$GPT_TOKENS_" "$GPT_RESPONSE_"
|
||||
# "${GPT_INPUT_FILE_}" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION_}" "${GPT_OUTPUT_FILE_}" "cost=$GPT_TOKENS_" "${GPT_RESPONSE_}"
|
||||
write_csv_gpt_tmp "$(cut_path "${PY_SCRIPT_}")" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION}" "${PY_LOG}" "" ""
|
||||
# add ChatGPT link to output file
|
||||
printf '%s\n\n' "" >> "${PY_LOG}"
|
||||
write_anchor_gpt "${GPT_ANCHOR_}" "${PY_LOG}"
|
||||
fi
|
||||
echo "$VULNS" >> "$TMP_DIR"/S21_VULNS.tmp
|
||||
echo "${VULNS}" >> "${TMP_DIR}"/S21_VULNS.tmp
|
||||
fi
|
||||
}
|
||||
|
||||
+82
-82
@@ -30,8 +30,8 @@ S22_php_check()
|
||||
S22_PHP_INI_CONFIGS=0
|
||||
S22_PHPINFO_ISSUES=0
|
||||
|
||||
if [[ $PHP_CHECK -eq 1 ]] ; then
|
||||
mapfile -t PHP_SCRIPTS < <( find "$FIRMWARE_PATH" -xdev -type f -iname "*.php" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
if [[ ${PHP_CHECK} -eq 1 ]] ; then
|
||||
mapfile -t PHP_SCRIPTS < <( find "${FIRMWARE_PATH}" -xdev -type f -iname "*.php" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
s22_vuln_check_caller "${PHP_SCRIPTS[@]}"
|
||||
|
||||
s22_vuln_check_semgrep "${PHP_SCRIPTS[@]}"
|
||||
@@ -41,12 +41,12 @@ S22_php_check()
|
||||
s22_phpinfo_check "${PHP_SCRIPTS[@]}"
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$S22_PHP_VULNS:$S22_PHP_SCRIPTS:$S22_PHP_INI_ISSUES:$S22_PHP_INI_CONFIGS"
|
||||
write_log "[*] Statistics:${S22_PHP_VULNS}:${S22_PHP_SCRIPTS}:${S22_PHP_INI_ISSUES}:${S22_PHP_INI_CONFIGS}"
|
||||
|
||||
else
|
||||
print_output "[-] PHP check is disabled ... no tests performed"
|
||||
fi
|
||||
module_end_log "${FUNCNAME[0]}" "$(( "$S22_PHP_VULNS" + "$S22_PHP_INI_ISSUES" + "$S22_PHPINFO_ISSUES" + "$S22_SEMGREP_ISSUES" ))"
|
||||
module_end_log "${FUNCNAME[0]}" "$(( "${S22_PHP_VULNS}" + "${S22_PHP_INI_ISSUES}" + "${S22_PHPINFO_ISSUES}" + "${S22_SEMGREP_ISSUES}" ))"
|
||||
}
|
||||
|
||||
s22_phpinfo_check() {
|
||||
@@ -55,9 +55,9 @@ s22_phpinfo_check() {
|
||||
local PHPINFO=""
|
||||
|
||||
for PHPINFO in "${PHP_SCRIPTS[@]}" ; do
|
||||
if grep -q "phpinfo()" "$PHPINFO"; then
|
||||
print_output "[+] Found php file with debugging information: $ORANGE$PHPINFO$NC"
|
||||
grep -A 2 -B 2 "phpinfo()" "$PHPINFO" | tee -a "$LOG_FILE"
|
||||
if grep -q "phpinfo()" "${PHPINFO}"; then
|
||||
print_output "[+] Found php file with debugging information: ${ORANGE}${PHPINFO}${NC}"
|
||||
grep -A 2 -B 2 "phpinfo()" "${PHPINFO}" | tee -a "${LOG_FILE}"
|
||||
((S22_PHPINFO_ISSUES+=1))
|
||||
fi
|
||||
done
|
||||
@@ -66,27 +66,27 @@ s22_phpinfo_check() {
|
||||
|
||||
s22_vuln_check_semgrep() {
|
||||
sub_module_title "PHP script vulnerabilities - semgrep"
|
||||
local PHP_SEMGREP_LOG="$LOG_PATH_MODULE"/semgrep_php_results_xml.log
|
||||
local PHP_SEMGREP_LOG="${LOG_PATH_MODULE}"/semgrep_php_results_xml.log
|
||||
local S22_SEMGREP_VULNS=0
|
||||
local SEMG_SOURCES_ARR=()
|
||||
|
||||
semgrep --disable-version-check --junit-xml --config "$EXT_DIR"/semgrep-rules/php "$LOG_DIR"/firmware/ > "$PHP_SEMGREP_LOG" 2>&1 || true
|
||||
semgrep --disable-version-check --junit-xml --config "${EXT_DIR}"/semgrep-rules/php "${LOG_DIR}"/firmware/ > "${PHP_SEMGREP_LOG}" 2>&1 || true
|
||||
|
||||
if [[ -f "$PHP_SEMGREP_LOG" ]]; then
|
||||
S22_SEMGREP_ISSUES=$(grep -c "testcase name" "$PHP_SEMGREP_LOG" || true)
|
||||
S22_SEMGREP_VULNS=$(grep -c "semgrep-rules.php.lang.security" "$PHP_SEMGREP_LOG" || true)
|
||||
S22_SEMGREP_SCRIPTS=$(grep "Scanning\ .* rules\." "$PHP_SEMGREP_LOG" | awk '{print $2}' || true)
|
||||
if [[ -f "${PHP_SEMGREP_LOG}" ]]; then
|
||||
S22_SEMGREP_ISSUES=$(grep -c "testcase name" "${PHP_SEMGREP_LOG}" || true)
|
||||
S22_SEMGREP_VULNS=$(grep -c "semgrep-rules.php.lang.security" "${PHP_SEMGREP_LOG}" || true)
|
||||
S22_SEMGREP_SCRIPTS=$(grep "Scanning\ .* rules\." "${PHP_SEMGREP_LOG}" | awk '{print $2}' || true)
|
||||
print_ln
|
||||
|
||||
if [[ "$S22_SEMGREP_VULNS" -gt 0 ]]; then
|
||||
print_output "[+] Found ""$ORANGE""$S22_SEMGREP_ISSUES"" issues""$GREEN"" (""$ORANGE""$S22_SEMGREP_VULNS"" vulnerabilites${GREEN}) in ""$ORANGE""$S22_SEMGREP_SCRIPTS""$GREEN"" php files""$NC" "" "$PHP_SEMGREP_LOG"
|
||||
elif [[ "$S22_SEMGREP_ISSUES" -gt 0 ]]; then
|
||||
print_output "[+] Found ""$ORANGE""$S22_SEMGREP_ISSUES"" issues""$GREEN"" in ""$ORANGE""$S22_SEMGREP_SCRIPTS""$GREEN"" php files""$NC" "" "$PHP_SEMGREP_LOG"
|
||||
if [[ "${S22_SEMGREP_VULNS}" -gt 0 ]]; then
|
||||
print_output "[+] Found ""${ORANGE}""${S22_SEMGREP_ISSUES}"" issues""${GREEN}"" (""${ORANGE}""${S22_SEMGREP_VULNS}"" vulnerabilites${GREEN}) in ""${ORANGE}""${S22_SEMGREP_SCRIPTS}""${GREEN}"" php files""${NC}" "" "${PHP_SEMGREP_LOG}"
|
||||
elif [[ "${S22_SEMGREP_ISSUES}" -gt 0 ]]; then
|
||||
print_output "[+] Found ""${ORANGE}""${S22_SEMGREP_ISSUES}"" issues""${GREEN}"" in ""${ORANGE}""${S22_SEMGREP_SCRIPTS}""${GREEN}"" php files""${NC}" "" "${PHP_SEMGREP_LOG}"
|
||||
fi
|
||||
# highlight security findings in semgrep log:
|
||||
sed -i -r "s/.*external\.semgrep-rules\.php\.lang\.security.*/\x1b[32m&\x1b[0m/" "$PHP_SEMGREP_LOG"
|
||||
sed -i -r "s/.*external\.semgrep-rules\.php\.lang\.security.*/\x1b[32m&\x1b[0m/" "${PHP_SEMGREP_LOG}"
|
||||
|
||||
mapfile -t SEMG_SOURCES_ARR < <(grep -E -o "name=.* file=.*\" line=\"[0-9]+" "$PHP_SEMGREP_LOG" | sort -u || true)
|
||||
mapfile -t SEMG_SOURCES_ARR < <(grep -E -o "name=.* file=.*\" line=\"[0-9]+" "${PHP_SEMGREP_LOG}" | sort -u || true)
|
||||
|
||||
for SEMG_SOURCE_NOTE in "${SEMG_SOURCES_ARR[@]}"; do
|
||||
local SEMG_ISSUE_NAME=""
|
||||
@@ -96,26 +96,26 @@ s22_vuln_check_semgrep() {
|
||||
local GPT_PRIO_=3
|
||||
local GPT_ANCHOR_=""
|
||||
|
||||
! [[ -d "$LOG_PATH_MODULE"/semgrep_sources/ ]] && mkdir "$LOG_PATH_MODULE"/semgrep_sources/
|
||||
! [[ -d "${LOG_PATH_MODULE}"/semgrep_sources/ ]] && mkdir "${LOG_PATH_MODULE}"/semgrep_sources/
|
||||
|
||||
SEMG_ISSUE_NAME=$(echo "${SEMG_SOURCE_NOTE}" | tr ' ' '\n' | grep "^name=")
|
||||
SEMG_ISSUE_NAME="$(echo "$SEMG_ISSUE_NAME" | sed 's/name=\"//' | tr -d '"')"
|
||||
SEMG_ISSUE_NAME="$(echo "${SEMG_ISSUE_NAME}" | sed 's/name=\"//' | tr -d '"')"
|
||||
|
||||
SEMG_SOURCE_FILE=$(echo "${SEMG_SOURCE_NOTE}" | tr ' ' '\n' | grep "^file=")
|
||||
SEMG_SOURCE_FILE="$(echo "$SEMG_SOURCE_FILE" | sed 's/file=\"//' | tr -d '"')"
|
||||
SEMG_SOURCE_FILE="$(echo "${SEMG_SOURCE_FILE}" | sed 's/file=\"//' | tr -d '"')"
|
||||
SEMG_SOURCE_FILE_NAME=$(basename "${SEMG_SOURCE_FILE}")
|
||||
|
||||
[[ -f "$SEMG_SOURCE_FILE" && ! -f "$LOG_PATH_MODULE"/semgrep_sources/"${SEMG_SOURCE_FILE_NAME}".log ]] && cp "$SEMG_SOURCE_FILE" "$LOG_PATH_MODULE"/semgrep_sources/"${SEMG_SOURCE_FILE_NAME}".log
|
||||
[[ -f "${SEMG_SOURCE_FILE}" && ! -f "${LOG_PATH_MODULE}"/semgrep_sources/"${SEMG_SOURCE_FILE_NAME}".log ]] && cp "${SEMG_SOURCE_FILE}" "${LOG_PATH_MODULE}"/semgrep_sources/"${SEMG_SOURCE_FILE_NAME}".log
|
||||
|
||||
SEMG_LINE_NR=$(echo "${SEMG_SOURCE_NOTE}" | tr ' ' '\n' | grep "^line=")
|
||||
SEMG_LINE_NR="$(echo "$SEMG_LINE_NR" | sed 's/line=\"//' | tr -d '"')"
|
||||
SEMG_LINE_NR="$(echo "${SEMG_LINE_NR}" | sed 's/line=\"//' | tr -d '"')"
|
||||
|
||||
sed -i -r "${SEMG_LINE_NR}s/.*/\x1b[32m&\x1b[0m/" "$LOG_PATH_MODULE"/semgrep_sources/"${SEMG_SOURCE_FILE_NAME}".log
|
||||
print_output "[+] Found possible PHP vulnerability ${ORANGE}${SEMG_ISSUE_NAME}${GREEN} in ${ORANGE}${SEMG_SOURCE_FILE_NAME}${GREEN}" "" "$LOG_PATH_MODULE/semgrep_sources/${SEMG_SOURCE_FILE_NAME}.log"
|
||||
sed -i -r "${SEMG_LINE_NR}s/.*/\x1b[32m&\x1b[0m/" "${LOG_PATH_MODULE}"/semgrep_sources/"${SEMG_SOURCE_FILE_NAME}".log
|
||||
print_output "[+] Found possible PHP vulnerability ${ORANGE}${SEMG_ISSUE_NAME}${GREEN} in ${ORANGE}${SEMG_SOURCE_FILE_NAME}${GREEN}" "" "${LOG_PATH_MODULE}/semgrep_sources/${SEMG_SOURCE_FILE_NAME}.log"
|
||||
|
||||
if [[ "${GPT_OPTION}" -gt 0 ]]; then
|
||||
GPT_ANCHOR_="$(openssl rand -hex 8)"
|
||||
# "${GPT_INPUT_FILE_}" "$GPT_ANCHOR_" "$GPT_PRIO_" "$GPT_QUESTION_" "$GPT_OUTPUT_FILE_" "cost=$GPT_TOKENS_" "$GPT_RESPONSE_"
|
||||
# "${GPT_INPUT_FILE_}" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION_}" "${GPT_OUTPUT_FILE_}" "cost=$GPT_TOKENS_" "${GPT_RESPONSE_}"
|
||||
write_csv_gpt_tmp "$(cut_path "${SEMG_SOURCE_FILE}")" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION} And I think there might be something in line ${SEMG_LINE_NR}" "${LOG_PATH_MODULE}/semgrep_sources/${SEMG_SOURCE_FILE_NAME}.log" "" ""
|
||||
# add ChatGPT link
|
||||
printf '%s\n\n' "" >> "${LOG_PATH_MODULE}/semgrep_sources/${SEMG_SOURCE_FILE_NAME}.log"
|
||||
@@ -124,7 +124,7 @@ s22_vuln_check_semgrep() {
|
||||
done
|
||||
fi
|
||||
write_log ""
|
||||
write_log "[*] Statistics1:$S22_SEMGREP_ISSUES:$S22_SEMGREP_SCRIPTS"
|
||||
write_log "[*] Statistics1:${S22_SEMGREP_ISSUES}:${S22_SEMGREP_SCRIPTS}"
|
||||
}
|
||||
|
||||
s22_vuln_check_caller() {
|
||||
@@ -135,37 +135,37 @@ s22_vuln_check_caller() {
|
||||
local PHP_SCRIPT=""
|
||||
|
||||
for PHP_SCRIPT in "${PHP_SCRIPTS[@]}" ; do
|
||||
if ( file "$PHP_SCRIPT" | grep -q "PHP script" ) ; then
|
||||
if ( file "${PHP_SCRIPT}" | grep -q "PHP script" ) ; then
|
||||
((S22_PHP_SCRIPTS+=1))
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
s22_vuln_check "$PHP_SCRIPT" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
s22_vuln_check "${PHP_SCRIPT}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S22+=( "$TMP_PID" )
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S22[@]}"
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S22+=( "${TMP_PID}" )
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S22[@]}"
|
||||
continue
|
||||
else
|
||||
s22_vuln_check "$PHP_SCRIPT"
|
||||
s22_vuln_check "${PHP_SCRIPT}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S22[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S22[@]}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/S22_VULNS.tmp ]]; then
|
||||
S22_PHP_VULNS=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S22_VULNS.tmp)
|
||||
if [[ -f "${TMP_DIR}"/S22_VULNS.tmp ]]; then
|
||||
S22_PHP_VULNS=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S22_VULNS.tmp)
|
||||
fi
|
||||
|
||||
print_ln
|
||||
if [[ "$S22_PHP_VULNS" -gt 0 ]]; then
|
||||
print_output "[+] Found ""$ORANGE""$S22_PHP_VULNS"" vulnerabilities""$GREEN"" in ""$ORANGE""$S22_PHP_SCRIPTS""$GREEN"" php files.""$NC""\\n"
|
||||
if [[ "${S22_PHP_VULNS}" -gt 0 ]]; then
|
||||
print_output "[+] Found ""${ORANGE}""${S22_PHP_VULNS}"" vulnerabilities""${GREEN}"" in ""${ORANGE}""${S22_PHP_SCRIPTS}""${GREEN}"" php files.""${NC}""\\n"
|
||||
fi
|
||||
}
|
||||
|
||||
s22_vuln_check() {
|
||||
local PHP_SCRIPT_="${1:-}"
|
||||
|
||||
if ! [[ -f "$PHP_SCRIPT_" ]]; then
|
||||
if ! [[ -f "${PHP_SCRIPT_}" ]]; then
|
||||
print_output "[-] No PHP script for analysis provided"
|
||||
return
|
||||
fi
|
||||
@@ -174,26 +174,26 @@ s22_vuln_check() {
|
||||
local VULNS=0
|
||||
|
||||
TOTAL_MEMORY="$(grep MemTotal /proc/meminfo | awk '{print $2}' || true)"
|
||||
local MEM_LIMIT=$(( "$TOTAL_MEMORY"/2 ))
|
||||
local MEM_LIMIT=$(( "${TOTAL_MEMORY}"/2 ))
|
||||
|
||||
NAME=$(basename "$PHP_SCRIPT_" 2> /dev/null | sed -e 's/:/_/g')
|
||||
local PHP_LOG="$LOG_PATH_MODULE""/php_vuln_""$NAME""-$RANDOM.txt"
|
||||
NAME=$(basename "${PHP_SCRIPT_}" 2> /dev/null | sed -e 's/:/_/g')
|
||||
local PHP_LOG="${LOG_PATH_MODULE}""/php_vuln_""${NAME}""-${RANDOM}.txt"
|
||||
|
||||
ulimit -Sv "$MEM_LIMIT"
|
||||
"$EXT_DIR"/progpilot "$PHP_SCRIPT_" >> "$PHP_LOG" 2>&1 || true
|
||||
ulimit -Sv "${MEM_LIMIT}"
|
||||
"${EXT_DIR}"/progpilot "${PHP_SCRIPT_}" >> "${PHP_LOG}" 2>&1 || true
|
||||
ulimit -Sv unlimited
|
||||
|
||||
VULNS=$(grep -c "vuln_name" "$PHP_LOG" 2> /dev/null || true)
|
||||
VULNS=$(grep -c "vuln_name" "${PHP_LOG}" 2> /dev/null || true)
|
||||
local GPT_PRIO_=3
|
||||
local GPT_ANCHOR_=""
|
||||
if [[ "$VULNS" -gt 0 ]] ; then
|
||||
if [[ "${VULNS}" -gt 0 ]] ; then
|
||||
# check if this is common linux file:
|
||||
local COMMON_FILES_FOUND
|
||||
local CFF
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
COMMON_FILES_FOUND=" (""${RED}""common linux file: no""${GREEN}"")"
|
||||
CFF="no"
|
||||
if grep -q "^$NAME\$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
if grep -q "^${NAME}\$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
COMMON_FILES_FOUND=" (""${CYAN}""common linux file: yes""${GREEN}"")"
|
||||
CFF="yes"
|
||||
GPT_PRIO_=1
|
||||
@@ -202,20 +202,20 @@ s22_vuln_check() {
|
||||
COMMON_FILES_FOUND=""
|
||||
CFF="NA"
|
||||
fi
|
||||
print_output "[+] Found ""$ORANGE""$VULNS"" vulnerabilities""$GREEN"" in php file"": ""$ORANGE""$(print_path "$PHP_SCRIPT_")""$GREEN""$COMMON_FILES_FOUND""$NC" "" "$PHP_LOG"
|
||||
write_csv_log "$(print_path "$PHP_SCRIPT_")" "$VULNS" "$CFF" "NA"
|
||||
print_output "[+] Found ""${ORANGE}""${VULNS}"" vulnerabilities""${GREEN}"" in php file"": ""${ORANGE}""$(print_path "${PHP_SCRIPT_}")""${GREEN}""${COMMON_FILES_FOUND}""${NC}" "" "${PHP_LOG}"
|
||||
write_csv_log "$(print_path "${PHP_SCRIPT_}")" "${VULNS}" "${CFF}" "NA"
|
||||
if [[ "${GPT_OPTION}" -gt 0 ]]; then
|
||||
GPT_ANCHOR_="$(openssl rand -hex 8)"
|
||||
# "${GPT_INPUT_FILE_}" "$GPT_ANCHOR_" "GPT-Prio-$GPT_PRIO_" "$GPT_QUESTION_" "$GPT_OUTPUT_FILE_" "cost=$GPT_TOKENS_" "$GPT_RESPONSE_"
|
||||
# "${GPT_INPUT_FILE_}" "${GPT_ANCHOR_}" "GPT-Prio-$GPT_PRIO_" "${GPT_QUESTION_}" "${GPT_OUTPUT_FILE_}" "cost=$GPT_TOKENS_" "${GPT_RESPONSE_}"
|
||||
write_csv_gpt_tmp "$(cut_path "${PHP_SCRIPT_}")" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION}" "${TMP_DIR}/S22_VULNS.tmp" "" ""
|
||||
# add ChatGPT link
|
||||
printf '%s\n\n' "" >> "${TMP_DIR}"/S22_VULNS.tmp
|
||||
write_anchor_gpt "${GPT_ANCHOR_}" "${TMP_DIR}"/S22_VULNS.tmp
|
||||
fi
|
||||
echo "$VULNS" >> "$TMP_DIR"/S22_VULNS.tmp
|
||||
echo "${VULNS}" >> "${TMP_DIR}"/S22_VULNS.tmp
|
||||
else
|
||||
# print_output "[*] Warning: No VULNS detected in $PHP_LOG" "no_log"
|
||||
rm "$PHP_LOG" 2>/dev/null || true
|
||||
rm "${PHP_LOG}" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -228,70 +228,70 @@ s22_check_php_ini(){
|
||||
local PHP_FILE=""
|
||||
local INISCAN_RESULT=()
|
||||
local LINE=""
|
||||
local PHP_INISCAN_PATH="$EXT_DIR""/iniscan/vendor/bin/iniscan"
|
||||
local PHP_INISCAN_PATH="${EXT_DIR}""/iniscan/vendor/bin/iniscan"
|
||||
PHP_INI_FAILURE=0
|
||||
PHP_INI_LIMIT_EXCEEDED=0
|
||||
PHP_INI_WARNINGS=0
|
||||
|
||||
mapfile -t PHP_INI_FILE < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname 'php.ini' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
mapfile -t PHP_INI_FILE < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname 'php.ini' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
|
||||
disable_strict_mode "$STRICT_MODE"
|
||||
disable_strict_mode "${STRICT_MODE}"
|
||||
for PHP_FILE in "${PHP_INI_FILE[@]}" ; do
|
||||
# print_output "[*] iniscan check of ""$(print_path "$PHP_FILE")"
|
||||
mapfile -t INISCAN_RESULT < <( "$PHP_INISCAN_PATH" scan --path="$PHP_FILE" || true)
|
||||
# print_output "[*] iniscan check of ""$(print_path "${PHP_FILE}")"
|
||||
mapfile -t INISCAN_RESULT < <( "${PHP_INISCAN_PATH}" scan --path="${PHP_FILE}" || true)
|
||||
for LINE in "${INISCAN_RESULT[@]}" ; do
|
||||
local LIMIT_CHECK
|
||||
IFS='|' read -ra LINE_ARR <<< "$LINE"
|
||||
IFS='|' read -ra LINE_ARR <<< "${LINE}"
|
||||
# TODO: STRICT mode not working here:
|
||||
add_recommendations "${LINE_ARR[3]}" "${LINE_ARR[4]}"
|
||||
LIMIT_CHECK="$?"
|
||||
if [[ "$LIMIT_CHECK" -eq 1 ]]; then
|
||||
print_output "$(magenta "$LINE")"
|
||||
if [[ "${LIMIT_CHECK}" -eq 1 ]]; then
|
||||
print_output "$(magenta "${LINE}")"
|
||||
PHP_INI_LIMIT_EXCEEDED=$(( PHP_INI_LIMIT_EXCEEDED+1 ))
|
||||
elif ( echo "$LINE" | grep -q "FAIL" ) && ( echo "$LINE" | grep -q "ERROR" ) ; then
|
||||
print_output "$(red "$LINE")"
|
||||
elif ( echo "$LINE" | grep -q "FAIL" ) && ( echo "$LINE" | grep -q "WARNING" ) ; then
|
||||
print_output "$(orange "$LINE")"
|
||||
elif ( echo "$LINE" | grep -q "FAIL" ) && ( echo "$LINE" | grep -q "INFO" ) ; then
|
||||
print_output "$(blue "$LINE")"
|
||||
elif ( echo "$LINE" | grep -q "PASS" ) ; then
|
||||
elif ( echo "${LINE}" | grep -q "FAIL" ) && ( echo "${LINE}" | grep -q "ERROR" ) ; then
|
||||
print_output "$(red "${LINE}")"
|
||||
elif ( echo "${LINE}" | grep -q "FAIL" ) && ( echo "${LINE}" | grep -q "WARNING" ) ; then
|
||||
print_output "$(orange "${LINE}")"
|
||||
elif ( echo "${LINE}" | grep -q "FAIL" ) && ( echo "${LINE}" | grep -q "INFO" ) ; then
|
||||
print_output "$(blue "${LINE}")"
|
||||
elif ( echo "${LINE}" | grep -q "PASS" ) ; then
|
||||
continue
|
||||
else
|
||||
if ( echo "$LINE" | grep -q "failure" ) && ( echo "$LINE" | grep -q "warning" ) ; then
|
||||
IFS=' ' read -ra LINE_ARR <<< "$LINE"
|
||||
if ( echo "${LINE}" | grep -q "failure" ) && ( echo "${LINE}" | grep -q "warning" ) ; then
|
||||
IFS=' ' read -ra LINE_ARR <<< "${LINE}"
|
||||
PHP_INI_FAILURE=${LINE_ARR[0]}
|
||||
PHP_INI_WARNINGS=${LINE_ARR[3]}
|
||||
(( S22_PHP_INI_ISSUES="$S22_PHP_INI_ISSUES"+"$PHP_INI_LIMIT_EXCEEDED"+"$PHP_INI_FAILURE"+"$PHP_INI_WARNINGS" ))
|
||||
(( S22_PHP_INI_ISSUES="${S22_PHP_INI_ISSUES}"+"${PHP_INI_LIMIT_EXCEEDED}"+"${PHP_INI_FAILURE}"+"${PHP_INI_WARNINGS}" ))
|
||||
S22_PHP_INI_CONFIGS=$(( S22_PHP_INI_CONFIGS+1 ))
|
||||
elif ( echo "$LINE" | grep -q "passing" ) ; then
|
||||
IFS=' ' read -ra LINE_ARR <<< "$LINE"
|
||||
elif ( echo "${LINE}" | grep -q "passing" ) ; then
|
||||
IFS=' ' read -ra LINE_ARR <<< "${LINE}"
|
||||
# semgrep does not like the following line of code:
|
||||
LINE_ARR[0]=$(( "${LINE_ARR[0]}" - "${PHP_INI_LIMIT_EXCEEDED}" ))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "$S22_PHP_INI_ISSUES" -gt 0 ]]; then
|
||||
if [[ "${S22_PHP_INI_ISSUES}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] Found ""$ORANGE""$S22_PHP_INI_ISSUES""$GREEN"" PHP configuration issues in php config file :""$ORANGE"" ""$(print_path "$PHP_FILE")"
|
||||
print_output "[+] Found ""${ORANGE}""${S22_PHP_INI_ISSUES}""${GREEN}"" PHP configuration issues in php config file :""${ORANGE}"" ""$(print_path "${PHP_FILE}")"
|
||||
print_ln
|
||||
fi
|
||||
done
|
||||
enable_strict_mode "$STRICT_MODE"
|
||||
enable_strict_mode "${STRICT_MODE}"
|
||||
}
|
||||
|
||||
add_recommendations(){
|
||||
local VALUE="${1:-}"
|
||||
local KEY="${2:-}"
|
||||
|
||||
if [[ $VALUE == *"M"* ]]; then
|
||||
if [[ ${VALUE} == *"M"* ]]; then
|
||||
LIMIT="${VALUE//M/}"
|
||||
fi
|
||||
|
||||
if [[ $KEY == *"memory_limit"* ]] && [[ $(( LIMIT)) -gt 50 ]]; then
|
||||
if [[ ${KEY} == *"memory_limit"* ]] && [[ $(( LIMIT)) -gt 50 ]]; then
|
||||
return 1
|
||||
elif [[ $KEY == *"post_max_size"* ]] && [[ $(( LIMIT)) -gt 20 ]]; then
|
||||
elif [[ ${KEY} == *"post_max_size"* ]] && [[ $(( LIMIT)) -gt 20 ]]; then
|
||||
return 1
|
||||
elif [[ $KEY == *"max_execution_time"* ]] && [[ $(( LIMIT )) -gt 60 ]]; then
|
||||
elif [[ ${KEY} == *"max_execution_time"* ]] && [[ $(( LIMIT )) -gt 60 ]]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
|
||||
+28
-28
@@ -26,38 +26,38 @@ S23_lua_check()
|
||||
export S23_ISSUE_FOUND=0
|
||||
|
||||
write_csv_log "Script path" "LUA issues detected" "LUA vulnarabilities detected" "common linux file"
|
||||
mapfile -t S23_LUA_SCRIPTS < <(find "$FIRMWARE_PATH" -xdev -type f -iname "*.lua" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
mapfile -t S23_LUA_SCRIPTS < <(find "${FIRMWARE_PATH}" -xdev -type f -iname "*.lua" -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
|
||||
sub_module_title "LUA linter checks module"
|
||||
|
||||
for LUA_SCRIPT in "${S23_LUA_SCRIPTS[@]}" ; do
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
# linting check:
|
||||
s23_luacheck "$LUA_SCRIPT" &
|
||||
s23_luacheck "${LUA_SCRIPT}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S23+=( "$TMP_PID" )
|
||||
max_pids_protection "$MAX_MOD_THREADS" "${WAIT_PIDS_S23[@]}"
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S23+=( "${TMP_PID}" )
|
||||
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S23[@]}"
|
||||
continue
|
||||
else
|
||||
s23_luacheck "$LUA_SCRIPT"
|
||||
s23_luacheck "${LUA_SCRIPT}"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S23[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S23[@]}"
|
||||
|
||||
# simple lua checks to identify files which should be analysed in more detail
|
||||
print_ln
|
||||
s23_luaseccheck
|
||||
|
||||
if [[ "$S23_LUA_VULNS" -gt 0 ]]; then
|
||||
if [[ "${S23_LUA_VULNS}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] Found ""$ORANGE""$S23_LUA_VULNS"" security issues""$GREEN"" in ""$ORANGE""${#LUA_CGI_FILES[@]}""$GREEN"" lua files""$NC""\\n"
|
||||
print_output "[+] Found ""${ORANGE}""${S23_LUA_VULNS}"" security issues""${GREEN}"" in ""${ORANGE}""${#LUA_CGI_FILES[@]}""${GREEN}"" lua files""${NC}""\\n"
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$S23_LUA_VULNS:${#LUA_CGI_FILES[@]}"
|
||||
module_end_log "${FUNCNAME[0]}" "$S23_ISSUE_FOUND"
|
||||
write_log "[*] Statistics:${S23_LUA_VULNS}:${#LUA_CGI_FILES[@]}"
|
||||
module_end_log "${FUNCNAME[0]}" "${S23_ISSUE_FOUND}"
|
||||
}
|
||||
|
||||
# this is a very basic checker for LUA issues
|
||||
@@ -77,11 +77,11 @@ s23_luaseccheck() {
|
||||
| sed 's/.*cgilua.QUERY.//' | grep -o -E "^[[:alnum:]]+" | grep -v "^local$" | sort -u || true)
|
||||
|
||||
for ENTRY in "${QUERY_ENTRIES[@]}"; do
|
||||
ENTRY="$(echo "$ENTRY" | tr -dc '[:print:]')"
|
||||
[[ -z "$ENTRY" ]] && continue
|
||||
! [[ "$ENTRY" =~ ^[a-zA-Z0-9_-]+$ ]] && continue
|
||||
ENTRY="$(echo "${ENTRY}" | tr -dc '[:print:]')"
|
||||
[[ -z "${ENTRY}" ]] && continue
|
||||
! [[ "${ENTRY}" =~ ^[a-zA-Z0-9_-]+$ ]] && continue
|
||||
|
||||
if grep "$ENTRY" "${QUERY_FILE}" | grep -E -q "io\.(p)?open"; then
|
||||
if grep "${ENTRY}" "${QUERY_FILE}" | grep -E -q "io\.(p)?open"; then
|
||||
# possible file access
|
||||
S23_LUA_VULNS=$((S23_LUA_VULNS+1))
|
||||
ISSUES_FILE=$((ISSUES_FILE+1))
|
||||
@@ -89,7 +89,7 @@ s23_luaseccheck() {
|
||||
S23_ISSUE_FOUND=1
|
||||
GPT_PRIO=$((GPT_PRIO+1))
|
||||
fi
|
||||
if grep "$ENTRY" "${QUERY_FILE}" | grep -q "os.execute"; then
|
||||
if grep "${ENTRY}" "${QUERY_FILE}" | grep -q "os.execute"; then
|
||||
# command exec - critical
|
||||
S23_LUA_VULNS=$((S23_LUA_VULNS+1))
|
||||
ISSUES_FILE=$((ISSUES_FILE+1))
|
||||
@@ -110,10 +110,10 @@ s23_luaseccheck() {
|
||||
fi
|
||||
|
||||
if [[ "${ISSUES_FILE}" -gt 0 ]]; then
|
||||
write_csv_log "$(print_path "$QUERY_FILE")" "0" "$ISSUES_FILE" "NA"
|
||||
write_csv_log "$(print_path "${QUERY_FILE}")" "0" "${ISSUES_FILE}" "NA"
|
||||
if [[ "${GPT_OPTION}" -gt 0 ]]; then
|
||||
GPT_ANCHOR_="$(openssl rand -hex 8)"
|
||||
# "${GPT_INPUT_FILE_}" "$GPT_ANCHOR_" "$GPT_PRIO_" "$GPT_QUESTION_" "$GPT_OUTPUT_FILE_" "cost=$GPT_TOKENS_" "$GPT_RESPONSE_"
|
||||
# "${GPT_INPUT_FILE_}" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION_}" "${GPT_OUTPUT_FILE_}" "cost=$GPT_TOKENS_" "${GPT_RESPONSE_}"
|
||||
write_csv_gpt_tmp "$(cut_path "${QUERY_FILE}")" "${GPT_ANCHOR_}" "${GPT_PRIO_}" "${GPT_QUESTION}" "${CSV_DIR}/s23_lua_check.csv" "" ""
|
||||
# add ChatGPT link
|
||||
print_ln
|
||||
@@ -129,20 +129,20 @@ s23_luacheck() {
|
||||
local NAME=""
|
||||
local LUA_LOG=""
|
||||
|
||||
NAME=$(basename "$LUA_SCRIPT_" 2> /dev/null | sed -e 's/:/_/g')
|
||||
LUA_LOG="$LOG_PATH_MODULE""/luacheck_""$NAME"".txt"
|
||||
luacheck "$LUA_SCRIPT_" > "$LUA_LOG" 2> /dev/null || true
|
||||
NAME=$(basename "${LUA_SCRIPT_}" 2> /dev/null | sed -e 's/:/_/g')
|
||||
LUA_LOG="${LOG_PATH_MODULE}""/luacheck_""${NAME}"".txt"
|
||||
luacheck "${LUA_SCRIPT_}" > "${LUA_LOG}" 2> /dev/null || true
|
||||
|
||||
ISSUES=$(strip_color_codes "$(grep Total "$LUA_LOG" | awk '{print $2}' 2> /dev/null || true)")
|
||||
if [[ "$ISSUES" -gt 0 ]] ; then
|
||||
ISSUES=$(strip_color_codes "$(grep Total "${LUA_LOG}" | awk '{print $2}' 2> /dev/null || true)")
|
||||
if [[ "${ISSUES}" -gt 0 ]] ; then
|
||||
S23_ISSUE_FOUND=1
|
||||
# check if this is common linux file:
|
||||
local COMMON_FILES_FOUND
|
||||
local CFF
|
||||
if [[ -f "$BASE_LINUX_FILES" ]]; then
|
||||
if [[ -f "${BASE_LINUX_FILES}" ]]; then
|
||||
COMMON_FILES_FOUND="(""${RED}""common linux file: no""${GREEN}"")"
|
||||
CFF="no"
|
||||
if grep -q "^$NAME\$" "$BASE_LINUX_FILES" 2>/dev/null; then
|
||||
if grep -q "^${NAME}\$" "${BASE_LINUX_FILES}" 2>/dev/null; then
|
||||
COMMON_FILES_FOUND="(""${CYAN}""common linux file: yes""${GREEN}"")"
|
||||
CFF="yes"
|
||||
fi
|
||||
@@ -150,7 +150,7 @@ s23_luacheck() {
|
||||
COMMON_FILES_FOUND=""
|
||||
CFF="NA"
|
||||
fi
|
||||
print_output "[+] Found ""$ORANGE""$ISSUES"" coding issues""$GREEN"" in lua script ""$COMMON_FILES_FOUND"":""$NC"" ""$(print_path "$LUA_SCRIPT_")" "" "$LUA_LOG"
|
||||
write_csv_log "$(print_path "$LUA_SCRIPT_")" "$ISSUES" "0" "$CFF"
|
||||
print_output "[+] Found ""${ORANGE}""${ISSUES}"" coding issues""${GREEN}"" in lua script ""${COMMON_FILES_FOUND}"":""${NC}"" ""$(print_path "${LUA_SCRIPT_}")" "" "${LUA_LOG}"
|
||||
write_csv_log "$(print_path "${LUA_SCRIPT_}")" "${ISSUES}" "0" "${CFF}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ S24_kernel_bin_identifier()
|
||||
local CFG_MD5=""
|
||||
export KCFG_MD5=()
|
||||
|
||||
prepare_file_arr_limited "$FIRMWARE_PATH_CP"
|
||||
prepare_file_arr_limited "${FIRMWARE_PATH_CP}"
|
||||
|
||||
write_csv_log "Kernel version orig" "Kernel version stripped" "file" "generated elf" "identified init" "config extracted" "kernel symbols" "architecture" "endianness"
|
||||
|
||||
@@ -43,41 +43,41 @@ S24_kernel_bin_identifier()
|
||||
local K_ARCH="NA"
|
||||
local K_ARCH_END="NA"
|
||||
|
||||
if file "$FILE" | grep -q "ASCII text"; then
|
||||
if file "${FILE}" | grep -q "ASCII text"; then
|
||||
# reduce false positive rate
|
||||
continue
|
||||
fi
|
||||
K_VER=$(strings "$FILE" 2>/dev/null | grep -E "^Linux version [0-9]+\.[0-9]+" | sort -u || true)
|
||||
K_VER=$(strings "${FILE}" 2>/dev/null | grep -E "^Linux version [0-9]+\.[0-9]+" | sort -u || true)
|
||||
|
||||
if [[ "$K_VER" =~ Linux\ version\ .* ]]; then
|
||||
if [[ "${K_VER}" =~ Linux\ version\ .* ]]; then
|
||||
print_ln
|
||||
print_output "[+] Possible Linux Kernel found: $ORANGE$FILE$NC"
|
||||
print_output "[+] Possible Linux Kernel found: ${ORANGE}${FILE}${NC}"
|
||||
print_ln
|
||||
print_output "$(indent "$(orange "$K_VER")")"
|
||||
print_output "$(indent "$(orange "${K_VER}")")"
|
||||
print_ln
|
||||
|
||||
# not perfect, but not too bad for now:
|
||||
mapfile -t K_INITS < <(strings "$FILE" 2>/dev/null | grep -E "init=\/" | sed 's/.*rdinit/rdinit/' | sed 's/.*\ init/init/' | awk '{print $1}' | tr -d '"' | sort -u || true)
|
||||
mapfile -t K_INITS < <(strings "${FILE}" 2>/dev/null | grep -E "init=\/" | sed 's/.*rdinit/rdinit/' | sed 's/.*\ init/init/' | awk '{print $1}' | tr -d '"' | sort -u || true)
|
||||
for K_INIT in "${K_INITS[@]}"; do
|
||||
if [[ "$K_INIT" =~ init=\/.* ]]; then
|
||||
print_output "[+] Init found in Linux kernel file $ORANGE$FILE$NC"
|
||||
if [[ "${K_INIT}" =~ init=\/.* ]]; then
|
||||
print_output "[+] Init found in Linux kernel file ${ORANGE}${FILE}${NC}"
|
||||
print_ln
|
||||
print_output "$(indent "$(orange "$K_INIT")")"
|
||||
print_output "$(indent "$(orange "${K_INIT}")")"
|
||||
print_ln
|
||||
else
|
||||
K_INIT="NA"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -e "$EXT_DIR"/vmlinux-to-elf/vmlinux-to-elf ]]; then
|
||||
print_output "[*] Testing possible Linux kernel file $ORANGE$FILE$NC with ${ORANGE}vmlinux-to-elf:$NC"
|
||||
if [[ -e "${EXT_DIR}"/vmlinux-to-elf/vmlinux-to-elf ]]; then
|
||||
print_output "[*] Testing possible Linux kernel file ${ORANGE}${FILE}${NC} with ${ORANGE}vmlinux-to-elf:${NC}"
|
||||
print_ln
|
||||
"$EXT_DIR"/vmlinux-to-elf/vmlinux-to-elf "$FILE" "$FILE".elf 2>/dev/null | tee -a "$LOG_FILE" || true
|
||||
if [[ -f "$FILE".elf ]]; then
|
||||
K_ELF=$(file "$FILE".elf)
|
||||
if [[ "$K_ELF" == *"ELF "* ]]; then
|
||||
"${EXT_DIR}"/vmlinux-to-elf/vmlinux-to-elf "${FILE}" "${FILE}".elf 2>/dev/null | tee -a "${LOG_FILE}" || true
|
||||
if [[ -f "${FILE}".elf ]]; then
|
||||
K_ELF=$(file "${FILE}".elf)
|
||||
if [[ "${K_ELF}" == *"ELF "* ]]; then
|
||||
print_ln
|
||||
print_output "[+] Successfully generated Linux kernel elf file: $ORANGE$FILE.elf$NC"
|
||||
print_output "[+] Successfully generated Linux kernel elf file: ${ORANGE}${FILE}.elf${NC}"
|
||||
else
|
||||
print_ln
|
||||
print_output "[-] No Linux kernel elf file was created."
|
||||
@@ -86,39 +86,39 @@ S24_kernel_bin_identifier()
|
||||
print_ln
|
||||
fi
|
||||
|
||||
disable_strict_mode "$STRICT_MODE" 0
|
||||
extract_kconfig "$FILE"
|
||||
enable_strict_mode "$STRICT_MODE" 0
|
||||
disable_strict_mode "${STRICT_MODE}" 0
|
||||
extract_kconfig "${FILE}"
|
||||
enable_strict_mode "${STRICT_MODE}" 0
|
||||
|
||||
# double check we really have a Kernel config extracted
|
||||
if [[ -f "$KCONFIG_EXTRACTED" ]] && [[ $(grep -c CONFIG_ "$KCONFIG_EXTRACTED") -gt 50 ]]; then
|
||||
CFG_CNT=$(grep -c CONFIG_ "$KCONFIG_EXTRACTED")
|
||||
print_output "[+] Extracted kernel configuration ($ORANGE$CFG_CNT configuration entries$GREEN) from $ORANGE$(basename "$FILE")$NC" "" "$KCONFIG_EXTRACTED"
|
||||
check_kconfig "$KCONFIG_EXTRACTED"
|
||||
if [[ -f "${KCONFIG_EXTRACTED}" ]] && [[ $(grep -c CONFIG_ "${KCONFIG_EXTRACTED}") -gt 50 ]]; then
|
||||
CFG_CNT=$(grep -c CONFIG_ "${KCONFIG_EXTRACTED}")
|
||||
print_output "[+] Extracted kernel configuration (${ORANGE}${CFG_CNT} configuration entries${GREEN}) from ${ORANGE}$(basename "${FILE}")${NC}" "" "${KCONFIG_EXTRACTED}"
|
||||
check_kconfig "${KCONFIG_EXTRACTED}"
|
||||
fi
|
||||
|
||||
K_VER_TMP="${K_VER/Linux version /}"
|
||||
demess_kv_version "$K_VER_TMP"
|
||||
demess_kv_version "${K_VER_TMP}"
|
||||
# -> KV_ARR
|
||||
|
||||
if [[ "$K_ELF" == *"ELF "* ]]; then
|
||||
K_ELF="$(echo "$K_ELF" | cut -d: -f1)"
|
||||
K_SYMBOLS="$(readelf -s "$K_ELF" | grep -c "FUNC\|OBJECT" || true)"
|
||||
K_FILE="$(file "$K_ELF" | cut -d: -f2-)"
|
||||
if [[ "${K_ELF}" == *"ELF "* ]]; then
|
||||
K_ELF="$(echo "${K_ELF}" | cut -d: -f1)"
|
||||
K_SYMBOLS="$(readelf -s "${K_ELF}" | grep -c "FUNC\|OBJECT" || true)"
|
||||
K_FILE="$(file "${K_ELF}" | cut -d: -f2-)"
|
||||
|
||||
[[ "$K_FILE" == *"LSB"* ]] && K_ARCH_END="EL"
|
||||
[[ "$K_FILE" == *"MSB"* ]] && K_ARCH_END="EB"
|
||||
[[ "${K_FILE}" == *"LSB"* ]] && K_ARCH_END="EL"
|
||||
[[ "${K_FILE}" == *"MSB"* ]] && K_ARCH_END="EB"
|
||||
|
||||
[[ "$K_FILE" == *"MIPS"* ]] && K_ARCH="MIPS"
|
||||
[[ "$K_FILE" == *"ARM"* ]] && K_ARCH="ARM"
|
||||
[[ "$K_FILE" == *"80386"* ]] && K_ARCH="x86"
|
||||
[[ "$K_FILE" == *"x86-64"* ]] && K_ARCH="x64"
|
||||
[[ "$K_FILE" == *"PowerPC"* ]] && K_ARCH="PPC"
|
||||
[[ "$K_FILE" == *"UCB RISC-V"* ]] && K_ARCH="RISCV"
|
||||
[[ "$K_FILE" == *"QUALCOMM DSP6"* ]] && K_ARCH="QCOM_DSP6"
|
||||
[[ "${K_FILE}" == *"MIPS"* ]] && K_ARCH="MIPS"
|
||||
[[ "${K_FILE}" == *"ARM"* ]] && K_ARCH="ARM"
|
||||
[[ "${K_FILE}" == *"80386"* ]] && K_ARCH="x86"
|
||||
[[ "${K_FILE}" == *"x86-64"* ]] && K_ARCH="x64"
|
||||
[[ "${K_FILE}" == *"PowerPC"* ]] && K_ARCH="PPC"
|
||||
[[ "${K_FILE}" == *"UCB RISC-V"* ]] && K_ARCH="RISCV"
|
||||
[[ "${K_FILE}" == *"QUALCOMM DSP6"* ]] && K_ARCH="QCOM_DSP6"
|
||||
else
|
||||
# fallback
|
||||
K_ARCH=$(grep "Guessed architecture" "$LOG_FILE" | cut -d: -f2 | awk '{print $1}' || true)
|
||||
K_ARCH=$(grep "Guessed architecture" "${LOG_FILE}" | cut -d: -f2 | awk '{print $1}' || true)
|
||||
[[ "${K_ARCH: -2}" == "le" ]] && K_ARCH_END="EL"
|
||||
[[ "${K_ARCH: -2}" == "be" ]] && K_ARCH_END="EB"
|
||||
fi
|
||||
@@ -127,34 +127,34 @@ S24_kernel_bin_identifier()
|
||||
for K_VER_CLEAN in "${KV_ARR[@]}"; do
|
||||
if [[ "${#K_INITS[@]}" -gt 0 ]]; then
|
||||
for K_INIT in "${K_INITS[@]}"; do
|
||||
if [[ "$CFG_CNT" -lt 50 ]]; then
|
||||
if [[ "${CFG_CNT}" -lt 50 ]]; then
|
||||
KCONFIG_EXTRACTED="NA"
|
||||
fi
|
||||
write_csv_log "$K_VER" "$K_VER_CLEAN" "$FILE" "$K_ELF" "$K_INIT" "$KCONFIG_EXTRACTED" "$K_SYMBOLS" "$K_ARCH" "$K_ARCH_END"
|
||||
write_csv_log "${K_VER}" "${K_VER_CLEAN}" "${FILE}" "${K_ELF}" "${K_INIT}" "${KCONFIG_EXTRACTED}" "${K_SYMBOLS}" "${K_ARCH}" "${K_ARCH_END}"
|
||||
done
|
||||
else
|
||||
write_csv_log "$K_VER" "$K_VER_CLEAN" "$FILE" "$K_ELF" "NA" "$KCONFIG_EXTRACTED" "$K_SYMBOLS" "$K_ARCH" "$K_ARCH_END"
|
||||
write_csv_log "${K_VER}" "${K_VER_CLEAN}" "${FILE}" "${K_ELF}" "NA" "${KCONFIG_EXTRACTED}" "${K_SYMBOLS}" "${K_ARCH}" "${K_ARCH_END}"
|
||||
fi
|
||||
done
|
||||
NEG_LOG=1
|
||||
|
||||
# ASCII kernel config files:
|
||||
elif file "$FILE" | grep -q "ASCII"; then
|
||||
CFG_MD5=$(md5sum "$FILE" | awk '{print $1}')
|
||||
elif file "${FILE}" | grep -q "ASCII"; then
|
||||
CFG_MD5=$(md5sum "${FILE}" | awk '{print $1}')
|
||||
if [[ ! " ${KCFG_MD5[*]} " =~ ${CFG_MD5} ]]; then
|
||||
K_CON_DET=$(strings "$FILE" 2>/dev/null | grep -E "^# Linux.*[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,2}.* Kernel Configuration" || true)
|
||||
if [[ "$K_CON_DET" =~ \ Kernel\ Configuration ]]; then
|
||||
K_CON_DET=$(strings "${FILE}" 2>/dev/null | grep -E "^# Linux.*[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,2}.* Kernel Configuration" || true)
|
||||
if [[ "${K_CON_DET}" =~ \ Kernel\ Configuration ]]; then
|
||||
print_ln
|
||||
print_output "[+] Found kernel configuration file: $ORANGE$FILE$NC"
|
||||
check_kconfig "$FILE"
|
||||
print_output "[+] Found kernel configuration file: ${ORANGE}${FILE}${NC}"
|
||||
check_kconfig "${FILE}"
|
||||
NEG_LOG=1
|
||||
KCFG_MD5+=("$CFG_MD5")
|
||||
KCFG_MD5+=("${CFG_MD5}")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
extract_kconfig() {
|
||||
@@ -173,24 +173,24 @@ extract_kconfig() {
|
||||
export IMG="${1:-}"
|
||||
export KCONFIG_EXTRACTED=""
|
||||
|
||||
if ! [[ -f "$IMG" ]]; then
|
||||
print_output "[-] No kernel file to analyze here - $ORANGE$IMG$NC"
|
||||
if ! [[ -f "${IMG}" ]]; then
|
||||
print_output "[-] No kernel file to analyze here - ${ORANGE}${IMG}${NC}"
|
||||
return
|
||||
fi
|
||||
|
||||
print_output "[*] Trying to extract kernel configuration from $ORANGE$IMG$NC"
|
||||
print_output "[*] Trying to extract kernel configuration from ${ORANGE}${IMG}${NC}"
|
||||
|
||||
export CF1='IKCFG_ST\037\213\010'
|
||||
export CF2='0123456789'
|
||||
|
||||
# Prepare temp files:
|
||||
export TMP1="$TMP_DIR"/ikconfig$$.1
|
||||
export TMP2="$TMP_DIR"/ikconfig$$.2
|
||||
export TMP1="${TMP_DIR}"/ikconfig$$.1
|
||||
export TMP2="${TMP_DIR}"/ikconfig$$.2
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -f $TMP1 $TMP2" 0
|
||||
trap "rm -f ${TMP1} ${TMP2}" 0
|
||||
|
||||
# Initial attempt for uncompressed images or objects:
|
||||
dump_config "$IMG"
|
||||
dump_config "${IMG}"
|
||||
[[ $? -eq 4 ]] && return
|
||||
|
||||
# That didn't work, so retry after decompression.
|
||||
@@ -221,32 +221,32 @@ dump_config() {
|
||||
local IMG_="${1:-}"
|
||||
local CFG_MD5=""
|
||||
|
||||
if ! [[ -f "$IMG_" ]]; then
|
||||
print_output "[-] No kernel file to analyze here - $ORANGE$IMG_$NC"
|
||||
if ! [[ -f "${IMG_}" ]]; then
|
||||
print_output "[-] No kernel file to analyze here - ${ORANGE}${IMG_}${NC}"
|
||||
return
|
||||
fi
|
||||
|
||||
if POS=$(tr "$CF1\n$CF2" "\n$CF2=" < "$IMG_" | grep -abo "^$CF2"); then
|
||||
if POS=$(tr "${CF1}\n${CF2}" "\n${CF2}=" < "${IMG_}" | grep -abo "^${CF2}"); then
|
||||
POS=${POS%%:*}
|
||||
|
||||
tail -c+"$((POS + 8))" "$IMG_" | zcat > "$TMP1" 2> /dev/null
|
||||
tail -c+"$((POS + 8))" "${IMG_}" | zcat > "${TMP1}" 2> /dev/null
|
||||
|
||||
if [[ $? != 1 ]]; then # exit status must be 0 or 2 (trailing garbage warning)
|
||||
[[ "$STRICT_MODE" -eq 1 ]] && set +e
|
||||
[[ "${STRICT_MODE}" -eq 1 ]] && set +e
|
||||
|
||||
if ! [[ -f "$TMP1" ]]; then
|
||||
if ! [[ -f "${TMP1}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
CFG_MD5=$(md5sum "$TMP1" | awk '{print $1}')
|
||||
CFG_MD5=$(md5sum "${TMP1}" | awk '{print $1}')
|
||||
if [[ ! " ${KCFG_MD5[*]} " =~ ${CFG_MD5} ]]; then
|
||||
KCONFIG_EXTRACTED="$LOG_PATH_MODULE/kernel_config_extracted_$(basename "$IMG_").log"
|
||||
cp "$TMP1" "$KCONFIG_EXTRACTED"
|
||||
KCFG_MD5+=("$CFG_MD5")
|
||||
KCONFIG_EXTRACTED="${LOG_PATH_MODULE}/kernel_config_extracted_$(basename "${IMG_}").log"
|
||||
cp "${TMP1}" "${KCONFIG_EXTRACTED}"
|
||||
KCFG_MD5+=("${CFG_MD5}")
|
||||
# return value of 4 means we are done and we are going back to the main function of this module for the next file
|
||||
return 4
|
||||
else
|
||||
print_output "[*] Firmware binary $ORANGE$IMG$NC already analyzed .. skipping"
|
||||
print_output "[*] Firmware binary ${ORANGE}${IMG}${NC} already analyzed .. skipping"
|
||||
return 4
|
||||
fi
|
||||
fi
|
||||
@@ -255,10 +255,10 @@ dump_config() {
|
||||
|
||||
try_decompress() {
|
||||
# Source: https://raw.githubusercontent.com/torvalds/linux/master/scripts/extract-ikconfig
|
||||
for POS in $(tr "$1\n$2" "\n$2=" < "$IMG" | grep -abo "^$2"); do
|
||||
for POS in $(tr "$1\n$2" "\n$2=" < "${IMG}" | grep -abo "^$2"); do
|
||||
POS=${POS%%:*}
|
||||
tail -c+"$POS" "$IMG" | "$3" > "$TMP2" 2> /dev/null
|
||||
dump_config "$TMP2"
|
||||
tail -c+"${POS}" "${IMG}" | "${3}" > "${TMP2}" 2> /dev/null
|
||||
dump_config "${TMP2}"
|
||||
[[ $? -eq 4 ]] && return 4
|
||||
done
|
||||
}
|
||||
@@ -272,20 +272,20 @@ check_kconfig() {
|
||||
return
|
||||
fi
|
||||
|
||||
if ! [[ -f "$KCONFIG_FILE" ]]; then
|
||||
if ! [[ -f "${KCONFIG_FILE}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
print_output "[*] Testing kernel configuration file $ORANGE$KCONFIG_FILE$NC with kconfig-hardened-check"
|
||||
print_output "[*] Testing kernel configuration file ${ORANGE}${KCONFIG_FILE}${NC} with kconfig-hardened-check"
|
||||
local KCONF_LOG=""
|
||||
KCONF_LOG="$LOG_PATH_MODULE/kconfig_hardening_check_$(basename "$KCONFIG_FILE").log"
|
||||
"$KCONF_HARD_CHECKER" -c "$KCONFIG_FILE" | tee -a "$KCONF_LOG" || true
|
||||
if [[ -f "$KCONF_LOG" ]]; then
|
||||
FAILED_KSETTINGS=$(grep -c "FAIL: " "$KCONF_LOG" || true)
|
||||
if [[ "$FAILED_KSETTINGS" -gt 0 ]]; then
|
||||
print_output "[+] Found $ORANGE$FAILED_KSETTINGS$GREEN security related kernel settings which should be reviewed - $ORANGE$(print_path "$KCONFIG_FILE")$NC" "" "$KCONF_LOG"
|
||||
KCONF_LOG="${LOG_PATH_MODULE}/kconfig_hardening_check_$(basename "${KCONFIG_FILE}").log"
|
||||
"${KCONF_HARD_CHECKER}" -c "${KCONFIG_FILE}" | tee -a "${KCONF_LOG}" || true
|
||||
if [[ -f "${KCONF_LOG}" ]]; then
|
||||
FAILED_KSETTINGS=$(grep -c "FAIL: " "${KCONF_LOG}" || true)
|
||||
if [[ "${FAILED_KSETTINGS}" -gt 0 ]]; then
|
||||
print_output "[+] Found ${ORANGE}${FAILED_KSETTINGS}${GREEN} security related kernel settings which should be reviewed - ${ORANGE}$(print_path "${KCONFIG_FILE}")${NC}" "" "${KCONF_LOG}"
|
||||
print_ln
|
||||
write_log "[*] Statistics:$FAILED_KSETTINGS"
|
||||
write_log "[*] Statistics:${FAILED_KSETTINGS}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
+78
-78
@@ -42,14 +42,14 @@ S25_kernel_check()
|
||||
write_csv_log "BINARY" "VERSION" "CVE identifier" "CVSS rating" "exploit db exploit available" "metasploit module" "trickest PoC" "Routersploit" "local exploit" "remote exploit" "DoS exploit" "known exploited vuln"
|
||||
print_output "Kernel version:"
|
||||
for LINE in "${KERNEL_VERSION[@]}" ; do
|
||||
print_output "$(indent "$ORANGE$LINE$NC")"
|
||||
print_output "$(indent "${ORANGE}${LINE}${NC}")"
|
||||
FOUND=1
|
||||
done
|
||||
if [[ ${#KERNEL_DESC[@]} -ne 0 ]] ; then
|
||||
print_ln
|
||||
print_output "Kernel details:"
|
||||
for LINE in "${KERNEL_DESC[@]}" ; do
|
||||
print_output "$(indent "$LINE")"
|
||||
print_output "$(indent "${LINE}")"
|
||||
FOUND=1
|
||||
done
|
||||
fi
|
||||
@@ -59,9 +59,9 @@ S25_kernel_check()
|
||||
print_output "[-] No kernel version identified"
|
||||
fi
|
||||
|
||||
if [[ "$KERNEL" -eq 1 ]] && [[ -f "$KERNEL_CONFIG" ]]; then
|
||||
if [[ "${KERNEL}" -eq 1 ]] && [[ -f "${KERNEL_CONFIG}" ]]; then
|
||||
# we use check_kconfig from s24 module
|
||||
check_kconfig "$KERNEL_CONFIG"
|
||||
check_kconfig "${KERNEL_CONFIG}"
|
||||
FOUND=1
|
||||
else
|
||||
print_output "[-] No check for kernel configuration"
|
||||
@@ -74,12 +74,12 @@ S25_kernel_check()
|
||||
|
||||
if [[ ${#KERNEL_VERSION[@]} -ne 0 ]] ; then
|
||||
for K_VERS in "${KERNEL_VERSION[@]}" ; do
|
||||
write_log "[*] Statistics:$K_VERS"
|
||||
write_log "[*] Statistics:${K_VERS}"
|
||||
done
|
||||
fi
|
||||
write_log "[*] Statistics1:${#KERNEL_MODULES[@]}:$KMOD_BAD"
|
||||
write_log "[*] Statistics1:${#KERNEL_MODULES[@]}:${KMOD_BAD}"
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$FOUND"
|
||||
module_end_log "${FUNCNAME[0]}" "${FOUND}"
|
||||
}
|
||||
|
||||
populate_karrays() {
|
||||
@@ -89,19 +89,19 @@ populate_karrays() {
|
||||
local K_VER=""
|
||||
local V=""
|
||||
|
||||
mapfile -t KERNEL_MODULES < <( find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev \( -iname "*.ko" -o -iname "*.o" \) -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
mapfile -t KERNEL_MODULES < <( find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev \( -iname "*.ko" -o -iname "*.o" \) -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
|
||||
for K_MODULE in "${KERNEL_MODULES[@]}"; do
|
||||
if [[ "$K_MODULE" =~ .*\.o ]]; then
|
||||
KERNEL_VERSION+=( "$(strings "$K_MODULE" 2>/dev/null | grep "kernel_version=" | cut -d= -f2 || true)" )
|
||||
if [[ "${K_MODULE}" =~ .*\.o ]]; then
|
||||
KERNEL_VERSION+=( "$(strings "${K_MODULE}" 2>/dev/null | grep "kernel_version=" | cut -d= -f2 || true)" )
|
||||
continue
|
||||
fi
|
||||
KERNEL_VERSION+=( "$(modinfo "$K_MODULE" 2>/dev/null | grep -E "vermagic" | cut -d: -f2 | sed 's/^ *//g' || true)" )
|
||||
KERNEL_DESC+=( "$(modinfo "$K_MODULE" 2>/dev/null | grep -E "description" | cut -d: -f2 | sed 's/^ *//g' | tr -c '[:alnum:]\n\r' '_' | sort -u || true)" )
|
||||
KERNEL_VERSION+=( "$(modinfo "${K_MODULE}" 2>/dev/null | grep -E "vermagic" | cut -d: -f2 | sed 's/^ *//g' || true)" )
|
||||
KERNEL_DESC+=( "$(modinfo "${K_MODULE}" 2>/dev/null | grep -E "description" | cut -d: -f2 | sed 's/^ *//g' | tr -c '[:alnum:]\n\r' '_' | sort -u || true)" )
|
||||
done
|
||||
|
||||
for VER in "${KERNEL_VERSION[@]}" ; do
|
||||
demess_kv_version "$VER"
|
||||
demess_kv_version "${VER}"
|
||||
|
||||
IFS=" " read -r -a KV_C_ARR <<< "$(echo "${KV_ARR[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
|
||||
for V in "${KV_C_ARR[@]}" ; do
|
||||
@@ -109,48 +109,48 @@ populate_karrays() {
|
||||
# remove empty entries:
|
||||
continue
|
||||
fi
|
||||
if ! [[ "$V" =~ .*[0-9]\.[0-9].* ]]; then
|
||||
if ! [[ "${V}" =~ .*[0-9]\.[0-9].* ]]; then
|
||||
continue
|
||||
fi
|
||||
KERNEL_VERSION_+=( "$V" )
|
||||
KERNEL_VERSION_+=( "${V}" )
|
||||
done
|
||||
done
|
||||
|
||||
# if we have found a kernel version in binary kernel:
|
||||
if [[ -f "$CSV_DIR"/s24_kernel_bin_identifier.csv ]]; then
|
||||
if [[ -f "${CSV_DIR}"/s24_kernel_bin_identifier.csv ]]; then
|
||||
while IFS=";" read -r K_VER; do
|
||||
K_VER="$(echo "$K_VER" | sed 's/Linux\ version\ //g' | tr -d "(" | tr -d ")" | tr -d "#")"
|
||||
K_VER="$(echo "${K_VER}" | sed 's/Linux\ version\ //g' | tr -d "(" | tr -d ")" | tr -d "#")"
|
||||
|
||||
demess_kv_version "$K_VER"
|
||||
demess_kv_version "${K_VER}"
|
||||
|
||||
IFS=" " read -r -a KV_C_ARR <<< "$(echo "${KV_ARR[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
|
||||
|
||||
for V in "${KV_C_ARR[@]}" ; do
|
||||
KERNEL_VERSION_+=( "$V" )
|
||||
KERNEL_VERSION_+=( "${V}" )
|
||||
done
|
||||
done < <(cut -d ";" -f1 "$CSV_DIR"/s24_kernel_bin_identifier.csv | tail -n +2)
|
||||
done < <(cut -d ";" -f1 "${CSV_DIR}"/s24_kernel_bin_identifier.csv | tail -n +2)
|
||||
fi
|
||||
|
||||
# unique our results
|
||||
eval "KERNEL_VERSION_=($(for i in "${KERNEL_VERSION_[@]}" ; do
|
||||
if [[ -z "$i" ]]; then
|
||||
if [[ -z "${i}" ]]; then
|
||||
# remove empty entries:
|
||||
continue;
|
||||
fi
|
||||
if ! [[ "$i" =~ .*[0-9]\.[0-9].* ]]; then
|
||||
if ! [[ "${i}" =~ .*[0-9]\.[0-9].* ]]; then
|
||||
# remove lines without a possible version identifier like *1.2*
|
||||
continue;
|
||||
fi
|
||||
echo "\"$i\"" ;
|
||||
echo "\"${i}\"" ;
|
||||
done | sort -u))"
|
||||
|
||||
eval "KERNEL_DESC=($(for i in "${KERNEL_DESC[@]}" ; do echo "\"$i\"" ; done | sort -u))"
|
||||
eval "KERNEL_DESC=($(for i in "${KERNEL_DESC[@]}" ; do echo "\"${i}}\"" ; done | sort -u))"
|
||||
|
||||
# if we have no kernel version identified -> we try to identify a possible identifier in the path:
|
||||
if [[ "${#KERNEL_VERSION_[@]}" -eq 0 && "${#KERNEL_MODULES[@]}" -ne 0 ]];then
|
||||
# remove the first part of the path:
|
||||
KERNEL_VERSION1=$(echo "${KERNEL_MODULES[0]}" | sed 's/.*\/lib\/modules\///')
|
||||
KERNEL_VERSION_+=("$KERNEL_VERSION1")
|
||||
KERNEL_VERSION_+=("${KERNEL_VERSION1}")
|
||||
# demess_kv_version removes the unneeded stuff after the version:
|
||||
demess_kv_version "${KERNEL_VERSION_[@]}"
|
||||
# now rewrite the temp KERNEL_VERSION_ array
|
||||
@@ -168,21 +168,21 @@ demess_kv_version() {
|
||||
|
||||
# sometimes our kernel version is wasted with some "-" -> so we exchange them with spaces for the exploit suggester
|
||||
for VER in "${K_VERSION[@]}" ; do
|
||||
if ! [[ "$VER" == *[0-9]* ]]; then
|
||||
if ! [[ "${VER}" == *[0-9]* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
KV=$(echo "$VER" | tr "-" " ")
|
||||
KV=$(echo "$KV" | tr "+" " ")
|
||||
KV=$(echo "$KV" | tr "_" " ")
|
||||
KV=$(echo "$KV" | tr "/" " ")
|
||||
KV=$(echo "${VER}" | tr "-" " ")
|
||||
KV=$(echo "${KV}" | tr "+" " ")
|
||||
KV=$(echo "${KV}" | tr "_" " ")
|
||||
KV=$(echo "${KV}" | tr "/" " ")
|
||||
# the first field is the real kernel version:
|
||||
KV=$(echo "$KV" | cut -d\ -f1)
|
||||
KV=$(echo "${KV}" | cut -d\ -f1)
|
||||
|
||||
while echo "$KV" | grep -q '[a-zA-Z]'; do
|
||||
while echo "${KV}" | grep -q '[a-zA-Z]'; do
|
||||
KV="${KV::-1}"
|
||||
done
|
||||
KV_ARR=("${KV_ARR[@]}" "$KV")
|
||||
KV_ARR=("${KV_ARR[@]}" "${KV}")
|
||||
done
|
||||
}
|
||||
|
||||
@@ -194,33 +194,33 @@ get_kernel_vulns() {
|
||||
if [[ "${#KERNEL_VERSION[@]}" -gt 0 ]]; then
|
||||
print_output "[+] Found linux kernel version/s:"
|
||||
for VER in "${KERNEL_VERSION[@]}" ; do
|
||||
print_output "$(indent "$ORANGE$VER$NC")"
|
||||
print_output "$(indent "${ORANGE}${VER}${NC}")"
|
||||
done
|
||||
print_ln
|
||||
|
||||
if [[ -f "$EXT_DIR""/linux-exploit-suggester.sh" ]] ; then
|
||||
if [[ -f "${EXT_DIR}""/linux-exploit-suggester.sh" ]] ; then
|
||||
# sometimes our kernel version is wasted with some "-" -> so we exchange them with spaces for the exploit suggester
|
||||
demess_kv_version "${KERNEL_VERSION[@]}"
|
||||
IFS=" " read -r -a KV_C_ARR <<< "$(echo "${KV_ARR[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
|
||||
for VER in "${KV_C_ARR[@]}" ; do
|
||||
sub_module_title "Possible exploits via linux-exploit-suggester.sh for kernel version $ORANGE$VER$NC"
|
||||
print_output "[*] Search possible exploits via linux-exploit-suggester.sh for kernel version $ORANGE$VER$NC"
|
||||
sub_module_title "Possible exploits via linux-exploit-suggester.sh for kernel version ${ORANGE}${VER}${NC}"
|
||||
print_output "[*] Search possible exploits via linux-exploit-suggester.sh for kernel version ${ORANGE}${VER}${NC}"
|
||||
print_output "$(indent "https://github.com/mzet-/linux-exploit-suggester")"
|
||||
"$EXT_DIR""/linux-exploit-suggester.sh" --skip-more-checks -f -d -k "$VER" >> "$LOG_PATH_MODULE""/linux_exploit_suggester_kernel_$VER.txt"
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE""/linux_exploit_suggester_kernel_$VER.txt"
|
||||
if [[ -f "$LOG_PATH_MODULE""/linux_exploit_suggester_kernel_$VER.txt" ]]; then
|
||||
mapfile -t LES_CVE_ENTRIES < <(grep "[+]" "$LOG_PATH_MODULE""/linux_exploit_suggester_kernel_$VER.txt" | grep -E "CVE-[0-9]+")
|
||||
"${EXT_DIR}""/linux-exploit-suggester.sh" --skip-more-checks -f -d -k "${VER}" >> "${LOG_PATH_MODULE}""/linux_exploit_suggester_kernel_${VER}.txt"
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}""/linux_exploit_suggester_kernel_${VER}.txt"
|
||||
if [[ -f "${LOG_PATH_MODULE}""/linux_exploit_suggester_kernel_${VER}.txt" ]]; then
|
||||
mapfile -t LES_CVE_ENTRIES < <(grep "[+]" "${LOG_PATH_MODULE}""/linux_exploit_suggester_kernel_${VER}.txt" | grep -E "CVE-[0-9]+")
|
||||
for LES_ENTRY in "${LES_CVE_ENTRIES[@]}"; do
|
||||
LES_ENTRY=$(strip_color_codes "$LES_ENTRY")
|
||||
LES_CVE=$(echo "$LES_ENTRY" | awk '{print $2}' | tr -d '[' | tr -d ']')
|
||||
LES_ENTRY=$(strip_color_codes "${LES_ENTRY}")
|
||||
LES_CVE=$(echo "${LES_ENTRY}" | awk '{print $2}' | tr -d '[' | tr -d ']')
|
||||
KNOWN_EXPLOITED=0
|
||||
if [[ -f "$KNOWN_EXP_CSV" ]]; then
|
||||
if grep -q \""${LES_CVE}"\", "$KNOWN_EXP_CSV"; then
|
||||
print_output "[+] ${ORANGE}WARNING:$GREEN Vulnerability $ORANGE$LES_CVE$GREEN is a known exploited vulnerability."
|
||||
if [[ -f "${KNOWN_EXP_CSV}" ]]; then
|
||||
if grep -q \""${LES_CVE}"\", "${KNOWN_EXP_CSV}"; then
|
||||
print_output "[+] ${ORANGE}WARNING:${GREEN }Vulnerability ${ORANGE}${LES_CVE}${GREEN} is a known exploited vulnerability."
|
||||
KNOWN_EXPLOITED=1
|
||||
fi
|
||||
fi
|
||||
write_csv_log "kernel" "$VER" "$LES_CVE" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "$KNOWN_EXPLOITED"
|
||||
write_csv_log "kernel" "${VER}" "${LES_CVE}" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "NA" "${KNOWN_EXPLOITED}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
@@ -240,25 +240,25 @@ analyze_kernel_module() {
|
||||
KMOD_BAD=0
|
||||
local KMODULE=""
|
||||
|
||||
print_output "[*] Found $ORANGE${#KERNEL_MODULES[@]}$NC kernel modules."
|
||||
print_output "[*] Found ${ORANGE}${#KERNEL_MODULES[@]}${NC} kernel modules."
|
||||
|
||||
for KMODULE in "${KERNEL_MODULES[@]}" ; do
|
||||
# modinfos can run in parallel:
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
module_analyzer "$KMODULE" &
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
module_analyzer "${KMODULE}" &
|
||||
local TMP_PID="$!"
|
||||
store_kill_pids "$TMP_PID"
|
||||
WAIT_PIDS_S25+=( "$TMP_PID" )
|
||||
store_kill_pids "${TMP_PID}"
|
||||
WAIT_PIDS_S25+=( "${TMP_PID}" )
|
||||
else
|
||||
module_analyzer "$KMODULE"
|
||||
module_analyzer "${KMODULE}"
|
||||
fi
|
||||
done
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S25[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S25[@]}"
|
||||
|
||||
# in threading we need to go via a temp file with the need to count it now:
|
||||
if [[ -f "$TMP_DIR"/KMOD_BAD.tmp ]]; then
|
||||
KMOD_BAD=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/KMOD_BAD.tmp)
|
||||
if [[ -f "${TMP_DIR}"/KMOD_BAD.tmp ]]; then
|
||||
KMOD_BAD=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/KMOD_BAD.tmp)
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -266,30 +266,30 @@ module_analyzer() {
|
||||
local KMODULE="${1:-}"
|
||||
local LINE=""
|
||||
|
||||
if [[ "$KMODULE" == *".ko" ]]; then
|
||||
LINE=$(modinfo "$KMODULE" | grep -E "filename|license" | cut -d: -f1,2 | sed ':a;N;$!ba;s/\nlicense//g' | sed 's/filename: //' | sed 's/ //g' | sed 's/:/||license:/' || true)
|
||||
if [[ "${KMODULE}" == *".ko" ]]; then
|
||||
LINE=$(modinfo "${KMODULE}" | grep -E "filename|license" | cut -d: -f1,2 | sed ':a;N;$!ba;s/\nlicense//g' | sed 's/filename: //' | sed 's/ //g' | sed 's/:/||license:/' || true)
|
||||
local M_PATH
|
||||
M_PATH="$( echo "$LINE" | cut -d '|' -f 1 )"
|
||||
M_PATH="$( echo "${LINE}" | cut -d '|' -f 1 )"
|
||||
local LICENSE
|
||||
LICENSE="$( echo "$LINE" | cut -d '|' -f 3 | sed 's/license:/License: /' )"
|
||||
LICENSE="$( echo "${LINE}" | cut -d '|' -f 3 | sed 's/license:/License: /' )"
|
||||
|
||||
if file "$M_PATH" 2>/dev/null | grep -q 'not stripped'; then
|
||||
if echo "$LINE" | grep -q -e 'license:*GPL' -e 'license:.*BSD' ; then
|
||||
if file "${M_PATH}" 2>/dev/null | grep -q 'not stripped'; then
|
||||
if echo "${LINE}" | grep -q -e 'license:*GPL' -e 'license:.*BSD' ; then
|
||||
# kernel module is GPL/BSD license then not stripped is fine
|
||||
print_output "[-] Found kernel module ""${NC}""$(print_path "$M_PATH")"" ${ORANGE}""$LICENSE""${NC}"" - ""${GREEN}""NOT STRIPPED""${NC}"
|
||||
elif ! [[ $LICENSE =~ "License:" ]] ; then
|
||||
print_output "[+] Found kernel module ""${NC}""$(print_path "$M_PATH")"" ${ORANGE}""License not found""${NC}"" - ""${RED}""NOT STRIPPED""${NC}"
|
||||
print_output "[-] Found kernel module ""${NC}""$(print_path "${M_PATH}")"" ${ORANGE}""${LICENSE}""${NC}"" - ""${GREEN}""NOT STRIPPED""${NC}"
|
||||
elif ! [[ ${LICENSE} =~ "License:" ]] ; then
|
||||
print_output "[+] Found kernel module ""${NC}""$(print_path "${M_PATH}")"" ${ORANGE}""License not found""${NC}"" - ""${RED}""NOT STRIPPED""${NC}"
|
||||
else
|
||||
# kernel module is NOT GPL license then not stripped is bad!
|
||||
print_output "[+] Found kernel module ""${NC}""$(print_path "$M_PATH")"" ${ORANGE}""$LICENSE""${NC}"" - ""${RED}""NOT STRIPPED""${NC}"
|
||||
echo "1" >> "$TMP_DIR"/KMOD_BAD.tmp
|
||||
print_output "[+] Found kernel module ""${NC}""$(print_path "${M_PATH}")"" ${ORANGE}""${LICENSE}""${NC}"" - ""${RED}""NOT STRIPPED""${NC}"
|
||||
echo "1" >> "${TMP_DIR}"/KMOD_BAD.tmp
|
||||
fi
|
||||
else
|
||||
print_output "[-] Found kernel module ""${NC}""$(print_path "$M_PATH")"" ${ORANGE}""$LICENSE""${NC}"" - ""${GREEN}""STRIPPED""${NC}"
|
||||
print_output "[-] Found kernel module ""${NC}""$(print_path "${M_PATH}")"" ${ORANGE}""${LICENSE}""${NC}"" - ""${GREEN}""STRIPPED""${NC}"
|
||||
fi
|
||||
|
||||
elif [[ "$KMODULE" == *".o" ]]; then
|
||||
print_output "[-] No support for .o kernel modules - $ORANGE$KMODULE$NC"
|
||||
elif [[ "${KMODULE}" == *".o" ]]; then
|
||||
print_output "[-] No support for .o kernel modules - ${ORANGE}${KMODULE}${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -302,24 +302,24 @@ check_modprobe() {
|
||||
local MODPROBE_D_DIRS=()
|
||||
local MPROBE_DIR=""
|
||||
|
||||
readarray -t MODPROBE_D_DIRS < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*modprobe.d*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t MODPROBE_D_DIRS < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*modprobe.d*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
for MPROBE_DIR in "${MODPROBE_D_DIRS[@]}"; do
|
||||
if [[ -d "$MPROBE_DIR" ]] ; then
|
||||
if [[ -d "${MPROBE_DIR}" ]] ; then
|
||||
MP_CHECK=1
|
||||
print_output "[+] Found ""$(print_path "$MPROBE_DIR")"
|
||||
readarray -t MODPROBE_D_DIR_CONTENT <<< "$( find "$MPROBE_DIR" -xdev -iname '*.conf' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )"
|
||||
print_output "[+] Found ""$(print_path "${MPROBE_DIR}")"
|
||||
readarray -t MODPROBE_D_DIR_CONTENT <<< "$( find "${MPROBE_DIR}" -xdev -iname '*.conf' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )"
|
||||
for MP_CONF in "${MODPROBE_D_DIR_CONTENT[@]}"; do
|
||||
if [[ -e "$MP_CONF" ]] ; then
|
||||
if [[ -e "${MP_CONF}" ]] ; then
|
||||
MP_F_CHECK=1
|
||||
print_output "$(indent "$(orange "$(print_path "$MP_CONF")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${MP_CONF}")")")"
|
||||
fi
|
||||
done
|
||||
if [[ $MP_F_CHECK -eq 0 ]] ; then
|
||||
if [[ ${MP_F_CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No config files in modprobe.d directory found"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ $MP_CHECK -eq 0 ]] ; then
|
||||
if [[ ${MP_CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No modprobe.d directory found"
|
||||
fi
|
||||
}
|
||||
|
||||
+217
-217
@@ -26,14 +26,14 @@ S26_kernel_vuln_verifier()
|
||||
|
||||
HOME_DIR="$(pwd)"
|
||||
# KERNEL_ARCH_PATH is the directory where we store all the kernels
|
||||
KERNEL_ARCH_PATH="$EXT_DIR""/linux_kernel_sources"
|
||||
S24_CSV_LOG="$CSV_DIR""/s24_kernel_bin_identifier.csv"
|
||||
KERNEL_ARCH_PATH="${EXT_DIR}""/linux_kernel_sources"
|
||||
S24_CSV_LOG="${CSV_DIR}""/s24_kernel_bin_identifier.csv"
|
||||
WAIT_PIDS_S26=()
|
||||
NEG_LOG=0
|
||||
|
||||
if ! [[ -d "$KERNEL_ARCH_PATH" ]]; then
|
||||
if ! [[ -d "${KERNEL_ARCH_PATH}" ]]; then
|
||||
print_output "[-] Missing directory for kernel sources ... exit module now"
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -41,14 +41,14 @@ S26_kernel_vuln_verifier()
|
||||
module_wait "S24_kernel_bin_identifier"
|
||||
|
||||
# now we should have a csv log with a kernel version:
|
||||
if ! [[ -f "$S24_CSV_LOG" ]] || [[ "$(wc -l "$S24_CSV_LOG" | awk '{print $1}')" -lt 2 ]]; then
|
||||
if ! [[ -f "${S24_CSV_LOG}" ]] || [[ "$(wc -l "${S24_CSV_LOG}" | awk '{print $1}')" -lt 2 ]]; then
|
||||
print_output "[-] No Kernel version file (s24 results) identified ..."
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
return
|
||||
fi
|
||||
|
||||
# extract kernel version
|
||||
get_csv_data_s24 "$S24_CSV_LOG"
|
||||
get_csv_data_s24 "${S24_CSV_LOG}"
|
||||
|
||||
local KERNEL_DATA=""
|
||||
local KERNEL_ELF_EMBA=()
|
||||
@@ -58,41 +58,41 @@ S26_kernel_vuln_verifier()
|
||||
|
||||
for K_VERSION in "${K_VERSIONS[@]}"; do
|
||||
local K_FOUND=0
|
||||
print_output "[+] Identified kernel version: $ORANGE$K_VERSION$NC"
|
||||
print_output "[+] Identified kernel version: ${ORANGE}${K_VERSION}${NC}"
|
||||
|
||||
mapfile -t KERNEL_ELF_EMBA < <(grep "$K_VERSION" "$S24_CSV_LOG" | cut -d\; -f4-7 | \
|
||||
mapfile -t KERNEL_ELF_EMBA < <(grep "${K_VERSION}" "${S24_CSV_LOG}" | cut -d\; -f4-7 | \
|
||||
grep -v "config extracted" | sort -u | sort -r -n -t\; -k4 || true)
|
||||
|
||||
# we check for a kernel configuration
|
||||
for KERNEL_DATA in "${KERNEL_ELF_EMBA[@]}"; do
|
||||
if [[ "$(echo "$KERNEL_DATA" | cut -d\; -f3)" == "/"* ]]; then
|
||||
if [[ "$(echo "${KERNEL_DATA}" | cut -d\; -f3)" == "/"* ]]; then
|
||||
# field 3 is the kernel config file
|
||||
KERNEL_CONFIG_PATH=$(echo "$KERNEL_DATA" | cut -d\; -f3)
|
||||
print_output "[+] Found kernel configuration file: $ORANGE$KERNEL_CONFIG_PATH$NC"
|
||||
KERNEL_CONFIG_PATH=$(echo "${KERNEL_DATA}" | cut -d\; -f3)
|
||||
print_output "[+] Found kernel configuration file: ${ORANGE}${KERNEL_CONFIG_PATH}${NC}"
|
||||
# we use the first entry with a kernel config detected
|
||||
if [[ "$(echo "$KERNEL_DATA" | cut -d\; -f1)" == "/"* ]]; then
|
||||
if [[ "$(echo "${KERNEL_DATA}" | cut -d\; -f1)" == "/"* ]]; then
|
||||
# field 1 is the matching kernel elf file - sometimes we have a config but no elf file
|
||||
KERNEL_ELF_PATH=$(echo "$KERNEL_DATA" | cut -d\; -f1)
|
||||
print_output "[+] Found kernel elf file: $ORANGE$KERNEL_ELF_PATH$NC"
|
||||
KERNEL_ELF_PATH=$(echo "${KERNEL_DATA}" | cut -d\; -f1)
|
||||
print_output "[+] Found kernel elf file: ${ORANGE}${KERNEL_ELF_PATH}${NC}"
|
||||
K_FOUND=1
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$K_FOUND" -ne 1 ]]; then
|
||||
print_output "[-] No kernel configuration file with matching elf file found for kernel $ORANGE$K_VERSION$NC."
|
||||
if [[ "${K_FOUND}" -ne 1 ]]; then
|
||||
print_output "[-] No kernel configuration file with matching elf file found for kernel ${ORANGE}${K_VERSION}${NC}."
|
||||
fi
|
||||
|
||||
if [[ "$K_FOUND" -ne 1 ]]; then
|
||||
if [[ "${K_FOUND}" -ne 1 ]]; then
|
||||
for KERNEL_DATA in "${KERNEL_ELF_EMBA[@]}"; do
|
||||
# check for some path indicator for the elf file
|
||||
if [[ "$(echo "$KERNEL_DATA" | cut -d\; -f1)" == "/"* ]]; then
|
||||
if [[ "$(echo "${KERNEL_DATA}" | cut -d\; -f1)" == "/"* ]]; then
|
||||
# now we check for init entries
|
||||
if ! [[ "$(echo "$KERNEL_DATA" | cut -d\; -f2)" == "NA" ]]; then
|
||||
KERNEL_ELF_PATH=$(echo "$KERNEL_DATA" | cut -d\; -f1)
|
||||
if ! [[ "$(echo "${KERNEL_DATA}" | cut -d\; -f2)" == "NA" ]]; then
|
||||
KERNEL_ELF_PATH=$(echo "${KERNEL_DATA}" | cut -d\; -f1)
|
||||
# we use the first entry with a kernel init detected
|
||||
print_output "[+] Found kernel elf file with init entry: $ORANGE$KERNEL_ELF_PATH$NC"
|
||||
print_output "[+] Found kernel elf file with init entry: ${ORANGE}${KERNEL_ELF_PATH}${NC}"
|
||||
K_FOUND=1
|
||||
break
|
||||
fi
|
||||
@@ -100,15 +100,15 @@ S26_kernel_vuln_verifier()
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$K_FOUND" -ne 1 ]]; then
|
||||
if [[ "${K_FOUND}" -ne 1 ]]; then
|
||||
for KERNEL_DATA in "${KERNEL_ELF_EMBA[@]}"; do
|
||||
# check for some path indicator for the elf file
|
||||
if [[ "$(echo "$KERNEL_DATA" | cut -d\; -f1)" == "/"* ]]; then
|
||||
if [[ "$(echo "${KERNEL_DATA}" | cut -d\; -f1)" == "/"* ]]; then
|
||||
# this means we have no kernel configuration found
|
||||
# and no init entry -> we just use the first valid elf file
|
||||
if ! [[ "$(echo "$KERNEL_DATA" | cut -d\; -f1)" == "NA" ]]; then
|
||||
KERNEL_ELF_PATH=$(echo "$KERNEL_DATA" | cut -d\; -f1)
|
||||
print_output "[+] Found kernel elf file: $ORANGE$KERNEL_ELF_PATH$NC"
|
||||
if ! [[ "$(echo "${KERNEL_DATA}" | cut -d\; -f1)" == "NA" ]]; then
|
||||
KERNEL_ELF_PATH=$(echo "${KERNEL_DATA}" | cut -d\; -f1)
|
||||
print_output "[+] Found kernel elf file: ${ORANGE}${KERNEL_ELF_PATH}${NC}"
|
||||
# we use the first entry as final resort
|
||||
K_FOUND=1
|
||||
break
|
||||
@@ -117,74 +117,74 @@ S26_kernel_vuln_verifier()
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -f "$KERNEL_CONFIG" ]]; then
|
||||
if [[ -f "${KERNEL_CONFIG}" ]]; then
|
||||
# check if the provided configuration is for the kernel version under test
|
||||
if grep -q "$K_VERSION" "$KERNEL_CONFIG"; then
|
||||
KERNEL_CONFIG_PATH="$KERNEL_CONFIG"
|
||||
print_output "[+] Using provided kernel configuration file: $ORANGE$KERNEL_CONFIG_PATH$NC"
|
||||
if grep -q "${K_VERSION}" "${KERNEL_CONFIG}"; then
|
||||
KERNEL_CONFIG_PATH="${KERNEL_CONFIG}"
|
||||
print_output "[+] Using provided kernel configuration file: ${ORANGE}${KERNEL_CONFIG_PATH}${NC}"
|
||||
K_FOUND=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$K_FOUND" -ne 1 ]]; then
|
||||
print_output "[-] No valid kernel information found for kernel $ORANGE$K_VERSION$NC."
|
||||
if [[ "${K_FOUND}" -ne 1 ]]; then
|
||||
print_output "[-] No valid kernel information found for kernel ${ORANGE}${K_VERSION}${NC}."
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! [[ -f "$KERNEL_ELF_PATH" ]]; then
|
||||
if ! [[ -f "${KERNEL_ELF_PATH}" ]]; then
|
||||
print_output "[-] Warning: Kernel ELF file not found"
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
continue
|
||||
fi
|
||||
if ! [[ -v K_VERSION ]]; then
|
||||
print_output "[-] Missing kernel version .. exit now"
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
continue
|
||||
fi
|
||||
|
||||
CVE_DETAILS_PATH="$LOG_PATH_MODULE""/kernel-$K_VERSION-vulns.json"
|
||||
CVE_DETAILS_PATH="${LOG_PATH_MODULE}""/kernel-${K_VERSION}-vulns.json"
|
||||
|
||||
if ! [[ -f $PATH_CVE_SEARCH ]]; then
|
||||
if ! [[ -f ${PATH_CVE_SEARCH} ]]; then
|
||||
print_output "[-] CVE search binary search.py not found."
|
||||
print_output "[-] Run the installer or install it from here: https://github.com/cve-search/cve-search."
|
||||
print_output "[-] Installation instructions can be found on github.io: https://cve-search.github.io/cve-search/getting_started/installation.html#installation"
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
return
|
||||
fi
|
||||
|
||||
check_cve_search
|
||||
|
||||
if [[ "$CVE_SEARCH" -eq 0 ]]; then
|
||||
if [[ "${CVE_SEARCH}" -eq 0 ]]; then
|
||||
print_output "[*] Waiting for the cve-search environment ..."
|
||||
sleep 120
|
||||
check_cve_search
|
||||
|
||||
if [[ "$CVE_SEARCH" -eq 0 ]]; then
|
||||
if [[ "${CVE_SEARCH}" -eq 0 ]]; then
|
||||
print_output "[*] Waiting for the cve-search environment ..."
|
||||
sleep 120
|
||||
check_cve_search
|
||||
fi
|
||||
fi
|
||||
if [[ "$CVE_SEARCH" -ne 1 ]]; then
|
||||
if [[ "${CVE_SEARCH}" -ne 1 ]]; then
|
||||
print_cve_search_failure
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$KERNEL_ELF_PATH" ]]; then
|
||||
extract_kernel_arch "$KERNEL_ELF_PATH"
|
||||
if [[ -f "${KERNEL_ELF_PATH}" ]]; then
|
||||
extract_kernel_arch "${KERNEL_ELF_PATH}"
|
||||
fi
|
||||
|
||||
if [[ "$K_VERSION" == *".0" ]]; then
|
||||
if [[ "${K_VERSION}" == *".0" ]]; then
|
||||
K_VERSION_KORG=${K_VERSION%.0}
|
||||
else
|
||||
K_VERSION_KORG="$K_VERSION"
|
||||
K_VERSION_KORG="${K_VERSION}"
|
||||
fi
|
||||
# we need to wait for the downloaded linux kernel sources from the host
|
||||
WAIT_CNT=0
|
||||
while ! [[ -f "$KERNEL_ARCH_PATH/linux-$K_VERSION_KORG.tar.gz" ]]; do
|
||||
while ! [[ -f "${KERNEL_ARCH_PATH}/linux-${K_VERSION_KORG}.tar.gz" ]]; do
|
||||
print_output "[*] Waiting for kernel sources ..." "no_log"
|
||||
((WAIT_CNT+=1))
|
||||
if [[ "$WAIT_CNT" -gt 60 ]] || [[ -f "$TMP_DIR"/linux_download_failed ]]; then
|
||||
if [[ "${WAIT_CNT}" -gt 60 ]] || [[ -f "${TMP_DIR}"/linux_download_failed ]]; then
|
||||
print_output "[-] No valid kernel source file available ... check for further kernel versions"
|
||||
continue 2
|
||||
fi
|
||||
@@ -195,69 +195,69 @@ S26_kernel_vuln_verifier()
|
||||
# Probably it is just downloaded partly and we need to wait a bit longer
|
||||
WAIT_CNT=0
|
||||
print_output "[*] Testing kernel sources ..." "no_log"
|
||||
while ! gunzip -t "$KERNEL_ARCH_PATH/linux-$K_VERSION_KORG.tar.gz" 2> /dev/null; do
|
||||
while ! gunzip -t "${KERNEL_ARCH_PATH}/linux-${K_VERSION_KORG}.tar.gz" 2> /dev/null; do
|
||||
print_output "[*] Testing kernel sources ..." "no_log"
|
||||
((WAIT_CNT+=1))
|
||||
if [[ "$WAIT_CNT" -gt 60 ]] || [[ -f "$TMP_DIR"/linux_download_failed ]]; then
|
||||
if [[ "${WAIT_CNT}" -gt 60 ]] || [[ -f "${TMP_DIR}"/linux_download_failed ]]; then
|
||||
print_output "[-] No valid kernel source file available ... check for further kernel versions"
|
||||
continue 2
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
|
||||
print_output "[*] Kernel sources for version $ORANGE$K_VERSION$NC available"
|
||||
write_link "$LOG_DIR/kernel_downloader.log"
|
||||
print_output "[*] Kernel sources for version ${ORANGE}${K_VERSION}${NC} available"
|
||||
write_link "${LOG_DIR}/kernel_downloader.log"
|
||||
|
||||
KERNEL_DIR="$LOG_PATH_MODULE/linux-$K_VERSION_KORG"
|
||||
[[ -d "$KERNEL_DIR" ]] && rm -rf "$KERNEL_DIR"
|
||||
if ! [[ -d "$KERNEL_DIR" ]] && [[ "$(file "$KERNEL_ARCH_PATH/linux-$K_VERSION_KORG.tar.gz")" == *"gzip compressed data"* ]]; then
|
||||
print_output "[*] Kernel version $ORANGE$K_VERSION$NC extraction ... "
|
||||
tar -xzf "$KERNEL_ARCH_PATH/linux-$K_VERSION_KORG.tar.gz" -C "$LOG_PATH_MODULE"
|
||||
KERNEL_DIR="${LOG_PATH_MODULE}/linux-${K_VERSION_KORG}"
|
||||
[[ -d "${KERNEL_DIR}" ]] && rm -rf "${KERNEL_DIR}"
|
||||
if ! [[ -d "${KERNEL_DIR}" ]] && [[ "$(file "${KERNEL_ARCH_PATH}/linux-${K_VERSION_KORG}.tar.gz")" == *"gzip compressed data"* ]]; then
|
||||
print_output "[*] Kernel version ${ORANGE}${K_VERSION}${NC} extraction ... "
|
||||
tar -xzf "${KERNEL_ARCH_PATH}/linux-${K_VERSION_KORG}.tar.gz" -C "${LOG_PATH_MODULE}"
|
||||
fi
|
||||
|
||||
# we get a json result file with the results in $CVE_DETAILS_PATH
|
||||
get_cve_kernel_data "$K_VERSION"
|
||||
get_cve_kernel_data "${K_VERSION}"
|
||||
|
||||
if ! [[ -f "$CVE_DETAILS_PATH" ]]; then
|
||||
if ! [[ -f "${CVE_DETAILS_PATH}" ]]; then
|
||||
print_output "[-] No CVE details generated ... check for further kernel version"
|
||||
continue
|
||||
fi
|
||||
|
||||
print_output "[*] Create CVE vulnerabilities array for kernel version $ORANGE$K_VERSION$NC ..."
|
||||
mapfile -t ALL_KVULNS < <(jq -rc '"\(.id):\(.cvss):\(.cvss3):\(.summary)"' "$CVE_DETAILS_PATH")
|
||||
print_output "[*] Create CVE vulnerabilities array for kernel version ${ORANGE}${K_VERSION}${NC} ..."
|
||||
mapfile -t ALL_KVULNS < <(jq -rc '"\(.id):\(.cvss):\(.cvss3):\(.summary)"' "${CVE_DETAILS_PATH}")
|
||||
# readable log file for the web report:
|
||||
jq -rc '"\(.id):\(.cvss):\(.cvss3):\(.summary)"' "$CVE_DETAILS_PATH" > "$LOG_PATH_MODULE""/kernel-$K_VERSION-vulns.log"
|
||||
jq -rc '"\(.id):\(.cvss):\(.cvss3):\(.summary)"' "${CVE_DETAILS_PATH}" > "${LOG_PATH_MODULE}""/kernel-${K_VERSION}-vulns.log"
|
||||
|
||||
print_ln
|
||||
print_output "[+] Extracted $ORANGE${#ALL_KVULNS[@]}$GREEN vulnerabilities based on kernel version only" "" "$LOG_PATH_MODULE""/kernel-$K_VERSION-vulns.log"
|
||||
print_output "[+] Extracted ${ORANGE}${#ALL_KVULNS[@]}${GREEN} vulnerabilities based on kernel version only" "" "${LOG_PATH_MODULE}""/kernel-${K_VERSION}-vulns.log"
|
||||
|
||||
if [[ -f "$KERNEL_CONFIG_PATH" ]] && [[ -d "$KERNEL_DIR" ]]; then
|
||||
compile_kernel "$KERNEL_CONFIG_PATH" "$KERNEL_DIR" "$ORIG_K_ARCH"
|
||||
if [[ -f "${KERNEL_CONFIG_PATH}" ]] && [[ -d "${KERNEL_DIR}" ]]; then
|
||||
compile_kernel "${KERNEL_CONFIG_PATH}" "${KERNEL_DIR}" "${ORIG_K_ARCH}"
|
||||
fi
|
||||
|
||||
print_ln
|
||||
sub_module_title "Identify kernel symbols ..."
|
||||
readelf -s "$KERNEL_ELF_PATH" | grep "FUNC\|OBJECT" | sed 's/.*FUNC//' | sed 's/.*OBJECT//' | awk '{print $4}' | \
|
||||
sed 's/\[\.\.\.\]//' > "$LOG_PATH_MODULE"/symbols.txt
|
||||
SYMBOLS_CNT=$(wc -l "$LOG_PATH_MODULE"/symbols.txt | awk '{print $1}')
|
||||
print_output "[*] Extracted $ORANGE$SYMBOLS_CNT$NC symbols from kernel"
|
||||
readelf -s "${KERNEL_ELF_PATH}" | grep "FUNC\|OBJECT" | sed 's/.*FUNC//' | sed 's/.*OBJECT//' | awk '{print $4}' | \
|
||||
sed 's/\[\.\.\.\]//' > "${LOG_PATH_MODULE}"/symbols.txt
|
||||
SYMBOLS_CNT=$(wc -l "${LOG_PATH_MODULE}"/symbols.txt | awk '{print $1}')
|
||||
print_output "[*] Extracted ${ORANGE}${SYMBOLS_CNT}${NC} symbols from kernel"
|
||||
|
||||
if [[ -d "$LOG_DIR""/firmware" ]]; then
|
||||
if [[ -d "${LOG_DIR}""/firmware" ]]; then
|
||||
print_output "[*] Identify kernel modules symbols ..."
|
||||
find "$LOG_DIR/firmware" -name "*.ko" -exec readelf -a {} \; | grep FUNC | sed 's/.*FUNC//' | \
|
||||
awk '{print $4}' | sed 's/\[\.\.\.\]//' >> "$LOG_PATH_MODULE"/symbols.txt || true
|
||||
find "${LOG_DIR}/firmware" -name "*.ko" -exec readelf -a {} \; | grep FUNC | sed 's/.*FUNC//' | \
|
||||
awk '{print $4}' | sed 's/\[\.\.\.\]//' >> "${LOG_PATH_MODULE}"/symbols.txt || true
|
||||
fi
|
||||
|
||||
uniq "$LOG_PATH_MODULE"/symbols.txt > "$LOG_PATH_MODULE"/symbols_uniq.txt
|
||||
SYMBOLS_CNT=$(wc -l "$LOG_PATH_MODULE"/symbols_uniq.txt | awk '{print $1}')
|
||||
uniq "${LOG_PATH_MODULE}"/symbols.txt > "${LOG_PATH_MODULE}"/symbols_uniq.txt
|
||||
SYMBOLS_CNT=$(wc -l "${LOG_PATH_MODULE}"/symbols_uniq.txt | awk '{print $1}')
|
||||
|
||||
if [[ "$SYMBOLS_CNT" -eq 0 ]]; then
|
||||
if [[ "${SYMBOLS_CNT}" -eq 0 ]]; then
|
||||
print_output "[-] No symbols found ... check for further kernel version"
|
||||
continue
|
||||
fi
|
||||
|
||||
print_ln
|
||||
print_output "[+] Extracted $ORANGE$SYMBOLS_CNT$GREEN unique symbols"
|
||||
print_output "[+] Extracted ${ORANGE}${SYMBOLS_CNT}${GREEN} unique symbols"
|
||||
print_ln
|
||||
|
||||
split_symbols_file
|
||||
@@ -271,7 +271,7 @@ S26_kernel_vuln_verifier()
|
||||
export CNT_PATHS_FOUND_WRONG_ARCH=0
|
||||
|
||||
print_ln
|
||||
print_output "[*] Checking vulnerabilities for kernel version $ORANGE$K_VERSION$NC"
|
||||
print_output "[*] Checking vulnerabilities for kernel version ${ORANGE}${K_VERSION}${NC}"
|
||||
print_ln
|
||||
|
||||
for VULN in "${ALL_KVULNS[@]}"; do
|
||||
@@ -280,60 +280,60 @@ S26_kernel_vuln_verifier()
|
||||
K_PATHS_FILES_TMP=()
|
||||
K_PATH="missing vulnerability path from advisory"
|
||||
|
||||
CVE=$(echo "$VULN" | cut -d: -f1)
|
||||
print_output "[*] Testing vulnerability $ORANGE$VULN_CNT$NC / $ORANGE${#ALL_KVULNS[@]}$NC / $ORANGE$CVE$NC"
|
||||
CVE=$(echo "${VULN}" | cut -d: -f1)
|
||||
print_output "[*] Testing vulnerability ${ORANGE}${VULN_CNT}${NC} / ${ORANGE}${#ALL_KVULNS[@]}${NC} / ${ORANGE}${CVE}${NC}"
|
||||
|
||||
CVSS2="$(echo "$VULN" | cut -d: -f2)"
|
||||
CVSS3="$(echo "$VULN" | cut -d: -f3)"
|
||||
SUMMARY="$(echo "$VULN" | cut -d: -f4-)"
|
||||
CVSS2="$(echo "${VULN}" | cut -d: -f2)"
|
||||
CVSS3="$(echo "${VULN}" | cut -d: -f3)"
|
||||
SUMMARY="$(echo "${VULN}" | cut -d: -f4-)"
|
||||
|
||||
# extract kernel source paths from summary -> we use these paths to check if they are used by our
|
||||
# symbols or during kernel compilation
|
||||
mapfile -t K_PATHS < <(echo "$SUMMARY" | tr ' ' '\n' | grep ".*\.[chS]$" | sed -r 's/CVE-[0-9]+-[0-9]+:[0-9].*://' \
|
||||
mapfile -t K_PATHS < <(echo "${SUMMARY}" | tr ' ' '\n' | grep ".*\.[chS]$" | sed -r 's/CVE-[0-9]+-[0-9]+:[0-9].*://' \
|
||||
| sed -r 's/CVE-[0-9]+-[0-9]+:null.*://' | sed 's/^(//' | sed 's/)$//' | sed 's/,$//' | sed 's/\.$//' | cut -d: -f1 || true)
|
||||
|
||||
for K_PATH in "${K_PATHS[@]}"; do
|
||||
# we have only a filename without path -> we search for possible candidate files in the kernel sources
|
||||
if ! [[ "$K_PATH" == *"/"* ]]; then
|
||||
print_output "[*] Found file name $ORANGE$K_PATH$NC for $ORANGE$CVE$NC without path details ... looking for candidates now"
|
||||
mapfile -t K_PATHS_FILES_TMP < <(find "$KERNEL_DIR" -name "$K_PATH" | sed "s&$KERNEL_DIR\/&&")
|
||||
if ! [[ "${K_PATH}" == *"/"* ]]; then
|
||||
print_output "[*] Found file name ${ORANGE}${K_PATH}${NC} for ${ORANGE}${CVE}${NC} without path details ... looking for candidates now"
|
||||
mapfile -t K_PATHS_FILES_TMP < <(find "${KERNEL_DIR}" -name "${K_PATH}" | sed "s&${KERNEL_DIR}\/&&")
|
||||
fi
|
||||
K_PATHS+=("${K_PATHS_FILES_TMP[@]}")
|
||||
done
|
||||
|
||||
if [[ "${#K_PATHS[@]}" -gt 0 ]]; then
|
||||
for K_PATH in "${K_PATHS[@]}"; do
|
||||
if [[ -f "$KERNEL_DIR/$K_PATH" ]]; then
|
||||
if [[ -f "${KERNEL_DIR}/${K_PATH}" ]]; then
|
||||
# check if arch is in path -> if so we check if our architecture is also in the path
|
||||
# if we find our architecture then we can proceed with symbol_verifier
|
||||
if [[ "$K_PATH" == "arch/"* ]]; then
|
||||
if [[ "$K_PATH" == "arch/$ORIG_K_ARCH/"* ]]; then
|
||||
if [[ "${K_PATH}" == "arch/"* ]]; then
|
||||
if [[ "${K_PATH}" == "arch/${ORIG_K_ARCH}/"* ]]; then
|
||||
((CNT_PATHS_FOUND+=1))
|
||||
symbol_verifier "$CVE" "$K_VERSION" "$K_PATH" "$CVSS2/$CVSS3" &
|
||||
symbol_verifier "${CVE}" "${K_VERSION}" "${K_PATH}" "${CVSS2}/${CVSS3}" &
|
||||
WAIT_PIDS_S26+=( "$!" )
|
||||
compile_verifier "$CVE" "$K_VERSION" "$K_PATH" "$CVSS2/$CVSS3" &
|
||||
compile_verifier "${CVE}" "${K_VERSION}" "${K_PATH}" "${CVSS2}/${CVSS3}" &
|
||||
WAIT_PIDS_S26+=( "$!" )
|
||||
else
|
||||
# this vulnerability is for a different architecture -> we can skip it for our kernel
|
||||
print_output "[-] Vulnerable path for different architecture found for $ORANGE$K_PATH$NC - not further processing $ORANGE$CVE$NC"
|
||||
print_output "[-] Vulnerable path for different architecture found for ${ORANGE}${K_PATH}${NC} - not further processing ${ORANGE}${CVE}${NC}"
|
||||
((CNT_PATHS_FOUND_WRONG_ARCH+=1))
|
||||
fi
|
||||
else
|
||||
((CNT_PATHS_FOUND+=1))
|
||||
symbol_verifier "$CVE" "$K_VERSION" "$K_PATH" "$CVSS2/$CVSS3" &
|
||||
symbol_verifier "${CVE}" "${K_VERSION}" "${K_PATH}" "${CVSS2}/${CVSS3}" &
|
||||
WAIT_PIDS_S26+=( "$!" )
|
||||
compile_verifier "$CVE" "$K_VERSION" "$K_PATH" "$CVSS2/$CVSS3" &
|
||||
compile_verifier "${CVE}" "${K_VERSION}" "${K_PATH}" "${CVSS2}/${CVSS3}" &
|
||||
WAIT_PIDS_S26+=( "$!" )
|
||||
fi
|
||||
else
|
||||
# no source file in our kernel sources -> no vulns
|
||||
print_output "[-] $ORANGE$CVE$NC - $ORANGE$K_PATH$NC - vulnerable source file not found in kernel sources"
|
||||
print_output "[-] ${ORANGE}${CVE}${NC} - ${ORANGE}${K_PATH}${NC} - vulnerable source file not found in kernel sources"
|
||||
((CNT_PATHS_NOT_FOUND+=1))
|
||||
fi
|
||||
max_pids_protection 20 "${WAIT_PIDS_S26[@]}"
|
||||
done
|
||||
else
|
||||
print_output "[-] $CVE - $K_PATH"
|
||||
print_output "[-] ${CVE} - ${K_PATH}"
|
||||
((CNT_PATHS_UNK+=1))
|
||||
fi
|
||||
((VULN_CNT+=1))
|
||||
@@ -341,33 +341,33 @@ S26_kernel_vuln_verifier()
|
||||
|
||||
wait_for_pid "${WAIT_PIDS_S26[@]}"
|
||||
|
||||
final_log_kernel_vulns "$K_VERSION" "${ALL_KVULNS[@]}"
|
||||
final_log_kernel_vulns "${K_VERSION}" "${ALL_KVULNS[@]}"
|
||||
done
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
split_symbols_file() {
|
||||
print_output "[*] Splitting symbols file for processing"
|
||||
split -l 100 "$LOG_PATH_MODULE"/symbols_uniq.txt "$LOG_PATH_MODULE"/symbols_uniq.split.
|
||||
sed -i 's/^/EXPORT_SYMBOL\(/' "$LOG_PATH_MODULE"/symbols_uniq.split.*
|
||||
sed -i 's/$/\)/' "$LOG_PATH_MODULE"/symbols_uniq.split.*
|
||||
split -l 100 "${LOG_PATH_MODULE}"/symbols_uniq.txt "${LOG_PATH_MODULE}"/symbols_uniq.split.
|
||||
sed -i 's/^/EXPORT_SYMBOL\(/' "${LOG_PATH_MODULE}"/symbols_uniq.split.*
|
||||
sed -i 's/$/\)/' "${LOG_PATH_MODULE}"/symbols_uniq.split.*
|
||||
|
||||
split -l 100 "$LOG_PATH_MODULE"/symbols_uniq.txt "$LOG_PATH_MODULE"/symbols_uniq.split_gpl.
|
||||
sed -i 's/^/EXPORT_SYMBOL_GPL\(/' "$LOG_PATH_MODULE"/symbols_uniq.split_gpl.*
|
||||
sed -i 's/$/\)/' "$LOG_PATH_MODULE"/symbols_uniq.split_gpl.*
|
||||
split -l 100 "${LOG_PATH_MODULE}"/symbols_uniq.txt "${LOG_PATH_MODULE}"/symbols_uniq.split_gpl.
|
||||
sed -i 's/^/EXPORT_SYMBOL_GPL\(/' "${LOG_PATH_MODULE}"/symbols_uniq.split_gpl.*
|
||||
sed -i 's/$/\)/' "${LOG_PATH_MODULE}"/symbols_uniq.split_gpl.*
|
||||
}
|
||||
|
||||
get_cve_kernel_data() {
|
||||
sub_module_title "Version based vulnerability detection"
|
||||
local K_VERSION_="${1:-}"
|
||||
print_output "[*] Extract CVE data for kernel version $ORANGE$K_VERSION_$NC"
|
||||
"$PATH_CVE_SEARCH" -p "linux_kernel:""$K_VERSION_"":" -o json > "$CVE_DETAILS_PATH"
|
||||
print_output "[*] Extract CVE data for kernel version ${ORANGE}${K_VERSION_}${NC}"
|
||||
"${PATH_CVE_SEARCH}" -p "linux_kernel:""${K_VERSION_}"":" -o json > "${CVE_DETAILS_PATH}"
|
||||
}
|
||||
|
||||
extract_kernel_arch() {
|
||||
KERNEL_ELF_PATH="${1:-}"
|
||||
ORIG_K_ARCH=$(file "$KERNEL_ELF_PATH" | cut -d, -f2)
|
||||
ORIG_K_ARCH=$(file "${KERNEL_ELF_PATH}" | cut -d, -f2)
|
||||
|
||||
# for ARM -> ARM aarch64 to ARM64
|
||||
ORIG_K_ARCH=${ORIG_K_ARCH/ARM\ aarch64/arm64}
|
||||
@@ -375,8 +375,8 @@ extract_kernel_arch() {
|
||||
ORIG_K_ARCH=${ORIG_K_ARCH/MIPS64/MIPS}
|
||||
ORIG_K_ARCH=${ORIG_K_ARCH/*PowerPC*/powerpc}
|
||||
|
||||
ORIG_K_ARCH=$(echo "$ORIG_K_ARCH" | tr -d ' ' | tr "[:upper:]" "[:lower:]")
|
||||
print_output "[+] Identified kernel architecture $ORANGE$ORIG_K_ARCH$NC"
|
||||
ORIG_K_ARCH=$(echo "${ORIG_K_ARCH}" | tr -d ' ' | tr "[:upper:]" "[:lower:]")
|
||||
print_output "[+] Identified kernel architecture ${ORANGE}${ORIG_K_ARCH}${NC}"
|
||||
}
|
||||
|
||||
symbol_verifier() {
|
||||
@@ -386,12 +386,12 @@ symbol_verifier() {
|
||||
local CVSS="${4:-}"
|
||||
local VULN_FOUND=0
|
||||
|
||||
for CHUNK_FILE in "$LOG_PATH_MODULE"/symbols_uniq.split.* ; do
|
||||
for CHUNK_FILE in "${LOG_PATH_MODULE}"/symbols_uniq.split.* ; do
|
||||
# echo "testing chunk file $CHUNK_FILE"
|
||||
if grep -q -f "$CHUNK_FILE" "$KERNEL_DIR/$K_PATH" ; then
|
||||
if grep -q -f "${CHUNK_FILE}" "${KERNEL_DIR}/${K_PATH}" ; then
|
||||
# echo "verified chunk file $CHUNK_FILE"
|
||||
print_output "[+] $CVE ($CVSS) - $K_PATH verified - exported symbol$NC"
|
||||
echo "$CVE ($CVSS) - $K_VERSION - exported symbol verified - $K_PATH" >> "$LOG_PATH_MODULE""/${CVE}_symbol_verified.txt"
|
||||
print_output "[+] ${CVE} (${CVSS}) - ${K_PATH} verified - exported symbol${NC}"
|
||||
echo "${CVE} (${CVSS}) - ${K_VERSION} - exported symbol verified - ${K_PATH}" >> "${LOG_PATH_MODULE}""/${CVE}_symbol_verified.txt"
|
||||
VULN_FOUND=1
|
||||
break
|
||||
fi
|
||||
@@ -399,14 +399,14 @@ symbol_verifier() {
|
||||
|
||||
# if we have already a match for this path we can skip the 2nd check
|
||||
# this is only for speed up the process a bit
|
||||
[[ "$VULN_FOUND" -eq 1 ]] && return
|
||||
[[ "${VULN_FOUND}" -eq 1 ]] && return
|
||||
|
||||
for CHUNK_FILE in "$LOG_PATH_MODULE"/symbols_uniq.split_gpl.* ; do
|
||||
for CHUNK_FILE in "${LOG_PATH_MODULE}"/symbols_uniq.split_gpl.* ; do
|
||||
# echo "testing chunk file $CHUNK_FILE"
|
||||
if grep -q -f "$CHUNK_FILE" "$KERNEL_DIR/$K_PATH" ; then
|
||||
if grep -q -f "${CHUNK_FILE}" "${KERNEL_DIR}/${K_PATH}" ; then
|
||||
# print_output "[*] verified chunk file $CHUNK_FILE (GPL)"
|
||||
print_output "[+] $CVE ($CVSS) - $K_PATH verified - exported symbol (gpl)$NC"
|
||||
echo "$CVE ($CVSS) - $K_VERSION - exported symbol verified (gpl) - $K_PATH" >> "$LOG_PATH_MODULE""/${CVE}_symbol_verified.txt"
|
||||
print_output "[+] ${CVE} (${CVSS}) - ${K_PATH} verified - exported symbol (gpl)${NC}"
|
||||
echo "${CVE} (${CVSS}) - ${K_VERSION} - exported symbol verified (gpl) - ${K_PATH}" >> "${LOG_PATH_MODULE}""/${CVE}_symbol_verified.txt"
|
||||
VULN_FOUND=1
|
||||
break
|
||||
fi
|
||||
@@ -419,13 +419,13 @@ compile_verifier() {
|
||||
local K_PATH="${3:-}"
|
||||
local CVSS="${4:-}"
|
||||
local VULN_FOUND=0
|
||||
if ! [[ -f "$LOG_PATH_MODULE"/kernel-compile-files_verified.log ]]; then
|
||||
if ! [[ -f "${LOG_PATH_MODULE}"/kernel-compile-files_verified.log ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if grep -q "$K_PATH" "$LOG_PATH_MODULE"/kernel-compile-files_verified.log ; then
|
||||
print_output "[+] $CVE_ ($CVSS) - $K_PATH verified - compiled path"
|
||||
echo "$CVE_ ($CVSS) - $K_VERSION - compiled path verified - $K_PATH" >> "$LOG_PATH_MODULE""/${CVE_}_compiled_verified.txt"
|
||||
if grep -q "${K_PATH}" "${LOG_PATH_MODULE}"/kernel-compile-files_verified.log ; then
|
||||
print_output "[+] ${CVE_} (${CVSS}) - ${K_PATH} verified - compiled path"
|
||||
echo "${CVE_} (${CVSS}) - ${K_VERSION} - compiled path verified - ${K_PATH}" >> "${LOG_PATH_MODULE}""/${CVE_}_compiled_verified.txt"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -436,66 +436,66 @@ compile_kernel() {
|
||||
local KARCH="${3:-}"
|
||||
export COMPILE_SOURCE_FILES=0
|
||||
|
||||
if ! [[ -f "$KERNEL_CONFIG_FILE" ]]; then
|
||||
print_output "[-] No supported kernel config found - $ORANGE$KERNEL_CONFIG_FILE$NC"
|
||||
if ! [[ -f "${KERNEL_CONFIG_FILE}" ]]; then
|
||||
print_output "[-] No supported kernel config found - ${ORANGE}${KERNEL_CONFIG_FILE}${NC}"
|
||||
return
|
||||
fi
|
||||
if ! [[ -d "$KERNEL_DIR" ]]; then
|
||||
print_output "[-] No supported kernel source directory found - $ORANGE$KERNEL_DIR$NC"
|
||||
if ! [[ -d "${KERNEL_DIR}" ]]; then
|
||||
print_output "[-] No supported kernel source directory found - ${ORANGE}${KERNEL_DIR}${NC}"
|
||||
return
|
||||
fi
|
||||
print_ln
|
||||
sub_module_title "Compile Linux kernel - dry run mode"
|
||||
|
||||
KARCH=$(echo "$KARCH" | tr '[:upper:]' '[:lower:]')
|
||||
if ! [[ -d "$KERNEL_DIR"/arch/"$KARCH" ]]; then
|
||||
print_output "[!] No supported architecture found - $ORANGE$KARCH$NC"
|
||||
KARCH=$(echo "${KARCH}" | tr '[:upper:]' '[:lower:]')
|
||||
if ! [[ -d "${KERNEL_DIR}"/arch/"${KARCH}" ]]; then
|
||||
print_output "[!] No supported architecture found - ${ORANGE}${KARCH}${NC}"
|
||||
return
|
||||
else
|
||||
print_output "[*] Supported architecture found - $ORANGE$KARCH$NC"
|
||||
print_output "[*] Supported architecture found - ${ORANGE}${KARCH}${NC}"
|
||||
fi
|
||||
|
||||
cd "$KERNEL_DIR" || exit
|
||||
cd "${KERNEL_DIR}" || exit
|
||||
# print_output "[*] Create default kernel config for $ORANGE$KARCH$NC architecture"
|
||||
# LANG=en make ARCH="$KARCH" defconfig | tee -a "$LOG_PATH_MODULE"/kernel-compile-defconfig.log || true
|
||||
# LANG=en make ARCH="${KARCH}" defconfig | tee -a "${LOG_PATH_MODULE}"/kernel-compile-defconfig.log || true
|
||||
# print_output "[*] Finished creating default kernel config for $ORANGE$KARCH$NC architecture" "" "$LOG_PATH_MODULE/kernel-compile-defconfig.log"
|
||||
print_ln
|
||||
|
||||
print_output "[*] Install kernel config of the identified configuration of the firmware"
|
||||
cp "$KERNEL_CONFIG_FILE" .config
|
||||
cp "${KERNEL_CONFIG_FILE}" .config
|
||||
# https://stackoverflow.com/questions/4178526/what-does-make-oldconfig-do-exactly-in-the-linux-kernel-makefile
|
||||
LANG=en make ARCH="$KARCH" olddefconfig | tee -a "$LOG_PATH_MODULE"/kernel-compile-olddefconfig.log
|
||||
print_output "[*] Finished updating kernel config with the identified firmware configuration" "" "$LOG_PATH_MODULE/kernel-compile-olddefconfig.log"
|
||||
LANG=en make ARCH="${KARCH}" olddefconfig | tee -a "${LOG_PATH_MODULE}"/kernel-compile-olddefconfig.log
|
||||
print_output "[*] Finished updating kernel config with the identified firmware configuration" "" "${LOG_PATH_MODULE}/kernel-compile-olddefconfig.log"
|
||||
print_ln
|
||||
|
||||
print_output "[*] Starting kernel compile dry run ..."
|
||||
LANG=en make ARCH="$KARCH" target=all -Bndi | tee -a "$LOG_PATH_MODULE"/kernel-compile.log
|
||||
LANG=en make ARCH="${KARCH}" target=all -Bndi | tee -a "${LOG_PATH_MODULE}"/kernel-compile.log
|
||||
print_ln
|
||||
print_output "[*] Finished kernel compile dry run ... generated used source files" "" "$LOG_PATH_MODULE/kernel-compile.log"
|
||||
print_output "[*] Finished kernel compile dry run ... generated used source files" "" "${LOG_PATH_MODULE}/kernel-compile.log"
|
||||
|
||||
cd "$HOME_DIR" || exit
|
||||
cd "${HOME_DIR}" || exit
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE"/kernel-compile.log ]]; then
|
||||
tr ' ' '\n' < "$LOG_PATH_MODULE"/kernel-compile.log | grep ".*\.[chS]" | tr -d '"' | tr -d ')' | tr -d '<' | tr -d '>' \
|
||||
if [[ -f "${LOG_PATH_MODULE}"/kernel-compile.log ]]; then
|
||||
tr ' ' '\n' < "${LOG_PATH_MODULE}"/kernel-compile.log | grep ".*\.[chS]" | tr -d '"' | tr -d ')' | tr -d '<' | tr -d '>' \
|
||||
| tr -d '(' | sed 's/^\.\///' | sed '/^\/.*/d' | tr -d ';' | sed 's/^>//' | sed 's/^-o//' | tr -d \' \
|
||||
| sed 's/--defines=//' | sed 's/\.$//' | sort -u > "$LOG_PATH_MODULE"/kernel-compile-files.log
|
||||
COMPILE_SOURCE_FILES=$(wc -l "$LOG_PATH_MODULE"/kernel-compile-files.log | awk '{print $1}')
|
||||
print_output "[+] Found $ORANGE$COMPILE_SOURCE_FILES$GREEN used source files during compilation" "" "$LOG_PATH_MODULE/kernel-compile-files.log"
|
||||
| sed 's/--defines=//' | sed 's/\.$//' | sort -u > "${LOG_PATH_MODULE}"/kernel-compile-files.log
|
||||
COMPILE_SOURCE_FILES=$(wc -l "${LOG_PATH_MODULE}"/kernel-compile-files.log | awk '{print $1}')
|
||||
print_output "[+] Found ${ORANGE}${COMPILE_SOURCE_FILES}${GREEN} used source files during compilation" "" "${LOG_PATH_MODULE}/kernel-compile-files.log"
|
||||
|
||||
# lets check the entries and verify them in our kernel sources
|
||||
# entries without a real file are not further processed
|
||||
# with this mechanism we can eliminate garbage
|
||||
while read -r COMPILE_SOURCE_FILE; do
|
||||
if [[ -f "$KERNEL_DIR""/""$COMPILE_SOURCE_FILE" ]]; then
|
||||
if [[ -f "${KERNEL_DIR}""/""${COMPILE_SOURCE_FILE}" ]]; then
|
||||
# print_output "[*] Verified Source file $ORANGE$KERNEL_DIR/$COMPILE_SOURCE_FILE$NC is available"
|
||||
echo "$COMPILE_SOURCE_FILE" >> "$LOG_PATH_MODULE"/kernel-compile-files_verified.log
|
||||
echo "${COMPILE_SOURCE_FILE}" >> "${LOG_PATH_MODULE}"/kernel-compile-files_verified.log
|
||||
fi
|
||||
done < "$LOG_PATH_MODULE"/kernel-compile-files.log
|
||||
COMPILE_SOURCE_FILES_VERIFIED=$(wc -l "$LOG_PATH_MODULE"/kernel-compile-files_verified.log | awk '{print $1}')
|
||||
done < "${LOG_PATH_MODULE}"/kernel-compile-files.log
|
||||
COMPILE_SOURCE_FILES_VERIFIED=$(wc -l "${LOG_PATH_MODULE}"/kernel-compile-files_verified.log | awk '{print $1}')
|
||||
print_ln
|
||||
print_output "[+] Found $ORANGE$COMPILE_SOURCE_FILES_VERIFIED$GREEN used and available source files during compilation" "" "$LOG_PATH_MODULE/kernel-compile-files_verified.log"
|
||||
print_output "[+] Found ${ORANGE}${COMPILE_SOURCE_FILES_VERIFIED}${GREEN} used and available source files during compilation" "" "${LOG_PATH_MODULE}/kernel-compile-files_verified.log"
|
||||
else
|
||||
print_output "[-] Found ${RED}NO$NC used source files during compilation"
|
||||
print_output "[-] Found ${RED}NO${NC} used source files during compilation"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -510,8 +510,8 @@ final_log_kernel_vulns() {
|
||||
return
|
||||
fi
|
||||
|
||||
find "$LOG_PATH_MODULE" -name "symbols_uniq.split.*" -delete || true
|
||||
find "$LOG_PATH_MODULE" -name "symbols_uniq.split_gpl.*" -delete || true
|
||||
find "${LOG_PATH_MODULE}" -name "symbols_uniq.split.*" -delete || true
|
||||
find "${LOG_PATH_MODULE}" -name "symbols_uniq.split_gpl.*" -delete || true
|
||||
|
||||
NEG_LOG=1
|
||||
|
||||
@@ -528,7 +528,7 @@ final_log_kernel_vulns() {
|
||||
|
||||
print_ln
|
||||
print_output "[*] Generating final kernel report ..." "no_log"
|
||||
echo "Kernel version;Architecture;CVE;CVSSv2;CVSSv3;Verified with symbols;Verified with compile files" >> "$LOG_PATH_MODULE"/cve_results_kernel_"$K_VERSION".csv
|
||||
echo "Kernel version;Architecture;CVE;CVSSv2;CVSSv3;Verified with symbols;Verified with compile files" >> "${LOG_PATH_MODULE}"/cve_results_kernel_"${K_VERSION}".csv
|
||||
|
||||
# we walk through the original version based kernel vulnerabilities and report the results
|
||||
# from symbols and kernel configuration
|
||||
@@ -541,80 +541,80 @@ final_log_kernel_vulns() {
|
||||
local CVE_SYMBOL_FOUND=0
|
||||
local CVE_COMPILE_FOUND=0
|
||||
|
||||
CVE=$(echo "$VULN" | cut -d: -f1)
|
||||
CVSS2="$(echo "$VULN" | cut -d: -f2)"
|
||||
CVSS3="$(echo "$VULN" | cut -d: -f3)"
|
||||
CVE_SYMBOL_FOUND=$(find "$LOG_PATH_MODULE" -name "${CVE}_symbol_verified.txt" | wc -l)
|
||||
CVE_COMPILE_FOUND=$(find "$LOG_PATH_MODULE" -name "${CVE}_compiled_verified.txt" | wc -l)
|
||||
echo "$K_VERSION;$ORIG_K_ARCH;$CVE;$CVSS2;$CVSS3;$CVE_SYMBOL_FOUND;$CVE_COMPILE_FOUND" >> "$LOG_PATH_MODULE"/cve_results_kernel_"$K_VERSION".csv
|
||||
CVE=$(echo "${VULN}" | cut -d: -f1)
|
||||
CVSS2="$(echo "${VULN}" | cut -d: -f2)"
|
||||
CVSS3="$(echo "${VULN}" | cut -d: -f3)"
|
||||
CVE_SYMBOL_FOUND=$(find "${LOG_PATH_MODULE}" -name "${CVE}_symbol_verified.txt" | wc -l)
|
||||
CVE_COMPILE_FOUND=$(find "${LOG_PATH_MODULE}" -name "${CVE}_compiled_verified.txt" | wc -l)
|
||||
echo "${K_VERSION};${ORIG_K_ARCH};${CVE};${CVSS2};${CVSS3};${CVE_SYMBOL_FOUND};${CVE_COMPILE_FOUND}" >> "${LOG_PATH_MODULE}"/cve_results_kernel_"${K_VERSION}".csv
|
||||
done
|
||||
|
||||
SYM_USAGE_VERIFIED=$(wc -l "$LOG_PATH_MODULE"/CVE-*symbol_* | tail -1 | awk '{print $1}' 2>/dev/null || true)
|
||||
SYM_USAGE_VERIFIED=$(wc -l "${LOG_PATH_MODULE}"/CVE-*symbol_* | tail -1 | awk '{print $1}' 2>/dev/null || true)
|
||||
# nosemgrep
|
||||
VULN_PATHS_VERIFIED_SYMBOLS=$(cat "$LOG_PATH_MODULE"/CVE-*symbol_verified.txt 2>/dev/null | grep "exported symbol" | sed 's/.*verified - //' | sed 's/.*verified (GPL) - //' | sort -u | wc -l || true)
|
||||
VULN_PATHS_VERIFIED_SYMBOLS=$(cat "${LOG_PATH_MODULE}"/CVE-*symbol_verified.txt 2>/dev/null | grep "exported symbol" | sed 's/.*verified - //' | sed 's/.*verified (GPL) - //' | sort -u | wc -l || true)
|
||||
# nosemgrep
|
||||
VULN_PATHS_VERIFIED_COMPILED=$(cat "$LOG_PATH_MODULE"/CVE-*compiled_verified.txt 2>/dev/null | grep "compiled path verified" | sed 's/.*verified - //' | sort -u | wc -l || true)
|
||||
VULN_PATHS_VERIFIED_COMPILED=$(cat "${LOG_PATH_MODULE}"/CVE-*compiled_verified.txt 2>/dev/null | grep "compiled path verified" | sed 's/.*verified - //' | sort -u | wc -l || true)
|
||||
# nosemgrep
|
||||
CVE_VERIFIED_SYMBOLS=$(cat "$LOG_PATH_MODULE"/CVE-*symbol_verified.txt 2>/dev/null | grep "exported symbol" | cut -d\ -f1 | sort -u | wc -l || true)
|
||||
CVE_VERIFIED_SYMBOLS=$(cat "${LOG_PATH_MODULE}"/CVE-*symbol_verified.txt 2>/dev/null | grep "exported symbol" | cut -d\ -f1 | sort -u | wc -l || true)
|
||||
# nosemgrep
|
||||
CVE_VERIFIED_COMPILED=$(cat "$LOG_PATH_MODULE"/CVE-*compiled_verified.txt 2>/dev/null| grep "compiled path verified" | cut -d\ -f1 | sort -u | wc -l || true)
|
||||
CVE_VERIFIED_ONE=$(cut -d\; -f6-7 "$LOG_PATH_MODULE"/cve_results_kernel_"$K_VERSION".csv | grep -c "1" || true)
|
||||
CVE_VERIFIED_OVERLAP=$(grep -c ";1;1" "$LOG_PATH_MODULE"/cve_results_kernel_"$K_VERSION".csv || true)
|
||||
mapfile -t CVE_VERIFIED_OVERLAP_CRITICAL < <(grep ";1;1$" "$LOG_PATH_MODULE"/cve_results_kernel_"$K_VERSION".csv | grep ";9.[0-9];\|;10;" || true)
|
||||
mapfile -t CVE_VERIFIED_ONE_CRITICAL < <(grep ";1;\|;1$" "$LOG_PATH_MODULE"/cve_results_kernel_"$K_VERSION".csv | grep ";9.[0-9];\|;10;" || true)
|
||||
CVE_VERIFIED_COMPILED=$(cat "${LOG_PATH_MODULE}"/CVE-*compiled_verified.txt 2>/dev/null| grep "compiled path verified" | cut -d\ -f1 | sort -u | wc -l || true)
|
||||
CVE_VERIFIED_ONE=$(cut -d\; -f6-7 "${LOG_PATH_MODULE}"/cve_results_kernel_"${K_VERSION}".csv | grep -c "1" || true)
|
||||
CVE_VERIFIED_OVERLAP=$(grep -c ";1;1" "${LOG_PATH_MODULE}"/cve_results_kernel_"${K_VERSION}".csv || true)
|
||||
mapfile -t CVE_VERIFIED_OVERLAP_CRITICAL < <(grep ";1;1$" "${LOG_PATH_MODULE}"/cve_results_kernel_"${K_VERSION}".csv | grep ";9.[0-9];\|;10;" || true)
|
||||
mapfile -t CVE_VERIFIED_ONE_CRITICAL < <(grep ";1;\|;1$" "${LOG_PATH_MODULE}"/cve_results_kernel_"${K_VERSION}".csv | grep ";9.[0-9];\|;10;" || true)
|
||||
|
||||
print_output "[+] Identified $ORANGE${#ALL_KVULNS[@]}$GREEN unverified CVE vulnerabilities for kernel version $ORANGE$K_VERSION$NC"
|
||||
print_output "[*] Detected architecture $ORANGE$ORIG_K_ARCH$NC"
|
||||
print_output "[*] Extracted $ORANGE$SYMBOLS_CNT$NC unique symbols from kernel and modules"
|
||||
print_output "[+] Identified ${ORANGE}${#ALL_KVULNS[@]}${GREEN} unverified CVE vulnerabilities for kernel version ${ORANGE}${K_VERSION}${NC}"
|
||||
print_output "[*] Detected architecture ${ORANGE}${ORIG_K_ARCH}${NC}"
|
||||
print_output "[*] Extracted ${ORANGE}${SYMBOLS_CNT}${NC} unique symbols from kernel and modules"
|
||||
if [[ -v COMPILE_SOURCE_FILES ]]; then
|
||||
print_output "[*] Extracted $ORANGE$COMPILE_SOURCE_FILES$NC used source files during compilation"
|
||||
print_output "[*] Extracted ${ORANGE}${COMPILE_SOURCE_FILES}${NC} used source files during compilation"
|
||||
fi
|
||||
print_output "[*] Found $ORANGE$CNT_PATHS_UNK$NC advisories with missing vulnerable path details"
|
||||
print_output "[*] Found $ORANGE$CNT_PATHS_NOT_FOUND$NC path details in CVE advisories but no real kernel path found in vanilla kernel source"
|
||||
print_output "[*] Found $ORANGE$CNT_PATHS_FOUND$NC path details in CVE advisories with real kernel path"
|
||||
print_output "[*] Found $ORANGE$CNT_PATHS_FOUND_WRONG_ARCH$NC path details in CVE advisories with real kernel path but wrong architecture"
|
||||
print_output "[*] $ORANGE$SYM_USAGE_VERIFIED$NC symbol usage verified"
|
||||
print_output "[*] $ORANGE$VULN_PATHS_VERIFIED_SYMBOLS$NC vulnerable paths verified via symbols"
|
||||
print_output "[*] $ORANGE$VULN_PATHS_VERIFIED_COMPILED$NC vulnerable paths verified via compiled paths"
|
||||
print_output "[*] Found ${ORANGE}${CNT_PATHS_UNK}${NC} advisories with missing vulnerable path details"
|
||||
print_output "[*] Found ${ORANGE}${CNT_PATHS_NOT_FOUND}${NC} path details in CVE advisories but no real kernel path found in vanilla kernel source"
|
||||
print_output "[*] Found ${ORANGE}${CNT_PATHS_FOUND}${NC} path details in CVE advisories with real kernel path"
|
||||
print_output "[*] Found ${ORANGE}${CNT_PATHS_FOUND_WRONG_ARCH}${NC} path details in CVE advisories with real kernel path but wrong architecture"
|
||||
print_output "[*] ${ORANGE}${SYM_USAGE_VERIFIED}${NC} symbol usage verified"
|
||||
print_output "[*] ${ORANGE}${VULN_PATHS_VERIFIED_SYMBOLS}${NC} vulnerable paths verified via symbols"
|
||||
print_output "[*] ${ORANGE}${VULN_PATHS_VERIFIED_COMPILED}${NC} vulnerable paths verified via compiled paths"
|
||||
print_ln
|
||||
|
||||
if [[ "$CVE_VERIFIED_SYMBOLS" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: $ORANGE$CVE_VERIFIED_SYMBOLS$GREEN (exported symbols)"
|
||||
if [[ "${CVE_VERIFIED_SYMBOLS}" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: ${ORANGE}${CVE_VERIFIED_SYMBOLS}${GREEN} (exported symbols)"
|
||||
fi
|
||||
if [[ "$CVE_VERIFIED_COMPILED" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: $ORANGE$CVE_VERIFIED_COMPILED$GREEN (compiled paths)"
|
||||
if [[ "${CVE_VERIFIED_COMPILED}" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: ${ORANGE}${CVE_VERIFIED_COMPILED}${GREEN} (compiled paths)"
|
||||
fi
|
||||
if [[ "$CVE_VERIFIED_ONE" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: $ORANGE$CVE_VERIFIED_ONE$GREEN (one mechanism succeeded)"
|
||||
if [[ "${CVE_VERIFIED_ONE}" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: ${ORANGE}${CVE_VERIFIED_ONE}${GREEN} (one mechanism succeeded)"
|
||||
fi
|
||||
if [[ "$CVE_VERIFIED_OVERLAP" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: $ORANGE$CVE_VERIFIED_OVERLAP$GREEN (both mechanisms overlap)"
|
||||
if [[ "${CVE_VERIFIED_OVERLAP}" -gt 0 ]]; then
|
||||
print_output "[+] Verified CVEs: ${ORANGE}${CVE_VERIFIED_OVERLAP}${GREEN} (both mechanisms overlap)"
|
||||
fi
|
||||
|
||||
if [[ "${#CVE_VERIFIED_ONE_CRITICAL[@]}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] Verified CRITICAL CVEs: $ORANGE${#CVE_VERIFIED_ONE_CRITICAL[@]}$GREEN (one mechanism succeeded)"
|
||||
print_output "[+] Verified CRITICAL CVEs: ${ORANGE}${#CVE_VERIFIED_ONE_CRITICAL[@]}${GREEN} (one mechanism succeeded)"
|
||||
for CVE_VERIFIED_ONE_CRITICAL_ in "${CVE_VERIFIED_ONE_CRITICAL[@]}"; do
|
||||
CVE_CRITICAL=$(echo "$CVE_VERIFIED_ONE_CRITICAL_" | cut -d\; -f3)
|
||||
CVSS2_CRITICAL=$(echo "$CVE_VERIFIED_ONE_CRITICAL_" | cut -d\; -f4)
|
||||
CVSS3_CRITICAL=$(echo "$CVE_VERIFIED_ONE_CRITICAL_" | cut -d\; -f5)
|
||||
identify_exploits "$CVE_CRITICAL"
|
||||
print_output "$(indent "$(orange "$ORANGE$CVE_CRITICAL$GREEN\t-\t$ORANGE$CVSS2_CRITICAL$GREEN / $ORANGE$CVSS3_CRITICAL$GREEN\t-\tExploit/PoC: $ORANGE$EXPLOIT_DETECTED $EXP / $POC_DETECTED $POC$NC")")"
|
||||
CVE_CRITICAL=$(echo "${CVE_VERIFIED_ONE_CRITICAL_}" | cut -d\; -f3)
|
||||
CVSS2_CRITICAL=$(echo "${CVE_VERIFIED_ONE_CRITICAL_}" | cut -d\; -f4)
|
||||
CVSS3_CRITICAL=$(echo "${CVE_VERIFIED_ONE_CRITICAL_}" | cut -d\; -f5)
|
||||
identify_exploits "${CVE_CRITICAL}"
|
||||
print_output "$(indent "$(orange "${ORANGE}${CVE_CRITICAL}${GREEN}\t-\t${ORANGE}${CVSS2_CRITICAL}${GREEN} / ${ORANGE}${CVSS3_CRITICAL}${GREEN}\t-\tExploit/PoC: ${ORANGE}${EXPLOIT_DETECTED} ${EXP} / ${POC_DETECTED} ${POC}${NC}")")"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "${#CVE_VERIFIED_OVERLAP_CRITICAL[@]}" -gt 0 ]]; then
|
||||
print_ln
|
||||
print_output "[+] Verified CRITICAL CVEs: $ORANGE${#CVE_VERIFIED_OVERLAP_CRITICAL[@]}$GREEN (both mechanisms overlap)"
|
||||
print_output "[+] Verified CRITICAL CVEs: ${ORANGE}${#CVE_VERIFIED_OVERLAP_CRITICAL[@]}${GREEN} (both mechanisms overlap)"
|
||||
for CVE_VERIFIED_OVERLAP_CRITICAL_ in "${CVE_VERIFIED_OVERLAP_CRITICAL[@]}"; do
|
||||
CVE_CRITICAL=$(echo "$CVE_VERIFIED_OVERLAP_CRITICAL_" | cut -d\; -f3)
|
||||
CVSS2_CRITICAL=$(echo "$CVE_VERIFIED_OVERLAP_CRITICAL_" | cut -d\; -f4)
|
||||
CVSS3_CRITICAL=$(echo "$CVE_VERIFIED_OVERLAP_CRITICAL_" | cut -d\; -f5)
|
||||
identify_exploits "$CVE_CRITICAL"
|
||||
print_output "$(indent "$(orange "$ORANGE$CVE_CRITICAL$GREEN\t-\t$ORANGE$CVSS2_CRITICAL$GREEN / $ORANGE$CVSS3_CRITICAL$GREEN\t-\tExploit/PoC: $ORANGE$EXPLOIT_DETECTED $EXP / $POC_DETECTED $POC$NC")")"
|
||||
CVE_CRITICAL=$(echo "${CVE_VERIFIED_OVERLAP_CRITICAL_}" | cut -d\; -f3)
|
||||
CVSS2_CRITICAL=$(echo "${CVE_VERIFIED_OVERLAP_CRITICAL_}" | cut -d\; -f4)
|
||||
CVSS3_CRITICAL=$(echo "${CVE_VERIFIED_OVERLAP_CRITICAL_}" | cut -d\; -f5)
|
||||
identify_exploits "${CVE_CRITICAL}"
|
||||
print_output "$(indent "$(orange "${ORANGE}${CVE_CRITICAL}${GREEN}\t-\t${ORANGE}${CVSS2_CRITICAL}${GREEN} / ${ORANGE}${CVSS3_CRITICAL}${GREEN}\t-\tExploit/PoC: ${ORANGE}${EXPLOIT_DETECTED} ${EXP} / ${POC_DETECTED} ${POC}${NC}")")"
|
||||
done
|
||||
fi
|
||||
write_log "[*] Statistics:$K_VERSION:${#ALL_KVULNS[@]}:$CVE_VERIFIED_SYMBOLS:$CVE_VERIFIED_COMPILED"
|
||||
write_log "[*] Statistics:${K_VERSION}:${#ALL_KVULNS[@]}:${CVE_VERIFIED_SYMBOLS}:${CVE_VERIFIED_COMPILED}"
|
||||
}
|
||||
|
||||
identify_exploits() {
|
||||
@@ -625,39 +625,39 @@ identify_exploits() {
|
||||
export EXP=""
|
||||
|
||||
if command -v cve_searchsploit >/dev/null; then
|
||||
if cve_searchsploit "$CVE_VALUE" 2>/dev/null | grep -q "Exploit DB Id:"; then
|
||||
if cve_searchsploit "${CVE_VALUE}" 2>/dev/null | grep -q "Exploit DB Id:"; then
|
||||
EXPLOIT_DETECTED="yes"
|
||||
EXP="(EDB)"
|
||||
fi
|
||||
fi
|
||||
if [[ -f "$MSF_DB_PATH" ]]; then
|
||||
if grep -q -E "$CVE_VALUE"$ "$MSF_DB_PATH"; then
|
||||
if [[ -f "${MSF_DB_PATH}" ]]; then
|
||||
if grep -q -E "${CVE_VALUE}"$ "${MSF_DB_PATH}"; then
|
||||
EXPLOIT_DETECTED="yes"
|
||||
EXP="$EXP(MSF)"
|
||||
EXP="${EXP}(MSF)"
|
||||
fi
|
||||
fi
|
||||
if [[ -f "$KNOWN_EXP_CSV" ]]; then
|
||||
if grep -q \""${CVE_VALUE}"\", "$KNOWN_EXP_CSV"; then
|
||||
if [[ -f "${KNOWN_EXP_CSV}" ]]; then
|
||||
if grep -q \""${CVE_VALUE}"\", "${KNOWN_EXP_CSV}"; then
|
||||
EXPLOIT_DETECTED="yes"
|
||||
EXP="$EXP(KNOWN)"
|
||||
EXP="${EXP}(KNOWN)"
|
||||
fi
|
||||
fi
|
||||
if [[ -f "$TRICKEST_DB_PATH" ]]; then
|
||||
if grep -q -E "$CVE_VALUE\.md" "$TRICKEST_DB_PATH"; then
|
||||
if [[ -f "${TRICKEST_DB_PATH}" ]]; then
|
||||
if grep -q -E "${CVE_VALUE}\.md" "${TRICKEST_DB_PATH}"; then
|
||||
POC_DETECTED="yes"
|
||||
POC="$POC(GH)"
|
||||
POC="${POC}(GH)"
|
||||
fi
|
||||
fi
|
||||
if [[ -f "$CONFIG_DIR/Snyk_PoC_results.csv" ]]; then
|
||||
if grep -q -E "^$CVE_VALUE;" "$CONFIG_DIR/Snyk_PoC_results.csv"; then
|
||||
if [[ -f "${CONFIG_DIR}/Snyk_PoC_results.csv" ]]; then
|
||||
if grep -q -E "^${CVE_VALUE};" "${CONFIG_DIR}/Snyk_PoC_results.csv"; then
|
||||
POC_DETECTED="yes"
|
||||
POC="$POC(SNYK)"
|
||||
POC="${POC}(SNYK)"
|
||||
fi
|
||||
fi
|
||||
if [[ -f "$CONFIG_DIR/PS_PoC_results.csv" ]]; then
|
||||
if grep -q -E "^$CVE_VALUE;" "$CONFIG_DIR/PS_PoC_results.csv"; then
|
||||
if [[ -f "${CONFIG_DIR}/PS_PoC_results.csv" ]]; then
|
||||
if grep -q -E "^${CVE_VALUE};" "${CONFIG_DIR}/PS_PoC_results.csv"; then
|
||||
POC_DETECTED="yes"
|
||||
POC="$POC(PS)"
|
||||
POC="${POC}(PS)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -665,7 +665,7 @@ identify_exploits() {
|
||||
get_csv_data_s24() {
|
||||
local S24_CSV_LOG="${1:-}"
|
||||
|
||||
if ! [[ -f "$S24_CSV_LOG" ]];then
|
||||
if ! [[ -f "${S24_CSV_LOG}" ]];then
|
||||
print_output "[-] No EMBA log found ..."
|
||||
return
|
||||
fi
|
||||
@@ -674,5 +674,5 @@ get_csv_data_s24() {
|
||||
|
||||
# currently we only support one kernel version
|
||||
# if we detect multiple kernel versions we only process the first one after sorting
|
||||
mapfile -t K_VERSIONS < <(cut -d\; -f2 "$S24_CSV_LOG" | tail -n +2 | grep -v "NA" | sort -u)
|
||||
mapfile -t K_VERSIONS < <(cut -d\; -f2 "${S24_CSV_LOG}" | tail -n +2 | grep -v "NA" | sort -u)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ S35_http_file_check()
|
||||
webserver_check
|
||||
php_check
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$HTTP_COUNTER"
|
||||
module_end_log "${FUNCNAME[0]}" "${HTTP_COUNTER}"
|
||||
}
|
||||
|
||||
web_file_search()
|
||||
@@ -39,14 +39,14 @@ web_file_search()
|
||||
local WEB_STUFF=()
|
||||
local WEB_FILE=""
|
||||
|
||||
mapfile -t WEB_STUFF < <(find "$FIRMWARE_PATH" -xdev -type f \( -iname "*.htm" -o -iname "*.html" -o -iname "*.cgi" \
|
||||
mapfile -t WEB_STUFF < <(find "${FIRMWARE_PATH}" -xdev -type f \( -iname "*.htm" -o -iname "*.html" -o -iname "*.cgi" \
|
||||
-o -iname "*.asp" -o -iname "*.php" -o -iname "*.xml" -o -iname "*.rg" \) -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3)
|
||||
|
||||
if [[ -v WEB_STUFF[@] ]] ; then
|
||||
print_output "[+] Found web related files:"
|
||||
for WEB_FILE in "${WEB_STUFF[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$WEB_FILE")")"
|
||||
write_csv_log "Web served files" "$(basename "$WEB_FILE")" "$WEB_FILE"
|
||||
print_output "$(indent "$(print_path "${WEB_FILE}")")"
|
||||
write_csv_log "Web served files" "$(basename "${WEB_FILE}")" "${WEB_FILE}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
@@ -60,14 +60,14 @@ http_file_search()
|
||||
|
||||
local HTTP_STUFF=()
|
||||
local HTTP_FILE=""
|
||||
mapfile -t HTTP_STUFF < <(config_find "$CONFIG_DIR""/http_files.cfg")
|
||||
mapfile -t HTTP_STUFF < <(config_find "${CONFIG_DIR}""/http_files.cfg")
|
||||
|
||||
if [[ "${HTTP_STUFF[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#HTTP_STUFF[@]}" -ne 0 ]] ; then
|
||||
print_output "[+] Found http related files:"
|
||||
for HTTP_FILE in "${HTTP_STUFF[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$HTTP_FILE")")"
|
||||
write_csv_log "HTTP server files" "$(basename "$HTTP_FILE")" "$HTTP_FILE"
|
||||
print_output "$(indent "$(print_path "${HTTP_FILE}")")"
|
||||
write_csv_log "HTTP server files" "$(basename "${HTTP_FILE}")" "${HTTP_FILE}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
@@ -86,17 +86,17 @@ webserver_check()
|
||||
local HTTPD_FILE_ARR=()
|
||||
local LINE=""
|
||||
|
||||
readarray -t APACHE_FILE_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*apache*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t NGINX_FILE_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*nginx*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t LIGHTTP_FILE_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*lighttp*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t CHEROKEE_FILE_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*cheroke*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t HTTPD_FILE_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*httpd*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t APACHE_FILE_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*apache*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t NGINX_FILE_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*nginx*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t LIGHTTP_FILE_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*lighttp*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t CHEROKEE_FILE_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*cheroke*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t HTTPD_FILE_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*httpd*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
|
||||
if [[ ${#APACHE_FILE_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found Apache related files:"
|
||||
for LINE in "${APACHE_FILE_ARR[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
write_csv_log "Apache web server file" "$(basename "$LINE")" "$LINE"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
write_csv_log "Apache web server file" "$(basename "${LINE}")" "${LINE}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
@@ -106,8 +106,8 @@ webserver_check()
|
||||
if [[ ${#NGINX_FILE_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found nginx related files:"
|
||||
for LINE in "${NGINX_FILE_ARR[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
write_csv_log "Nginx web server file" "$(basename "$LINE")" "$LINE"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
write_csv_log "Nginx web server file" "$(basename "${LINE}")" "${LINE}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
@@ -117,8 +117,8 @@ webserver_check()
|
||||
if [[ ${#LIGHTTP_FILE_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found Lighttpd related files:"
|
||||
for LINE in "${LIGHTTP_FILE_ARR[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
write_csv_log "Lighttpd web server file" "$(basename "$LINE")" "$LINE"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
write_csv_log "Lighttpd web server file" "$(basename "${LINE}")" "${LINE}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
@@ -128,8 +128,8 @@ webserver_check()
|
||||
if [[ ${#CHEROKEE_FILE_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found Cherokee related files:"
|
||||
for LINE in "${CHEROKEE_FILE_ARR[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
write_csv_log "Cherokee web server file" "$(basename "$LINE")" "$LINE"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
write_csv_log "Cherokee web server file" "$(basename "${LINE}")" "${LINE}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
@@ -139,8 +139,8 @@ webserver_check()
|
||||
if [[ ${#HTTPD_FILE_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found HTTPd related files:"
|
||||
for LINE in "${HTTPD_FILE_ARR[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
write_csv_log "HTTPd web server file" "$(basename "$LINE")" "$LINE"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
write_csv_log "HTTPd web server file" "$(basename "${LINE}")" "${LINE}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
@@ -154,13 +154,13 @@ php_check()
|
||||
local PHP_INI_ARR=()
|
||||
local PHP_INI_ENTRY=""
|
||||
|
||||
readarray -t PHP_INI_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*php.ini' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t PHP_INI_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*php.ini' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
|
||||
if [[ ${#PHP_INI_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found php.ini:"
|
||||
for PHP_INI_ENTRY in "${PHP_INI_ARR[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$PHP_INI_ENTRY")")"
|
||||
write_csv_log "php.ini file" "$(basename "$PHP_INI_ENTRY")" "$PHP_INI_ENTRY"
|
||||
print_output "$(indent "$(print_path "${PHP_INI_ENTRY}")")"
|
||||
write_csv_log "php.ini file" "$(basename "${PHP_INI_ENTRY}")" "${PHP_INI_ENTRY}"
|
||||
((HTTP_COUNTER+=1))
|
||||
done
|
||||
else
|
||||
|
||||
+126
-126
@@ -31,8 +31,8 @@ S36_lighttpd() {
|
||||
local LIGHTTP_BIN_ARR=()
|
||||
local FILE=""
|
||||
|
||||
readarray -t LIGHTTP_CFG_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*lighttp*conf*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 || true)
|
||||
readarray -t LIGHTTP_BIN_ARR < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -type f -iname 'lighttpd' -exec file {} \; 2>/dev/null | grep "ELF" | cut -d ':' -f1 | sort -u || true)
|
||||
readarray -t LIGHTTP_CFG_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*lighttp*conf*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 || true)
|
||||
readarray -t LIGHTTP_BIN_ARR < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -type f -iname 'lighttpd' -exec file {} \; 2>/dev/null | grep "ELF" | cut -d ':' -f1 | sort -u || true)
|
||||
|
||||
if [[ ${#LIGHTTP_BIN_ARR[@]} -gt 0 ]] ; then
|
||||
lighttpd_binary_analysis "${LIGHTTP_BIN_ARR[@]}"
|
||||
@@ -40,15 +40,15 @@ S36_lighttpd() {
|
||||
|
||||
if [[ ${#LIGHTTP_CFG_ARR[@]} -gt 0 ]] ; then
|
||||
for FILE in "${LIGHTTP_CFG_ARR[@]}" ; do
|
||||
lighttpd_config_analysis "$FILE" "${LIGHT_VERSIONS[@]}"
|
||||
write_csv_log "Lighttpd web server configuration file" "$(basename "$FILE")" "$FILE"
|
||||
lighttpd_config_analysis "${FILE}" "${LIGHT_VERSIONS[@]}"
|
||||
write_csv_log "Lighttpd web server configuration file" "$(basename "${FILE}")" "${FILE}"
|
||||
local NEG_LOG=1
|
||||
done
|
||||
else
|
||||
print_output "[-] No Lighttpd related configuration files found"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
lighttpd_binary_analysis() {
|
||||
@@ -56,51 +56,51 @@ lighttpd_binary_analysis() {
|
||||
local LIGHTTP_BIN_ARR=("${@}")
|
||||
export LIGHT_VERSIONS=()
|
||||
|
||||
if [[ -f "$CSV_DIR/s09_firmware_base_version_check.csv" ]] && grep -q "lighttpd" "$CSV_DIR"/s09_firmware_base_version_check.csv; then
|
||||
if [[ -f "${CSV_DIR}/s09_firmware_base_version_check.csv" ]] && grep -q "lighttpd" "${CSV_DIR}"/s09_firmware_base_version_check.csv; then
|
||||
# if we already have results from s09 we just use them
|
||||
mapfile -t LIGHT_VERSIONS < <(grep "lighttpd" "$CSV_DIR"/s09_firmware_base_version_check.csv | cut -d\; -f4 | sort -u || true)
|
||||
mapfile -t LIGHT_VERSIONS < <(grep "lighttpd" "${CSV_DIR}"/s09_firmware_base_version_check.csv | cut -d\; -f4 | sort -u || true)
|
||||
else
|
||||
# most of the time we run through the lighttpd version identifiers and check them against the lighttpd binaries
|
||||
while read -r VERSION_LINE; do
|
||||
if safe_echo "$VERSION_LINE" | grep -v -q "^[^#*/;]"; then
|
||||
if safe_echo "${VERSION_LINE}" | grep -v -q "^[^#*/;]"; then
|
||||
continue
|
||||
fi
|
||||
if safe_echo "$VERSION_LINE" | grep -q ";no_static;"; then
|
||||
if safe_echo "${VERSION_LINE}" | grep -q ";no_static;"; then
|
||||
continue
|
||||
fi
|
||||
if safe_echo "$VERSION_LINE" | grep -q ";live;"; then
|
||||
if safe_echo "${VERSION_LINE}" | grep -q ";live;"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
CSV_REGEX="$(echo "$VERSION_LINE" | cut -d\; -f5)"
|
||||
LIC="$(safe_echo "$VERSION_LINE" | cut -d\; -f3)"
|
||||
VERSION_IDENTIFIER="$(safe_echo "$VERSION_LINE" | cut -d\; -f4)"
|
||||
CSV_REGEX="$(echo "${VERSION_LINE}" | cut -d\; -f5)"
|
||||
LIC="$(safe_echo "${VERSION_LINE}" | cut -d\; -f3)"
|
||||
VERSION_IDENTIFIER="$(safe_echo "${VERSION_LINE}" | cut -d\; -f4)"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER/\"}"
|
||||
VERSION_IDENTIFIER="${VERSION_IDENTIFIER%\"}"
|
||||
|
||||
for BIN in "${LIGHTTP_BIN_ARR[@]}" ; do
|
||||
VERSION_FINDER=$(strings "$BIN" | grep -o -a -E "$VERSION_IDENTIFIER" | head -1 2> /dev/null || true)
|
||||
if [[ -n $VERSION_FINDER ]]; then
|
||||
VERSION_FINDER=$(strings "${BIN}" | grep -o -a -E "${VERSION_IDENTIFIER}" | head -1 2> /dev/null || true)
|
||||
if [[ -n ${VERSION_FINDER} ]]; then
|
||||
print_ln "no_log"
|
||||
print_output "[+] Version information found ${RED}$VERSION_FINDER${NC}${GREEN} in binary $ORANGE$(print_path "$BIN")$GREEN (license: $ORANGE$LIC$GREEN) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "$VERSION_FINDER" "$CSV_REGEX"
|
||||
LIGHT_VERSIONS+=( "$CSV_RULE" )
|
||||
print_output "[+] Version information found ${RED}${VERSION_FINDER}${NC}${GREEN} in binary ${ORANGE}$(print_path "${BIN}")${GREEN} (license: ${ORANGE}${LIC}${GREEN}) (${ORANGE}static${GREEN})."
|
||||
get_csv_rule "${VERSION_FINDER}" "${CSV_REGEX}"
|
||||
LIGHT_VERSIONS+=( "${CSV_RULE}" )
|
||||
continue
|
||||
fi
|
||||
done
|
||||
done < <(grep "^lighttpd" "$CONFIG_DIR"/bin_version_strings.cfg)
|
||||
done < <(grep "^lighttpd" "${CONFIG_DIR}"/bin_version_strings.cfg)
|
||||
fi
|
||||
eval "LIGHT_VERSIONS=($(for i in "${LIGHT_VERSIONS[@]}" ; do echo "\"$i\"" ; done | sort -u))"
|
||||
eval "LIGHT_VERSIONS=($(for i in "${LIGHT_VERSIONS[@]}" ; do echo "\"${i}\"" ; done | sort -u))"
|
||||
|
||||
if [[ ${#LIGHT_VERSIONS[@]} -gt 0 ]] ; then
|
||||
prepare_cve_search_module
|
||||
print_ln
|
||||
# lets do a quick vulnerability check on our lighttpd version
|
||||
if ! [[ -d "$LOG_PATH_MODULE"/cve_sum ]]; then
|
||||
mkdir "$LOG_PATH_MODULE"/cve_sum
|
||||
if ! [[ -d "${LOG_PATH_MODULE}"/cve_sum ]]; then
|
||||
mkdir "${LOG_PATH_MODULE}"/cve_sum
|
||||
fi
|
||||
for LIGHT_VER in "${LIGHT_VERSIONS[@]}"; do
|
||||
cve_db_lookup_version "$LIGHT_VER"
|
||||
cve_db_lookup_version "${LIGHT_VER}"
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -108,30 +108,30 @@ lighttpd_binary_analysis() {
|
||||
print_ln
|
||||
print_output "[*] Testing lighttpd binaries for binary protection mechanisms:\\n"
|
||||
for BIN in "${LIGHTTP_BIN_ARR[@]}" ; do
|
||||
print_output "$("$EXT_DIR"/checksec --file="$BIN")"
|
||||
print_output "$("${EXT_DIR}"/checksec --file="${BIN}")"
|
||||
done
|
||||
|
||||
print_ln
|
||||
print_output "[*] Testing lighttpd binaries for deprecated function calls:\\n"
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "$CONFIG_DIR""/functions.cfg")"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "$VULNERABLE_FUNCTIONS_VAR" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
VULNERABLE_FUNCTIONS_VAR="$(config_list "${CONFIG_DIR}""/functions.cfg")"
|
||||
IFS=" " read -r -a VULNERABLE_FUNCTIONS <<<"$( echo -e "${VULNERABLE_FUNCTIONS_VAR}" | sed ':a;N;$!ba;s/\n/ /g' )"
|
||||
for BIN in "${LIGHTTP_BIN_ARR[@]}" ; do
|
||||
if ( file "$BIN" | grep -q "x86-64" ) ; then
|
||||
function_check_x86_64 "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "$BIN" | grep -q "Intel 80386" ) ; then
|
||||
function_check_x86 "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "$BIN" | grep -q "32-bit.*ARM" ) ; then
|
||||
function_check_ARM32 "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "$BIN" | grep -q "64-bit.*ARM" ) ; then
|
||||
function_check_ARM64 "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "$BIN" | grep -q "MIPS" ) ; then
|
||||
function_check_MIPS "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "$BIN" | grep -q "PowerPC" ) ; then
|
||||
function_check_PPC32 "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "$BIN" | grep -q "Altera Nios II" ) ; then
|
||||
function_check_NIOS2 "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "$BIN" | grep -q "QUALCOMM DSP6" ) ; then
|
||||
radare_function_check_hexagon "$BIN" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
if ( file "${BIN}" | grep -q "x86-64" ) ; then
|
||||
function_check_x86_64 "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "${BIN}" | grep -q "Intel 80386" ) ; then
|
||||
function_check_x86 "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "${BIN}" | grep -q "32-bit.*ARM" ) ; then
|
||||
function_check_ARM32 "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "${BIN}" | grep -q "64-bit.*ARM" ) ; then
|
||||
function_check_ARM64 "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "${BIN}" | grep -q "MIPS" ) ; then
|
||||
function_check_MIPS "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "${BIN}" | grep -q "PowerPC" ) ; then
|
||||
function_check_PPC32 "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "${BIN}" | grep -q "Altera Nios II" ) ; then
|
||||
function_check_NIOS2 "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
elif ( file "${BIN}" | grep -q "QUALCOMM DSP6" ) ; then
|
||||
radare_function_check_hexagon "${BIN}" "${VULNERABLE_FUNCTIONS[@]}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -145,19 +145,19 @@ prepare_cve_search_module() {
|
||||
if command -v cve_searchsploit > /dev/null ; then
|
||||
export CVE_SEARCHSPLOIT=1
|
||||
fi
|
||||
if [[ -f "$MSF_DB_PATH" ]]; then
|
||||
if [[ -f "${MSF_DB_PATH}" ]]; then
|
||||
export MSF_SEARCH=1
|
||||
fi
|
||||
if [[ -f "$TRICKEST_DB_PATH" ]]; then
|
||||
if [[ -f "${TRICKEST_DB_PATH}" ]]; then
|
||||
export TRICKEST_SEARCH=1
|
||||
fi
|
||||
if [[ -f "$CONFIG_DIR"/routersploit_cve-db.txt || -f "$CONFIG_DIR"/routersploit_exploit-db.txt ]]; then
|
||||
if [[ -f "${CONFIG_DIR}"/routersploit_cve-db.txt || -f "${CONFIG_DIR}"/routersploit_exploit-db.txt ]]; then
|
||||
export RS_SEARCH=1
|
||||
fi
|
||||
if [[ -f "$CONFIG_DIR"/PS_PoC_results.csv ]]; then
|
||||
if [[ -f "${CONFIG_DIR}"/PS_PoC_results.csv ]]; then
|
||||
export PS_SEARCH=1
|
||||
fi
|
||||
if [[ -f "$CONFIG_DIR"/Snyk_PoC_results.csv ]]; then
|
||||
if [[ -f "${CONFIG_DIR}"/Snyk_PoC_results.csv ]]; then
|
||||
export SNYK_SEARCH=1
|
||||
fi
|
||||
}
|
||||
@@ -168,171 +168,171 @@ lighttpd_config_analysis() {
|
||||
local LIGHT_VERSIONS=("${@}")
|
||||
local SSL_ENABLED=0
|
||||
|
||||
if ! [[ -f "$LIGHTTPD_CONFIG" ]]; then
|
||||
if ! [[ -f "${LIGHTTPD_CONFIG}" ]]; then
|
||||
print_output "[-] No configuration file available"
|
||||
return
|
||||
fi
|
||||
sub_module_title "Lighttpd configuration analysis for $(basename "$LIGHTTPD_CONFIG")"
|
||||
sub_module_title "Lighttpd configuration analysis for $(basename "${LIGHTTPD_CONFIG}")"
|
||||
|
||||
print_output "[*] Testing web server configuration file $ORANGE$LIGHTTPD_CONFIG$NC\\n"
|
||||
print_output "[*] Testing web server configuration file ${ORANGE}${LIGHTTPD_CONFIG}${NC}\\n"
|
||||
print_output "[*] Testing web server user"
|
||||
if grep "user=root" "$LIGHTTPD_CONFIG" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server running as root user:$NC"
|
||||
print_output "$(indent "$(orange "$(grep "user=root" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep "user=root" "${LIGHTTPD_CONFIG}" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server running as root user:${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "user=root" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
if grep -E "server.username.*root" "$LIGHTTPD_CONFIG" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server running as root user:$NC"
|
||||
print_output "$(indent "$(orange "$(grep -E "server.username.*root" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "server.username.*root" "${LIGHTTPD_CONFIG}" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server running as root user:${NC}"
|
||||
print_output "$(indent "$(orange "$(grep -E "server.username.*root" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server root directory location"
|
||||
if grep -E "server_root\|server\.document-root" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
if grep -E "server_root\|server\.document-root" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[*] ${ORANGE}Configuration note:${NC} Web server using the following root directory"
|
||||
print_output "$(indent "$(orange "$(grep -E "server_root\|server\.document-root" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
print_output "$(indent "$(orange "$(grep -E "server_root\|server\.document-root" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing for additional web server binaries"
|
||||
if grep -E "bin-path" "$LIGHTTPD_CONFIG" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
if grep -E "bin-path" "${LIGHTTPD_CONFIG}" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[*] ${ORANGE}Configuration note:${NC} Web server using the following additional binaries"
|
||||
print_output "$(indent "$(orange "$(grep -E "bin-path" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
print_output "$(indent "$(orange "$(grep -E "bin-path" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing for directory listing configuration"
|
||||
if grep -E "dir-listing.activate.*enable" "$LIGHTTPD_CONFIG" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Configuration issue detected: ${ORANGE}Web server allows directory listings$NC"
|
||||
print_output "$(indent "$(orange "$(grep -E "dir-listing.activate.*enable" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "dir-listing.activate.*enable" "${LIGHTTPD_CONFIG}" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Configuration issue detected: ${ORANGE}Web server allows directory listings${NC}"
|
||||
print_output "$(indent "$(orange "$(grep -E "dir-listing.activate.*enable" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
if grep -E "server.dir-listing.*enable" "$LIGHTTPD_CONFIG" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Configuration issue detected: ${ORANGE}Web server allows directory listings$NC"
|
||||
print_output "$(indent "$(orange "$(grep -E "server.dir-listing.*enable" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "server.dir-listing.*enable" "${LIGHTTPD_CONFIG}" | grep -E -v -q "^([[:space:]])?#"; then
|
||||
print_output "[+] Configuration issue detected: ${ORANGE}Web server allows directory listings${NC}"
|
||||
print_output "$(indent "$(orange "$(grep -E "server.dir-listing.*enable" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server ssl.engine usage"
|
||||
if ! grep -E "ssl.engine.*enable" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not using ssl engine$NC"
|
||||
if ! grep -E "ssl.engine.*enable" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not using ssl engine${NC}"
|
||||
else
|
||||
SSL_ENABLED=1
|
||||
fi
|
||||
|
||||
if [[ "$SSL_ENABLED" -eq 1 ]]; then
|
||||
if [[ "${SSL_ENABLED}" -eq 1 ]]; then
|
||||
print_output "[*] Testing web server pemfile location"
|
||||
if grep -E "ssl.pemfile" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[*] ${ORANGE}Configuration note:$NC Web server using the following pem file"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.pemfile" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#" || true)")")"
|
||||
mapfile -t PEM_FILES < <(grep -E "ssl.pemfile" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#" | cut -d= -f2 | tr -d '"' || true)
|
||||
if grep -E "ssl.pemfile" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[*] ${ORANGE}Configuration note:${NC} Web server using the following pem file"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.pemfile" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#" || true)")")"
|
||||
mapfile -t PEM_FILES < <(grep -E "ssl.pemfile" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#" | cut -d= -f2 | tr -d '"' || true)
|
||||
for PEM_FILE in "${PEM_FILES[@]}"; do
|
||||
PEM_FILE=$(echo "$PEM_FILE" | tr -d "[:space:]")
|
||||
mapfile -t REAL_PEMS < <(find "$FIRMWARE_PATH" -wholename "*$PEM_FILE" || true)
|
||||
PEM_FILE=$(echo "${PEM_FILE}" | tr -d "[:space:]")
|
||||
mapfile -t REAL_PEMS < <(find "${FIRMWARE_PATH}" -wholename "*${PEM_FILE}" || true)
|
||||
for REAL_PEM in "${REAL_PEMS[@]}"; do
|
||||
print_output "[*] ${ORANGE}Configuration note:${NC} Web server pem file found: $ORANGE$REAL_PEM$NC"
|
||||
print_output "[*] $(find "$REAL_PEM" -ls)"
|
||||
print_output "[*] ${ORANGE}Configuration note:${NC} Web server pem file found: ${ORANGE}${REAL_PEM}${NC}"
|
||||
print_output "[*] $(find "${REAL_PEM}" -ls)"
|
||||
# Todo: check for permissions 400 on pem file
|
||||
if [[ "$(stat -c "%a" "$REAL_PEM")" -ne 400 ]]; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Privileges of web server pem file not correct$NC"
|
||||
if [[ "$(stat -c "%a" "${REAL_PEM}")" -ne 400 ]]; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Privileges of web server pem file not correct${NC}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
print_output "[*] Testing web server private key file"
|
||||
if grep -E "ssl.privkey" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
if grep -E "ssl.privkey" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[*] ${ORANGE}Configuration note:${NC} Web server using the following private key file"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.privkey" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.privkey" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server BEAST mitigation"
|
||||
if grep -E "ssl.disable-client-renegotiation.*disable" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the BEAST attack (CVE-2009-3555) via ssl.disable-client-renegotiation.$NC"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.disable-client-renegotiation.*disable" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.disable-client-renegotiation.*disable" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the BEAST attack (CVE-2009-3555) via ssl.disable-client-renegotiation.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.disable-client-renegotiation.*disable" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
if grep -E "ssl.honor-cipher-order.*disable" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
if grep -E "ssl.honor-cipher-order.*disable" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
# defaults to enable -> we only need to check if it is disabled
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the BEAST attack (CVE-2009-3555) via ssl.honor-cipher-order.$NC"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.honor-cipher-order.*disable" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the BEAST attack (CVE-2009-3555) via ssl.honor-cipher-order.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.honor-cipher-order.*disable" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server for SSL ciphers supported"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list\|ssl.openssl.ssl-conf-cmd" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list\|ssl.openssl.ssl-conf-cmd" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
|
||||
if grep "ssl.cipher-list\|ssl.openssl.ssl-conf-cmd" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
if grep "ssl.cipher-list\|ssl.openssl.ssl-conf-cmd" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
|
||||
print_output "[*] Testing web server POODLE attack mitigation"
|
||||
if grep -E "ssl.cipher-list.*:SSLv3" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
if grep -E "ssl.cipher-list.*:SSLv3" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
if [[ ${#LIGHT_VERSIONS[@]} -eq 0 ]] ; then
|
||||
# if we have no version detected we show this issue:
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the POODLE attack (CVE-2014-3566) via disabled SSLv3 ciphers.$NC"
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the POODLE attack (CVE-2014-3566) via disabled SSLv3 ciphers.${NC}"
|
||||
print_output "[*] Note that SSLv3 is automatically disabled on lighttpd since version ${ORANGE}1.4.36${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
for LIGHT_VER in "${LIGHT_VERSIONS[@]}"; do
|
||||
LIGHT_VER="${LIGHT_VER/*:/}"
|
||||
if [[ "$(version "$LIGHT_VER")" -le "$(version "1.4.35")" ]]; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the POODLE attack (CVE-2014-3566) via disabled SSLv3 ciphers.$NC"
|
||||
if [[ "$(version "${LIGHT_VER}")" -le "$(version "1.4.35")" ]]; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not mitigating the POODLE attack (CVE-2014-3566) via disabled SSLv3 ciphers.${NC}"
|
||||
print_output "[*] Note that SSLv3 is automatically disabled on lighttpd since version ${ORANGE}1.4.36${NC}"
|
||||
print_output "[*] EMBA detected lighttpd version ${ORANGE}$LIGHT_VER${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
print_output "[*] EMBA detected lighttpd version ${ORANGE}${LIGHT_VER}${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server enabled SSLv2"
|
||||
if grep -E "ssl.use-sslv2.*enable" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enables SSLv2 ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.use-sslv2" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.use-sslv2.*enable" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enables SSLv2 ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.use-sslv2" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server enabled SSLv3"
|
||||
if grep -E "ssl.use-sslv3.*enable" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enables SSLv3 ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.use-sslv3" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.use-sslv3.*enable" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enables SSLv3 ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep -E "ssl.use-sslv3" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server FREAK attack mitigation"
|
||||
if grep -E "ssl.cipher-list.*:EXPORT" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling EXPORT ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:EXPORT" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling EXPORT ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server NULL ciphers"
|
||||
if grep -E "ssl.cipher-list.*:[ae]NULL" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling NULL ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:[ae]NULL" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling NULL ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server RC4 ciphers"
|
||||
if grep -E "ssl.cipher-list.*:RC4" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling RC4 ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:RC4" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling RC4 ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server DES ciphers"
|
||||
if grep -E "ssl.cipher-list.*:DES" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling DES ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:DES" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling DES ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server 3DES ciphers"
|
||||
if grep -E "ssl.cipher-list.*:3DES" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling 3DES ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:3DES" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling 3DES ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
print_output "[*] Testing web server MD5 ciphers"
|
||||
if grep -E "ssl.cipher-list.*:MD5" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling MD5 ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:MD5" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server not disabling MD5 ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
|
||||
# lighttpd implicitly applies ssl.cipher-list = "HIGH" (since lighttpd 1.4.54) if ssl.cipher-list is not explicitly set in lighttpd.conf.
|
||||
print_output "[*] Testing web server LOW ciphers"
|
||||
if grep -E "ssl.cipher-list.*:LOW" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enabling LOW ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:LOW" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enabling LOW ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
print_output "[*] Testing web server MEDIUM ciphers"
|
||||
if grep -E "ssl.cipher-list.*:MEDIUM" "$LIGHTTPD_CONFIG" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enabling MEDIUM ciphers.$NC"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "$LIGHTTPD_CONFIG" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
if grep -E "ssl.cipher-list.*:MEDIUM" "${LIGHTTPD_CONFIG}" | grep -q -E -v "^([[:space:]])?#"; then
|
||||
print_output "[+] Possible configuration issue detected: ${ORANGE}Web server enabling MEDIUM ciphers.${NC}"
|
||||
print_output "$(indent "$(orange "$(grep "ssl.cipher-list" "${LIGHTTPD_CONFIG}" | sort -u | grep -q -E -v "^([[:space:]])?#")")")"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -29,9 +29,9 @@ S40_weak_perm_check() {
|
||||
local ETC_ARR
|
||||
ETC_ARR=("$(mod_path "/ETC_PATHS")")
|
||||
|
||||
readarray -t SETUID_FILES < <(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -user root -perm -4000 -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 2>/dev/null || true)
|
||||
readarray -t SETGID_FILES < <(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -user root -perm -2000 -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 2>/dev/null || true)
|
||||
readarray -t WORLD_WRITE_FILES < <(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -type f -perm -o+w -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 2>/dev/null || true)
|
||||
readarray -t SETUID_FILES < <(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -user root -perm -4000 -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 2>/dev/null || true)
|
||||
readarray -t SETGID_FILES < <(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -user root -perm -2000 -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 2>/dev/null || true)
|
||||
readarray -t WORLD_WRITE_FILES < <(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -type f -perm -o+w -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 2>/dev/null || true)
|
||||
readarray -t WEAK_SHADOW_FILES < <(find "${ETC_ARR[@]}" "${EXCL_FIND[@]}" -xdev -type f -iname "shadow*" -perm -600 -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 2>/dev/null || true)
|
||||
|
||||
ETC_ARR=("$(mod_path "/ETC_PATHS/rc.d")")
|
||||
@@ -44,13 +44,13 @@ S40_weak_perm_check() {
|
||||
if [[ ${#SETUID_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#SETUID_FILES[@]}"" setuid files:"
|
||||
for LINE in "${SETUID_FILES[@]}" ; do
|
||||
SETUID_NAME=$(basename "$LINE")
|
||||
GTFO_LINK=$(grep "/$SETUID_NAME/" "$GTFO_CFG" || true)
|
||||
if [[ "$GTFO_LINK" == "https://"* ]]; then
|
||||
print_output "$(indent "$GREEN$(print_path "$LINE")$NC")"
|
||||
write_link "$GTFO_LINK"
|
||||
SETUID_NAME=$(basename "${LINE}")
|
||||
GTFO_LINK=$(grep "/${SETUID_NAME}/" "${GTFO_CFG}" || true)
|
||||
if [[ "${GTFO_LINK}" == "https://"* ]]; then
|
||||
print_output "$(indent "${GREEN}$(print_path "${LINE}")${NC}")"
|
||||
write_link "${GTFO_LINK}"
|
||||
else
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
fi
|
||||
((WEAK_PERM_COUNTER+=1))
|
||||
done
|
||||
@@ -62,7 +62,7 @@ S40_weak_perm_check() {
|
||||
if [[ ${#SETGID_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#SETGID_FILES[@]}"" setgid files:"
|
||||
for LINE in "${SETGID_FILES[@]}"; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
((WEAK_PERM_COUNTER+=1))
|
||||
done
|
||||
print_ln "no_log"
|
||||
@@ -73,7 +73,7 @@ S40_weak_perm_check() {
|
||||
if [[ ${#WORLD_WRITE_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#WORLD_WRITE_FILES[@]}"" world writeable files:"
|
||||
for LINE in "${WORLD_WRITE_FILES[@]}"; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
((WEAK_PERM_COUNTER+=1))
|
||||
done
|
||||
print_ln "no_log"
|
||||
@@ -84,7 +84,7 @@ S40_weak_perm_check() {
|
||||
if [[ ${#WEAK_SHADOW_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#WEAK_SHADOW_FILES[@]}"" weak shadow files:"
|
||||
for LINE in "${WEAK_SHADOW_FILES[@]}"; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
((WEAK_PERM_COUNTER+=1))
|
||||
done
|
||||
print_ln "no_log"
|
||||
@@ -95,7 +95,7 @@ S40_weak_perm_check() {
|
||||
if [[ ${#WEAK_RC_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#WEAK_RC_FILES[@]}"" rc.d files not belonging to root:"
|
||||
for LINE in "${WEAK_RC_FILES[@]}"; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
((WEAK_PERM_COUNTER+=1))
|
||||
done
|
||||
print_ln "no_log"
|
||||
@@ -106,7 +106,7 @@ S40_weak_perm_check() {
|
||||
if [[ ${#WEAK_INIT_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#WEAK_INIT_FILES[@]}"" init.d files not belonging to root:"
|
||||
for LINE in "${WEAK_INIT_FILES[@]}"; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
((WEAK_PERM_COUNTER+=1))
|
||||
done
|
||||
print_ln "no_log"
|
||||
@@ -115,7 +115,7 @@ S40_weak_perm_check() {
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$WEAK_PERM_COUNTER"
|
||||
write_log "[*] Statistics:${WEAK_PERM_COUNTER}"
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$WEAK_PERM_COUNTER"
|
||||
module_end_log "${FUNCNAME[0]}" "${WEAK_PERM_COUNTER}"
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ S45_pass_file_check()
|
||||
local LINE=""
|
||||
local PASSWD_STUFF=()
|
||||
|
||||
mapfile -t PASSWD_STUFF < <(config_find "$CONFIG_DIR""/pass_files.cfg")
|
||||
mapfile -t PASSWD_STUFF < <(config_find "${CONFIG_DIR}""/pass_files.cfg")
|
||||
|
||||
if [[ "${PASSWD_STUFF[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#PASSWD_STUFF[@]}" -ne 0 ]] ; then
|
||||
@@ -39,67 +39,67 @@ S45_pass_file_check()
|
||||
mapfile -t SUDOERS_FILE_PATH < <(mod_path "/ETC_PATHS/sudoers")
|
||||
|
||||
for SUDOERS_FILE in "${SUDOERS_FILE_PATH[@]}" ; do
|
||||
if [[ -e "$SUDOERS_FILE" ]] ; then
|
||||
SUDOERS="$SUDOERS""\\n""$(grep -v -e '^$' "$SUDOERS_FILE" 2>/dev/null | grep -v "#" 2>/dev/null)"
|
||||
if [[ -e "${SUDOERS_FILE}" ]] ; then
|
||||
SUDOERS="${SUDOERS}""\\n""$(grep -v -e '^$' "${SUDOERS_FILE}" 2>/dev/null | grep -v "#" 2>/dev/null)"
|
||||
fi
|
||||
done
|
||||
# who has sudoed in the past
|
||||
# This test is based on the source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
WHO_HAS_BEEN_SUDO=$(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -name .sudo_as_admin_successful 2>/dev/null)
|
||||
WHO_HAS_BEEN_SUDO=$(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -name .sudo_as_admin_successful 2>/dev/null)
|
||||
|
||||
if [[ "${#PASSWD_STUFF[@]}" -gt 0 ]] || [[ -n "$SUDOERS" ]] || [[ -n "$WHO_HAS_BEEN_SUDO" ]] ; then
|
||||
if [[ "${#PASSWD_STUFF[@]}" -gt 0 ]] || [[ -n "${SUDOERS}" ]] || [[ -n "${WHO_HAS_BEEN_SUDO}" ]] ; then
|
||||
print_output "[+] Found ""${#PASSWD_STUFF[@]}"" password related files:"
|
||||
for LINE in "${PASSWD_STUFF[@]}" ; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
if [[ -f "$LINE" ]] && ! [[ -x "$LINE" ]] ; then
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
if [[ -f "${LINE}" ]] && ! [[ -x "${LINE}" ]] ; then
|
||||
local POSSIBLE_PASSWD
|
||||
# regex source: https://serverfault.com/questions/972572/regex-for-etc-passwd-content
|
||||
# POSSIBLE_PASSWD=$(grep -hIE '^([^:]*:){6}[^:]*$' "$LINE" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null)
|
||||
POSSIBLE_PASSWD=$(grep -hIE '^[a-zA-Z0-9]+:.:[0-9]+:[0-9]+([^:]*:){3}[^:]*$' "$LINE" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null || true)
|
||||
# POSSIBLE_PASSWD=$(grep -hIE '^([^:]*:){6}[^:]*$' "${LINE}" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null)
|
||||
POSSIBLE_PASSWD=$(grep -hIE '^[a-zA-Z0-9]+:.:[0-9]+:[0-9]+([^:]*:){3}[^:]*$' "${LINE}" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null || true)
|
||||
|
||||
local POSSIBLE_SHADOWS
|
||||
# POSSIBLE_SHADOWS=$(grep -hIE '^([^:]*:){8}[^:]*$' "$LINE" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null)
|
||||
POSSIBLE_SHADOWS=$(grep -hIE '^[a-zA-Z0-9]+:\$[0-9a-z]\$.*:[0-9]+:[0-9]+:[0-9]+([^:]*:){4}[^:]*' "$LINE" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null || true)
|
||||
# POSSIBLE_SHADOWS=$(grep -hIE '^([^:]*:){8}[^:]*$' "${LINE}" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null)
|
||||
POSSIBLE_SHADOWS=$(grep -hIE '^[a-zA-Z0-9]+:\$[0-9a-z]\$.*:[0-9]+:[0-9]+:[0-9]+([^:]*:){4}[^:]*' "${LINE}" | grep -v ":x:" | grep -v ":\*:" | grep -v ":!:" 2> /dev/null || true)
|
||||
|
||||
local ROOT_ACCOUNTS
|
||||
# This test is based on the source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
ROOT_ACCOUNTS=$(grep -v -E "^#" "$LINE" 2>/dev/null| awk -F: '$3 == 0 { print $1}' 2> /dev/null || true)
|
||||
ROOT_ACCOUNTS=$(grep -v -E "^#" "${LINE}" 2>/dev/null| awk -F: '$3 == 0 { print $1}' 2> /dev/null || true)
|
||||
|
||||
local L_BREAK=0
|
||||
if [[ "$(echo "$ROOT_ACCOUNTS" | wc -w)" -gt 0 ]] ; then
|
||||
if [[ "$(echo "${ROOT_ACCOUNTS}" | wc -w)" -gt 0 ]] ; then
|
||||
print_output "$(indent "$(green "Identified the following root accounts:")")"
|
||||
print_output "$(indent "$(indent "$(orange "$ROOT_ACCOUNTS")")")"
|
||||
print_output "$(indent "$(indent "$(orange "${ROOT_ACCOUNTS}")")")"
|
||||
L_BREAK=1
|
||||
fi
|
||||
|
||||
if [[ "$(echo "$POSSIBLE_SHADOWS" | wc -w)" -gt 0 ]] || [[ "$(echo "$POSSIBLE_PASSWD" | wc -w)" -gt 0 ]] ; then
|
||||
if [[ "$(echo "${POSSIBLE_SHADOWS}" | wc -w)" -gt 0 ]] || [[ "$(echo "${POSSIBLE_PASSWD}" | wc -w)" -gt 0 ]] ; then
|
||||
print_output "$(indent "$(green "Found passwords or weak configuration:")")"
|
||||
PASS_FILES_FOUND=1
|
||||
export PASS_FILES_FOUND
|
||||
if [[ "$(echo "$POSSIBLE_SHADOWS" | wc -w)" -gt 0 ]] ; then
|
||||
print_output "$(indent "$(indent "$(orange "$POSSIBLE_SHADOWS")")")"
|
||||
if [[ "$(echo "${POSSIBLE_SHADOWS}" | wc -w)" -gt 0 ]] ; then
|
||||
print_output "$(indent "$(indent "$(orange "${POSSIBLE_SHADOWS}")")")"
|
||||
fi
|
||||
if [[ "$(echo "$POSSIBLE_PASSWD" | wc -w)" -gt 0 ]] ; then
|
||||
print_output "$(indent "$(indent "$(orange "$POSSIBLE_PASSWD")")")"
|
||||
if [[ "$(echo "${POSSIBLE_PASSWD}" | wc -w)" -gt 0 ]] ; then
|
||||
print_output "$(indent "$(indent "$(orange "${POSSIBLE_PASSWD}")")")"
|
||||
fi
|
||||
L_BREAK=1
|
||||
fi
|
||||
if ! [[ $L_BREAK -eq 0 ]] ; then
|
||||
if ! [[ ${L_BREAK} -eq 0 ]] ; then
|
||||
print_ln
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ -n "$SUDOERS" ]] ; then
|
||||
if [[ -n "${SUDOERS}" ]] ; then
|
||||
print_output "[+] Sudoers configuration:"
|
||||
print_output "$(indent "$(orange "$SUDOERS")")"
|
||||
print_output "$(indent "$(orange "${SUDOERS}")")"
|
||||
fi
|
||||
if [[ -n "$WHO_HAS_BEEN_SUDO" ]] ; then
|
||||
if [[ -n "${WHO_HAS_BEEN_SUDO}" ]] ; then
|
||||
print_output "[+] Accounts that have recently used sudo:"
|
||||
print_output "$(indent "$(orange "$WHO_HAS_BEEN_SUDO")")"
|
||||
print_output "$(indent "$(orange "${WHO_HAS_BEEN_SUDO}")")"
|
||||
fi
|
||||
fi
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$PASS_FILES_FOUND"
|
||||
write_log "[*] Statistics:${PASS_FILES_FOUND}"
|
||||
else
|
||||
print_output "[-] No password files found"
|
||||
fi
|
||||
|
||||
+148
-148
@@ -26,7 +26,7 @@ S50_authentication_check() {
|
||||
local AUTH_ISSUES=0
|
||||
|
||||
# disabled internal module threading as the output is not readable anymore
|
||||
if [[ "$THREADED" -eq 9 ]]; then
|
||||
if [[ "${THREADED}" -eq 9 ]]; then
|
||||
user_zero &
|
||||
WAIT_PIDS_S50+=( "$!" )
|
||||
search_shadow &
|
||||
@@ -69,14 +69,14 @@ S50_authentication_check() {
|
||||
search_pam_files
|
||||
fi
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S50[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S50[@]}"
|
||||
|
||||
if [[ -f "$TMP_DIR"/S50_AUTH_ISSUES.tmp ]]; then
|
||||
AUTH_ISSUES=$(awk '{sum += $1 } END { print sum }' "$TMP_DIR"/S50_AUTH_ISSUES.tmp)
|
||||
if [[ -f "${TMP_DIR}"/S50_AUTH_ISSUES.tmp ]]; then
|
||||
AUTH_ISSUES=$(awk '{sum += $1 } END { print sum }' "${TMP_DIR}"/S50_AUTH_ISSUES.tmp)
|
||||
fi
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$AUTH_ISSUES"
|
||||
module_end_log "${FUNCNAME[0]}" "$AUTH_ISSUES"
|
||||
write_log "[*] Statistics:${AUTH_ISSUES}"
|
||||
module_end_log "${FUNCNAME[0]}" "${AUTH_ISSUES}"
|
||||
}
|
||||
|
||||
search_shadow() {
|
||||
@@ -90,38 +90,38 @@ search_shadow() {
|
||||
local HASH=""
|
||||
local CHECK=0
|
||||
|
||||
mapfile -t SHADOW_FILE_PATHS < <(find "$LOG_DIR"/firmware -xdev -name "*shadow*" -exec file {} \; | grep "ASCII text" | cut -d: -f1 || true)
|
||||
mapfile -t SHADOW_FILE_PATHS < <(find "${LOG_DIR}"/firmware -xdev -name "*shadow*" -exec file {} \; | grep "ASCII text" | cut -d: -f1 || true)
|
||||
for SHADOW_FILE in "${SHADOW_FILE_PATHS[@]}"; do
|
||||
if [[ -f "$SHADOW_FILE" ]] ; then
|
||||
mapfile -t HASHES < <(grep -E '\$[1-6][ay]?\$' "$SHADOW_FILE" || true)
|
||||
if [[ -f "${SHADOW_FILE}" ]] ; then
|
||||
mapfile -t HASHES < <(grep -E '\$[1-6][ay]?\$' "${SHADOW_FILE}" || true)
|
||||
for HASH in "${HASHES[@]}"; do
|
||||
local HTYPE="unknown"
|
||||
if [[ "$HASH" =~ .*\$1\$.* ]]; then
|
||||
if [[ "${HASH}" =~ .*\$1\$.* ]]; then
|
||||
HTYPE="MD5"
|
||||
elif [[ "$HASH" =~ .*\$2a\$.* ]]; then
|
||||
elif [[ "${HASH}" =~ .*\$2a\$.* ]]; then
|
||||
HTYPE="Blowfish"
|
||||
elif [[ "$HASH" =~ .*\$2y\$.* ]]; then
|
||||
elif [[ "${HASH}" =~ .*\$2y\$.* ]]; then
|
||||
HTYPE="Eksblowfish"
|
||||
elif [[ "$HASH" =~ .*\$5\$.* ]]; then
|
||||
elif [[ "${HASH}" =~ .*\$5\$.* ]]; then
|
||||
HTYPE="SHA-256"
|
||||
elif [[ "$HASH" =~ .*\$6\$.* ]]; then
|
||||
elif [[ "${HASH}" =~ .*\$6\$.* ]]; then
|
||||
HTYPE="SHA-512"
|
||||
fi
|
||||
if [[ "$HTYPE" == "unknown" ]]; then
|
||||
print_output "[+] Found shadow file ""$ORANGE$(print_path "$SHADOW_FILE")$GREEN with possible hash $ORANGE$HASH$NC"
|
||||
if [[ "${HTYPE}" == "unknown" ]]; then
|
||||
print_output "[+] Found shadow file ""${ORANGE}$(print_path "${SHADOW_FILE}")${GREEN} with possible hash ${ORANGE}${HASH}${NC}"
|
||||
((AUTH_ISSUES+=1))
|
||||
continue
|
||||
fi
|
||||
print_output "[+] Found shadow file ""$ORANGE$(print_path "$SHADOW_FILE")$GREEN with possible hash $ORANGE$HASH$GREEN of hashtype: $ORANGE$HTYPE$NC"
|
||||
print_output "[+] Found shadow file ""${ORANGE}$(print_path "${SHADOW_FILE}")${GREEN} with possible hash ${ORANGE}${HASH}${GREEN} of hashtype: ${ORANGE}${HTYPE}${NC}"
|
||||
((AUTH_ISSUES+=1))
|
||||
done
|
||||
CHECK=1
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] shadow file not available"
|
||||
fi
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
user_zero() {
|
||||
@@ -134,21 +134,21 @@ user_zero() {
|
||||
mapfile -t PASSWD_FILE_PATHS < <(mod_path "/ETC_PATHS/passwd")
|
||||
|
||||
for PASSWD_FILE in "${PASSWD_FILE_PATHS[@]}"; do
|
||||
if [[ -f "$PASSWD_FILE" ]] ; then
|
||||
if [[ -f "${PASSWD_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
local FIND=""
|
||||
FIND=$(grep ':0:' "$PASSWD_FILE" | grep -v '^#|^root:|^(\+:\*)?:0:0:::' | cut -d ":" -f1,3 | grep ':0' || true)
|
||||
if [[ -n "$FIND" ]] ; then
|
||||
print_output "[+] Found administrator account/s with UID 0 in ""$(print_path "$PASSWD_FILE")"
|
||||
print_output "$(indent "$(orange "Administrator account: $FIND")")"
|
||||
FIND=$(grep ':0:' "${PASSWD_FILE}" | grep -v '^#|^root:|^(\+:\*)?:0:0:::' | cut -d ":" -f1,3 | grep ':0' || true)
|
||||
if [[ -n "${FIND}" ]] ; then
|
||||
print_output "[+] Found administrator account/s with UID 0 in ""$(print_path "${PASSWD_FILE}")"
|
||||
print_output "$(indent "$(orange "Administrator account: ${FIND}")")"
|
||||
((AUTH_ISSUES+=1))
|
||||
else
|
||||
print_output "[-] Found no administrator account (root) with UID 0"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/passwd not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/passwd not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
non_unique_acc() {
|
||||
@@ -163,21 +163,21 @@ non_unique_acc() {
|
||||
mapfile -t PASSWD_FILE_PATHS < <(mod_path "/ETC_PATHS/passwd")
|
||||
|
||||
for PASSWD_FILE in "${PASSWD_FILE_PATHS[@]}"; do
|
||||
if [[ -f "$PASSWD_FILE" ]] ; then
|
||||
if [[ -f "${PASSWD_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
local FIND=""
|
||||
FIND=$(grep -v '^#' "$PASSWD_FILE" | cut -d ':' -f3 | sort | uniq -d || true)
|
||||
if [[ "$FIND" = "" ]] ; then
|
||||
print_output "[-] All accounts found in ""$(print_path "$PASSWD_FILE")"" are unique"
|
||||
FIND=$(grep -v '^#' "${PASSWD_FILE}" | cut -d ':' -f3 | sort | uniq -d || true)
|
||||
if [[ "${FIND}" = "" ]] ; then
|
||||
print_output "[-] All accounts found in ""$(print_path "${PASSWD_FILE}")"" are unique"
|
||||
else
|
||||
print_output "[+] Non-unique accounts found in ""$(print_path "$PASSWD_FILE")"
|
||||
print_output "$(indent "$(orange "$FIND")")"
|
||||
print_output "[+] Non-unique accounts found in ""$(print_path "${PASSWD_FILE}")"
|
||||
print_output "$(indent "$(orange "${FIND}")")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/passwd not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/passwd not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
non_unique_group_id() {
|
||||
@@ -192,21 +192,21 @@ non_unique_group_id() {
|
||||
mapfile -t GROUP_PATHS < <(mod_path "/ETC_PATHS/group")
|
||||
|
||||
for GROUP_PATH in "${GROUP_PATHS[@]}"; do
|
||||
if [[ -f "$GROUP_PATH" ]] ; then
|
||||
if [[ -f "${GROUP_PATH}" ]] ; then
|
||||
CHECK=1
|
||||
local FIND=""
|
||||
FIND=$(grep -v '^#' "$GROUP_PATH" | grep -v '^$' | awk -F: '{ print $3 }' | sort | uniq -d || true)
|
||||
if [[ "$FIND" = "" ]] ; then
|
||||
print_output "[-] All group ID's found in ""$(print_path "$GROUP_PATH")"" are unique"
|
||||
FIND=$(grep -v '^#' "${GROUP_PATH}" | grep -v '^$' | awk -F: '{ print $3 }' | sort | uniq -d || true)
|
||||
if [[ "${FIND}" = "" ]] ; then
|
||||
print_output "[-] All group ID's found in ""$(print_path "${GROUP_PATH}")"" are unique"
|
||||
else
|
||||
print_output "[+] Found the same group ID multiple times"
|
||||
print_output "$(indent "$(orange "Non-unique group id: ""$FIND")")"
|
||||
print_output "$(indent "$(orange "Non-unique group id: ""${FIND}")")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/group not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/group not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
non_unique_group_name() {
|
||||
@@ -220,21 +220,21 @@ non_unique_group_name() {
|
||||
mapfile -t GROUP_PATHS < <(mod_path "/ETC_PATHS/group")
|
||||
|
||||
for GROUP_PATH in "${GROUP_PATHS[@]}"; do
|
||||
if [[ -f "$GROUP_PATH" ]] ; then
|
||||
if [[ -f "${GROUP_PATH}" ]] ; then
|
||||
CHECK=1
|
||||
local FIND
|
||||
FIND=$(grep -v '^#' "$GROUP_PATH" | grep -v '^$' | awk -F: '{ print $1 }' | sort | uniq -d || true)
|
||||
if [[ "$FIND" = "" ]] ; then
|
||||
print_output "[-] All group names found in ""$(print_path "$GROUP_PATH")"" are unique"
|
||||
FIND=$(grep -v '^#' "${GROUP_PATH}" | grep -v '^$' | awk -F: '{ print $1 }' | sort | uniq -d || true)
|
||||
if [[ "${FIND}" = "" ]] ; then
|
||||
print_output "[-] All group names found in ""$(print_path "${GROUP_PATH}")"" are unique"
|
||||
else
|
||||
print_output "[+] Found the same group name multiple times"
|
||||
print_output "$(indent "$(orange "Non-unique group name: ""$FIND")")"
|
||||
print_output "$(indent "$(orange "Non-unique group name: ""${FIND}")")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/group not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/group not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
query_user_acc() {
|
||||
@@ -248,31 +248,31 @@ query_user_acc() {
|
||||
mapfile -t PASSWD_FILE_PATHS < <(mod_path "/ETC_PATHS/passwd")
|
||||
|
||||
for PASSWD_FILE in "${PASSWD_FILE_PATHS[@]}"; do
|
||||
if [[ -f "$PASSWD_FILE" ]] ; then
|
||||
if [[ -f "${PASSWD_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
local UID_MIN LOGIN_DEFS_PATH
|
||||
UID_MIN=""
|
||||
mapfile -t LOGIN_DEFS_PATH < <(mod_path "/ETC_PATHS/login.defs")
|
||||
for LOGIN_DEF in "${LOGIN_DEFS_PATH[@]}"; do
|
||||
if [[ -f "$LOGIN_DEF" ]] ; then
|
||||
UID_MIN=$(grep "^UID_MIN" "$LOGIN_DEF" | awk '{print $2}')
|
||||
print_output "[*] Found minimal user id specified: ""$UID_MIN"
|
||||
if [[ -f "${LOGIN_DEF}" ]] ; then
|
||||
UID_MIN=$(grep "^UID_MIN" "${LOGIN_DEF}" | awk '{print $2}')
|
||||
print_output "[*] Found minimal user id specified: ""${UID_MIN}"
|
||||
fi
|
||||
done
|
||||
[[ "$UID_MIN" = "" ]] && UID_MIN="1000"
|
||||
print_output "[*] Linux real users output (ID = 0, or ""$UID_MIN""+, but not 65534):"
|
||||
FIND=$(awk -v UID_MIN="$UID_MIN" -F: '($3 >= UID_MIN && $3 != 65534) || ($3 == 0) { print $1","$3 }' "$PASSWD_FILE")
|
||||
[[ "${UID_MIN}" = "" ]] && UID_MIN="1000"
|
||||
print_output "[*] Linux real users output (ID = 0, or ""${UID_MIN}""+, but not 65534):"
|
||||
FIND=$(awk -v UID_MIN="${UID_MIN}" -F: '($3 >= UID_MIN && $3 != 65534) || ($3 == 0) { print $1","$3 }' "${PASSWD_FILE}")
|
||||
|
||||
if [[ "$FIND" = "" ]] ; then
|
||||
if [[ "${FIND}" = "" ]] ; then
|
||||
print_output "[-] No users found/unknown result"
|
||||
else
|
||||
print_output "[+] Query system user"
|
||||
print_output "$(indent "$(orange "$FIND")")"
|
||||
print_output "$(indent "$(orange "${FIND}")")"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/passwd not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/passwd not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
query_nis_plus_auth_supp() {
|
||||
@@ -286,25 +286,25 @@ query_nis_plus_auth_supp() {
|
||||
mapfile -t NSS_PATH_L < <(mod_path "/ETC_PATHS/nsswitch.conf")
|
||||
|
||||
for NSS_PATH in "${NSS_PATH_L[@]}"; do
|
||||
if [[ -f "$NSS_PATH" ]] ; then
|
||||
if [[ -f "${NSS_PATH}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] ""$(print_path "$NSS_PATH")"" exist"
|
||||
print_output "[+] ""$(print_path "${NSS_PATH}")"" exist"
|
||||
local FIND
|
||||
FIND="$(grep "^passwd" "$NSS_PATH" | grep "compat|nis" | grep -v "nisplus" || true)"
|
||||
if [[ -z "$FIND" ]] ; then
|
||||
FIND="$(grep "^passwd" "${NSS_PATH}" | grep "compat|nis" | grep -v "nisplus" || true)"
|
||||
if [[ -z "${FIND}" ]] ; then
|
||||
print_output "[-] NIS/NIS+ authentication not enabled"
|
||||
else
|
||||
local FIND2, FIND3, FIND4, FIND5
|
||||
FIND2=$(grep "^passwd_compat" "$NSS_PATH" | grep "nis" | grep -v "nisplus" || true)
|
||||
FIND3=$(grep "^passwd" "$NSS_PATH" | grep "nis" | grep -v "nisplus" || true)
|
||||
if [[ -n "$FIND2" ]] || [[ -n "$FIND3" ]] ; then
|
||||
FIND2=$(grep "^passwd_compat" "${NSS_PATH}" | grep "nis" | grep -v "nisplus" || true)
|
||||
FIND3=$(grep "^passwd" "${NSS_PATH}" | grep "nis" | grep -v "nisplus" || true)
|
||||
if [[ -n "${FIND2}" ]] || [[ -n "${FIND3}" ]] ; then
|
||||
print_output "[+] Result: NIS authentication enabled"
|
||||
else
|
||||
print_output "[+] Result: NIS authentication not enabled"
|
||||
fi
|
||||
FIND4=$(grep "^passwd_compat" "$NSS_PATH" | grep "nisplus" || true)
|
||||
FIND5=$(grep "^passwd" "$NSS_PATH" | grep "nisplus" || true)
|
||||
if [[ -n "$FIND4" ]] || [[ -n "$FIND5" ]] ; then
|
||||
FIND4=$(grep "^passwd_compat" "${NSS_PATH}" | grep "nisplus" || true)
|
||||
FIND5=$(grep "^passwd" "${NSS_PATH}" | grep "nisplus" || true)
|
||||
if [[ -n "${FIND4}" ]] || [[ -n "${FIND5}" ]] ; then
|
||||
print_output "[+] Result: NIS+ authentication enabled"
|
||||
else
|
||||
print_output "[+] Result: NIS+ authentication not enabled"
|
||||
@@ -312,8 +312,8 @@ query_nis_plus_auth_supp() {
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/nsswitch.conf not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/nsswitch.conf not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
check_sudoers() {
|
||||
@@ -327,24 +327,24 @@ check_sudoers() {
|
||||
|
||||
for R_PATH in "${ROOT_PATH[@]}"; do
|
||||
# as we only have one search term we can handle it like this:
|
||||
readarray -t SUDOERS_FILES_ARR < <(find "$R_PATH" -xdev -type f -name sudoers 2>/dev/null)
|
||||
readarray -t SUDOERS_FILES_ARR < <(find "${R_PATH}" -xdev -type f -name sudoers 2>/dev/null)
|
||||
if [[ "${#SUDOERS_FILES_ARR[@]}" -gt 0 ]]; then
|
||||
for SUDOERS_FILE in "${SUDOERS_FILES_ARR[@]}"; do
|
||||
print_output "$(indent "$(orange "$(print_path "$SUDOERS_FILE")")")"
|
||||
if [[ -f "$EXT_DIR"/sudo-parser.pl ]]; then
|
||||
print_output "$(indent "$(orange "$(print_path "${SUDOERS_FILE}")")")"
|
||||
if [[ -f "${EXT_DIR}"/sudo-parser.pl ]]; then
|
||||
print_output "[*] Testing sudoers file with sudo-parse.pl:"
|
||||
readarray SUDOERS_ISSUES < <("$EXT_DIR"/sudo-parser.pl -f "$SUDOERS_FILE" -r "$R_PATH" | grep -E "^E:\ " || true)
|
||||
readarray SUDOERS_ISSUES < <("${EXT_DIR}"/sudo-parser.pl -f "${SUDOERS_FILE}" -r "${R_PATH}" | grep -E "^E:\ " || true)
|
||||
for S_ISSUE in "${SUDOERS_ISSUES[@]}"; do
|
||||
print_output "[+] $S_ISSUE"
|
||||
print_output "[+] ${S_ISSUE}"
|
||||
((AUTH_ISSUES+=1))
|
||||
done
|
||||
fi
|
||||
done
|
||||
else
|
||||
print_output "[-] No sudoers files found in $R_PATH"
|
||||
print_output "[-] No sudoers files found in ${R_PATH}"
|
||||
fi
|
||||
done
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
check_owner_perm_sudo_config() {
|
||||
@@ -356,59 +356,59 @@ check_owner_perm_sudo_config() {
|
||||
if [[ "${#SUDOERS_FILES_ARR[@]}" -gt 0 ]]; then
|
||||
for FILE in "${SUDOERS_FILES_ARR[@]}"; do
|
||||
local SUDOERS_D
|
||||
SUDOERS_D="$FILE"".d"
|
||||
if [[ -d "$SUDOERS_D" ]] ; then
|
||||
print_output "[*] Checking drop-in directory (""$(print_path "$SUDOERS_D")"")"
|
||||
SUDOERS_D="${FILE}"".d"
|
||||
if [[ -d "${SUDOERS_D}" ]] ; then
|
||||
print_output "[*] Checking drop-in directory (""$(print_path "${SUDOERS_D}")"")"
|
||||
local FIND FIND2 FIND3 FIND4
|
||||
|
||||
FIND="$(permission_clean "$SUDOERS_D")"
|
||||
FIND2="$(owner_clean "$SUDOERS_D")"":""$(group_clean "$SUDOERS_D")"
|
||||
FIND="$(permission_clean "${SUDOERS_D}")"
|
||||
FIND2="$(owner_clean "${SUDOERS_D}")"":""$(group_clean "${SUDOERS_D}")"
|
||||
|
||||
print_output "[*] ""$(print_path "$SUDOERS_D")"": Found permissions: $FIND and owner UID GID: $FIND2"
|
||||
print_output "[*] ""$(print_path "${SUDOERS_D}")"": Found permissions: ${FIND} and owner UID GID: ${FIND2}"
|
||||
|
||||
case "$FIND" in
|
||||
case "${FIND}" in
|
||||
drwx[r-][w-][x-]---)
|
||||
print_output "[-] ""$(print_path "$SUDOERS_D")"" permissions OK"
|
||||
if [[ "$FIND2" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "$SUDOERS_D")"" ownership OK"
|
||||
print_output "[-] ""$(print_path "${SUDOERS_D}")"" permissions OK"
|
||||
if [[ "${FIND2}" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "${SUDOERS_D}")"" ownership OK"
|
||||
else
|
||||
print_output "[+] ""$(print_path "$SUDOERS_D")"" ownership unsafe"
|
||||
print_output "[+] ""$(print_path "${SUDOERS_D}")"" ownership unsafe"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
print_output "[+] ""$(print_path "$SUDOERS_D")"" permissions possibly unsafe"
|
||||
if [[ "$FIND2" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "$SUDOERS_D")"" ownership OK"
|
||||
print_output "[+] ""$(print_path "${SUDOERS_D}")"" permissions possibly unsafe"
|
||||
if [[ "${FIND2}" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "${SUDOERS_D}")"" ownership OK"
|
||||
else
|
||||
print_output "[+] ""$(print_path "$SUDOERS_D")"" ownership unsafe"
|
||||
print_output "[+] ""$(print_path "${SUDOERS_D}")"" ownership unsafe"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
FIND3="$(permission_clean "$FILE")"
|
||||
FIND4="$(owner_clean "$FILE")"":""$(group_clean "$FILE")"
|
||||
FIND3="$(permission_clean "${FILE}")"
|
||||
FIND4="$(owner_clean "${FILE}")"":""$(group_clean "${FILE}")"
|
||||
|
||||
print_output "[*] ""$(print_path "$FILE")"": Found permissions: ""$FIND3"" and owner UID GID: ""$FIND4"
|
||||
print_output "[*] ""$(print_path "${FILE}")"": Found permissions: ""${FIND3}"" and owner UID GID: ""${FIND4}"
|
||||
|
||||
case "$FIND3" in
|
||||
case "${FIND3}" in
|
||||
rwx[r-][w-][x-]---)
|
||||
print_output "[-] ""$(print_path "$FILE")"" permissions OK"
|
||||
if [[ "$FIND4" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "$FILE")"" ownership OK"
|
||||
print_output "[-] ""$(print_path "${FILE}")"" permissions OK"
|
||||
if [[ "${FIND4}" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "${FILE}")"" ownership OK"
|
||||
else
|
||||
print_output "[+] ""$(print_path "$FILE")"" ownership unsafe"
|
||||
print_output "[+] ""$(print_path "${FILE}")"" ownership unsafe"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
print_output "[+] ""$(print_path "$FILE")"" permissions possibly unsafe"
|
||||
if [[ "$FIND4" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "$FILE")"" ownership OK"
|
||||
print_output "[+] ""$(print_path "${FILE}")"" permissions possibly unsafe"
|
||||
if [[ "${FIND4}" = "0:0" ]] ; then
|
||||
print_output "[-] ""$(print_path "${FILE}")"" ownership OK"
|
||||
else
|
||||
print_output "[+] ""$(print_path "$FILE")"" ownership unsafe"
|
||||
print_output "[+] ""$(print_path "${FILE}")"" ownership unsafe"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
;;
|
||||
@@ -417,7 +417,7 @@ check_owner_perm_sudo_config() {
|
||||
else
|
||||
print_output "[-] No sudoers files found - no check possible"
|
||||
fi
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
search_pam_testing_libs() {
|
||||
@@ -427,7 +427,7 @@ search_pam_testing_libs() {
|
||||
|
||||
local FILE_PATH FOUND FOUND_CRACKLIB FOUND_PASSWDQC FOUND_PWQUALITY
|
||||
local AUTH_ISSUES=0
|
||||
mapfile -t FILE_PATH < <(mod_path_array "$(config_list "$CONFIG_DIR""/pam_files.cfg" "")")
|
||||
mapfile -t FILE_PATH < <(mod_path_array "$(config_list "${CONFIG_DIR}""/pam_files.cfg" "")")
|
||||
|
||||
if [[ "${FILE_PATH[0]-}" == "C_N_F" ]] ; then
|
||||
print_output "[!] Config not found"
|
||||
@@ -439,32 +439,32 @@ search_pam_testing_libs() {
|
||||
|
||||
for PATH_F in "${FILE_PATH[@]}"; do
|
||||
local FULL_PATH
|
||||
FULL_PATH="$FIRMWARE_PATH""/""$PATH_F"
|
||||
FULL_PATH="${FIRMWARE_PATH}""/""${PATH_F}"
|
||||
|
||||
if [[ -f "$FULL_PATH""/pam_cracklib.so" ]] ; then
|
||||
if [[ -f "${FULL_PATH}""/pam_cracklib.so" ]] ; then
|
||||
FOUND_CRACKLIB=1
|
||||
FOUND=1
|
||||
print_output "[+] Found pam_cracklib.so (crack library PAM) in ""$(print_path "$FULL_PATH")"
|
||||
print_output "[+] Found pam_cracklib.so (crack library PAM) in ""$(print_path "${FULL_PATH}")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
|
||||
if [[ -f "$FULL_PATH""/pam_passwdqc.so" ]] ; then
|
||||
if [[ -f "${FULL_PATH}""/pam_passwdqc.so" ]] ; then
|
||||
FOUND_PASSWDQC=1
|
||||
FOUND=1
|
||||
print_output "[+] Found pam_passwdqc.so (passwd quality control PAM) in ""$(print_path "$FULL_PATH")"
|
||||
print_output "[+] Found pam_passwdqc.so (passwd quality control PAM) in ""$(print_path "${FULL_PATH}")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
|
||||
if [[ -f "$FULL_PATH""/pam_pwquality.so" ]] ; then
|
||||
if [[ -f "${FULL_PATH}""/pam_pwquality.so" ]] ; then
|
||||
FOUND_PWQUALITY=1
|
||||
FOUND=1
|
||||
print_output "[+] Found pam_pwquality.so (password quality control PAM) in ""$(print_path "$FULL_PATH")"
|
||||
print_output "[+] Found pam_pwquality.so (password quality control PAM) in ""$(print_path "${FULL_PATH}")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
done
|
||||
|
||||
# Cracklib
|
||||
if [[ $FOUND_CRACKLIB -eq 1 ]] ; then
|
||||
if [[ ${FOUND_CRACKLIB} -eq 1 ]] ; then
|
||||
print_output "[+] pam_cracklib.so found"
|
||||
((AUTH_ISSUES+=1))
|
||||
else
|
||||
@@ -472,7 +472,7 @@ search_pam_testing_libs() {
|
||||
fi
|
||||
|
||||
# Password quality control
|
||||
if [[ $FOUND_PASSWDQC -eq 1 ]] ; then
|
||||
if [[ ${FOUND_PASSWDQC} -eq 1 ]] ; then
|
||||
print_output "[+] pam_passwdqc.so found"
|
||||
((AUTH_ISSUES+=1))
|
||||
else
|
||||
@@ -480,14 +480,14 @@ search_pam_testing_libs() {
|
||||
fi
|
||||
|
||||
# pwquality module
|
||||
if [[ $FOUND_PWQUALITY -eq 1 ]] ; then
|
||||
if [[ ${FOUND_PWQUALITY} -eq 1 ]] ; then
|
||||
print_output "[+] pam_pwquality.so found"
|
||||
((AUTH_ISSUES+=1))
|
||||
else
|
||||
print_output "[-] pam_pwquality.so not found"
|
||||
fi
|
||||
|
||||
if [[ $FOUND -eq 0 ]] ; then
|
||||
if [[ ${FOUND} -eq 0 ]] ; then
|
||||
print_output "[-] No PAM modules for password strength testing found"
|
||||
else
|
||||
print_output "[-] Found at least one PAM module for password strength testing"
|
||||
@@ -497,7 +497,7 @@ search_pam_testing_libs() {
|
||||
else
|
||||
print_output "[-] No pam files found"
|
||||
fi
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
scan_pam_conf() {
|
||||
@@ -508,24 +508,24 @@ scan_pam_conf() {
|
||||
local PAM_PATH_L
|
||||
mapfile -t PAM_PATH_L < <(mod_path "/ETC_PATHS/pam.conf")
|
||||
for PAM_PATH in "${PAM_PATH_L[@]}"; do
|
||||
if [[ -f "$PAM_PATH" ]] ; then
|
||||
if [[ -f "${PAM_PATH}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] ""$(print_path "$PAM_PATH")"" exist"
|
||||
print_output "[+] ""$(print_path "${PAM_PATH}")"" exist"
|
||||
local FIND
|
||||
FIND=$(grep -v "^#" "$PAM_PATH" | grep -v "^$" | sed 's/[[:space:]]/ /g' | sed 's/ / /g' | sed 's/ /:space:/g' || true)
|
||||
if [[ -z "$FIND" ]] ; then
|
||||
FIND=$(grep -v "^#" "${PAM_PATH}" | grep -v "^$" | sed 's/[[:space:]]/ /g' | sed 's/ / /g' | sed 's/ /:space:/g' || true)
|
||||
if [[ -z "${FIND}" ]] ; then
|
||||
print_output "[-] File has no configuration options defined (empty, or only filled with comments and empty lines)"
|
||||
else
|
||||
print_output "[+] Found one or more configuration lines"
|
||||
local LINE
|
||||
LINE=${FIND//[[:space:]]/}
|
||||
print_output "$(indent "$(orange "$LINE")")"
|
||||
print_output "$(indent "$(orange "${LINE}")")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/pam.conf not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/pam.conf not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
search_pam_configs() {
|
||||
@@ -537,38 +537,38 @@ search_pam_configs() {
|
||||
local PAM_PATH_L
|
||||
mapfile -t PAM_PATH_L < <(mod_path "/ETC_PATHS/pam.d")
|
||||
for PAM_PATH in "${PAM_PATH_L[@]}"; do
|
||||
if [[ -d "$PAM_PATH" ]] ; then
|
||||
if [[ -d "${PAM_PATH}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] ""$(print_path "${PAM_PATH}")"" exist"
|
||||
local FIND
|
||||
FIND=$(find "${PAM_PATH}" -xdev -not -name "*.pam-old" -type f -print | sort)
|
||||
readarray -t FILES_ARR < <(printf '%s' "$FIND")
|
||||
readarray -t FILES_ARR < <(printf '%s' "${FIND}")
|
||||
for FILE in "${FILES_ARR[@]}"; do
|
||||
print_output "$(indent "$(orange "$(print_path "$FILE")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${FILE}")")")"
|
||||
done
|
||||
local AUTH_FILES
|
||||
AUTH_FILES=("$PAM_PATH""/common-auth" "$PAM_PATH""/system-auth")
|
||||
AUTH_FILES=("${PAM_PATH}""/common-auth" "${PAM_PATH}""/system-auth")
|
||||
for FILE in "${AUTH_FILES[@]}"; do
|
||||
print_output "[*] Check if LDAP support in PAM files"
|
||||
if [[ -f "$FILE" ]] ; then
|
||||
if [[ -f "${FILE}" ]] ; then
|
||||
((AUTH_ISSUES+=1))
|
||||
print_output "[+] ""$(print_path "$FILE")"" exist"
|
||||
print_output "[+] ""$(print_path "${FILE}")"" exist"
|
||||
local FIND2
|
||||
FIND2=$(grep "^auth.*ldap" "$FILE" || true)
|
||||
if [[ -n "$FIND2" ]] ; then
|
||||
FIND2=$(grep "^auth.*ldap" "${FILE}" || true)
|
||||
if [[ -n "${FIND2}" ]] ; then
|
||||
print_output "[+] LDAP module present"
|
||||
print_output "$(indent "$(orange "$FIND2")")"
|
||||
print_output "$(indent "$(orange "${FIND2}")")"
|
||||
else
|
||||
print_output "[-] LDAP module not found"
|
||||
fi
|
||||
else
|
||||
print_output "[-] ""$(print_path "$FILE")"" not found"
|
||||
print_output "[-] ""$(print_path "${FILE}")"" not found"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] /etc/pam.d not available"
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] /etc/pam.d not available"
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
search_pam_files() {
|
||||
@@ -578,31 +578,31 @@ search_pam_files() {
|
||||
local AUTH_ISSUES=0
|
||||
local PAM_FILES=()
|
||||
local PAM_FILE=""
|
||||
readarray -t PAM_FILES < <(config_find "$CONFIG_DIR""/pam_files.cfg")
|
||||
readarray -t PAM_FILES < <(config_find "${CONFIG_DIR}""/pam_files.cfg")
|
||||
|
||||
if [[ "${PAM_FILES[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ ${#PAM_FILES[@]} -ne 0 ]] ; then
|
||||
print_output "[*] Found ""$ORANGE${#PAM_FILES[@]}$NC"" possible interesting areas for PAM:"
|
||||
print_output "[*] Found ""${ORANGE}${#PAM_FILES[@]}${NC}"" possible interesting areas for PAM:"
|
||||
for PAM_FILE in "${PAM_FILES[@]}" ; do
|
||||
if [[ -f "$PAM_FILE" ]] ; then
|
||||
if [[ -f "${PAM_FILE}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "$(indent "$(orange "$(print_path "$PAM_FILE")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${PAM_FILE}")")")"
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
if [[ -d "$PAM_FILE" ]] && [[ ! -L "$PAM_FILE" ]] ; then
|
||||
print_output "$(indent "$(print_path "$PAM_FILE")")"
|
||||
if [[ -d "${PAM_FILE}" ]] && [[ ! -L "${PAM_FILE}" ]] ; then
|
||||
print_output "$(indent "$(print_path "${PAM_FILE}")")"
|
||||
local FIND
|
||||
mapfile -t FIND < <(find "$PAM_FILE" -xdev -maxdepth 1 -type f -name "pam_*.so" -print | sort)
|
||||
mapfile -t FIND < <(find "${PAM_FILE}" -xdev -maxdepth 1 -type f -name "pam_*.so" -print | sort)
|
||||
for FIND_FILE in "${FIND[@]}"; do
|
||||
CHECK=1
|
||||
print_output "$(indent "$(orange "$FIND_FILE")")"
|
||||
print_output "$(indent "$(orange "${FIND_FILE}")")"
|
||||
done
|
||||
((AUTH_ISSUES+=1))
|
||||
fi
|
||||
done
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] Nothing interesting found"
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] Nothing interesting found"
|
||||
else
|
||||
print_output "[-] Nothing found"
|
||||
fi
|
||||
echo "$AUTH_ISSUES" >> "$TMP_DIR"/S50_AUTH_ISSUES.tmp
|
||||
echo "${AUTH_ISSUES}" >> "${TMP_DIR}"/S50_AUTH_ISSUES.tmp
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ S55_history_file_check()
|
||||
local HIST_FILES=()
|
||||
local LINE=""
|
||||
|
||||
mapfile -t HIST_FILES < <(config_find "$CONFIG_DIR""/history_files.cfg")
|
||||
mapfile -t HIST_FILES < <(config_find "${CONFIG_DIR}""/history_files.cfg")
|
||||
|
||||
if [[ "${HIST_FILES[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#HIST_FILES[@]}" -ne 0 ]] ; then
|
||||
print_output "[+] Found history files:"
|
||||
for LINE in "${HIST_FILES[@]}" ; do
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")"
|
||||
done
|
||||
else
|
||||
print_output "[-] No history files found"
|
||||
|
||||
@@ -22,7 +22,7 @@ S60_cert_file_check()
|
||||
pre_module_reporter "${FUNCNAME[0]}"
|
||||
|
||||
local CERT_FILES_ARR=()
|
||||
readarray -t CERT_FILES_ARR < <(config_find "$CONFIG_DIR""/cert_files.cfg")
|
||||
readarray -t CERT_FILES_ARR < <(config_find "${CONFIG_DIR}""/cert_files.cfg")
|
||||
|
||||
local CERT_FILES_CNT=0
|
||||
local TOTAL_CERT_CNT=0
|
||||
@@ -42,26 +42,26 @@ S60_cert_file_check()
|
||||
if [[ "${CERT_FILES_ARR[0]-}" == "C_N_F" ]]; then print_output "[!] Config not found"
|
||||
elif [[ ${#CERT_FILES_ARR[@]} -ne 0 ]]; then
|
||||
write_csv_log "Certificate file" "Certificate expire on" "Certificate expired"
|
||||
print_output "[+] Found ""$ORANGE${#CERT_FILES_ARR[@]}$GREEN"" possible certification files:"
|
||||
print_output "[+] Found ""${ORANGE}${#CERT_FILES_ARR[@]}${GREEN}"" possible certification files:"
|
||||
print_ln
|
||||
CURRENT_DATE=$(date +%s)
|
||||
FUTURE_DATE=$(date --date="$EXPIRE_WATCH_DATE" +%s)
|
||||
FUTURE_DATE=$(date --date="${EXPIRE_WATCH_DATE}" +%s)
|
||||
for LINE in "${CERT_FILES_ARR[@]}" ; do
|
||||
if [[ -f "$LINE" && $(wc -l "$LINE" | awk '{print $1}'|| true) -gt 1 ]]; then
|
||||
if [[ -f "${LINE}" && $(wc -l "${LINE}" | awk '{print $1}'|| true) -gt 1 ]]; then
|
||||
((CERT_FILES_CNT+=1))
|
||||
if command -v openssl > /dev/null ; then
|
||||
CERT_NAME=$(basename "$LINE")
|
||||
CERT_LOG="$LOG_PATH_MODULE/cert_details_$CERT_NAME.txt"
|
||||
write_log "[*] Cert file: $LINE\n" "$CERT_LOG"
|
||||
timeout --preserve-status --signal SIGINT 10 openssl storeutl -noout -text -certs "$LINE" 2>/dev/null >> "$CERT_LOG" || true
|
||||
NESTED_CERT_CNT=$(tail -n 1 < "$CERT_LOG" | grep -o '[0-9]\+')
|
||||
CERT_NAME=$(basename "${LINE}")
|
||||
CERT_LOG="${LOG_PATH_MODULE}/cert_details_${CERT_NAME}.txt"
|
||||
write_log "[*] Cert file: ${LINE}\n" "${CERT_LOG}"
|
||||
timeout --preserve-status --signal SIGINT 10 openssl storeutl -noout -text -certs "${LINE}" 2>/dev/null >> "${CERT_LOG}" || true
|
||||
NESTED_CERT_CNT=$(tail -n 1 < "${CERT_LOG}" | grep -o '[0-9]\+')
|
||||
((TOTAL_CERT_CNT+=NESTED_CERT_CNT))
|
||||
for ((i=1; i<=NESTED_CERT_CNT; i++)); do
|
||||
index=$((i - 1))
|
||||
CERT_DATE=$(date --date="$(grep 'Not After :' "$CERT_LOG" | awk -v cnt="$i" 'NR==cnt {sub(/.*: /, ""); print}')" --iso-8601 || true)
|
||||
CERT_DATE_=$(date --date="$(grep 'Not After :' "$CERT_LOG" | awk -v cnt="$i" 'NR==cnt {sub(/.*: /, ""); print}')" +%s || true)
|
||||
SIGNATURE=$(sed -n '/Signature Value:/!b;n;p' "$CERT_LOG" | sed -n "${i}p" | xargs)
|
||||
SPECIFIC_CERT=$(head -n -1 < "$CERT_LOG" | awk -v idx="$index" '
|
||||
CERT_DATE=$(date --date="$(grep 'Not After :' "${CERT_LOG}" | awk -v cnt="${i}" 'NR==cnt {sub(/.*: /, ""); print}')" --iso-8601 || true)
|
||||
CERT_DATE_=$(date --date="$(grep 'Not After :' "${CERT_LOG}" | awk -v cnt="${i}" 'NR==cnt {sub(/.*: /, ""); print}')" +%s || true)
|
||||
SIGNATURE=$(sed -n '/Signature Value:/!b;n;p' "${CERT_LOG}" | sed -n "${i}p" | xargs)
|
||||
SPECIFIC_CERT=$(head -n -1 < "${CERT_LOG}" | awk -v idx="${index}" '
|
||||
BEGIN { found = 0 }
|
||||
/^[0-9]+: Certificate$/ {
|
||||
if (found) {
|
||||
@@ -82,31 +82,31 @@ S60_cert_file_check()
|
||||
}
|
||||
}' | tail -n+2)
|
||||
|
||||
if [[ $CERT_DATE_ -lt $CURRENT_DATE ]]; then
|
||||
print_output " ${RED}$CERT_DATE - $(print_path "$LINE") $SIGNATURE ${NC}" "" "$SPECIFIC_CERT"
|
||||
write_csv_log "$LINE" "$CERT_DATE_" "yes"
|
||||
if [[ ${CERT_DATE_} -lt ${CURRENT_DATE} ]]; then
|
||||
print_output " ${RED}${CERT_DATE} - $(print_path "${LINE}") ${SIGNATURE} ${NC}" "" "${SPECIFIC_CERT}"
|
||||
write_csv_log "${LINE}" "${CERT_DATE_}" "yes"
|
||||
((CERT_OUT_CNT+=1))
|
||||
elif [[ $CERT_DATE_ -le $FUTURE_DATE ]]; then
|
||||
print_output " ${ORANGE}$CERT_DATE - $(print_path "$LINE") $SIGNATURE ${NC}" "" "$SPECIFIC_CERT"
|
||||
write_csv_log "$LINE" "$CERT_DATE_" "expires within $EXPIRE_WATCH_DATE"
|
||||
elif [[ ${CERT_DATE_} -le ${FUTURE_DATE} ]]; then
|
||||
print_output " ${ORANGE}${CERT_DATE} - $(print_path "${LINE}") ${SIGNATURE} ${NC}" "" "${SPECIFIC_CERT}"
|
||||
write_csv_log "${LINE}" "${CERT_DATE_}" "expires within ${EXPIRE_WATCH_DATE}"
|
||||
((CERT_WARNING_CNT+=1))
|
||||
else
|
||||
print_output " ${GREEN}$CERT_DATE - $(print_path "$LINE") $SIGNATURE ${NC}" "" "$SPECIFIC_CERT"
|
||||
write_csv_log "$LINE" "$CERT_DATE_" "no"
|
||||
print_output " ${GREEN}${CERT_DATE} - $(print_path "${LINE}") ${SIGNATURE} ${NC}" "" "${SPECIFIC_CERT}"
|
||||
write_csv_log "${LINE}" "${CERT_DATE_}" "no"
|
||||
fi
|
||||
done
|
||||
else
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")"
|
||||
write_csv_log "$LINE" "unknown" "unknown"
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")"
|
||||
write_csv_log "${LINE}" "unknown" "unknown"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$TOTAL_CERT_CNT:$CERT_FILES_CNT:$CERT_OUT_CNT:$CERT_WARNING_CNT"
|
||||
write_log "[*] Statistics:${TOTAL_CERT_CNT}:${CERT_FILES_CNT}:${CERT_OUT_CNT}:${CERT_WARNING_CNT}"
|
||||
else
|
||||
print_output "[-] No certification files found"
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$TOTAL_CERT_CNT"
|
||||
module_end_log "${FUNCNAME[0]}" "${TOTAL_CERT_CNT}"
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ S65_config_file_check()
|
||||
NEG_LOG=1
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
scan_config()
|
||||
@@ -42,13 +42,13 @@ scan_config()
|
||||
sub_module_title "Search for config file"
|
||||
local LINE=""
|
||||
|
||||
readarray -t CONF_FILES_ARR < <(config_find "$CONFIG_DIR""/config_files.cfg")
|
||||
readarray -t CONF_FILES_ARR < <(config_find "${CONFIG_DIR}""/config_files.cfg")
|
||||
|
||||
if [[ "${CONF_FILES_ARR[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ ${#CONF_FILES_ARR[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#CONF_FILES_ARR[@]}"" possible configuration files:"
|
||||
for LINE in "${CONF_FILES_ARR[@]}" ; do
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")"
|
||||
done
|
||||
else
|
||||
print_output "[-] No configuration files found"
|
||||
@@ -71,7 +71,7 @@ check_fstab()
|
||||
if [[ ${#FSTAB_USER_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#FSTAB_USER_FILES[@]}"" fstab files with user details included:"
|
||||
for LINE in "${FSTAB_USER_FILES[@]}"; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
done
|
||||
print_ln "no_log"
|
||||
else
|
||||
@@ -81,7 +81,7 @@ check_fstab()
|
||||
if [[ ${#FSTAB_PASS_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#FSTAB_PASS_FILES[@]}"" fstab files with password credentials included:"
|
||||
for LINE in "${FSTAB_PASS_FILES[@]}"; do
|
||||
print_output "$(indent "$(print_path "$LINE")")"
|
||||
print_output "$(indent "$(print_path "${LINE}")")"
|
||||
done
|
||||
print_ln "no_log"
|
||||
else
|
||||
|
||||
@@ -24,12 +24,12 @@ S70_hidden_file_check()
|
||||
local HIDDEN_FILES=()
|
||||
local LINE=""
|
||||
|
||||
mapfile -t HIDDEN_FILES < <(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -xdev -name ".*" -type f)
|
||||
mapfile -t HIDDEN_FILES < <(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -xdev -name ".*" -type f)
|
||||
|
||||
if [[ ${#HIDDEN_FILES[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#HIDDEN_FILES[@]}"" hidden files:"
|
||||
for LINE in "${HIDDEN_FILES[@]}" ; do
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")"
|
||||
done
|
||||
else
|
||||
print_output "[-] No hidden files found!"
|
||||
|
||||
@@ -29,7 +29,7 @@ S75_network_check()
|
||||
check_snmp
|
||||
check_network_configs
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NET_CFG_FOUND"
|
||||
module_end_log "${FUNCNAME[0]}" "${NET_CFG_FOUND}"
|
||||
}
|
||||
|
||||
check_resolv()
|
||||
@@ -43,18 +43,18 @@ check_resolv()
|
||||
|
||||
mapfile -t RES_CONF_PATHS < <(mod_path "/ETC_PATHS/resolv.conf")
|
||||
for RES_INFO_P in "${RES_CONF_PATHS[@]}"; do
|
||||
if [[ -e "$RES_INFO_P" ]] ; then
|
||||
if [[ -e "${RES_INFO_P}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] DNS config ""$(print_path "$RES_INFO_P")"
|
||||
print_output "[+] DNS config ""$(print_path "${RES_INFO_P}")"
|
||||
|
||||
DNS_INFO=$(grep "nameserver" "$RES_INFO_P" 2>/dev/null || true)
|
||||
if [[ "$DNS_INFO" ]] ; then
|
||||
print_output "$(indent "$DNS_INFO")"
|
||||
DNS_INFO=$(grep "nameserver" "${RES_INFO_P}" 2>/dev/null || true)
|
||||
if [[ "${DNS_INFO}" ]] ; then
|
||||
print_output "$(indent "${DNS_INFO}")"
|
||||
((NET_CFG_FOUND+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]]; then
|
||||
if [[ ${CHECK} -eq 0 ]]; then
|
||||
print_output "[-] No or empty network configuration found"
|
||||
fi
|
||||
}
|
||||
@@ -69,13 +69,13 @@ check_iptables()
|
||||
|
||||
mapfile -t IPT_CONF_PATHS < <(mod_path "/ETC_PATHS/iptables")
|
||||
for IPT_INFO_P in "${IPT_CONF_PATHS[@]}"; do
|
||||
if [[ -e "$IPT_INFO_P" ]] ; then
|
||||
if [[ -e "${IPT_INFO_P}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] iptables config ""$(print_path "$IPT_INFO_P")"
|
||||
print_output "[+] iptables config ""$(print_path "${IPT_INFO_P}")"
|
||||
((NET_CFG_FOUND+=1))
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]]; then
|
||||
if [[ ${CHECK} -eq 0 ]]; then
|
||||
print_output "[-] No iptables configuration found"
|
||||
fi
|
||||
}
|
||||
@@ -93,20 +93,20 @@ check_snmp()
|
||||
|
||||
mapfile -t SNMP_CONF_PATHS < <(mod_path "/ETC_PATHS/snmp/snmpd.conf")
|
||||
for SNMP_CONF_P in "${SNMP_CONF_PATHS[@]}"; do
|
||||
if [[ -e "$SNMP_CONF_P" ]] ; then
|
||||
if [[ -e "${SNMP_CONF_P}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] SNMP config ""$(print_path "$SNMP_CONF_P")"
|
||||
mapfile -t FIND < <(awk '/^com2sec/ { print $4 }' "$SNMP_CONF_P")
|
||||
print_output "[+] SNMP config ""$(print_path "${SNMP_CONF_P}")"
|
||||
mapfile -t FIND < <(awk '/^com2sec/ { print $4 }' "${SNMP_CONF_P}")
|
||||
if [[ "${#FIND[@]}" -ne 0 ]] ; then
|
||||
print_output "[*] com2sec line/s:"
|
||||
for I in "${FIND[@]}"; do
|
||||
print_output "$(indent "$(orange "$I")")"
|
||||
print_output "$(indent "$(orange "${I}")")"
|
||||
((NET_CFG_FOUND+=1))
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]]; then
|
||||
if [[ ${CHECK} -eq 0 ]]; then
|
||||
print_output "[-] No SNMP configuration found"
|
||||
fi
|
||||
}
|
||||
@@ -118,13 +118,13 @@ check_network_configs()
|
||||
local NETWORK_CONFS=()
|
||||
local LINE=""
|
||||
|
||||
readarray -t NETWORK_CONFS < <(printf '%s' "$(config_find "$CONFIG_DIR""/network_conf_files.cfg")")
|
||||
readarray -t NETWORK_CONFS < <(printf '%s' "$(config_find "${CONFIG_DIR}""/network_conf_files.cfg")")
|
||||
|
||||
if [[ "${NETWORK_CONFS[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ ${#NETWORK_CONFS[@]} -gt 0 ]] ; then
|
||||
print_output "[+] Found ""${#NETWORK_CONFS[@]}"" possible network configs:"
|
||||
for LINE in "${NETWORK_CONFS[@]}" ; do
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")"
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")"
|
||||
((NET_CFG_FOUND+=1))
|
||||
done
|
||||
else
|
||||
|
||||
@@ -29,27 +29,27 @@ S80_cronjob_check()
|
||||
|
||||
mapfile -t CJ_FILE_PATH < <(mod_path "/ETC_PATHS/cron")
|
||||
for CJ_FILE in "${CJ_FILE_PATH[@]}"; do
|
||||
if [[ -e "$CJ_FILE" ]] ; then
|
||||
if [[ -e "${CJ_FILE}" ]] ; then
|
||||
local CRONJOBS
|
||||
# This check is based on source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
# CRONJOBS=$(ls -la "$CJ_FILE"* 2>/dev/null)
|
||||
CRONJOBS=$(find "$CJ_FILE"* -xdev -type f 2>/dev/null)
|
||||
if [[ "$CRONJOBS" ]] ; then
|
||||
# CRONJOBS=$(ls -la "${CJ_FILE}"* 2>/dev/null)
|
||||
CRONJOBS=$(find "${CJ_FILE}"* -xdev -type f 2>/dev/null)
|
||||
if [[ "${CRONJOBS}" ]] ; then
|
||||
print_output "[+] Cronjobs:"
|
||||
print_output "$(indent "$CRONJOBS")"
|
||||
print_output "$(indent "${CRONJOBS}")"
|
||||
((RESULTS+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for CJ_FILE in "${CJ_FILE_PATH[@]}" ; do
|
||||
if [[ -e "$CJ_FILE" ]] ; then
|
||||
if [[ -e "${CJ_FILE}" ]] ; then
|
||||
local CRONJOBWWPERMS
|
||||
# This check is based on source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
CRONJOBWWPERMS=$(find "$CJ_FILE"* -xdev -perm -0002 -type f -exec ls -la {} \; -exec cat {} \; 2>/dev/null)
|
||||
if [[ "$CRONJOBWWPERMS" ]] ; then
|
||||
CRONJOBWWPERMS=$(find "${CJ_FILE}"* -xdev -perm -0002 -type f -exec ls -la {} \; -exec cat {} \; 2>/dev/null)
|
||||
if [[ "${CRONJOBWWPERMS}" ]] ; then
|
||||
print_output "[+] World-writable cron jobs and file contents:"
|
||||
print_output "$(indent "$CRONJOBWWPERMS")"
|
||||
print_output "$(indent "${CRONJOBWWPERMS}")"
|
||||
((RESULTS+=1))
|
||||
fi
|
||||
fi
|
||||
@@ -57,59 +57,59 @@ S80_cronjob_check()
|
||||
|
||||
mapfile -t CJ_FILE_PATH < <(mod_path "/ETC_PATHS/crontab")
|
||||
for CJ_FILE in "${CJ_FILE_PATH[@]}"; do
|
||||
if [[ -e "$CJ_FILE" ]] ; then
|
||||
if [[ -e "${CJ_FILE}" ]] ; then
|
||||
local CRONTABVALUE
|
||||
# This check is based on source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
CRONTABVALUE=$(cat "$CJ_FILE" 2>/dev/null)
|
||||
if [[ "$CRONTABVALUE" ]] ; then
|
||||
CRONTABVALUE=$(cat "${CJ_FILE}" 2>/dev/null)
|
||||
if [[ "${CRONTABVALUE}" ]] ; then
|
||||
print_output "[+] Crontab content:"
|
||||
print_output "$(indent "$CRONTABVALUE")"
|
||||
print_output "$(indent "${CRONTABVALUE}")"
|
||||
((RESULTS+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# mapfile -t CJ_FILE_PATH < <(mod_path "/var/spool/cron/crontabs")
|
||||
mapfile -t CJ_FILE_PATH < <(find "$FIRMWARE_PATH" -xdev -type d -iwholename "/var/spool/cron/crontabs")
|
||||
mapfile -t CJ_FILE_PATH < <(find "${FIRMWARE_PATH}" -xdev -type d -iwholename "/var/spool/cron/crontabs")
|
||||
for CT_VAR in "${CJ_FILE_PATH[@]}"; do
|
||||
local CRONTABVAR
|
||||
# This check is based on source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
# CRONTABVAR=$(ls -la "$CT_VAR" 2>/dev/null)
|
||||
CRONTABVAR=$(find "$CT_VAR"* -type f -ls 2>/dev/null)
|
||||
if [[ "$CRONTABVAR" ]] ; then
|
||||
print_output "[+] Anything interesting in ""$(print_path "$CT_VAR")"
|
||||
print_output "$(indent "$CRONTABVAR")"
|
||||
# CRONTABVAR=$(ls -la "${CT_VAR}" 2>/dev/null)
|
||||
CRONTABVAR=$(find "${CT_VAR}"* -type f -ls 2>/dev/null)
|
||||
if [[ "${CRONTABVAR}" ]] ; then
|
||||
print_output "[+] Anything interesting in ""$(print_path "${CT_VAR}")"
|
||||
print_output "$(indent "${CRONTABVAR}")"
|
||||
((RESULTS+=1))
|
||||
fi
|
||||
done
|
||||
|
||||
mapfile -t CJ_FILE_PATH < <(mod_path "/ETC_PATHS/anacrontab")
|
||||
for CJ_FILE in "${CJ_FILE_PATH[@]}"; do
|
||||
if [[ -e "$CJ_FILE" ]] ; then
|
||||
if [[ -e "${CJ_FILE}" ]] ; then
|
||||
local ANACRONJOBS
|
||||
# This check is based on source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
ANACRONJOBS=$(ls -la "$CJ_FILE" 2>/dev/null; cat "$CJ_FILE" 2>/dev/null)
|
||||
if [[ "$ANACRONJOBS" ]] ; then
|
||||
ANACRONJOBS=$(ls -la "${CJ_FILE}" 2>/dev/null; cat "${CJ_FILE}" 2>/dev/null)
|
||||
if [[ "${ANACRONJOBS}" ]] ; then
|
||||
print_output "[+] Anacron jobs and associated file permissions:"
|
||||
print_output "$(indent "$ANACRONJOBS")"
|
||||
print_output "$(indent "${ANACRONJOBS}")"
|
||||
((RESULTS+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# mapfile -t CJ_FILE_PATH < <(mod_path "/var/spool/anacron")
|
||||
mapfile -t CJ_FILE_PATH < <(find "$FIRMWARE_PATH" -xdev -type d -iwholename "/var/spool/anacron")
|
||||
mapfile -t CJ_FILE_PATH < <(find "${FIRMWARE_PATH}" -xdev -type d -iwholename "/var/spool/anacron")
|
||||
for CT_VAR in "${CJ_FILE_PATH[@]}"; do
|
||||
local ANACRONTAB
|
||||
# This check is based on source code from LinEnum: https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
|
||||
ANACRONTAB=$(ls -la "$CT_VAR" 2>/dev/null || true)
|
||||
if [[ "$ANACRONTAB" ]] ; then
|
||||
print_output "[+] When were jobs last executed (""$(print_path "$CT_VAR")"")"
|
||||
print_output "$(indent "$ANACRONTAB")"
|
||||
ANACRONTAB=$(ls -la "${CT_VAR}" 2>/dev/null || true)
|
||||
if [[ "${ANACRONTAB}" ]] ; then
|
||||
print_output "[+] When were jobs last executed (""$(print_path "${CT_VAR}")"")"
|
||||
print_output "$(indent "${ANACRONTAB}")"
|
||||
((RESULTS+=1))
|
||||
fi
|
||||
done
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$RESULTS"
|
||||
module_end_log "${FUNCNAME[0]}" "${RESULTS}"
|
||||
}
|
||||
|
||||
|
||||
+28
-28
@@ -29,13 +29,13 @@ S85_ssh_check()
|
||||
check_squid
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$SSH_VUL_CNT:$SQUID_VUL_CNT"
|
||||
write_log "[*] Statistics:${SSH_VUL_CNT}:${SQUID_VUL_CNT}"
|
||||
|
||||
if [[ "$SQUID_VUL_CNT" -gt 0 || "$SSH_VUL_CNT" -gt 0 ]]; then
|
||||
if [[ "${SQUID_VUL_CNT}" -gt 0 || "${SSH_VUL_CNT}" -gt 0 ]]; then
|
||||
NEG_LOG=1
|
||||
fi
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
search_ssh_files()
|
||||
@@ -47,36 +47,36 @@ search_ssh_files()
|
||||
local SSHD_ISSUES=()
|
||||
local S_ISSUE=""
|
||||
|
||||
mapfile -t SSH_FILES < <(config_find "$CONFIG_DIR""/ssh_files.cfg")
|
||||
mapfile -t SSH_FILES < <(config_find "${CONFIG_DIR}""/ssh_files.cfg")
|
||||
|
||||
if [[ "${SSH_FILES[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#SSH_FILES[@]}" -ne 0 ]] ; then
|
||||
print_output "[+] Found ""${#SSH_FILES[@]}"" ssh configuration files:"
|
||||
for LINE in "${SSH_FILES[@]}" ; do
|
||||
if [[ -f "$LINE" ]] ; then
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")" "" "$LINE"
|
||||
if [[ -f "$EXT_DIR"/sshdcc ]]; then
|
||||
if [[ -f "${LINE}" ]] ; then
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")" "" "${LINE}"
|
||||
if [[ -f "${EXT_DIR}"/sshdcc ]]; then
|
||||
local PRINTER=0
|
||||
if [[ "$(basename "$LINE")" == "sshd_config" ]]; then
|
||||
if [[ "$(basename "${LINE}")" == "sshd_config" ]]; then
|
||||
print_output "[*] Testing sshd configuration file with sshdcc"
|
||||
readarray SSHD_ISSUES < <("$EXT_DIR"/sshdcc -ns -nc -f "$LINE" || true)
|
||||
readarray SSHD_ISSUES < <("${EXT_DIR}"/sshdcc -ns -nc -f "${LINE}" || true)
|
||||
for S_ISSUE in "${SSHD_ISSUES[@]}"; do
|
||||
if [[ "$S_ISSUE" == *RESULTS* || "$PRINTER" -eq 1 ]]; then
|
||||
if [[ "${S_ISSUE}" == *RESULTS* || "${PRINTER}" -eq 1 ]]; then
|
||||
# print finding title as EMBA finding:
|
||||
if [[ "$S_ISSUE" =~ ^\([0-9+]\)\ \[[A-Z]+\]\ ]]; then
|
||||
print_output "[+] $S_ISSUE"
|
||||
if [[ "${S_ISSUE}" =~ ^\([0-9+]\)\ \[[A-Z]+\]\ ]]; then
|
||||
print_output "[+] ${S_ISSUE}"
|
||||
((SSH_VUL_CNT+=1))
|
||||
# print everything else (except RESULTS and done) as usual output
|
||||
elif ! [[ "$S_ISSUE" == *RESULTS* || "$S_ISSUE" == *done* ]]; then
|
||||
print_output "[*] $S_ISSUE"
|
||||
elif ! [[ "${S_ISSUE}" == *RESULTS* || "${S_ISSUE}" == *done* ]]; then
|
||||
print_output "[*] ${S_ISSUE}"
|
||||
# with indent the output looks weird:
|
||||
# print_output "$(indent "$(orange "$S_ISSUE")")"
|
||||
# print_output "$(indent "$(orange "${S_ISSUE}")")"
|
||||
fi
|
||||
PRINTER=1
|
||||
fi
|
||||
done
|
||||
elif [[ "$(basename "$LINE")" == *"authorized_key"* ]]; then
|
||||
print_output "[+] Warning: Possible ${ORANGE}authorized_key${GREEN} backdoor detected: ${ORANGE}$LINE${NC}"
|
||||
elif [[ "$(basename "${LINE}")" == *"authorized_key"* ]]; then
|
||||
print_output "[+] Warning: Possible ${ORANGE}authorized_key${GREEN} backdoor detected: ${ORANGE}${LINE}${NC}"
|
||||
((SSH_VUL_CNT+=1))
|
||||
fi
|
||||
fi
|
||||
@@ -97,12 +97,12 @@ check_squid()
|
||||
local SQUID_E=""
|
||||
|
||||
for BIN_FILE in "${BINARIES[@]}"; do
|
||||
if [[ "$BIN_FILE" == *"squid"* ]] && ( file "$BIN_FILE" | grep -q ELF ) ; then
|
||||
print_output "[+] Found possible squid executable: ""$ORANGE$(print_path "$BIN_FILE")$NC"
|
||||
if [[ "${BIN_FILE}" == *"squid"* ]] && ( file "${BIN_FILE}" | grep -q ELF ) ; then
|
||||
print_output "[+] Found possible squid executable: ""${ORANGE}$(print_path "${BIN_FILE}")${NC}"
|
||||
((SQUID_VUL_CNT+=1))
|
||||
fi
|
||||
done
|
||||
[[ $SQUID_VUL_CNT -eq 0 ]] && print_output "[-] No possible squid executable found"
|
||||
[[ ${SQUID_VUL_CNT} -eq 0 ]] && print_output "[-] No possible squid executable found"
|
||||
|
||||
local SQUID_DAEMON_CONFIG_LOCS=("/ETC_PATHS" "/ETC_PATHS/squid" "/ETC_PATHS/squid3" "/usr/local/etc/squid" "/usr/local/squid/etc")
|
||||
mapfile -t SQUID_PATHS_ARR < <(mod_path_array "${SQUID_DAEMON_CONFIG_LOCS[@]}")
|
||||
@@ -110,22 +110,22 @@ check_squid()
|
||||
print_output "[!] Config not found"
|
||||
elif [[ "${#SQUID_PATHS_ARR[@]}" -ne 0 ]] ; then
|
||||
for SQUID_E in "${SQUID_PATHS_ARR[@]}"; do
|
||||
if [[ -f "$SQUID_E""/squid.conf" ]] ; then
|
||||
if [[ -f "${SQUID_E}""/squid.conf" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found squid config: ""$ORANGE$(print_path "$SQUID_E")$NC"
|
||||
print_output "[+] Found squid config: ""${ORANGE}$(print_path "${SQUID_E}")${NC}"
|
||||
((SQUID_VUL_CNT+=1))
|
||||
elif [[ -f "$SQUID_E""/squid3.conf" ]] ; then
|
||||
elif [[ -f "${SQUID_E}""/squid3.conf" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found squid config: ""$ORANGE$(print_path "$SQUID_E")$NC"
|
||||
print_output "[+] Found squid config: ""${ORANGE}$(print_path "${SQUID_E}")${NC}"
|
||||
((SQUID_VUL_CNT+=1))
|
||||
fi
|
||||
if [[ $CHECK -eq 1 ]] ; then
|
||||
if [[ ${CHECK} -eq 1 ]] ; then
|
||||
print_output "[*] Check external access control list type:"
|
||||
print_output "$(indent "$(grep "^external_acl_type" "$SQUID_E")")"
|
||||
print_output "$(indent "$(grep "^external_acl_type" "${SQUID_E}")")"
|
||||
print_output "[*] Check access control list:"
|
||||
print_output "$(indent "$(grep "^acl" "$SQUID_E" | sed 's/ /!space!/g')")"
|
||||
print_output "$(indent "$(grep "^acl" "${SQUID_E}" | sed 's/ /!space!/g')")"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
[[ $CHECK -eq 0 ]] && print_output "[-] No squid configuration found"
|
||||
[[ ${CHECK} -eq 0 ]] && print_output "[-] No squid configuration found"
|
||||
}
|
||||
|
||||
+14
-14
@@ -27,14 +27,14 @@ S90_mail_check()
|
||||
local ELEM=""
|
||||
local MAILS=""
|
||||
|
||||
mapfile -t MAILS_PATH < <(find "$FIRMWARE_PATH" -xdev -type d -iwholename "/var/mail")
|
||||
mapfile -t MAILS_PATH < <(find "${FIRMWARE_PATH}" -xdev -type d -iwholename "/var/mail")
|
||||
for ELEM in "${MAILS_PATH[@]}" ; do
|
||||
if [[ -e "$ELEM" ]] ; then
|
||||
# MAILS="$(ls -la "$ELEM" 2>/dev/null)"
|
||||
MAILS="$(find "$ELEM" -xdev -ls 2>/dev/null)"
|
||||
if [[ -n "$MAILS" ]] ; then
|
||||
print_output "[+] Content of ""$(print_path "$ELEM")"":"
|
||||
print_output "$(indent "$(orange "$MAILS")")"
|
||||
if [[ -e "${ELEM}" ]] ; then
|
||||
# MAILS="$(ls -la "${ELEM}" 2>/dev/null)"
|
||||
MAILS="$(find "${ELEM}" -xdev -ls 2>/dev/null)"
|
||||
if [[ -n "${MAILS}" ]] ; then
|
||||
print_output "[+] Content of ""$(print_path "${ELEM}")"":"
|
||||
print_output "$(indent "$(orange "${MAILS}")")"
|
||||
((FINDING+=1))
|
||||
fi
|
||||
fi
|
||||
@@ -44,18 +44,18 @@ S90_mail_check()
|
||||
local ELEM=""
|
||||
local MAILS_ROOT=""
|
||||
|
||||
mapfile -t MAILS_PATH_ROOT < <(find "$FIRMWARE_PATH" -xdev -type d -iwholename "/var/mail/root")
|
||||
mapfile -t MAILS_PATH_ROOT < <(find "${FIRMWARE_PATH}" -xdev -type d -iwholename "/var/mail/root")
|
||||
for ELEM in "${MAILS_PATH_ROOT[@]}" ; do
|
||||
if [[ -e "$ELEM" ]] ; then
|
||||
MAILS_ROOT="$(head "$ELEM" 2>/dev/null)"
|
||||
if [[ -n "$MAILS_ROOT" ]] ; then
|
||||
print_output "[+] Content of ""$(print_path "$ELEM")"":"
|
||||
print_output "$(indent "$(orange "$MAILS_ROOT")")"
|
||||
if [[ -e "${ELEM}" ]] ; then
|
||||
MAILS_ROOT="$(head "${ELEM}" 2>/dev/null)"
|
||||
if [[ -n "${MAILS_ROOT}" ]] ; then
|
||||
print_output "[+] Content of ""$(print_path "${ELEM}")"":"
|
||||
print_output "$(indent "$(orange "${MAILS_ROOT}")")"
|
||||
((FINDING+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$FINDING"
|
||||
module_end_log "${FUNCNAME[0]}" "${FINDING}"
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ S95_interesting_binaries_check()
|
||||
local INT_COUNT=0
|
||||
local POST_COUNT=0
|
||||
|
||||
if [[ "$THREADED" -eq 1 ]]; then
|
||||
if [[ "${THREADED}" -eq 1 ]]; then
|
||||
interesting_binaries &
|
||||
WAIT_PIDS_S95+=( "$!" )
|
||||
post_exploitation &
|
||||
@@ -35,29 +35,29 @@ S95_interesting_binaries_check()
|
||||
post_exploitation
|
||||
fi
|
||||
|
||||
[[ "$THREADED" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S95[@]}"
|
||||
[[ "${THREADED}" -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S95[@]}"
|
||||
|
||||
if [[ -f "$LOG_PATH_MODULE"/interesting_binaries.txt ]]; then
|
||||
if [[ -f "${LOG_PATH_MODULE}"/interesting_binaries.txt ]]; then
|
||||
sub_module_title "Interesting binaries"
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/interesting_binaries.txt
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/interesting_binaries.txt
|
||||
fi
|
||||
if [[ -f "$LOG_PATH_MODULE"/post_exploitation_binaries.txt ]]; then
|
||||
if [[ -f "${LOG_PATH_MODULE}"/post_exploitation_binaries.txt ]]; then
|
||||
sub_module_title "Interesting binaries for post exploitation"
|
||||
tee -a "$LOG_FILE" < "$LOG_PATH_MODULE"/post_exploitation_binaries.txt
|
||||
tee -a "${LOG_FILE}" < "${LOG_PATH_MODULE}"/post_exploitation_binaries.txt
|
||||
fi
|
||||
|
||||
if [[ -f "$TMP_DIR"/INT_COUNT.tmp || -f "$TMP_DIR"/POST_COUNT.tmp ]]; then
|
||||
POST_COUNT=$(cat "$TMP_DIR"/POST_COUNT.tmp 2>/dev/null || true)
|
||||
INT_COUNT=$(cat "$TMP_DIR"/INT_COUNT.tmp 2>/dev/null || true)
|
||||
if [[ "$POST_COUNT" -gt 0 || "$INT_COUNT" -gt 0 ]]; then
|
||||
if [[ -f "${TMP_DIR}"/INT_COUNT.tmp || -f "${TMP_DIR}"/POST_COUNT.tmp ]]; then
|
||||
POST_COUNT=$(cat "${TMP_DIR}"/POST_COUNT.tmp 2>/dev/null || true)
|
||||
INT_COUNT=$(cat "${TMP_DIR}"/INT_COUNT.tmp 2>/dev/null || true)
|
||||
if [[ "${POST_COUNT}" -gt 0 || "${INT_COUNT}" -gt 0 ]]; then
|
||||
NEG_LOG=1
|
||||
fi
|
||||
fi
|
||||
|
||||
write_log ""
|
||||
write_log "[*] Statistics:$INT_COUNT:$POST_COUNT"
|
||||
write_log "[*] Statistics:${INT_COUNT}:${POST_COUNT}"
|
||||
|
||||
module_end_log "${FUNCNAME[0]}" "$NEG_LOG"
|
||||
module_end_log "${FUNCNAME[0]}" "${NEG_LOG}"
|
||||
}
|
||||
|
||||
interesting_binaries() {
|
||||
@@ -68,30 +68,30 @@ interesting_binaries() {
|
||||
local MD5_DONE_INT=()
|
||||
local BIN_MD5=""
|
||||
|
||||
mapfile -t INT_BIN < <(config_find "$CONFIG_DIR""/interesting_binaries.cfg")
|
||||
mapfile -t INT_BIN < <(config_find "${CONFIG_DIR}""/interesting_binaries.cfg")
|
||||
if [[ "${INT_BIN[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#INT_BIN[@]}" -ne 0 ]] ; then
|
||||
for LINE in "${INT_BIN[@]}" ; do
|
||||
if [[ -f "$LINE" ]] && file "$LINE" | grep -q "executable" ; then
|
||||
if [[ -f "${LINE}" ]] && file "${LINE}" | grep -q "executable" ; then
|
||||
# we need every binary only once. So calculate the checksum and store it for checking
|
||||
BIN_MD5=$(md5sum "$LINE" | cut -d\ -f1)
|
||||
BIN_MD5=$(md5sum "${LINE}" | cut -d\ -f1)
|
||||
if [[ ! " ${MD5_DONE_INT[*]} " =~ ${BIN_MD5} ]]; then
|
||||
if [[ $COUNT -eq 0 ]] ; then
|
||||
write_log "[+] Found interesting binaries:" "$LOG_PATH_MODULE"/interesting_binaries.txt
|
||||
if [[ ${COUNT} -eq 0 ]] ; then
|
||||
write_log "[+] Found interesting binaries:" "${LOG_PATH_MODULE}"/interesting_binaries.txt
|
||||
COUNT=1
|
||||
fi
|
||||
write_log "$(indent "$(orange "$(print_path "$LINE")")")" "$LOG_PATH_MODULE"/interesting_binaries.txt
|
||||
write_log "$(indent "$(orange "$(print_path "${LINE}")")")" "${LOG_PATH_MODULE}"/interesting_binaries.txt
|
||||
((INT_COUNT+=1))
|
||||
MD5_DONE_INT+=( "$BIN_MD5" )
|
||||
MD5_DONE_INT+=( "${BIN_MD5}" )
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $COUNT -eq 0 ]] ; then
|
||||
write_log "[-] No interesting binaries found" "$LOG_PATH_MODULE"/interesting_binaries.txt
|
||||
if [[ ${COUNT} -eq 0 ]] ; then
|
||||
write_log "[-] No interesting binaries found" "${LOG_PATH_MODULE}"/interesting_binaries.txt
|
||||
fi
|
||||
echo "$INT_COUNT" >> "$TMP_DIR"/INT_COUNT.tmp
|
||||
echo "${INT_COUNT}" >> "${TMP_DIR}"/INT_COUNT.tmp
|
||||
}
|
||||
|
||||
post_exploitation() {
|
||||
@@ -103,28 +103,28 @@ post_exploitation() {
|
||||
local BIN_MD5=""
|
||||
local MD5_DONE_POST=()
|
||||
|
||||
mapfile -t INT_BIN_PE < <(config_find "$CONFIG_DIR""/interesting_post_binaries.cfg")
|
||||
mapfile -t INT_BIN_PE < <(config_find "${CONFIG_DIR}""/interesting_post_binaries.cfg")
|
||||
if [[ "${INT_BIN_PE[0]-}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ "${#INT_BIN_PE[@]}" -ne 0 ]] ; then
|
||||
for LINE in "${INT_BIN_PE[@]}" ; do
|
||||
if [[ -f "$LINE" ]] && file "$LINE" | grep -q "executable" ; then
|
||||
if [[ -f "${LINE}" ]] && file "${LINE}" | grep -q "executable" ; then
|
||||
# we need every binary only once. Calculate the checksum and store it for checking
|
||||
BIN_MD5=$(md5sum "$LINE" | cut -d\ -f1)
|
||||
BIN_MD5=$(md5sum "${LINE}" | cut -d\ -f1)
|
||||
if [[ ! " ${MD5_DONE_POST[*]} " =~ ${BIN_MD5} ]]; then
|
||||
if [[ $COUNT -eq 0 ]] ; then
|
||||
write_log "[+] Found interesting binaries for post exploitation:" "$LOG_PATH_MODULE"/post_exploitation_binaries.txt
|
||||
if [[ ${COUNT} -eq 0 ]] ; then
|
||||
write_log "[+] Found interesting binaries for post exploitation:" "${LOG_PATH_MODULE}"/post_exploitation_binaries.txt
|
||||
COUNT=1
|
||||
fi
|
||||
write_log "$(indent "$(orange "$(print_path "$LINE")")")" "$LOG_PATH_MODULE"/post_exploitation_binaries.txt
|
||||
write_log "$(indent "$(orange "$(print_path "${LINE}")")")" "${LOG_PATH_MODULE}"/post_exploitation_binaries.txt
|
||||
((POST_COUNT+=1))
|
||||
MD5_DONE_POST+=( "$BIN_MD5" )
|
||||
MD5_DONE_POST+=( "${BIN_MD5}" )
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [[ $COUNT -eq 0 ]] ; then
|
||||
write_log "[-] No interesting binaries for post exploitation found" "$LOG_PATH_MODULE"/post_exploitation_binaries.txt
|
||||
if [[ ${COUNT} -eq 0 ]] ; then
|
||||
write_log "[-] No interesting binaries for post exploitation found" "${LOG_PATH_MODULE}"/post_exploitation_binaries.txt
|
||||
fi
|
||||
echo "$POST_COUNT" >> "$TMP_DIR"/POST_COUNT.tmp
|
||||
echo "${POST_COUNT}" >> "${TMP_DIR}"/POST_COUNT.tmp
|
||||
}
|
||||
|
||||
|
||||
+185
-185
File diff suppressed because it is too large
Load Diff
+27
-27
@@ -43,14 +43,14 @@ template_module() {
|
||||
local TESTVAR1=""
|
||||
local TESTVAR2=""
|
||||
|
||||
print_output "[*] TESTVAR1: $TESTVAR1"
|
||||
print_output "[*] TESTVAR2: $TESTVAR2"
|
||||
print_output "[*] TESTVAR1: ${TESTVAR1}"
|
||||
print_output "[*] TESTVAR2: ${TESTVAR2}"
|
||||
|
||||
# Prints everything to CLI, more information in function print_examples
|
||||
print_output "[*] Empty module output"
|
||||
|
||||
# Call a submodule inside of module with a parameter
|
||||
sub_module "$TESTVAR1"
|
||||
sub_module "${TESTVAR1}"
|
||||
|
||||
# How to use print_output
|
||||
print_examples
|
||||
@@ -68,7 +68,7 @@ template_module() {
|
||||
load_from_config
|
||||
|
||||
# Usage of `find`: add "${EXCL_FIND[@]}" to exclude all paths (added with '-e' parameter)
|
||||
print_output "$(find "$FIRMWARE_PATH" "${EXCL_FIND[@]}" -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l)"
|
||||
print_output "$(find "${FIRMWARE_PATH}" "${EXCL_FIND[@]}" -type f -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 | wc -l)"
|
||||
|
||||
# Ends module and saves status into log - $COUNT_FINDINGS has to be replaced by a number of your findings. If your module didn't found something, then it isn't needed to be generated in the final report
|
||||
# Required!
|
||||
@@ -81,7 +81,7 @@ sub_module() {
|
||||
# Create submodules inside of a module for better structure
|
||||
sub_module_title "Submodule example"
|
||||
|
||||
print_output "[*] local TESTVAR1_: $TESTVAR1_"
|
||||
print_output "[*] local TESTVAR1_: ${TESTVAR1_}"
|
||||
|
||||
# Analyze stuff ...
|
||||
}
|
||||
@@ -139,7 +139,7 @@ print_examples() {
|
||||
|
||||
path_handling() {
|
||||
# Firmware path - use this variable:
|
||||
print_output "$FIRMWARE_PATH"
|
||||
print_output "${FIRMWARE_PATH}"
|
||||
|
||||
# Print paths (standardized) with permissions and owner
|
||||
# e.g. /home/linux/firmware/var/etc (drwxr-xr-x firmware firmware)
|
||||
@@ -158,14 +158,14 @@ path_handling() {
|
||||
# Option 1: Search with find and loop trough results / don't use mod_path!
|
||||
# Insert "${EXCL_FIND[@]}" in your search-command to automatically remove excluded paths
|
||||
local CHECK=0
|
||||
readarray -t TEST < <( find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -iname '*xy*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
readarray -t TEST < <( find "${FIRMWARE_PATH}" -xdev "${EXCL_FIND[@]}" -iname '*xy*' -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
|
||||
for TEST_E in "${TEST[@]}"; do
|
||||
if [[ -f "$MP_DIR" ]] ; then
|
||||
if [[ -f "${MP_DIR}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found ""$(print_path "$TEST_E")"
|
||||
print_output "[+] Found ""$(print_path "${TEST_E}")"
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No modprobe.d directory found"
|
||||
fi
|
||||
|
||||
@@ -176,24 +176,24 @@ path_handling() {
|
||||
mapfile -t TEST_PATHS < <(mod_path "/ETC_PATHS/xy.cfg")
|
||||
|
||||
for TEST_E in "${TEST_PATHS[@]}" ; do
|
||||
if [[ -f "$TEST_E" ]] ; then
|
||||
if [[ -f "${TEST_E}" ]] ; then
|
||||
CHECK=1
|
||||
print_output "[+] Found xy config: ""$(print_path "$TEST_E")"
|
||||
print_output "[+] Found xy config: ""$(print_path "${TEST_E}")"
|
||||
fi
|
||||
done
|
||||
if [[ $CHECK -eq 0 ]] ; then
|
||||
if [[ ${CHECK} -eq 0 ]] ; then
|
||||
print_output "[-] No xy configuration file found"
|
||||
fi
|
||||
|
||||
# Using multiple paths as array:
|
||||
mapfile -t TEST_PATHS_ARR < <(mod_path_array "$(config_list "$CONFIG_DIR""/test_files.cfg" "")")
|
||||
mapfile -t TEST_PATHS_ARR < <(mod_path_array "$(config_list "${CONFIG_DIR}""/test_files.cfg" "")")
|
||||
|
||||
if [[ "${TEST_PATHS_ARR[0]}" == "C_N_F" ]] ; then
|
||||
print_output "[!] Config not found"
|
||||
elif [[ "${#TEST_PATHS_ARR[@]}" -ne 0 ]] ; then
|
||||
for TEST_E in "${TEST_PATHS_ARR[@]}"; do
|
||||
if [[ -f "$TEST_E" ]] ; then
|
||||
print_output "[+] Found: ""$(print_path "$TEST_E")"
|
||||
if [[ -f "${TEST_E}" ]] ; then
|
||||
print_output "[+] Found: ""$(print_path "${TEST_E}")"
|
||||
fi
|
||||
done
|
||||
else
|
||||
@@ -206,7 +206,7 @@ iterate_binary() {
|
||||
local BIN_FILE=""
|
||||
|
||||
for BIN_FILE in "${BINARIES[@]}"; do
|
||||
print_output "$BIN_FILE"
|
||||
print_output "${BIN_FILE}"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -231,10 +231,10 @@ webreport_functions() {
|
||||
}
|
||||
|
||||
load_from_config() {
|
||||
# config_grep.cfg contains grep statements, these will be all used for grepping "$FILE_PATH"
|
||||
# config_grep.cfg contains grep statements, these will be all used for grepping "${FILE_PATH}"
|
||||
local OUTPUT=""
|
||||
local OUTPUT_LINES=()
|
||||
mapfile -t OUTPUT_LINES < <(config_grep "$CONFIG_DIR""/config_grep.cfg" "$FILE_PATH")
|
||||
mapfile -t OUTPUT_LINES < <(config_grep "${CONFIG_DIR}""/config_grep.cfg" "${FILE_PATH}")
|
||||
|
||||
if [[ "${OUTPUT_LINES[0]}" == "C_N_F" ]] ; then
|
||||
print_output "[!] Config not found"
|
||||
@@ -243,8 +243,8 @@ load_from_config() {
|
||||
print_output "[+] Found ""${#OUTPUT_LINES[@]}"" files:"
|
||||
|
||||
for OUTPUT in "${OUTPUT_LINES[@]}"; do
|
||||
if [[ -f "$OUTPUT" ]] ; then
|
||||
print_output "$(print_path "$OUTPUT")"
|
||||
if [[ -f "${OUTPUT}" ]] ; then
|
||||
print_output "$(print_path "${OUTPUT}")"
|
||||
fi
|
||||
done
|
||||
else
|
||||
@@ -254,7 +254,7 @@ load_from_config() {
|
||||
|
||||
# config_list.cfg contains text, you get an array
|
||||
local OUTPUT_LINES=()
|
||||
mapfile -t OUTPUT_LINES < <(config_list "$CONFIG_DIR""/config_list.cfg")
|
||||
mapfile -t OUTPUT_LINES < <(config_list "${CONFIG_DIR}""/config_list.cfg")
|
||||
|
||||
if [[ "${OUTPUT_LINES[0]}" == "C_N_F" ]] ; then
|
||||
print_output "[!] Config not found"
|
||||
@@ -263,8 +263,8 @@ load_from_config() {
|
||||
print_output "[+] Found ""${#OUTPUT_LINES[@]}"" files:"
|
||||
|
||||
for OUTPUT in "${OUTPUT_LINES[@]}"; do
|
||||
if [[ -f "$OUTPUT" ]] ; then
|
||||
print_output "$(print_path "$OUTPUT")"
|
||||
if [[ -f "${OUTPUT}" ]] ; then
|
||||
print_output "$(print_path "${OUTPUT}")"
|
||||
fi
|
||||
done
|
||||
else
|
||||
@@ -275,14 +275,14 @@ load_from_config() {
|
||||
# Find files with search parameters (wildcard * is allowed)
|
||||
local OUTPUT_LINES=()
|
||||
local LINE=""
|
||||
readarray -t OUTPUT_LINES < <(printf '%s' "$(config_find "$CONFIG_DIR""/config_find.cfg")")
|
||||
readarray -t OUTPUT_LINES < <(printf '%s' "$(config_find "${CONFIG_DIR}""/config_find.cfg")")
|
||||
|
||||
if [[ "${OUTPUT_LINES[0]}" == "C_N_F" ]] ; then print_output "[!] Config not found"
|
||||
elif [[ ${#OUTPUT_LINES[@]} -ne 0 ]] ; then
|
||||
print_output "[+] Found ""${#OUTPUT_LINES[@]}"" files:"
|
||||
for LINE in "${OUTPUT_LINES[@]}" ; do
|
||||
if [[ -f "$LINE" ]] ; then
|
||||
print_output "$(indent "$(orange "$(print_path "$LINE")")")"
|
||||
if [[ -f "${LINE}" ]] ; then
|
||||
print_output "$(indent "$(orange "$(print_path "${LINE}")")")"
|
||||
fi
|
||||
done
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user