Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L10 improvements, more services #454

Merged
merged 2 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion emba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ main()
mkdir "$LOG_DIR" || true
fi
# check_kconfig
print_output "[!] Currently not supported"
print_output "[!] Currently not supported" "no_log"
exit 0
fi
fi
Expand Down
9 changes: 8 additions & 1 deletion modules/L10_system_emulation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ get_networking_details_emulation() {
mapfile -t NVRAM < <(grep -a "\[NVRAM\] " "$LOG_PATH_MODULE"/qemu.initial.serial.log | awk '{print $3}' | grep -E '[[:alnum:]]{3,50}' | sort -u || true)
# mapfile -t NVRAM_SET < <(grep -a "nvram_set" "$LOG_PATH_MODULE"/qemu.initial.serial.log | cut -d: -f2 | sed 's/^\ //g' | cut -d\ -f1 | sed 's/\"//g' | grep -v "^#" | grep -E '[[:alnum:]]{3,50}'| sort -u || true)
# we check all available qemu logs for services that are started:
mapfile -t PORTS < <(grep -a "inet_bind" "$LOG_PATH_MODULE"/qemu.*serial*.log | sed 's/.*inet_bind\[PID:\ //' | sort -u || true)
mapfile -t PORTS < <(grep -a "inet_bind" "$LOG_PATH_MODULE"/qemu.*serial*.log | sed -E 's/.*inet_bind\[PID:\ [0-9]+\ //' | sort -u || true)
mapfile -t VLAN_HW_INFO_DEV < <(grep -a -E "adding VLAN [0-9] to HW filter on device eth[0-9]" "$LOG_PATH_MODULE"/qemu.initial.serial.log | awk -F\ '{print $NF}' | sort -u || true)

NVRAM_TMP=( "${NVRAM[@]}" )
Expand Down Expand Up @@ -1337,6 +1337,13 @@ iterate_vlans() {
VLAN_ID="NONE"
fi
store_interface_details "$IP_ADDRESS_" "$NETWORK_DEVICE" "$ETH_INT" "$VLAN_ID" "$NETWORK_MODE"

# check this later
# store_interface_details "$IP_ADDRESS_" "$NETWORK_DEVICE" "eth0" "$VLAN_ID" "$NETWORK_MODE"
# store_interface_details "$IP_ADDRESS_" "$NETWORK_DEVICE" "eth0" "NONE" "$NETWORK_MODE"
# store_interface_details "$IP_ADDRESS_" "$NETWORK_DEVICE" "eth1" "$VLAN_ID" "$NETWORK_MODE"
# store_interface_details "$IP_ADDRESS_" "$NETWORK_DEVICE" "eth1" "NONE" "$NETWORK_MODE"

# if we have entries without an interface name, we need to identify an interface name:
# register_vlan_dev[PID: 212 (vconfig)]: dev:vlan1 vlan_id:1
# for this we try to check the qemu output for vlan entries and generate the configuration entry
Expand Down
29 changes: 26 additions & 3 deletions modules/L10_system_emulation/inferService.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ fi
# twonkystarter: F9K1119_WW_1.00.01.bin

for BINARY in $("${BUSYBOX}" find / -name "lighttpd" -type f -o -name "upnp" -type f -o -name "upnpd" -type f \
-o -name "telnetd" -type f -o -name "mini_httpd" -type f -o -name "miniupnpd" -type f -o -name "twonkystarter" -type f \
-o -name "httpd" -type f -o -name "goahead" -type f -o -name "alphapd" -type f -o -name "uhttpd" -type f -o -name "miniigd" -type f \
-o -name "ISS.exe" -type f -o -name "ubusd" -type f); do
-o -name "telnetd" -type f -o -name "mini_httpd" -type f -o -name "miniupnpd" -type f -o -name "mini_upnpd" -type f \
-o -name "twonkystarter" -type f -o -name "httpd" -type f -o -name "goahead" -type f -o -name "alphapd" -type f \
-o -name "uhttpd" -type f -o -name "miniigd" -type f -o -name "ISS.exe" -type f -o -name "ubusd" -type f \
-o -name "wscd" -type f -o -name "ftpd" -type f -o -name "11N_UDPserver" -type f); do

if [ -x "${BINARY}" ]; then
SERVICE_NAME=$("${BUSYBOX}" basename "${BINARY}")
# entry for lighttpd:
Expand All @@ -80,6 +82,27 @@ for BINARY in $("${BUSYBOX}" find / -name "lighttpd" -type f -o -name "upnp" -ty
"${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 service 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 service 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 service 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 service 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
Expand Down
2 changes: 1 addition & 1 deletion modules/L10_system_emulation/run_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if ("${FIRMAE_ETC}"); then
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 ..."
"${BINARY}" &
${BINARY} &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this on purpose

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ... otherwise the parameters of some commands are not working

"${BUSYBOX}" sleep 5
"${BUSYBOX}" echo "[*] Netstat output ..."
"${BUSYBOX}" netstat -antu
Expand Down