Advertisement
opexxx

mega-dl.sh

May 20th, 2015
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.98 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # mega-dl
  4. # Thanks to http://hacktracking.blogspot.com.au/2013/07/download-mega-files-from-command-line.html
  5.  
  6. url=$1
  7. enc_file=${2}.enc
  8. out_file=$2
  9.  
  10. id=$(echo $url | awk -F '!' '{print $2}')
  11. key=$(echo $url | awk -F '!' '{print $3}' | sed -e 's/-/+/g' -e 's/_/\//g' -e 's/,//g')
  12. b64_hex_key=$(echo -n $key | base64 --decode --ignore-garbage 2> /dev/null | xxd -p | tr -d '\n')
  13. key[0]=$(( 0x${b64_hex_key:00:16} ^ 0x${b64_hex_key:32:16} ))
  14. key[1]=$(( 0x${b64_hex_key:16:16} ^ 0x${b64_hex_key:48:16} ))
  15. key=$(printf "%x" ${key[*]})
  16. iv="${b64_hex_key:32:16}0000000000000000"
  17. new_url=$(curl --silent --request POST --data-binary '[{"a":"g","g":1,"p":"'$id'"}]' https://eu.api.mega.co.nz/cs | awk -F '"' '{print $10}')
  18. curl --output $enc_file $new_url
  19. openssl enc -d -aes-128-ctr -K $key -iv $iv -in $enc_file -out $out_file
  20. rm -f $enc_file
  21. # url='https://mega.co.nz/#!HFsiWYrJ!VkovRDl9kJkIMDBkiRlw-E9OGOkcD1DbNqs3d-CGNf8'
  22. # ./mega-dl $url toulouse.mp4
  23. # file toulouse.mp4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement