kospay/pay/www/getid.xjs

152 lines
4.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
while read kos
do
[ "${#kos}" -le "1" ]&&break;
koss="$kos
$koss"
done
[ "$conntyp" = "POST" ]&&{
ck=($(echo "$koss"|awk -F'[|:]' '{IGNORECASE=1}$1=="Cookie"{print $3}'))
sqlstart="SELECT passd,grups,isok,feilv,ckuser,ckname,ckkey FROM user WHERE userid = '${ck[2]}'"
dada="$($MYSQLS -e "$sqlstart" 2>>$0.errlog)"
sdata=($dada)
cksec=${ck[4]}
yunse=$(echo -n "$REMOTE_HOST${sdata[2]}${sdata[1]}${ck[2]}${sdata[0]}${dateddd:0:6}"|md5sum|tr -dc [0-9])
[ "$yunse" = "$cksec" ]||{
echo "HTTP/1.1 200 ok
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: private
Server: kos-1.0
Content-Language:zh-CN,zh
Content-Type: text/plain;charset=utf-8
noes"
exit 0
}
nn=$(echo "$koss"|awk '{IGNORECASE=1}/Content-Length:/{gsub("\r","",$2);print$2}')
[ "$nn" != "34" ]&&exit 0
read -N$nn hhhkkkk
zfid=$(cat ${rpath}/getid/$hhhkkkk 2>/dev/null)
[ ${#zfid} -ge 16 ]&&echo "HTTP/1.1 200 ok
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: private
Server: kos-1.0
Access-Control-Expose-Headers: zfid
zfid: $zfid
Content-Language:zh-CN,zh
Content-Type: text/plain;charset=utf-8
okay"||echo "HTTP/1.1 200 ok
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: private
Server: kos-1.0
Content-Language:zh-CN,zh
Content-Type: text/plain;charset=utf-8
wait"
}||{
eval $(echo -e ${1//&/\\n}|awk -F\= '$1=="code"||$1=="state"||$1=="auth_code"{gsub("[^0-9a-zA-Z]","",$2);printf $1"=\047"$2"\047;"}')
[ ${#auth_code} -ge 32 -a "${state:0:2}" = "al" -a "$(echo "$koss"|grep -i "^User-Agent:.*AlipayClient")" ]&&{
urlencode() {
local LANG=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}
app_id='2019051765009318'
timestamp="$(date "+%F %T")"
wait_sign="app_id=$app_id&charset=utf-8&code=$auth_code&grant_type=authorization_code&method=alipay.system.oauth.token&sign_type=RSA2&timestamp=$timestamp&version=1.0"
sign="$(echo -n "$wait_sign"|openssl dgst -sign $rpath/ca/${app_id}_private.pem -SHA256 |base64|tr -d '\n')"
sign="$(urlencode "$sign")"
redata="$(wget -qO- -t3 -T3 -UUOSBOX "https://openapi.alipay.com/gateway.do?$wait_sign&sign=$sign")"
user_id="$(echo -e "${redata//[\}\{\,]/\\n}"|awk -F\" '$2=="user_id"{print $4}')"
[ "$user_id" ]&&{
ttit="个人支付宝收款ID获取成功"
bbd="<h3>您的支付宝收款ID为</h3>
<h4>【$user_id】</h4>
<h3>请认真核对!</h3>"
echo "$user_id" >${rpath}/getid/$state
}
}
[ ${#code} -ge 32 -a "${state:0:2}" = "wx" -a "$(echo "$koss"|grep -i "^User-Agent:.*MicroMessenger")" ]&&{
appid='a'
sec='b'
redata="$(wget -qO- -t3 -T3 -UUOSBOX "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$sec&code=$code&grant_type=authorization_code")"
user_id="$(echo -e "${redata//[\}\{\,]/\\n}"|awk -F\" '$2=="openid"{print $4}')"
access_token="$(echo -e "${redata//[\}\{\,]/\\n}"|awk -F\" '$2=="access_token"{print $4}')"
wget -qO- -t3 -T3 -UUOSBOX "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$user_id&lang=zh_CN"
[ "$user_id" ]&&{
ttit="个人微信收款ID获取成功"
bbd="<h3>您的微信收款ID为</h3>
<h4>【$user_id】</h4>
<h3>请认真核对!</h3>"
echo "$user_id" >${rpath}getid/$state
}
}
echo "HTTP/1.1 200 ok
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: private
Server: kos-1.0
Content-Language:zh-CN,zh
Content-Type: text/html;charset=utf-8
<!DOCTYPE html>
<html>
<head>
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />
<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">
<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">
<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\">
<meta name=\"format-detection\" content=\"telephone=no\">
<title>${ttit:-请重新扫码}</title>
<style>
body{
background-color:#444;
font-size:14px;
}
h3{
font-size:30px;
color:#eee;
text-align:center;
padding-top:30px;
font-weight:normal;
}
h4{
font-size:15px;
color:#eee;
text-align:center;
padding-top:30px;
font-weight:normal;
}
</style>
</head>
<body>
${bbd:-<h3>请重新扫码</h3>}
</body>
</html>
"
}