-
-
Save marco79cgn/915cd223d702249c643ffa6fd68cf766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
userName="***" | |
password="***" | |
redirectResult=$(curl -s 'https://awsapi.future.smart.com/login-app/api/v1/authorize?uiLocales=de-DE&uiLocales=de-DE' \ | |
-H 'accept: */*' \ | |
-H 'accept-language: de-DE,de;q=0.9,en-DE;q=0.8,en-US;q=0.7,en;q=0.6' \ | |
-H 'x-requested-with: com.smart.hellosmart' \ | |
-H 'user-agent: Mozilla/5.0 (Linux; Android 9; ANE-LX1 Build/HUAWEIANE-L21; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/118.0.0.0 Mobile Safari/537.36' \ | |
--compressed) | |
redirectUrl=$(echo "$redirectResult" | cut -b 23-) | |
echo "Getting context..." | |
contextResult=$(curl -s --head $redirectUrl \ | |
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \ | |
-H 'accept-language: de-DE,de;q=0.9,en-DE;q=0.8,en-US;q=0.7,en;q=0.6' \ | |
-H 'x-requested-with: com.smart.hellosmart' \ | |
-H 'user-agent: Mozilla/5.0 (Linux; Android 9; ANE-LX1 Build/HUAWEIANE-L21; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/118.0.0.0 Mobile Safari/537.36') | |
location=$(echo "$contextResult" | grep location | cut -b 11-) | |
echo "Preparing login..." | |
loginResult=$(curl -s 'https://auth.smart.com/accounts.login' \ | |
-H 'accept: */*' \ | |
-H 'accept-language: de' \ | |
-H 'content-type: application/x-www-form-urlencoded' \ | |
-H 'x-requested-with: com.smart.hellosmart' \ | |
-H 'cookie: gmid=gmid.ver4.AcbHPqUK5Q.xOaWPhRTb7gy-6-GUW6cxQVf_t7LhbmeabBNXqqqsT6dpLJLOWCGWZM07EkmfM4j.u2AMsCQ9ZsKc6ugOIoVwCgryB2KJNCnbBrlY6pq0W2Ww7sxSkUa9_WTPBIwAufhCQYkb7gA2eUbb6EIZjrl5mQ.sc3; ucid=hPzasmkDyTeHN0DinLRGvw; hasGmid=ver4; gig_bootstrap_3_L94eyQ-wvJhWm7Afp1oBhfTGXZArUfSHHW9p9Pncg513hZELXsxCfMWHrF8f5P5a=auth_ver4' \ | |
-H 'origin: https://app.id.smart.com' \ | |
-H 'user-agent: Mozilla/5.0 (Linux; Android 9; ANE-LX1 Build/HUAWEIANE-L21; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/118.0.0.0 Mobile Safari/537.36' \ | |
--data-raw "loginID=${userName}&password=${password}&sessionExpiration=2592000&targetEnv=jssdk&include=profile%2Cdata%2Cemails%2Csubscriptions%2Cpreferences%2C&includeUserInfo=true&loginMode=standard&lang=de&APIKey=3_L94eyQ-wvJhWm7Afp1oBhfTGXZArUfSHHW9p9Pncg513hZELXsxCfMWHrF8f5P5a&source=showScreenSet&sdk=js_latest&authMode=cookie&pageURL=https%3A%2F%2Fapp.id.smart.com%2Flogin%3Fgig_ui_locales%3Dde-DE&sdkBuild=15482&format=json&riskContext=%7B%22b0%22%3A41187%2C%22b1%22%3A%5B0%2C2%2C3%2C1%5D%2C%22b2%22%3A4%2C%22b3%22%3A%5B%22-23%7C0.383%22%2C%22-81.33333587646484%7C0.236%22%5D%2C%22b4%22%3A3%2C%22b5%22%3A1%2C%22b6%22%3A%22Mozilla%2F5.0%20%28Linux%3B%20Android%209%3B%20ANE-LX1%20Build%2FHUAWEIANE-L21%3B%20wv%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Version%2F4.0%20Chrome%2F118.0.0.0%20Mobile%20Safari%2F537.36%22%2C%22b7%22%3A%5B%5D%2C%22b8%22%3A%2216%3A33%3A26%22%2C%22b9%22%3A-60%2C%22b10%22%3Anull%2C%22b11%22%3Afalse%2C%22b12%22%3A%7B%22charging%22%3Atrue%2C%22chargingTime%22%3Anull%2C%22dischargingTime%22%3Anull%2C%22level%22%3A0.58%7D%2C%22b13%22%3A%5B5%2C%22360%7C760%7C24%22%2Cfalse%2Ctrue%5D%7D" \ | |
--compressed | jq '.') | |
#echo $loginResult | |
loginToken=$(echo $loginResult | jq -r '.sessionInfo.login_token') | |
echo "Successfully obtained login token. Trying to authorize..." | |
context=$(echo "$location" | sed -E 's/.*context=([^&]+).*/\1/') | |
authUrl="https://auth.smart.com/oidc/op/v1.0/3_L94eyQ-wvJhWm7Afp1oBhfTGXZArUfSHHW9p9Pncg513hZELXsxCfMWHrF8f5P5a/authorize/continue?context=${context}&login_token=${loginToken}" | |
cookieValue="gmid=gmid.ver4.AcbHPqUK5Q.xOaWPhRTb7gy-6-GUW6cxQVf_t7LhbmeabBNXqqqsT6dpLJLOWCGWZM07EkmfM4j.u2AMsCQ9ZsKc6ugOIoVwCgryB2KJNCnbBrlY6pq0W2Ww7sxSkUa9_WTPBIwAufhCQYkb7gA2eUbb6EIZjrl5mQ.sc3; ucid=hPzasmkDyTeHN0DinLRGvw; hasGmid=ver4; gig_bootstrap_3_L94eyQ-wvJhWm7Afp1oBhfTGXZArUfSHHW9p9Pncg513hZELXsxCfMWHrF8f5P5a=auth_ver4; glt_3_L94eyQ-wvJhWm7Afp1oBhfTGXZArUfSHHW9p9Pncg513hZELXsxCfMWHrF8f5P5a=${loginToken}" | |
echo "cookieValue: $cookieValue" | |
authorize=$(curl -s --head $authUrl \ | |
--header "accept: */*" \ | |
--header "cookie: ${cookieValue}" \ | |
--header "accept-language: de-DE,de;q=0.9,en-DE;q=0.8,en-US;q=0.7,en;q=0.6" \ | |
--header "x-requested-with: com.smart.hellosmart" \ | |
--header "user-agent: Mozilla/5.0 (Linux; Android 9; ANE-LX1 Build/HUAWEIANE-L21; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/118.0.0.0 Mobile Safari/537.36" 2>&1) | |
authLocation=$(echo "$authorize" | grep "location: " | head -1 | cut -d" " -f2 | tr -cd "[:print:]") | |
tokenResult=$(curl -s ${authLocation} \ | |
--header "accept: */*" \ | |
--header "cookie: ${cookieValue}" \ | |
--header "accept-language: de-DE,de;q=0.9,en-DE;q=0.8,en-US;q=0.7,en;q=0.6" \ | |
--header "x-requested-with: com.smart.hellosmart" \ | |
--header "user-agent: Mozilla/5.0 (Linux; Android 9; ANE-LX1 Build/HUAWEIANE-L21; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/118.0.0.0 Mobile Safari/537.36" 2>&1) | |
echo $tokenResult | |
accessToken=$(echo $tokenResult |tr '?' '&' |cut -d'&' -f2 | sed 's/.*=//') | |
echo "accessToken: $accessToken" | |
echo -e $accessToken > accessToken | |
refreshToken=$(echo $tokenResult |tr '?' '&' |cut -d'&' -f4 | sed 's/.*=//') | |
echo "refreshToken: $refreshToken" | |
echo -e $refreshToken > refreshToken | |
echo "Token persisted, you are now logged in!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment