update for https, add php files
This commit is contained in:
parent
748499c021
commit
2cc105080a
33
README.md
33
README.md
|
@ -1,31 +1,30 @@
|
|||
# mcl
|
||||
|
||||
Minecraft launcher created out of dissatisfaction with other clients
|
||||
minecraft launcher for linux and maybe macos
|
||||
|
||||
## What's it do?
|
||||
## what does it do
|
||||
|
||||
- download many versions
|
||||
- download assets
|
||||
- download libraries
|
||||
|
||||
## What's it *not* do?
|
||||
|
||||
- set up natives
|
||||
- select the correct libraries for the version
|
||||
- set up natives (will only support linux)
|
||||
- get an authentication token (I will not support Mojang accounts)
|
||||
- get an authentication token (microsoft auth only)
|
||||
- instances
|
||||
- ...launch the game :/
|
||||
- launch the game
|
||||
|
||||
## Why not use the regular launcher?
|
||||
## what does it *not* do
|
||||
|
||||
- optifine, forge, etc
|
||||
- support external natives (openbsd, freebsd, etc)
|
||||
- windows support. i will not be adding this
|
||||
|
||||
## why not use the regular launcher
|
||||
|
||||
- closed source
|
||||
- really buggy, for some reason
|
||||
- I'd call it bloated but honestly this is probably slower
|
||||
- really buggy for some reason
|
||||
- i would call it bloated but honestly this is probably slower
|
||||
|
||||
## Why not a third party launcher?
|
||||
## why not a third party launcher
|
||||
|
||||
GDLauncher sounds great but it crashes for me and MultiMC's management sucks; they're terrible about custom builds and branding. I don't know of any other launchers and quite frankly I think I should just torture myself by making one.
|
||||
|
||||
## I want to steal your code.
|
||||
|
||||
I'm honored, I guess? The code is public domain. There's no license file, so just put in your own and pretend I put it there.
|
||||
theyre all too complex and weird and have Discourse
|
||||
|
|
150
main
150
main
|
@ -1,48 +1,158 @@
|
|||
# assume EDITOR is set
|
||||
BROWSER=firefox
|
||||
|
||||
# im not multimc who cares if you dont rename this
|
||||
PNAME=mcl
|
||||
MDIR=~/.$PNAME
|
||||
CACHE=/tmp/$PNAME\cache
|
||||
PLAT=linux
|
||||
|
||||
login() {
|
||||
$1 'https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize?client_id=ed8c593c-4c7f-4484-8dc4-d2ce60bf62a4&response_type=code&response_mode=query&scope=XboxLive.signin&redirect_uri=https%3A%2F%2Fmothcompute.lilylenora.net%2Fmcl_auth.php'
|
||||
echo -n 'opened sign-in link in firefox. paste the output into the file that is about to be opened (press enter to continue):'
|
||||
read
|
||||
$EDITOR "$MDIR/account$2"
|
||||
}
|
||||
|
||||
[ "$1" = edit ] && $EDITOR "$MDIR/profile/$2" && exit
|
||||
|
||||
[ ! -f "$MDIR/account$2" -o "$1" = 'login' ] && login "$BROWSER" "$2" && echo logged in && exit
|
||||
|
||||
[ $(date -d "$(jq -r .exp.mc "$MDIR/account$2")" +%s) -le $(date +%s) ] && if [ $(date -d "$(jq -r .exp.xb "$MDIR/account$2")" +%s) -le $(date +%s) ]; then
|
||||
login "$BROWSER" "$2"
|
||||
else
|
||||
curl 'https://mothcompute.lilylenora.net/mcl_auth.php?xb='$(jq -r .tok.xb "$MDIR/account$2")'&u='$(jq -r .xb_usr "$MDIR/account$2")'&e='$(jq -r .exp.xb "$MDIR/account$2") > "$MDIR/swp.account$2"
|
||||
mv "$MDIR/swp.account$2" "$MDIR/account$2"
|
||||
fi
|
||||
|
||||
user_type=msa
|
||||
auth_xuid=$(jq -r '.xb_uid' "$MDIR/account$2")
|
||||
auth_player_name=$(jq -r '.mc_usr' "$MDIR/account$2")
|
||||
auth_uuid=$(jq -r '.mc_uid' "$MDIR/account$2")
|
||||
auth_access_token=$(jq -r '.tok.mc' "$MDIR/account$2")
|
||||
auth_session="token:$auth_access_token:$auth_uuid"
|
||||
clientid=$(dd if=/dev/random bs=48 count=1 status=none|base64)
|
||||
|
||||
mkdir -p "$CACHE" "$MDIR/libs" "$MDIR/assets" "$MDIR/assets/indexes" "$MDIR/assets/objects" "$MDIR/minecraft" "$CACHE/natives" "$MDIR/profile"
|
||||
|
||||
[ ! -z "$1" -a ! -f "$MDIR/profile/$1" ] && echo -ne "# type 'snapshot', 'release', or a version number. get a list with:\n# curl https://launchermeta.mojang.com/mc/game/version_manifest.json | jq -r '.versions[].id' | less\nVERSION=snapshot\nJAVA8=/usr/lib/jvm/java-8-openjdk/bin/java\nJAVA_LATEST=/bin/java\ngame_directory=~/mclinstance\n# additional jvm arguments\njvm="> "$MDIR/profile/$1" && $EDITOR "$MDIR/profile/$1"
|
||||
|
||||
mkdir -p $CACHE sh node libs assets assets/indexes assets/objects minecraft
|
||||
echo fetching version manifest...
|
||||
wget https://launchermeta.mojang.com/mc/game/version_manifest.json -qO $CACHE/version_manifest.json
|
||||
|
||||
|
||||
# release|snapshot
|
||||
CHANNEL=release
|
||||
CHANNEL=snapshot
|
||||
JAVA8=/usr/lib/jvm/java-8-openjdk/bin/java
|
||||
JAVA_LATEST=/bin/java
|
||||
game_directory=~/mclinstance
|
||||
VERSION="$(jq -r .latest.$CHANNEL $CACHE/version_manifest.json)"
|
||||
jvm=""
|
||||
VIRTP=""
|
||||
|
||||
# ex. 1.17.1
|
||||
#VERSION=
|
||||
[ ! -z "$1" ] && . "$MDIR/profile/$1"
|
||||
mkdir -p "$game_directory"
|
||||
|
||||
[ "$VERSION" = 'snapshot' -o "$VERSION" = 'release' ] && CHANNEL=$VERSION && VERSION="$(jq -r .latest.$CHANNEL $CACHE/version_manifest.json)"
|
||||
|
||||
echo ver $VERSION
|
||||
|
||||
# create directory structure for version if missing
|
||||
mkdir -p minecraft minecraft/versions minecraft/versions/$VERSION
|
||||
mkdir -p $MDIR/minecraft/versions/$VERSION
|
||||
|
||||
# get json file for version
|
||||
VERSION_MANIFEST=$(jq ".versions[] | select(.id==\"$VERSION\")" $CACHE/version_manifest.json | jq -r .url)
|
||||
[ ! -f "minecraft/versions/$VERSION/$(basename $VERSION_MANIFEST)" ] && wget $VERSION_MANIFEST -qO "minecraft/versions/$VERSION/$(basename $VERSION_MANIFEST)"
|
||||
[ ! -f "$MDIR/minecraft/versions/$VERSION/$(basename $VERSION_MANIFEST)" ] && wget $VERSION_MANIFEST -qO "$MDIR/minecraft/versions/$VERSION/$(basename $VERSION_MANIFEST)"
|
||||
|
||||
# get jar file for version
|
||||
[ ! -f "minecraft/versions/$VERSION/$VERSION.jar" ] && wget "$(jq -r .downloads.client.url minecraft/versions/$VERSION/$VERSION.json)" -qO "minecraft/versions/$VERSION/$VERSION.jar"
|
||||
# get jar file for version TODO unwrapped filename
|
||||
[ ! -f "$MDIR/minecraft/versions/$VERSION/$VERSION.jar" ] && wget "$(jq -r .downloads.client.url $MDIR/minecraft/versions/$VERSION/$VERSION.json)" -qO "$MDIR/minecraft/versions/$VERSION/$VERSION.jar"
|
||||
|
||||
# get version assets
|
||||
VERSION_ASSETS="$(jq -r .assetIndex.url minecraft/versions/$VERSION/$VERSION.json)"
|
||||
[ ! -f "assets/indexes/$(basename $VERSION_ASSETS)" ] && wget $VERSION_ASSETS -qO "assets/indexes/$(basename $VERSION_ASSETS)"
|
||||
# get version assets TODO unwrapped filename
|
||||
VERSION_ASSETS="$(jq -r .assetIndex.url $MDIR/minecraft/versions/$VERSION/$VERSION.json)"
|
||||
[ ! -f "$MDIR/assets/indexes/$(basename $VERSION_ASSETS)" ] && wget $VERSION_ASSETS -qO "$MDIR/assets/indexes/$(basename $VERSION_ASSETS)"
|
||||
|
||||
# download objects
|
||||
for OBJ in `jq -r .objects[].hash "assets/indexes/$(basename $VERSION_ASSETS)"`; do
|
||||
mkdir -p "assets/objects/$(echo $OBJ | cut -b 1,2)"
|
||||
[ ! -f "assets/objects/$(echo $OBJ | cut -b 1,2)/$OBJ" ] && wget "http://resources.download.minecraft.net/$(echo $OBJ | cut -b 1,2)/$OBJ" -qO "assets/objects/$(echo $OBJ | cut -b 1,2)/$OBJ" &
|
||||
# download objects TODO unwrapped filename
|
||||
if [ "$(jq .map_to_resources $MDIR/assets/indexes/$(basename $VERSION_ASSETS))" = true -o "$(jq .virtual $MDIR/assets/indexes/$(basename $VERSION_ASSETS))" = true ]; then
|
||||
rsrc=1
|
||||
[ "$(jq .virtual $MDIR/assets/indexes/$(basename $VERSION_ASSETS))" = true ] && VIRTP=virtual/
|
||||
OLDIFS="$IFS"
|
||||
IFS=$'\n'
|
||||
for OBJ in `jq -r '.objects|to_entries[]|{"value":.value.hash,"key":.key}' "$MDIR/assets/indexes/$(basename $VERSION_ASSETS)"|tr -d '\n'|xargs|sed 's/[}]/\n/g'|sed 's/^.*value: //g;s/, key://g'`; do
|
||||
echo $OBJ
|
||||
OBJP="`echo $OBJ | sed 's/^[^ ]* //'`"
|
||||
OBJH="`echo $OBJ | sed 's/ .*//'`"
|
||||
eval mkdir -p '$(dirname "$MDIR/resources/$VIRTP$OBJP")'
|
||||
echo wget "https://resources.download.minecraft.net/$(echo $OBJH | cut -b 1,2)/$OBJH" -qO "$MDIR/resources/$VIRTP$OBJP"
|
||||
[ ! -f "$MDIR/resources/$VIRTP$OBJP" ] && wget "https://resources.download.minecraft.net/$(echo $OBJH | cut -b 1,2)/$OBJH" -qO "$MDIR/resources/$VIRTP$OBJP"
|
||||
done
|
||||
IFS="$OLDIFS"
|
||||
else
|
||||
for OBJ in `jq -r .objects[].hash "$MDIR/assets/indexes/$(basename $VERSION_ASSETS)"`; do
|
||||
mkdir -p "$MDIR/assets/objects/$(echo $OBJ | cut -b 1,2)"
|
||||
[ ! -f "$MDIR/assets/objects/$(echo $OBJ | cut -b 1,2)/$OBJ" ] && echo wget "https://resources.download.minecraft.net/$(echo $OBJ | cut -b 1,2)/$OBJ" && wget "https://resources.download.minecraft.net/$(echo $OBJ | cut -b 1,2)/$OBJ" -qO "$MDIR/assets/objects/$(echo $OBJ | cut -b 1,2)/$OBJ"
|
||||
done
|
||||
fi
|
||||
|
||||
echo object download complete
|
||||
|
||||
# get non-native libs
|
||||
for LIBINDEX in `seq 0 $(($(jq '.libraries|length' minecraft/versions/$VERSION/$VERSION.json)-1))`; do
|
||||
LIBPATH=libs/`jq -r ".libraries[$LIBINDEX].downloads.artifact.path" minecraft/versions/$VERSION/$VERSION.json`
|
||||
LIBURL=`jq -r ".libraries[$LIBINDEX].downloads.artifact.url" minecraft/versions/$VERSION/$VERSION.json`
|
||||
for LIBINDEX in `seq 0 $(($(jq '.libraries|length' "$MDIR/minecraft/versions/$VERSION/$VERSION.json")-1))`; do
|
||||
echo lib $LIBINDEX
|
||||
LIBPATH="$MDIR/libs/$VERSION/"`jq -r ".libraries[$LIBINDEX].downloads.artifact.path" "$MDIR/minecraft/versions/$VERSION/$VERSION.json"`
|
||||
LIBURL=`jq -r ".libraries[$LIBINDEX].downloads.artifact.url" "$MDIR/minecraft/versions/$VERSION/$VERSION.json"`
|
||||
mkdir -p "$(dirname $LIBPATH)"
|
||||
[ ! -f "$LIBPATH" ] && echo $LIBURL '=>' "$LIBPATH" && wget $LIBURL -qO "$LIBPATH"
|
||||
QNATIVE=`jq -r .libraries[$LIBINDEX].downloads.classifiers.'"natives-linux"' "$MDIR/minecraft/versions/$VERSION/$VERSION.json"`
|
||||
# TODO create natives for game
|
||||
[ ! "$QNATIVE" = "null" ] &&
|
||||
echo HAS NATIVE &&
|
||||
LIBPATH="$MDIR/libs/$VERSION/"`jq -r .libraries[$LIBINDEX].downloads.classifiers."\"natives-$PLAT\"".path "$MDIR/minecraft/versions/$VERSION/$VERSION.json"` &&
|
||||
LIBURL=`jq -r .libraries[$LIBINDEX].downloads.classifiers.'"natives-linux"'.url "$MDIR/minecraft/versions/$VERSION/$VERSION.json"` &&
|
||||
mkdir -p "$(dirname $LIBPATH)" &&
|
||||
echo $LIBURL '=>' "$LIBPATH" &&
|
||||
[ ! -f "$LIBPATH" ] && wget $LIBURL -qO "$LIBPATH" &&
|
||||
unzip -o "$LIBPATH" -d $CACHE/natives/$VERSION
|
||||
done
|
||||
|
||||
# all the libs in the classpath, minus the version jar
|
||||
# find /home/NAME/.minecraft/libraries/ | grep jar | sed 's/^\/home\/NAME\/.minecraft\/libraries\///g' | grep -v natives | wc -l
|
||||
|
||||
natives_directory=$CACHE/natives/$VERSION
|
||||
mkdir -p $natives_directory
|
||||
classpath=`find "$MDIR/libs/$VERSION" | grep -v "natives-" | grep -E '.jar$' | xargs | sed 's/ /:/g'`:"$MDIR/minecraft/versions/$VERSION/$VERSION.jar"
|
||||
version_name=$VERSION
|
||||
assets_root="$MDIR/assets"
|
||||
game_assets="$MDIR/assets"
|
||||
[ "$rsrc" = 1 ] && game_assets="$MDIR/resources/$VIRTP"
|
||||
#game_assets="$assets_root/virtual/pre-1.6" ???
|
||||
assets_index_name=`jq -r .assetIndex.id "$MDIR/minecraft/versions/$VERSION/$VERSION.json"`
|
||||
version_type=`jq -r .type "$MDIR/minecraft/versions/$VERSION/$VERSION.json"`
|
||||
|
||||
# TODO natives
|
||||
mkdir -p $CACHE/natives/$VERSION $game_directory
|
||||
for i in `find "$MDIR/libs/$VERSION" | grep natives-$PLAT`; do unzip -o $i -d $CACHE/natives/$VERSION; done
|
||||
|
||||
jvm="-Xss1M -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M $jvm "`jq -r .arguments.jvm "$MDIR/minecraft/versions/$VERSION/$VERSION.json" --indent 1 | grep -E '^ "' | sed 's/,$//' | xargs`
|
||||
|
||||
# TODO determine correct java version for old release versions
|
||||
JAVAV=$JAVA_LATEST
|
||||
|
||||
setleg() {
|
||||
JAVAV=$JAVA8
|
||||
#legacygame="--tweakClass net.minecraft.launchwrapper.AlphaVanillaTweaker --gameDir ${game_directory} --assetsDir ${assets_root}"
|
||||
jvm="-Djava.library.path=${natives_directory} -cp $classpath $jvm"
|
||||
}
|
||||
|
||||
[ "$version_type" = "old_alpha" -o "$version_type" = "old_beta" -o "$(echo $VERSION | sed 's/^[^\.]*\.//;s/\.[^\.]*$//')" -lt '13' ] && setleg
|
||||
[ $? = 2 ] && echo $VERSION | grep -v w && setleg
|
||||
|
||||
dbrun() {
|
||||
echo $@
|
||||
$@
|
||||
}
|
||||
|
||||
cd $MDIR
|
||||
eval dbrun $JAVAV \
|
||||
$jvm \
|
||||
`jq -r .mainClass "$MDIR/minecraft/versions/$VERSION/$VERSION.json" --indent 1` \
|
||||
`jq -r .minecraftArguments "$MDIR/minecraft/versions/$VERSION/$VERSION.json" --indent 1 | sed 's/,$//' | xargs | sed "s/null//g"` \
|
||||
`jq -r .arguments.game "$MDIR/minecraft/versions/$VERSION/$VERSION.json" --indent 1 | grep -E '^ "' | sed 's/,$//' | xargs` \
|
||||
$legacygame
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# mcl
|
||||
|
||||
php sources hosted at mothcompute.lilylenora.net. the secret token used here is not actually useful so i am leaving it in
|
||||
|
||||
- auth: the main authentication script
|
||||
- rf: secondary authentication script, used to refresh keys
|
||||
- penc: urlencode converter
|
||||
- spjwt: convert jwts
|
|
@ -0,0 +1,6 @@
|
|||
[ "$1" = 'clean' ] && rm -rf obj spjwt penc && exit
|
||||
|
||||
mkdir -p obj
|
||||
nasm -felf64 src/bswap.s -o obj/bswap.o
|
||||
cc src/penc.c -o penc
|
||||
cc src/spjwt.c obj/bswap.o -o spjwt
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/zsh
|
||||
echo '<style>body{color:white;background:black}</style><pre>'
|
||||
ACODE=$2
|
||||
SECRET=$1
|
||||
JSON=(-H 'Content-Type: application/json' -H 'Accept: application/json')
|
||||
curl -s https://login.microsoftonline.com/consumers/oauth2/v2.0/token -H 'Content-Type: application/x-www-form-urlencoded' -d "client_id=ed8c593c-4c7f-4484-8dc4-d2ce60bf62a4&scope=XboxLive.signin&code=$ACODE&redirect_uri=https%3A%2F%2Fmothcompute.lilylenora.net%2Fmcl_auth.php&grant_type=authorization_code&client_secret=$SECRET"|jq -r '.expires_in,.access_token'|xargs|read AUEXPIRES TOKEN
|
||||
curl -s https://user.auth.xboxlive.com/user/authenticate $JSON -d "{\"Properties\":{\"AuthMethod\":\"RPS\",\"SiteName\":\"user.auth.xboxlive.com\",\"RpsTicket\":\"d=$(bin/penc $TOKEN)\"},\"RelyingParty\":\"http://auth.xboxlive.com\",\"TokenType\":\"JWT\"}"|jq -r '.NotAfter,.Token,.DisplayClaims.xui[0].uhs'|xargs|read XBEXPIRES XBTOKEN USERHASH
|
||||
curl -s https://xsts.auth.xboxlive.com/xsts/authorize $JSON -d '{"Properties":{"SandboxId":"RETAIL","UserTokens":['"\"$XBTOKEN\""']},"RelyingParty":"rp://api.minecraftservices.com/","TokenType":"JWT"}'|jq -r '.NotAfter,.Token'|xargs|read XSEXPIRES XSTOKEN
|
||||
curl -s https://api.minecraftservices.com/authentication/login_with_xbox $JSON -d "{\"identityToken\":\"XBL3.0 x=$USERHASH;$XSTOKEN>\"}"|jq -r '.access_token,.expires_in'|xargs|read MCTOKEN MCEXPIRES
|
||||
bin/spjwt "$(curl -s https://api.minecraftservices.com/entitlements/mcstore -H "Authorization: Bearer $MCTOKEN"|jq -r 'select(.items[].name == "game_minecraft").signature')"|jq -r '.payload.signerId'|read XUID
|
||||
[ -z "$XUID" ]&&echo 'you do not own the game...'&&exit
|
||||
curl -s https://api.minecraftservices.com/minecraft/profile -H "Authorization: Bearer $MCTOKEN"|jq -r '.id,.name'|xargs|read MCID MCNAME
|
||||
echo "{\"xb_uid\":\"$XUID\",\"xb_usr\":\"$USERHASH\",\"mc_usr\":\"$MCNAME\",\"mc_uid\":\"$MCID\",\"exp\":{\"xb\":\"$XBEXPIRES\",\"mc\":\"$(date -d "+$MCEXPIRES seconds" +'%Y-%m-%dT%H:%M:%S.0000000Z')\"},\"tok\":{\"xb\":\"$XBTOKEN\",\"mc\":\"$MCTOKEN\"}}"
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/zsh
|
||||
echo '<pre>'
|
||||
XBTOKEN=$1
|
||||
USERHASH=$2
|
||||
XBEXPIRES=$3
|
||||
JSON=(-H 'Content-Type: application/json' -H 'Accept: application/json')
|
||||
curl -s https://xsts.auth.xboxlive.com/xsts/authorize $JSON -d '{"Properties":{"SandboxId":"RETAIL","UserTokens":['"\"$XBTOKEN\""']},"RelyingParty":"rp://api.minecraftservices.com/","TokenType":"JWT"}'|jq -r '.NotAfter,.Token'|xargs|read XSEXPIRES XSTOKEN
|
||||
curl -s https://api.minecraftservices.com/authentication/login_with_xbox $JSON -d "{\"identityToken\":\"XBL3.0 x=$USERHASH;$XSTOKEN>\"}"|jq -r '.access_token,.expires_in'|xargs|read MCTOKEN MCEXPIRES
|
||||
bin/spjwt "$(curl -s https://api.minecraftservices.com/entitlements/mcstore -H "Authorization: Bearer $MCTOKEN"|jq -r 'select(.items[].name == "game_minecraft").signature')"|jq -r '.payload.signerId'|read XUID
|
||||
[ -z "$XUID" ]&&echo 'you do not own the game...'&&exit
|
||||
curl -s https://api.minecraftservices.com/minecraft/profile -H "Authorization: Bearer $MCTOKEN"|jq -r '.id,.name'|xargs|read MCID MCNAME
|
||||
echo "{\"xb_uid\":\"$XUID\",\"mc_usr\":\"$MCNAME\",\"mc_uid\":\"$MCID\",\"exp\":{\"xb\":\"$XBEXPIRES\",\"mc\":\"$(date -d "+$MCEXPIRES seconds" +'%Y-%m-%dT%H:%M:%S.0000000Z')\"},\"tok\":{\"xb\":\"$XBTOKEN\",\"mc\":\"$MCTOKEN\"}}"
|
|
@ -0,0 +1,24 @@
|
|||
section .text
|
||||
|
||||
global bswap32
|
||||
global bswap64
|
||||
global to_little_endian32
|
||||
global to_little_endian64
|
||||
global to_big_endian32
|
||||
global to_big_endian64
|
||||
|
||||
to_big_endian32:
|
||||
bswap32:
|
||||
mov eax, edi
|
||||
bswap eax
|
||||
ret
|
||||
|
||||
to_big_endian64:
|
||||
bswap64:
|
||||
mov rax, rdi
|
||||
bswap rax
|
||||
ret
|
||||
|
||||
to_little_endian32:
|
||||
to_little_endian64:
|
||||
mov rax, rdi
|
|
@ -0,0 +1 @@
|
|||
int main(int a,char**v){if(a<2)exit(1);int i=0,c;if((a>2)&&!(i=(*((short*)v[1])==28717)))exit(1);while(c=*(v[1+i]++)){if(i&&c==32){c=43;goto p;}if((!((c^32)>>4)&&c!=34&&c!=45&&c!=46)||(c==58||c==59||c==61||c==63||c==64||c==91||c==93))printf("%%%02X",c);else p:putchar(c);}putchar(10);}
|
|
@ -0,0 +1,70 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned long p(char* s) {
|
||||
char*r=s;
|
||||
while(*s&&(*s^'.'))s++;
|
||||
return ((long)s)-((long)r);
|
||||
}
|
||||
|
||||
extern unsigned int bswap32(unsigned int d);
|
||||
|
||||
// buffer must be at least 3 bytes larger than output
|
||||
unsigned long b64d(unsigned char*d,unsigned char*s,long l) {
|
||||
char*b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
unsigned long o = 0;
|
||||
while(l > 0) {
|
||||
unsigned int v = 0;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
int c = 0;
|
||||
if(l > 3 || i < l) {
|
||||
for(;b64[c] != s[i];c++) if(!b64[c]) goto r;
|
||||
o++;
|
||||
}
|
||||
v = (v << 6) | c;
|
||||
}
|
||||
v = bswap32(v) >> 8;
|
||||
*((int*)d)=v;
|
||||
l-=4;
|
||||
s+=4;
|
||||
d+=3;
|
||||
}
|
||||
r: return ((o*3) >> 2);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if(argc < 2) exit(1);
|
||||
|
||||
long z=strlen(argv[1])+1;
|
||||
char s[z+sizeof(int)];
|
||||
memcpy(s,argv[1],z);
|
||||
*((int*)(s+z))=0;
|
||||
|
||||
unsigned long hz = p(s);
|
||||
unsigned long pz = p(s+hz+1);
|
||||
unsigned long gz = p(s+hz+pz+2);
|
||||
|
||||
char* hs = s;
|
||||
char* ps = s+hz+1;
|
||||
char* gs = s+hz+pz+2;
|
||||
|
||||
char hb[((hz*3)/4)+4];
|
||||
char pb[((pz*3)/4)+4];
|
||||
char gb[((gz*3)/4)+4];
|
||||
|
||||
memset(hb, 0, ((hz*3)/4)+4);
|
||||
memset(pb, 0, ((pz*3)/4)+4);
|
||||
memset(gb, 0, ((gz*3)/4)+4);
|
||||
|
||||
b64d(hb,hs,hz);
|
||||
b64d(pb,ps,pz);
|
||||
b64d(gb,gs,gz);
|
||||
|
||||
printf(
|
||||
"{\"header\":%s,\n"
|
||||
"\"payload\":%s,\n"
|
||||
"\"signature\":\"%s\"\n}\n",
|
||||
hb,pb,gs
|
||||
);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$p = array();
|
||||
parse_str($_SERVER['QUERY_STRING'], $p);
|
||||
system("bin/mcl_auth 'cJK8Q~KV7GWoZwMtusedzCHwbzPQhc6CWvaqzc-r' ".$p['code'])
|
||||
?>
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
$p = array();
|
||||
parse_str($_SERVER['QUERY_STRING'], $p);
|
||||
system("bin/mcl_auth_rf ".$p['xb']." ".$p['u']." ".$p['e'])
|
||||
?>
|
Loading…
Reference in New Issue