Skip to content

Instantly share code, notes, and snippets.

@kabili207
Created June 18, 2017 22:58
Show Gist options
  • Save kabili207/2f0d1ad062ca0e2e9eb2dfd20238d8d3 to your computer and use it in GitHub Desktop.
Save kabili207/2f0d1ad062ca0e2e9eb2dfd20238d8d3 to your computer and use it in GitHub Desktop.
Wii Friend Code Uploader
#!/bin/bash
function join_by { local IFS="$1"; shift; echo "$*"; }
upload=1
counter=0
found=( )
sess_id=$(od -N 4 -t uL -An /dev/urandom | tr -d " ")
pushd ~/.dolphin-emu/Wii/title/ > /dev/null
files=$(grep -robUaP "\x00\x00\x0F\x75\x74" . | cut -f1,2 -d:)
while read -r line; do
file_path=$(echo $line | cut -d: -f1)
offset=$(echo $line | cut -d: -f2)
IFS=/ read -r -a fc_data <<< $file_path
tid="${fc_data[1]}"
gameid="${fc_data[2]}"
gameidpid=$(perl -e 'print pack "H*", shift' $gameid)
rel_path=$(join_by / ${fc_data[@]:3})
b64_enc=$(dd if=$file_path bs=1 count=24 skip=$offset 2>/dev/null | base64)
hex_offset=$(echo "obase=16; $offset" | bc)
pair="$gameidpid - $gameid - $tid -$b64_enc"
if [[ ! " ${found[@]} " =~ " ${pair} " ]]; then
echo "$gameidpid - $gameid - $tid - 0x$hex_offset - $rel_path"
found=("${found[@]}" "${pair}")
((counter++))
if [[ $upload -ne 0 ]]; then
curl -s -m 10 -X POST --data "gameid=$gameidpid&data=$b64_enc&id=$sess_id" http://www.ninrankings.org/postdata.php > /dev/null
fi
#else
#echo "ignoring duplicate"
#echo "$gameidpid - $gameid - $tid - 0x$hex_offset - $rel_path"
fi
done <<<"$files"
popd > /dev/null
echo "Found $counter profiles"
if [[ $upload -ne 0 ]]; then
message=$(echo "done. uploaded ${counter} profiles" | base64)
curl -s -m 10 -X POST --data "message=$message&id=$sess_id" http://www.ninrankings.org/postdata.php > /dev/null
echo "http://maschell.de/pidtool.php?check=$sess_id"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment