Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
moeinfatehi committed Jun 16, 2022
0 parents commit 8075eeb
Show file tree
Hide file tree
Showing 20 changed files with 856 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .docker/hidden_fl4g.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Well Done.
Flag is "LFI_Can_L3ad_T0_RCE"
1 change: 1 addition & 0 deletions .docker/mycron
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* * * * * /bin/resetApache >> /var/log/cron.log 2>&1
4 changes: 4 additions & 0 deletions .docker/scr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
date >> /var/log/cron.log
rm /var/log/apache2/*
/usr/sbin/apache2ctl restart
13 changes: 13 additions & 0 deletions .docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[supervisord]
nodaemon=true
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10

[program:cron]
autorestart=false
command=cron -f

[program:apache2]
autorestart=false
command=/usr/sbin/apache2ctl -D FOREGROUND
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM php:8.0-apache

COPY ./src/ /var/www/html
RUN chown -R www-data:www-data /var/www/html
RUN rm /var/log/apache2/*
RUN apache2ctl restart
RUN chown -R root:www-data /var/log/apache2/
COPY .docker/hidden_fl4g.txt /
RUN chmod +r /hidden_fl4g.txt
RUN rm -rf /var/www/html/.docker/
COPY .docker/scr /bin/resetApache
RUN chmod +x /bin/resetApache
RUN apt-get update && apt-get -y install cron supervisor
COPY .docker/mycron /etc/cron.d/mycron
RUN chmod 0644 /etc/cron.d/mycron
RUN crontab /etc/cron.d/mycron
COPY .docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/moeinfatehi/lfi-to-rce)
![Docker Pulls](https://img.shields.io/docker/pulls/moeinfatehi/lfi-to-rce)
# LFI to RCE Scenario (challenge)
This repository is a Dockerized php application containing a LFI (Local File Inclusion) vulnerability which can lead to RCE (Remote Code Execution).<br><br>
The ideas behind the challenge are:</br>
* Bypass path traversal sanitization
* Execute OS command through LFI vulnerability.

# Quick Start Using Docker
**Using docker hub (Quickest):**
1. To access the challenges, you need <a href="https://docs.docker.com/install">docker</a> installed.</br>
2. Run this command to pull and run the image from docker hub:</br>`sudo docker run -d -p 9005:80 moeinfatehi/lfi-to-rce`
3. Access the challenges with this URL: <a href="http://localhost:9005">http://localhost:9005</a></br></br>

Help:
```
-d: detached mode (You can use terminal after running command
-p: specifies port (you can change 9005 to whatever you want. If you don't have a web server on your host, set it to 80)
```

**Using docker-compose:**
1. To access the challenges, you need <a href="https://docs.docker.com/install">docker</a> and <a href="https://docs.docker.com/compose/install/">docker-compose</a> installed.</br>
2. Clone the repository</br>`git clone https://github.com/moeinfatehi/lfi-to-rce.git`
3. Open the main directory of the project (where docker-compose.yml file exists) and run: `docker-compose up`
4. Access the challenges with this URL: <a href="http://localhost:9005">http://localhost:9005</a>

# Disclaimer
This project is for Educational purpose ONLY. The usual disclaimer applies, especially the fact that I'm not liable for any damages caused by direct or indirect use of the information or functionality provided by these programs. The author or any Internet provider bears NO responsibility for content or misuse of these programs or any derivatives thereof. By using these project you accept the fact that any damage (dataloss, system crash, system compromise, etc.) caused by the use of this program is not my responsibility.

# Hack and have fun !
If you have any further questions, please don't hesitate to contact me via my <a href="https://twitter.com/MoeinFatehi">twitter</a> account.
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'
services:
web:
container_name: lfi-to-rce
build:
context: .
dockerfile: Dockerfile
ports:
- 9005:80
volumes:
- ./src/:/var/www/html/
image: moeinfatehi/lfi-to-rce:latest
1 change: 1 addition & 0 deletions src/files/ctf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
There are a lot of Capture The Flag (CTF) competitions in our days, some of them have excelent tasks.
21 changes: 21 additions & 0 deletions src/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


<?php
/**
* Created by PhpStorm.
* User: moein
* Date: 12/12/18
* Time: 1:43 PM
*/
?>
<link rel="stylesheet" href="static/css/bootstrap.min.css">
<link rel="stylesheet" href="static/css/font-awesome.min.css">
<div class="footer text-center navbar-fixed-bottom">
<hr>
<div class="logo">
<a href="https://twitter.com/MoeinFatehi" title="Twitter" target="_blank"><i class="fa fa-twitter-square fa-3x twitter-icon"></i></a>
<a href="https://github.com/moeinfatehi" title="Github" target="_blank"><i class="fa fa-github-square fa-3x github-icon"></i></a>
<a href="https://www.linkedin.com/in/moein-fatehi-87a35936/" title="Linkedin" target="_blank"><i class="fa fa-linkedin-square fa-3x linkedin-icon"></i></a>
</div>
<p>If you need the solutions, follow <a href="https://twitter.com/MoeinFatehi">@MoeinFatehi</a> on twitter and ask for cheat sheet.</p>
</div>
43 changes: 43 additions & 0 deletions src/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

<html>
<head>
<title>LFI to RCE</title>
</head>
<body>
<div id="main">
<div class="container">
<div class="row">
<h1>CTF</h1>
</div>
<div class="row">
<p class="lead">
Do some bypass to find the flag.<br />
</p>
</div>
</div>
</div>
<div class="container">

<?php
$f='ctf.txt';
echo "<a class=\"btn btn-primary\" href=\".?file=$f\" /> What is CTF? </a><br><br>";

if($file=$_GET['file']){
$file=str_replace("../","",$file);
if($file!="../index.php"){
include('files/'.$file);
}
}
?>

<!--Hint: Find the flag in the root directory--!>
<!--For ease of use, the webserver will reset every minute.--!>

</div>
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
</body>
</html>

<?php
include ("footer.php");
?>
63 changes: 63 additions & 0 deletions src/static/css/bootstrap.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/static/css/font-awesome.min.css

Large diffs are not rendered by default.

Binary file added src/static/fonts/fontawesome-webfont.eot
Binary file not shown.
Loading

0 comments on commit 8075eeb

Please sign in to comment.