Skip to content

Instantly share code, notes, and snippets.

@kerus1024
Created April 23, 2021 15:28
Show Gist options
  • Save kerus1024/d5de3bc04c36743e1663dfecc2c57bd0 to your computer and use it in GitHub Desktop.
Save kerus1024/d5de3bc04c36743e1663dfecc2c57bd0 to your computer and use it in GitHub Desktop.
KT carrier reset (BASH)
#!/bin/bash
COOKIEJAR1='./tmp_cookie.tmp'
rm -f $COOKIEJAR1
touch $COOKIEJAR1
if [ "$?" -ne 0 ]; then
echo "uanble to access $COOKIEJAR1 file."
exit 1
fi
GETDATA1=`curl -sL -o /dev/null -w %{url_effective} http://access.olleh.com`
ENDPOINT_SCHEME=`echo $GETDATA1 | awk -F[/] '{ print $1 }'`
ENDPOINT_HOSTNAME=`echo $GETDATA1 | awk -F[/] '{ print $3 }'`
ENDPOINT="$ENDPOINT_SCHEME//$ENDPOINT_HOSTNAME"
if [[ ! $ENDPOINT =~ internet.kt.com ]]; then
echo "Cannot find kt signature..."
exit 1
fi
GETDATA2=`curl -sL --cookie-jar $COOKIEJAR1 $GETDATA1`
if [ "$?" -ne 0 ]; then
echo "unknown error"
exit 1
fi
PAGE_REQURI=`printf '%s' "$GETDATA2" | grep -oP "reset_id_confirm_msg\\('\/\K[^\']+"`
GETDATA3=`curl -sL --cookie $COOKIEJAR1 $ENDPOINT/$PAGE_REQURI`
USER_sso=`echo $PAGE_REQURI | sed -E 's/.*sso=([^,]*)&.*/\1/'`
USER_no=`echo $PAGE_REQURI | sed -E 's/.*&no=([^,]*).*/\1/'`
USER_ID=reset
USER_PW=reset1
if [ "$?" -ne 0 ] || [ $USER_sso = "" ] || [ $USER_no = "" ]; then
echo "unknown error2"
exit 1
fi
BODYDATA="userID=$USER_ID&userPW=$USER_PW&sso=$USER_sso&no=$USER_no"
POSTDATA=`curl -sL -X POST --cookie $COOKIEJAR1 -o /dev/null -w %{url_effective} -H "Referer: $ENDPOINT/$PAGE_REQURI" -d $BODYDATA $ENDPOINT/reauth_said.html`
rm -f $COOKIEJAR1
if [[ $POSTDATA =~ LOGIN_RESET_SUCCESS ]]; then
echo "Success"
exit 0
else
echo "error"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment