Release Notes: Enhanced Web App Architecture: - Optimized the structure for better scalability and maintainability. - Refined Data Fetching Logic: Improved the efficiency and reliability of data retrieval processes. - Optimized AT Terminal: Enhanced functionality for smoother interaction with AT commands. - Revamped UI/UX Design: Streamlined user interface and experience for improved accessibility and usability. New Features: - MTU Settings: Added customizable Maximum Transmission Unit (MTU) settings. - APN and IMEI Profiles: Introduced the ability to configure APN and IMEI profiles for better device management. - Persistent Cell Locking: Added native support for persistent cell locking, ensuring consistent network connections. - QuecWatch: Connection monitoring with auto reconnect and reboot settable Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
46 lines
1.3 KiB
Bash
Executable File
46 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Set Content-Type for CGI script
|
|
echo "Content-type: application/json"
|
|
echo ""
|
|
|
|
# Read POST data
|
|
read POST_DATA
|
|
|
|
# Debug log for generated hash
|
|
DEBUG_LOG = "/tmp/auth.log"
|
|
|
|
# Extract the password from POST data (URL encoded)
|
|
USER="root"
|
|
INPUT_PASSWORD=$(echo "$POST_DATA" | sed -n 's/^.*password=\([^&]*\).*$/\1/p')
|
|
|
|
# URL-decode the password (replace + with space and decode %XX)
|
|
INPUT_PASSWORD=$(echo "$INPUT_PASSWORD" | sed 's/+/ /g;s/%\(..\)/\\x\1/g' | xargs -0 printf "%b")
|
|
|
|
# Extract the hashed password from /etc/shadow for the specified user
|
|
USER_SHADOW_ENTRY=$(grep "^$USER:" /etc/shadow)
|
|
|
|
if [ -z "$USER_SHADOW_ENTRY" ]; then
|
|
echo '{"state":"failed", "message":"User not found"}'
|
|
exit 1
|
|
fi
|
|
|
|
# Extract the password hash (it's the second field, colon-separated)
|
|
USER_HASH=$(echo "$USER_SHADOW_ENTRY" | cut -d: -f2)
|
|
|
|
# Extract the salt (MD5 uses the $1$ prefix followed by the salt)
|
|
SALT=$(echo "$USER_HASH" | cut -d'$' -f3)
|
|
|
|
# Generate a hash from the input password using the same salt
|
|
GENERATED_HASH=$(echo "$INPUT_PASSWORD" | openssl passwd -1 -salt "$SALT" -stdin)
|
|
|
|
# Log generated hash for debugging
|
|
echo "Generated hash: $GENERATED_HASH" >> $DEBUG_LOG
|
|
|
|
# Compare the generated hash with the one in the shadow file
|
|
if [ "$GENERATED_HASH" = "$USER_HASH" ]; then
|
|
echo '{"state":"success"}'
|
|
else
|
|
echo '{"state":"failed"}'
|
|
fi
|