Last active
January 12, 2017 06:35
-
-
Save caiguanhao/7ea77a80e05224babe2a075874f925d7 to your computer and use it in GitHub Desktop.
shell script to buy HYR products (requires curl, jq, openssl)
This file contains hidden or 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 | |
set -e | |
KEY=b79ff42fc9d045aed383243a | |
TOKEN_KEY=6y9d6e9332f5428e89d2f8c2 | |
IV=24sddexs | |
PREFIX='{"app_version": "iPhone[10.2]", "app_from_type": "3", "app_version_mark": "3.1.0"' | |
USERAGENT='HengYiRong3.0/3.1.0.5 CFNetwork/808.2.16 Darwin/16.3.0' | |
KEY=$(echo -n $KEY | xxd -ps -c32) | |
TOKEN_KEY=$(echo -n $TOKEN_KEY | xxd -ps -c32) | |
IV=$(echo -n $IV | xxd -ps -c32) | |
request() { | |
token=$(echo "hengyirong-$(date +%s)-0" | openssl des-ede3-cbc -e -a -A -nopad -K $TOKEN_KEY -iv $IV) | |
input="$3" | |
while test $((${#input} % 8)) -ne 0; do | |
input="$input " | |
done | |
signature=$(echo -n "$input" | openssl des-ede3-cbc -e -a -A -nopad -K $KEY -iv $IV) | |
response=$(curl --max-time 5 --retry 5 --retry-delay 0 --retry-max-time 30 -s -A USERAGENT $1 \ | |
--data-urlencode "Token=$token" \ | |
--data-urlencode "Signature=$signature" \ | |
--data-urlencode "Key=$2" \ | |
--data-urlencode "Mcrypt=2.0") | |
decrypted=$(echo "$response" | openssl des-ede3-cbc -d -a -A -nopad -K $KEY -iv $IV) | |
} | |
buy() { | |
cellphone=$1 | |
password=$2 | |
money=$3 | |
case "$4" in | |
3年) dlbid=106 ;; | |
2年) dlbid=105 ;; | |
1.5年) dlbid=104 ;; | |
1年) dlbid=103 ;; | |
0.5年) dlbid=102 ;; | |
0.25年) dlbid=101 ;; | |
*) | |
echo "bad dlbid" | |
exit 1 | |
esac | |
case "$5" in | |
*复投) investway=1 ;; | |
*返还) investway=2 ;; | |
*) | |
echo "bad investway" | |
exit 1 | |
esac | |
json='"Num": "10022", "Control": "login", "islogin": "0", "usertype": "1"' | |
json="$PREFIX, $json, \"userpwd\": \"$(echo -n "${password:0:12}xxxxxxx" | openssl dgst -sha1 -binary | xxd -p)\", \"username\": \"$cellphone\"}" | |
request 'https://appport.hengyirong.com/2-0-0/index.php?r=user/login' "(null)" "$json" | |
if test "$(echo $decrypted | jq -r .code)" -ne 200; then | |
echo "[$cellphone]" $response | |
echo $decrypted | jq . | |
else | |
echo "[$cellphone]" $(echo $decrypted | jq -r .msg) | |
key=$(echo -n $(echo $decrypted | jq -r .yzm) | openssl dgst -md5 -binary | xxd -p) | |
uid=$(echo $decrypted | jq -r .data.id) | |
json='"Num": "10016", "Control": "confirmationpay"' | |
json="$PREFIX, $json, \"uid\": \"$uid\", \"dlbid\": \"$dlbid\", \"investway\": \"$investway\", \"money\": \"${money}.00\"}" | |
request 'https://appport.hengyirong.com/2-0-0/index.php?r=dlbpay/confirmationpay' "$key" "$json" | |
echo "[$cellphone]" $response | |
echo $decrypted | jq . | |
fi | |
} | |
buy 13812345678 password 10000 0.5年 收益返还 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment