Digging Into SNMP in 2007 - An Exercise On Breaking Networks
Digging Into SNMP in 2007 - An Exercise On Breaking Networks
Digging Into SNMP in 2007 - An Exercise On Breaking Networks
&
Daniel Mende, dmende@ernw.de
Agenda
Security Not Made Priority A (brief) overview of the history and features/capabilities of SNMP. Strictly not my Process Why SNMPv3 isn't widely used and what should be done when using SNMP. Skilled Network Mobbing Protocol How to organize sophisticated attacks on devices Statistical iNternet Monitoring Practice What can typically be found in an ASIAPAC Broadband /8 (and other parts of the Internet) Shoot Networks w/ Maximum Power (Ab-) using SNMP for botnet building or information warfare.
Who we are
Old-school networkers With special focus on security since 1997 Working as security guys and pentesters for German high level security consultancy ERNW GmbH Regular speakers at conferences and authors of several whitepapers & articles => we contribute to the community
What is SNMP?
Simple Network Management Protocol A protocol to manage networks ;-) : Where network management basically includes Getting parameters (e.g. interface throughput) from nodes Setting parameters on nodes (in a centralized way)
Manager
Box(es) used for management purposes Usually some server(s) running an expensive piece of software Often called NMS (Network Management Station)
SNMP Agent
The agent is a software function embedded in most networked devices, such as routers, switches, managed hubs, printers, and servers. It is responsible for processing SNMP requests from the manager. It is also responsible for the execution of routines that maintain variables as defined in the various supported MIBs.
Messages
There are three common message types:
Get - Enables the management station to retrieve the value of MIB objects from the agent. Set - Enables the management station to set the value of MIB objects at the agent. Trap - Enables the agent to notify the management station of significant events.
Each SNMP message contains a cleartext string (in v1 and v2c), called a community string. The community string is used like a password to restrict access to managed devices.
9
MIB
A MIB is used to store the structured information representing network elements and their attributes. The structure itself is defined in a standard called the SMI (Structure of Management Information ) The SMI defines the data types that can be used to store an object, how those objects are named, and how they are encoded for transmission over a network In short: Definition of stuff mgr and agent can talk about Hard coded in agent, (usually) to be loaded in NMS Often vendors implement their own MIBs (for their stuff)
10
11
SNMP Versions
SNMPv1 SNMPv2 in different flavors, mostly v2c (c stands for community here) SNMPv3 solves the security shortcomings of SNMPv1 and SNMPv2c. It provides secure access to MIBs by authenticating and encrypting packets over the network. However SNMPv3 is not widely used. Why? See below
12
13
SNMP Views
On some devices the accessible parts of the MIB(s) may be restricted on a branch level by the agent. The allowed branches are often called views: snmp-server view basic iso included snmp-server view basic ieee802dot11 included snmp-server community my_comm view basic RO
14
Vulnerabilities
Communities are transmitted in clear text Communities have well-known defaults (public for RO, private for RW) Protocol is UDP-based => packets may be spoofed Usually no logging of failed access attempts Corporate password change policies are rarely enforced with SNMP community strings (Dont touch them, we will lose NW mgmt! ;-)
15
SNMPv3
Nobody uses v3 (Laziness) v3 not supported by major NMS vendors (CWorks, HP-OV) Why? - V3 completely different architecture - Design weaknesses in v3 - e.g. Configuration must not be visible => is not displayed in sh run => repository tools/version diffs wont work for this
16
Interim summary
Nothing new so far... lets get a bit more practical then From attackers point of view the most interesting question is: what can be done (if compromised)?? Depends heavily on the MIB => Read the MIB, Luke!
17
18
Note: building this command line may be tedious... Fortunately some tools (including our one) meanwhile can do this... (at least for newer IOS versions, the variant described in [6]).
19
Step 1:
snmpset -c sagichnich 192.168.96.1 1.3.6.1.4.1.9.9.46.1.4.1.1.1.1 i 2 snmpset -c sagichnich 192.168.96.1 1.3.6.1.4.1.9.9.46.1.4.1.1.3.1 s "erey"
Step 2
[erey@ws23]$snmpset -c sagichnich 192.168.96.1 1.3.6.1.4.1.9.9.46.1.4.2.1.11.1.6 i 4 1.3.6.1.4.1.9.9.46.1.4.2.1.3.1.6 i 1 1.3.6.1.4.1.9.9.46.1.4.2.1.4.1.6 s "new_vlan" 1.3.6.1.4.1.9.9.46.1.4.2.1.6.1.6 x 000186A6 1.3.6.1.4.1.9.9.46.1.4.1.1.1.1 i 3 CISCO-VTP-MIB::vtpVlanEditRowStatus.1.6 = INTEGER: createAndGo(4) CISCO-VTP-MIB::vtpVlanEditType.1.6 = INTEGER: ethernet(1) CISCO-VTP-MIB::vtpVlanEditName.1.6 = STRING: "new_vlan" CISCO-VTP-MIB::vtpVlanEditDot10Said.1.6 = Hex-STRING: 00 01 86 A6 CISCO-VTP-MIB::vtpVlanEditOperation.1 = INTEGER: apply(3)
After
[erey@ws23]$snmpwalk -c sagichnich 192.168.96.1 1.3.6.1.4.1.9.9.46.1.3.1.1.2 CISCO-VTP-MIB::vtpVlanState.1.1 = INTEGER: operational(1) CISCO-VTP-MIB::vtpVlanState.1.5 = INTEGER: operational(1) CISCO-VTP-MIB::vtpVlanState.1.6 = INTEGER: operational(1) CISCO-VTP-MIB::vtpVlanState.1.31 = INTEGER: operational(1) CISCO-VTP-MIB::vtpVlanState.1.32 = INTEGER: operational(1) CISCO-VTP-MIB::vtpVlanState.1.64 = INTEGER: operational(1)
Step 3
[erey@ws23]$snmpset -c sagichnich vtpVlanEditOperation.1 i 4 CISCO-VTP-MIB::vtpVlanEditOperation.1 = INTEGER: release(4)
20
Types of Attacks
Directed attack against particular target Attacks on SNMP-speaking devices in the internet, for various purposes
21
Directed attack
May be necessary to determine authorized managers first [Looking-glass servers, other information gathering etc.] Get community string - Sniffing (requires medium access already) - Guessing (may work, certainly not reliable) - Bruteforcing Once community string is known, understand what can be done => again: read the MIB, Luke!
22
Bruteforcing SNMP
[erey@mobile ADMsnmp]$ ./ADMsnmp 192.168.96.1 -wordfile ./words_perm.txt ADMsnmp vbeta 0.1 (c) The ADM crew ftp://ADM.isp.at/ADM/ greets: !ADM, el8.org, ansia >>>>>>>>>>> get req name=1 id = 2 >>>>>>>>>>> ... >>>>>>>>>>> get req name=ro5ebud id = 113 >>>>>>>>>>> >>>>>>>>>>> get req name=r0sebud id = 119 >>>>>>>>>>> <<<<<<<<<<< recv snmpd paket id = 120 name = r0sebud ret =0 <<<<<<<<<< >>>>>>>>>>>> send setrequest id = 120 name = r0sebud >>>>>>>> >>>>>>>>>>> get req name=r0s3bud id = 122 >>>>>>>>>>> <<<<<<<<<<< recv snmpd paket id = 121 name = r0sebud ret =0 <<<<<<<<<< >>>>>>>>>>> get req name=ro53bud id = 125 >>>>>>>>>>> <<<<<<<<<<< recv snmpd paket id = 248 name = r0sebud ret =0 <<<<<<<<<< >>>>>>>>>>> get req name=r0538ud id = 128 >>>>>>>>>>> <<<<<<<<<<< recv snmpd paket id = 248 name = r0sebud ret =0 <<<<<<<<<< >>>>>>>>>>> get req name=rosebud1 id = 2 >>>>>>>>>>> ... >>>>>>>>>>> get req name=passzmodem id = 29 >>>>>>>>>>> >>>>>>>>>>> get req name= zmodem id = 32 >>>>>>>>>>> <!ADM!> snmp check on 192.168.96.1 <!ADM!> sys.sysName.:hdz-core-002.company.com name = r0sebud write access
23
24
Bruteforcing Statistics
3-letter community string: approx. 12 minutes 4-letter: approx. 6 hours 5-letter and more: still working on data ;-) => check our website
25
26
Advanced Techniques
Spoofing Multicasting (?) MPLS Labeling
27
Spoofing
Can easily be done, e.g. see [5] Goal: to subvert ACLs Attacker must first find out authorized managers
28
Multicasting
Question: do (which) systems accept SNMP packets sent to multicast addresses? [preferably 224.0.0.2] If so, less effort for an attacker. And potentially evasion of ACLs ;-) [as 224.0.0.2 might be allowed for routing protocol traffic] We tried, playing with Cisco gear and tcpreplay... without success. More research needed.
29
MPLS Labeling
SNMP is UDP based => perfectly qualified for one packet attacks (potentially blindly) throwing packets in foreign VPNs If receiving routers have (default) route to attackercontrolled host, attacker will still receive config files. If combined with multicast... - could be very efficient attack (one packet) - practically untraceable Victim might think mgmt vrf is not reachable from internet anyway... and thus leave public/private comfortably. [yes, this is the way it works out there ;-)]
30
CE
Mgmt vrf alpha
CE
PE
PE
CE
P PE
P PE CE
Mgmt
31
32
Methodology we used
Go through some network segments (scan is such an ugly word, isnt it? ;-) Test rather random addresses [ok, we skipped these ;-)
029/8 Jul 91 Defense Information Systems Agency 030/8 Jul 91 Defense Information Systems Agency
Check if hosts alive If alive, check given array of communities If community successful, try to write some dummy data => if successful, SNMP RW assumed (could still be restricted to views, in practice never is)
33
34
Agreed...
SNMP RW is cooler, but... SNMP RO might still be useful. Depends on the readible OID/objects. Leakage of/data mining passwords etc. Examples see below
35
Interesting OIDs
SNMP community strings ;-) Username(s)/password(s) of device Username(s)/password(s) of other devices (e.g. for dial-up, VPN) Nameserver, SIP proxies
36
37
38
39
40
41
42
"The IP Address of the Mediation Device's network interface to which to direct intercepted traffic."
::= { cTap2MediationEntry 3 }
43
45
46
47
48
49
50
51
52
53
54
55
(D)DoS
Amplification Attacks (remember Smurf?) Steps needed: - compile list of devices (will even be fast enough without due to UDP) - write some long strings to chosen places (e.g. sysContact) - perform snmpbulkwalk on these places - spoof source address of this operation with victims IP Bytes needed for command+control packet: approx. 60 bytes Bytes sent back (in some tests): up to 1500 => with one 2 MBit (upstream) line, 50 MBit of victim can be saturated Probably even much better ratios possible => more research needed.
56
Who is to blame
(Some? Most?) vendors of SOHO stuff Carriers: - for still using weak SNMP community strings in their networks - for delivering SNMP-enabled SOHO devices with their broadband products
57
58
Summary
Generally known (but still neglected) interesting attack vector Still widely exploitable in internet. Has dark community already discovered that? Vendors MUST change default behaviour.
59
Questions?
60
61
Sources
[5] Bypassing Cisco SNMP access lists using Spoofed SNMP Requests: http://remote-exploit.org/index.php/SNMP_Spoof [6] How To Copy Configurations To and From Cisco Devices Using SNMP: http://www.cisco.com/en/US/tech/tk648/tk362/technologies_tech_note09186a0080094aa 6.shtml [7] Cisco SNMP configuration attack with a GRE tunnel: http://www.securityfocus.com/infocus/1847
62