Skip to content

Commit

Permalink
Merge pull request #2520 from gemesa/shellcheck3
Browse files Browse the repository at this point in the history
test-airbase-ng-0002.sh: fix shellcheck findings (missing double quotes)
  • Loading branch information
Mister-X- committed Mar 14, 2023
2 parents 0d97047 + d8688f7 commit 648f7bf
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions test/test-airbase-ng-0002.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ airmon_ng_check
finish() {
cleanup
if [ -n "${AB_PID}" ]; then
is_pid_running ${AB_PID}
[ $? -eq 1 ] && kill -9 ${AB_PID}
is_pid_running "${AB_PID}"
[ $? -eq 1 ] && kill -9 "${AB_PID}"
fi
[ -n "${AB_TEMP}" ] && rm -f ${AB_TEMP}
[ -n "${AB_PCAP}" ] && rm -f ${AB_PCAP}
[ -n "${AB_TEMP}" ] && rm -f "${AB_TEMP}"
[ -n "${AB_PCAP}" ] && rm -f "${AB_PCAP}"
}

trap finish INT QUIT SEGV PIPE ALRM TERM EXIT
Expand All @@ -46,9 +46,9 @@ WI_IFACE2=${IFACE}


# Put other interface in monitor mode
set_monitor_mode ${WI_IFACE2}
set_monitor_mode "${WI_IFACE2}"
[ $? -eq 1 ] && exit 1
set_interface_channel ${WI_IFACE2} ${CHANNEL}
set_interface_channel "${WI_IFACE2}" ${CHANNEL}
[ $? -eq 1 ] && exit 1

# Run airbase-ng in the background
Expand All @@ -57,9 +57,9 @@ AB_TEMP=$(mktemp -u)
-W 1 \
-z 2 \
-e "${SSID}" \
-F $(mktemp -u) \
${WI_IFACE2} \
2>&1 >${AB_TEMP} \
-F "$(mktemp -u)" \
"${WI_IFACE2}" \
2>&1 >"${AB_TEMP}" \
&

AB_PID=$!
Expand All @@ -75,7 +75,7 @@ fi
PSK=password
TEMP_WPAS_CONF=$(mktemp)
ENCRYPT="TKIP"
cat >> ${TEMP_WPAS_CONF_FILE} << EOF
cat >> "${TEMP_WPAS_CONF_FILE}" << EOF
network={
ssid="${SSID}"
psk="${PSK}"
Expand All @@ -88,11 +88,11 @@ network={
EOF

# Set interface up
set_interface_channel ${WI_IFACE} ${CHANNEL}
set_interface_channel "${WI_IFACE}" ${CHANNEL}
[ $? -eq 1 ] && exit 1

# Start wpa_supplicant
run_wpa_supplicant ${TEMP_WPAS_CONF_FILE} ${WI_IFACE}
run_wpa_supplicant "${TEMP_WPAS_CONF_FILE}" "${WI_IFACE}"

# Wait for authentication then kill wpa supplicant
sleep 6
Expand All @@ -103,21 +103,21 @@ sleep 2
kill -9 ${AB_PID}

# Check Airbase-ng output
AB_PCAP="$(${GREP} 'Created capture file' ${AB_TEMP} | ${AWK} -F\" '{print $2}')"
CLIENT_CONNECT=$(${GREP} Client ${AB_TEMP} | ${GREP} ${ENCRYPT} | wc -l)
AB_PCAP="$(${GREP} 'Created capture file' "${AB_TEMP}" | ${AWK} -F\" '{print $2}')"
CLIENT_CONNECT=$(${GREP} Client "${AB_TEMP}" | ${GREP} ${ENCRYPT} | wc -l)

# Some cleanup
rm -f ${AB_TEMP}
rm -f "${AB_TEMP}"
cleanup

if [ ${CLIENT_CONNECT} -eq 0 ]; then
if [ "${CLIENT_CONNECT}" -eq 0 ]; then
echo "Client failed to connect to AP - possibly incorrect encryption"
exit 1
fi

# Crack the capture
timeout 60 "${abs_builddir}/../aircrack-ng${EXEEXT}" \
${AIRCRACK_NG_ARGS} \
"${AIRCRACK_NG_ARGS}" \
-w "${abs_srcdir}/password.lst" \
-a 2 \
-e "${SSID}" \
Expand All @@ -131,7 +131,7 @@ if [ ${RET} -eq 1 ]; then
echo "Failed cracking passphrase, PCAP: ${AB_PCAP}"
else
# Cleanup PCAP
rm -f ${AB_PCAP}
rm -f "${AB_PCAP}"
fi

# Cleanup
Expand Down

0 comments on commit 648f7bf

Please sign in to comment.