mirror of
https://github.com/wikiZ/RedGuard
synced 2026-06-08 18:18:32 +00:00
Compare commits
11 Commits
22.6.27.1332
...
22.7.14
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ca5f302df | |||
| 6c4b78b692 | |||
| 54240373ea | |||
| e41fdb7bd2 | |||
| c7a4657a2b | |||
| f51f9ae381 | |||
| 7ff6cc59e1 | |||
| 26719ed09e | |||
| 0281902237 | |||
| 79d6718f8d | |||
| f394f46062 |
@@ -1,3 +1,16 @@
|
||||
## [22.7.14.1043] - 2022-7-14
|
||||
### Added
|
||||
- Resolve the problem that the custom certificate is overwritten
|
||||
|
||||
## [22.7.12.1111] - 2022-7-12
|
||||
### Added
|
||||
- Profile Header authentication ignores case
|
||||
- Disable the default JARM fingerprint randomization parameter
|
||||
- Change the long version name!!
|
||||
- Forward the packet XFF header so that C2 gets the real IP address
|
||||
- Custom configuration file path
|
||||
- Added validity verification for parameter IP input
|
||||
|
||||
## [22.6.28.1712] - 2022-6-28
|
||||
### Added
|
||||
- JA3 fingerprint Identify sandbox
|
||||
@@ -11,4 +24,4 @@ due to the incompatibility of TLS jarm fingerprint randomize with custom certifi
|
||||
|
||||
## [22.5.20.1220] - 2022-5-20
|
||||
### Added
|
||||
- Initialize project
|
||||
- Initialize project
|
||||
|
||||
@@ -152,7 +152,7 @@ As shown in the figure above, in the case of unauthorized access, the response i
|
||||
|
||||
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 two strategies:
|
||||
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.
|
||||
@@ -196,6 +196,17 @@ The blue team tracing behavior is analyzed through the interception log of the t
|
||||
|
||||

|
||||
|
||||
|
||||
## 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.
|
||||
|
||||
```bash
|
||||
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.
|
||||
|
||||
+5
-1
@@ -84,12 +84,16 @@ func main() {
|
||||
)
|
||||
core.CmdParse(&parse, &cert, &_proxy)
|
||||
// Check whether RedGuard has been initialized
|
||||
if num, isExits := lib.CreateConfig(parse.C2Type /* C2 Facility Type */); isExits {
|
||||
if num, isExits := lib.CreateConfig(parse.C2Type /* C2 Facility Type */, parse.ConfigPath); isExits {
|
||||
switch {
|
||||
case parse.Update:
|
||||
lib.UpdateConfig(&cert, &_proxy) // Update RedGuard Config
|
||||
logger.Notice("RedGuard Configuration file updated successfully!")
|
||||
case parse.IP != "":
|
||||
if lib.CheckIP(parse.IP) == false {
|
||||
logger.Warning("Please enter a valid IP address")
|
||||
os.Exit(0)
|
||||
}
|
||||
logger.Noticef("Search ipLookUpHelper: %s", parse.IP)
|
||||
core.IPLookUp(parse.Location /* owning place to be verified */, parse.IP) // Query the location of an IP address
|
||||
case num == 0:
|
||||
|
||||
+21
-1527
File diff suppressed because it is too large
Load Diff
+18
-18
@@ -1,24 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEFTCCAv2gAwIBAgIIFvxjdqK07pAwDQYJKoZIhvcNAQELBQAwZjELMAkGA1UE
|
||||
MIIEFDCCAvygAwIBAgIIFwGR46UNXCwwDQ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bi5jb22C
|
||||
GyouYWNzLWludGVybmFsLmFsaXl1bmNzLmNvbYIUKi5jb25uZWN0LmFsaXl1bi5j
|
||||
b22CCmFsaXl1bi5jb22CEHdob2lzLnd3dy5uZXQuY26CEnRpYW5jaGktZ2xvYmFs
|
||||
LmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAHPsbex1ZR9p/5p/EdJrvlM3IhMIXUo2D
|
||||
tm/NWbEB4IVBa+mX0YGs60DiH8R+4VFWKvVhIzcf2/iZuiDKO8jeeZ3mSyDqdPD+
|
||||
T40gcNQhvPAH6YMPg8LzYAXVAZcxYCw0PmHr/Sl7EJH8LlR84Nz26HjPqNdLmIZA
|
||||
ui0jz4zSGtrcqFZzA2+DKiHsnKeQ4685FBUHJP51gyimYiPpQQW3uKPE1uC+8Aq/
|
||||
omArVJf9wnBLUWa1vZ4B12G4NVQXHcLvg13tOR0YHnRBJ5OR8ibYBy5VChbqktc4
|
||||
9hgOKhm4RO/6XIg6Dey/mBefannq2DgTj2lv9NNXiFppj81ugWhOmQ==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
+25
-25
@@ -1,27 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEA3bcmsObI34OtiyF0JlA17wkXjCY6DPZS6FdF/ec0H/ay35M7
|
||||
St236M4hPNXe5x5kdj7Ax5+O1Ywr/TeSXItTIRhAMLMPplZES+mKkfP+Euq0J2CO
|
||||
iAH5+Dv1/ihWDj4Lqh27CsiB3WLh6iOiP5tdHBRgk94Ru0wtCnPgrESSEQfmidej
|
||||
1ZIVmiXXGwwF805MHHQJQu6sdlM6MVVubh+wBiHLCGp3dKAxxGhQloCvg8d396Wa
|
||||
wdncTJT0Kg62FymbfIGz8mcMtAl1Pk2UKecoiPZQ7YOVqoldmhl7Dr66gwZ6Wjs/
|
||||
GpjcszulTi5hauKSTQuGAxspNEs6/TRoYrSBswIDAQABAoIBAHOUKoNFi6mZBzrk
|
||||
MZxX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pGiJ8Ryk+6i7pi
|
||||
8KP+scDUOGFfFwRycNwIoGP0J1WB4pRkTDqE8FQyh4TeOsK57NGp8wLt6COOnmps
|
||||
/8QRH+YqPG5n0yI3aQNOqkPuKoFYCiGF79VuhCuOGLaplXlmyQl/TTcCgYEAwhVp
|
||||
lLuo5phLvRTr6pgGVPCOhirdTktuRUp4NaNuGveUDww2TjdKBmqLcwVPEtuI3G/f
|
||||
k2AUKlWH0Q3N8340hG7hloSVQRHfoALy0Iljc4dFO0HrzOvSoaVYkhODqz6M6gfJ
|
||||
B+8Qiku93JI7G4qalg1jr3ItBK46KVTCQl5RE1kCgYBYEiYww82vKfRN0P6BIFbz
|
||||
pp44EGFNrfgQFtFPn5a+uDDAO9bzO444NC/3a7yBqpagY9xoIrVbTDKRt1+HmOEH
|
||||
CRSamVTGtEAoFCyrQBtxjidl685VYtY5WuKm7A/80Rjq3VIgfDxEU1oUZJG6tqac
|
||||
Z4/5arNUu7vghXRAjmi+2wKBgGUb/psLgJxRLvPcWGMou/O4NqfS4OQPC+1xNFrN
|
||||
P2kxHaMRO6FX0GqzSt6rH1y1ngEpDxKZ9Sdw04anaGm3j+iGU2O0woTZqOSVZKYb
|
||||
TQI8sGaEmzFwkZTArPm8zNWDiqnJUIOfmcBSYSDt1XktpgcSBqK6GpXbplUt4N3u
|
||||
gNJRAoGBAIo2SQXHObtfphpMVoDZm3A2DubekPuY5aHx0x5U24IDcF/19AJ3SvOh
|
||||
U7NHpHgGDal5WhLN9dIRBxujP/BL1TAKPpf6P5x4o1Jva0tUWcLvTzAM6NgFMY+0
|
||||
p4z+rF2IIkG383nWDpSL3r+0mpUEaPY5iCO8fyUQQtIr6gt+o8PW
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
||||
@@ -12,7 +12,7 @@ Organization = Alibaba (China) Technology Co., Ltd.
|
||||
# Cert User Country
|
||||
Country = CN
|
||||
# Whether to use the certificate you have applied for true/false
|
||||
HasCert = false
|
||||
HasCert = true
|
||||
|
||||
[proxy]
|
||||
# key : Header Host value of the reverse proxy
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ Github:%s
|
||||
|
||||
RedGuard is a C2 front flow control tool,Can avoid Blue Teams,AVs,EDRs check.
|
||||
`
|
||||
VERSION = "22.6.27.1332 Alpha"
|
||||
VERSION = "22.7.14 Alpha"
|
||||
TITLE = "RedGuard"
|
||||
LICENSE = "GPL-2.0"
|
||||
URL = "https://github.com/wikiZ/RedGuard"
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ func MalleableFilter(file string, req *http.Request) (isFilter bool) {
|
||||
var num int // Exception counter
|
||||
// Traverse the target profile requirements header slice
|
||||
for _, profileHeader := range malleable.headerParam {
|
||||
if reqHeader != profileHeader {
|
||||
if strings.ToLower(reqHeader) != strings.ToLower(profileHeader) {
|
||||
continue
|
||||
}
|
||||
num += 1 // The same header exists
|
||||
|
||||
+10
-4
@@ -51,7 +51,7 @@ func modifyResponse(drop bool) func(*http.Response) error {
|
||||
logger.Warningf("[RESPONSE] HTTP %s, length: %d", resp.Status, resp.ContentLength)
|
||||
if drop {
|
||||
// DROP Request
|
||||
logger.Alertf("[DROP] Source IP: %s", ip)
|
||||
logger.Alertf("[DROP] Source IP: %s", resp.Request.RemoteAddr)
|
||||
_ = Body.Close() // Direct shutdown response
|
||||
return
|
||||
}
|
||||
@@ -79,7 +79,13 @@ func (h *baseHandle) ServeHTTP(write http.ResponseWriter, req *http.Request) {
|
||||
var proxy *httputil.ReverseProxy
|
||||
// Determine the URL to be redirected to
|
||||
redirectURL = lib.ReadConfig("proxy", "Redirect", cfg)
|
||||
ip = lib.ConvertIP(req.RemoteAddr)
|
||||
req.RemoteAddr = lib.ConvertIP(req.RemoteAddr)
|
||||
// Obtaining the real IP address
|
||||
if req.Header.Get("X-Forwarded-For") != "" {
|
||||
req.RemoteAddr = req.Header.Get("X-Forwarded-For")
|
||||
}
|
||||
// Set the forwarding header XFF so that C2 obtains the online real IP address
|
||||
req.Header.Set("X-Forwarded-For", req.RemoteAddr)
|
||||
// Check whether the host is verified
|
||||
if IPHash := lib.EncodeMD5(req.JA3); arrays.ContainsString(_addressArray, req.JA3) == -1 {
|
||||
logger.Noticef("JA3 FingerPrint: %s", IPHash)
|
||||
@@ -88,7 +94,7 @@ func (h *baseHandle) ServeHTTP(write http.ResponseWriter, req *http.Request) {
|
||||
if !ProxyFilterManger(req) {
|
||||
goto LOOK // Redirect to the specified site
|
||||
}
|
||||
logger.Noticef("[REQUEST] %s - %s", ip, req.UserAgent())
|
||||
logger.Noticef("[REQUEST] %s - %s", req.RemoteAddr, req.UserAgent())
|
||||
_addressArray = append(_addressArray, IPHash) // Add to the list after verification for the first time
|
||||
}
|
||||
// Fetch directly from cache
|
||||
@@ -133,7 +139,7 @@ LOOK:
|
||||
proxy.ServeHTTP(write, req)
|
||||
REDIRECT:
|
||||
// REDIRECT Request
|
||||
logger.Alertf("[%s] Source IP: %s -> Destination Site: %s", strings.ToUpper(dropAction), ip, redirectURL)
|
||||
logger.Alertf("[%s] Source IP: %s -> Destination Site: %s", strings.ToUpper(dropAction), req.RemoteAddr, redirectURL)
|
||||
}
|
||||
|
||||
// ProxyManger Initialize the reverse proxy and pass in the address of the real back-end service
|
||||
|
||||
+2
-1
@@ -17,11 +17,12 @@ func CmdParse(parse *parameter.Parses, cert *parameter.Cert, proxy *parameter.Pr
|
||||
flag.BoolVar(&parse.Update, "u", false, `Enable configuration file modification`)
|
||||
flag.StringVar(&parse.C2Type, "type", `CobaltStrike`, `C2 Server Type`)
|
||||
flag.StringVar(&parse.IP, "ip", ``, `IPLookUP IP`)
|
||||
flag.StringVar(&parse.ConfigPath, "config", ``, `Set Config Path`)
|
||||
flag.StringVar(&parse.Location, "location", `风起`, `IPLookUP Location`)
|
||||
flag.StringVar(&cert.Country, "country", `CN`, `Cert Country`)
|
||||
flag.StringVar(&cert.CommonName, "common", `*.aliyun.com`, `Cert CommonName`)
|
||||
flag.StringVar(&cert.Organization, "organization", `Alibaba (China) Technology Co., Ltd.`, `Cert Organization`)
|
||||
flag.StringVar(&cert.HasCert, "HasCert", `false`, `Whether to use the certificate you have applied for`)
|
||||
flag.StringVar(&cert.HasCert, "HasCert", `true`, `Whether to use the certificate you have applied for`)
|
||||
flag.StringVar(&cert.DNSNameTo, "dns", `*.aliyun.com,manager.channel.aliyun.com,*.acs-internal.aliyuncs.com",*.connect.aliyun.com,aliyun.com,whois.www.net.cn,tianchi-global.com`, `Cert DNSName`)
|
||||
flag.StringVar(&cert.Locality, "locality", `HangZhou`, `Cert Locality`)
|
||||
flag.StringVar(&proxy.HostTarget, "host", `{"360.net":"http://127.0.0.1:8080","360.com":"https://127.0.0.1:4433"}`, `Set Proxy HostTarget`)
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
package parameter
|
||||
|
||||
type Parses struct {
|
||||
Update bool
|
||||
C2Type string
|
||||
IP string
|
||||
Location string
|
||||
Update bool
|
||||
IP string
|
||||
C2Type string
|
||||
Location string
|
||||
ConfigPath string
|
||||
}
|
||||
|
||||
type Cert struct {
|
||||
|
||||
+11
-1
@@ -150,7 +150,7 @@ Usage of ./RedGuard:
|
||||
|
||||
上述的基础拦截案例中,使用的是默认的拦截方式,也就是将非法流量以重定向的方式拦截,而通过配置文件的修改,我们可以更改拦截的方式,以及重定向的站点URL,其实这种方式与之说是重定向,描述为劫持、克隆或许更贴切,因为返回的响应状态码为200,是从另一个网站获取响应,以尽可能接近地模仿克隆/劫持的网站。
|
||||
|
||||
无效数据包可能会根据两种策略被错误路由:
|
||||
无效数据包可能会根据三种策略被错误路由:
|
||||
|
||||
- **reset**:立即终止 TCP 连接。
|
||||
- **proxy**:从另一个网站获取响应,以尽可能接近地模仿克隆/劫持的网站。
|
||||
@@ -194,6 +194,16 @@ Port_HTTP = :80
|
||||
|
||||

|
||||
|
||||
## RedGuard获取真实IP地址
|
||||
|
||||
针对于日常、域前置场景下获取真实请求IP,RG无需进行任何配置,仅需对启动C2设施的profile文件增加以下配置,即通过请求头X-Forwarded-For获取目标真实IP。
|
||||
|
||||
```bash
|
||||
http-config {
|
||||
set trust_x_forwarded_for "true";
|
||||
}
|
||||
```
|
||||
|
||||
## 请求地域限制
|
||||
|
||||
配置方式以AllowLocation = 济南,北京 为例,这里值得注意的是,RedGuard提供了两个IP归属地反查的API,一个适用于国内用户,另一个适用于海外用户,并且可以根据输入的地域名动态的分配使用哪个API,如果目标是中国的那么设置的地域就输入中文,反之输入英文地名,建议国内的用户使用中文名即可,这样反查到的归属地准确度以及API的响应速度都是最好的选择。
|
||||
|
||||
@@ -89,6 +89,12 @@ func GenerateSelfSignedCert(cert *parameter.Cert) {
|
||||
}
|
||||
|
||||
func InitGenerateSelfSignedCert() {
|
||||
// Check whether an SSL certificate is generated
|
||||
if _existsCrt, _ := FileExists("cert-rsa/ca.crt"); _existsCrt {
|
||||
if _existsKey, _ := FileExists("cert-rsa/ca.key"); _existsKey {
|
||||
return
|
||||
}
|
||||
}
|
||||
// Example Create a CA certificate storage directory
|
||||
if _, err := os.Stat("cert-rsa"); err != nil {
|
||||
_ = os.Mkdir("cert-rsa", 0766) // Directory permissions
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
@@ -37,3 +38,22 @@ func EncodeMD5(s string) string {
|
||||
md5Str := hex.EncodeToString(hash.Sum(nil))
|
||||
return md5Str
|
||||
}
|
||||
|
||||
// CheckIP Check whether the entered IP address is valid
|
||||
func CheckIP(ip string) bool {
|
||||
if m, _ := regexp.MatchString("^(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)$", ip); !m {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func FileExists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"RedGuard/config"
|
||||
"RedGuard/core/parameter"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
|
||||
"RedGuard/config"
|
||||
|
||||
"github.com/go-ini/ini"
|
||||
)
|
||||
|
||||
@@ -30,17 +30,19 @@ func InitConfig() *ini.File {
|
||||
// Check whether loading failed
|
||||
if err != nil {
|
||||
logger.Errorf("Fail to read file: %v", err)
|
||||
goto LOOK
|
||||
os.Exit(0)
|
||||
}
|
||||
// return *ini.File object
|
||||
return cfg
|
||||
LOOK:
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateConfig(C2Server string) (int, bool) {
|
||||
func CreateConfig(C2Server string, ConfigPath string) (int, bool) {
|
||||
currentUser, _ := user.Current() // Current operating system user directory
|
||||
_ConfigFilename = fmt.Sprintf("%s/.RedGuard_%s.ini", currentUser.HomeDir, C2Server)
|
||||
// Verify that the configuration file is customized
|
||||
if file, _ := ioutil.ReadFile(ConfigPath); len(file) != 0 {
|
||||
_ConfigFilename = ConfigPath // Configuration file using a custom path
|
||||
}
|
||||
// Check whether the current operating system user directory configuration file exists
|
||||
if _, err := os.Stat(_ConfigFilename); err == nil || os.IsExist(err) {
|
||||
return 0, true
|
||||
|
||||
Reference in New Issue
Block a user