'curl-authchecker.md' toevoegen
This commit is contained in:
72
curl-authchecker.md
Normal file
72
curl-authchecker.md
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
## curl keeps asking for password until correct, and downloads file
|
||||||
|
|
||||||
|
```
|
||||||
|
function getcurlsec {
|
||||||
|
|
||||||
|
local curlurl="$1"
|
||||||
|
local curluser="$2"
|
||||||
|
local curloutput="$3"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
curl --fail --user "$curluser" "$curlurl" -o "$curloutput"
|
||||||
|
local EC=$?
|
||||||
|
if [ $EC -eq 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Syntax: `getcurlsec <url to download> <username> <output file>`
|
||||||
|
|
||||||
|
|
||||||
|
## curl downloads file using given credentials
|
||||||
|
|
||||||
|
```
|
||||||
|
function getcurlsecwpassword {
|
||||||
|
|
||||||
|
local curlurl="$1"
|
||||||
|
local curluser="$2"
|
||||||
|
local curlpassword="$3"
|
||||||
|
local curloutput="$4"
|
||||||
|
curl --fail --user "$curluser":"curlpassword" "$curlurl" -o "$curloutput"
|
||||||
|
local EC=$?
|
||||||
|
if [ $EC -eq 0 ]; then
|
||||||
|
echo "Password correct"
|
||||||
|
else
|
||||||
|
echo "Password incorrect"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Syntax: `getcurlsecwpassword <url to download> <username> <password> <output file>`
|
||||||
|
|
||||||
|
|
||||||
|
## curl keeps asking for password until correct, and stores username and password as var
|
||||||
|
|
||||||
|
```
|
||||||
|
function checkusercurl {
|
||||||
|
|
||||||
|
local curlurl="$1"
|
||||||
|
curluser="$2"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -s -p "Enter password for user $curluser: " curlpassword
|
||||||
|
echo "";
|
||||||
|
curl -s --fail --user "$curluser":"$curlpassword" "$curlurl" -o /dev/null
|
||||||
|
local EC=$?
|
||||||
|
if [ $EC -eq 0 ]; then
|
||||||
|
echo "Password correct"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Incorrect password"
|
||||||
|
unset curlpassword
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Syntax: `checkusercurl <url to authenticate against> <username>`
|
||||||
|
username wil become var: curluser
|
||||||
|
password wil become var: $curlpassword
|
||||||
Reference in New Issue
Block a user