Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
HaiSoft (public)
Plesk - Mail Password Checker
Commits
4d4a8c40
Unverified
Commit
4d4a8c40
authored
Nov 21, 2017
by
UltimateByte
Committed by
GitHub
Nov 21, 2017
Browse files
Ability to display mutliple reasons
parent
e4161a4b
Changes
1
Show whitespace changes
Inline
Side-by-side
plesk_mail_password_check.sh
View file @
4d4a8c40
...
...
@@ -13,10 +13,10 @@
check_length
=
"on"
# Is the password long enough or not
check_password_selfname
=
"on"
# Is the mail name the password or not
check_password_domain
=
"on"
# Is the domain name the password or not
check_password_charset
=
"o
n
"
check_password_charset
=
"o
ff
"
# Strengh
passwordlength
=
"
4
"
passwordlength
=
"
5
"
##############
### Script ###
...
...
@@ -32,18 +32,30 @@ if [ ! -f "ultimate-bash-api.sh" ]; then
fi
source
ultimate-bash-api.sh
# If Plesk is
installe
d, then write all credentials into check_auth.txt
# If Plesk is
auth view is foun
d, then write all credentials into check_auth.txt
if
[
-f
"/usr/local/psa/admin/bin/mail_auth_view"
]
;
then
fn_logecho
"Writing password list"
/usr/local/psa/admin/bin/mail_auth_view |
grep
"|"
|
tail
-n
+2
>
check_auth.txt
else
fn_logecho
"Cannot find mail_auth_view from Plesk, skipping writing password list"
fn_logecho
"[ERROR] Cannot find mail_auth_view from Plesk"
exit
1
fi
# Add reason to test result
fn_add_reason
(){
}
# Analyzes result of the last test and takes action
fn_last_test_result
(){
if
[
"
${
test
}
"
==
"fail"
]
;
then
error+
=(
"[NOT SECURE] |
${
mailaddress
}
|
${
reason
}
|
${
mailpassword
}
"
)
# No reason yet
if
[
-z
"
${
reasons
}
"
]
;
then
reasons
=
"
${
reason
}
"
else
# Reasons already exist for the domain, add other ones
reasons
=
"
${
reasons
}
;
${
reason
}
"
fi
fi
}
...
...
@@ -90,38 +102,49 @@ if [ "${check_password_domain}" == "on" ]; then
fn_last_test_result
fi
}
# Check if charset is rich enough
# NOT READY YET
fn_check_password_charset
(){
if
[
"
${
check_password_charset
}
"
==
on
]
;
then
if
[
"
${
check_password_charset
}
"
==
"
on
"
]
;
then
if
[
"
${
mailpassword
}
"
]
;
then
test
=
"fail"
reason
=
"Password is domain name"
else
test
=
"pass"
fi
fn_last_test_result
fi
}
# Run all the checks
fn_check_password_global
(){
unset
reasons
fn_check_password_length
fn_check_password_selfname
fn_check_password_domain
fn_check_password_charset
}
#
C
heck for bad passwords
#
Actually c
heck for bad passwords
if
[
-f
"check_auth.txt"
]
;
then
# Loop through all mail address
while
read
-r
line
;
do
# Get mail address and password into variables
mailaddress
=
"
$(
echo
"
${
line
}
"
|
awk
'{print $2}'
)
"
mailpassword
=
"
$(
echo
"
${
line
}
"
|
awk
-F
"|"
'{print $4}'
|
awk
'{print $1}'
)
"
fn_echo
"Testing:
${
mailaddress
}
"
fn_check_password_global
if
[
-n
"
${
reasons
}
"
]
;
then
error+
=(
"[NOT SECURE] |
${
mailaddress
}
|
${
mailpassword
}
|
${
reasons
}
"
)
fi
done
< <
(
cat
check_auth.txt
)
fi
echo
""
# Display
error
s
# Display
unsecured mail addresse
s
for
((
index
=
0
;
index <
${#
error
[@]
}
;
index++
))
;
do
echo
-en
"
${
error
[index]
}
\n
"
done
...
...
@@ -129,3 +152,4 @@ done
if
[
-f
"check_auth.txt"
]
;
then
rm
-f
check_auth.txt
fi
fn_duration
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment