木马(python)反沙箱
目录
前言
完成免杀任务之后迅速上线了异国的网站,开启了这次木马的钓鱼生涯 但是这种被丢到沙箱里 然后给你上线一大堆没用的虚拟机 把你的远控搞得一团乱糟糟不说 还容易增加你shellcode被暴露的风险
反沙箱虚拟机操作
习惯用python我就用python 写了 而且我只挑了几个我认为准确率比较高的方法
开机时间检测
沙箱检测木马文件一般都是运行完就关机的,所以可以根据开机时间来判断是不是真实的运行状况
# 开机时间长短来判断是否是沙箱虚拟机
boot_time = psutil.boot_time()
boot_time_obj = datetime.fromtimestamp(boot_time)
h = boot_time_obj.hour
m = boot_time_obj.minute
s = boot_time_obj.second
b = int(h)*3600 + int(m)*60 + int(s)
now_time = datetime.now()
h = now_time.hour
m = now_time.minute
s = now_time.second
a = int(h)*3600 + int(m)*60 + int(s)
running_time = a - b
if running_time > 600:
tkinter.messagebox.showinfo('Windows提示', '开机运行时间正常显示')
else:tkinter.messagebox.showerror('Windows提示', '检测到运行环境为虚拟机')
这里是与600秒作比较,也就是判断机器是否运行超过10分钟
正常机器运行
虚拟机运行
检测CPU核心数
大多数pc拥有4核心cpu,许多在线检测的虚拟机沙盘是2核心,我们可以通过核心数来判断是否为真实机器或检测用的虚拟沙箱。
#检测CPU核心数
num_cpu = multiprocessing.cpu_count()
if num_cpu > 3:
tkinter.messagebox.showinfo('Windows提示', '正常客户端运行')
else:tkinter.messagebox.showerror('Windows提示', '检测到运行环境为虚拟机')
检测临时文件数
正常使用的系统,其中用户的临时文件夹中有一定数量的临时文件,可以通过判断临时文件夹内的文件数量来检测是否在沙箱中运行。
#检测系统临时文件的数量
path = 'C:\Windows\Temp'
files = os.listdir(path)
fold_num = len(files)
if fold_num > 20:
tkinter.messagebox.showinfo('Windows提示', '正常客户端运行')
else:tkinter.messagebox.showerror('Windows提示', '检测到运行环境为虚拟机')
传到沙箱看一下
检测临时文件数的时候报了个高风险,可以换个写法或者直接直接用计算temp文件夹大小来替代目录遍历