亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dps.c

?? its a full portscan... it works for all type of scanning. here we use libcap
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
 * Dynamic Port Scanner (DPS)
 * dps.c -- DPS core functions implementation
 *
 * Copyright (c) 2006 - 2008 AR Samhuri <ar@securebits.org>
 * ALL RIGHTS RESERVED.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
 * My Include
 */
#include "./dps.h"

/*
 * DPS Function Implementations
 */

void dps_init()
{
    int i;
    struct libnet_ether_addr *mac_addr;

    printf(
        "============================================================\n"
        BANNER "\n"
        COPYRIGHT "\n"
        "============================================================\n" );
    if( cfg.verbosity )
        printf("Initializing DPS...\n");
    /* 
     * Catch the interrupt signal so the prgram can print
     * the results before exiting
     */
    if( dps_catch_signal( SIGINT, dps_signal_handler ) == -1 )
    {
        printf("Cannot catch SIGINT signal.\n");
        exit( EXIT_FAILURE );
    }

    /* Initialize Libpcap, Libnet, and other DPS variables */

    /* Finding the device if the user didn't specify one */
    if( cfg.device == NULL )
    {
        cfg.device = pcap_lookupdev( pcap_cfg.p_errbuf );
        if( cfg.device == NULL )
        {
            printf("Error while looking for an interface: %s\n", pcap_cfg.p_errbuf );
            exit( EXIT_FAILURE );
        }
    }

    /* Opening the device */
    pcap_cfg.p = pcap_open_live( cfg.device, SNAPLEN, PROMISC, TIMEOUT, pcap_cfg.p_errbuf );
    if( pcap_cfg.p == NULL )
    {
        printf("Cannot open the device: %s\n", pcap_cfg.p_errbuf );
        exit( EXIT_FAILURE );
    }

    /* Checking the Data Link of the device */
    if( pcap_datalink( pcap_cfg.p ) != DLT_EN10MB )
    {
        printf("This program works only on Ethernet networks\n");
        pcap_close( pcap_cfg.p );
        exit( EXIT_FAILURE );
    }

    /* Setting up the Subnet Mask and Local Network Address */
    if( pcap_lookupnet( cfg.device, &pcap_cfg.local_net, &pcap_cfg.netmask, pcap_cfg.p_errbuf ) == -1 )
    {
        printf("Cannot set up the subnet mask and network address: %s\n", pcap_cfg.p_errbuf );
        pcap_close( pcap_cfg.p );
        exit( EXIT_FAILURE );
    }

    /* set the nonblock mode on the sniffin interface */
    pcap_setnonblock( pcap_cfg.p, 1, pcap_cfg.p_errbuf );

    /* Initialize the Libnet Context */
    libnet_cfg.l = libnet_init( LIBNET_LINK, cfg.device, libnet_cfg.l_errbuf );
    if( libnet_cfg.l == NULL )
    {
        printf("Cannot initialize Libnet context: %s\n", libnet_cfg.l_errbuf );
        exit( EXIT_FAILURE );
    }

    /* Get the Local IP Address */
    local_ip_addr = libnet_get_ipaddr4( libnet_cfg.l );

    /* Get the Local MAC Address */
    mac_addr = libnet_get_hwaddr( libnet_cfg.l );
    if( mac_addr == NULL )
    {
        printf("Cannot probe for local MAC: %s\n", libnet_geterror( libnet_cfg.l ) );
        exit( EXIT_FAILURE );
    }
    local_eth_addr = ( u_int8_t * ) malloc( HRD_ADDR_LENGTH );
    for( i = 0; i < HRD_ADDR_LENGTH; i++ )
        local_eth_addr[ i ] = mac_addr->ether_addr_octet[ i ];

    /* Set the Target IP Address */
    if( cfg.resolve )
        target_ip = libnet_name2addr4( NULL, cfg.target_ips, LIBNET_RESOLVE );
    else
        target_ip = libnet_name2addr4( NULL, cfg.target_ips, LIBNET_DONT_RESOLVE );
    if( target_ip == -1 )
    {
        printf("Incorrect IP Address: %s\n", cfg.target_ips );
        exit( EXIT_FAILURE );
    }

    /* 
     * If the target IP is NOT within the local net,
     * We need to get the IP of the default gateway.
     *
     * The remote MAC is the MAC of target IP if it's
     * within the local net, and it is the MAC of the
     * default gateway if the target IP is NOT within
     * the local net.
     */
    if( ( target_ip & pcap_cfg.netmask ) != pcap_cfg.local_net )
    {
        default_gateway = get_default_gateway();
        if( default_gateway == 0 )
        {
            printf("The target IP is unreachable. Default gateway couldn't be found\n");
            exit( EXIT_FAILURE );
        }
        remote_eth = get_macOfip( default_gateway );
        if( remote_eth == NULL )
        {
            printf("Couldn't ARP %s\n", libnet_addr2name4( default_gateway, LIBNET_DONT_RESOLVE ) );
            exit( EXIT_FAILURE );
        }
    }
    else
    {
        remote_eth = get_macOfip( target_ip );
        if( remote_eth == NULL )
        {
            printf("Couldn't ARP %s\n", libnet_addr2name4( target_ip, LIBNET_DONT_RESOLVE ) );
            exit( EXIT_FAILURE );
        }
        default_gateway = 0; /* unneeded */
    }

    /* Up-to-now, we have the following in our hands:
     * local_ip_addr       Local IP Address
     * local_eth_adddr     Local MAC Address
     * remote_eth          Remote MAC Address
     * target_ip           Target IP Address
     * pcap_cfg.netmask    Local Subnet Mask
     * pcap_cfg.local_net  Local Network Address
     * default_gateway     Gateway IP Address [?!]
     */

    /* Initialize the port list */
    if( !cfg.port_list )
    {
        cfg.port_list = ( char * ) malloc( 10 );
        strcpy( cfg.port_list, "1-1024" );
    }
    if( libnet_plist_chain_new( libnet_cfg.l, &libnet_cfg.plist, cfg.port_list ) == -1 )
    {
        printf("libnet_plist_chain_new(): %s\n", libnet_geterror( libnet_cfg.l ) );
        exit( EXIT_FAILURE );
    }
}

void dps_scan()
{
    int       received, i;
    u_int16_t bport,
              eport,
              src_port,
              dst_port;
    u_int32_t spoofed_src_ip,
              poisoned_ip;
    u_int8_t  *rcv_packet;
    time_t    start_time;
    time_t    scan_begin;
    time_t    scan_end;

    struct pcap_pkthdr       header;
    struct libnet_ipv4_hdr   *ip;
    struct libnet_tcp_hdr    *tcp;
    struct libnet_udp_hdr    *udp;
    struct libnet_icmpv4_hdr *icmp;
    struct port_data         *current_port;

    if( cfg.verbosity )
        printf("Starting Scanning...\n");
    /* 
     * if the user specified the Ping option,
     * we need to ping the target before scanning.
     * the target won't be scanned if it's unpingable
     */
    if( cfg.ping != 0 )
        if( dps_ping() == 0 )
        {
            printf("The target host is not PINGable. try -P0 to disable PINGing\n");
            exit( EXIT_FAILURE );
        }

    result.data = ( struct port_data * ) malloc( sizeof( struct port_data ) );
    result.counter       = 0;
    result.open          = 0;
    result.closed        = 0;
    result.filtered      = 0;
    result.unfiltered    = 0;
    result.open_filtered = 0;
    current_port = result.data;
    current_port->next = NULL;
    scan_begin = time( NULL );

    /* 
     * Here, we need to go through the list of ports,
     * send ARP poisoning packets (2 packets),
     * send the scan packet (TCP or UDP),
     * and listen for the response (timeout)
     */
    while( libnet_plist_chain_next_pair( libnet_cfg.plist, &bport, &eport ) >= 1 )
    {
        for( dst_port = bport; dst_port <= eport; dst_port++ )
        {
            src_port = generate_random_port( 2 ); /* PORT: 1025 <-> 65535 */

            if( default_gateway ) poisoned_ip = default_gateway;
            else                  poisoned_ip = target_ip;

            do
            {
                spoofed_src_ip = generate_random_ip( pcap_cfg.local_net, pcap_cfg.netmask );
            }while( spoofed_src_ip == poisoned_ip || spoofed_src_ip == pcap_cfg.local_net );

            current_port->spoofed_ip = spoofed_src_ip;
            current_port->port       = dst_port;
            result.counter ++;
            if( cfg.verbosity == 2 )
                printf("PORT [%d] SPOOFED IP [%s] ", current_port->port,
                        libnet_addr2name4( spoofed_src_ip, LIBNET_DONT_RESOLVE ) );

            /* 
             * Poison the remote end with the following:
             * spoofed_src_ip   Source IP Address
             * poisoned_ip      Destination IP Address
             * local_eth_addr   Source MAC Address
             * remote_eth       Destination MAC Address
             */

            /*
             * QUICK ARP POISONING LESSON:
             * To effectively poison a host, send two ARP packets.
             * The first is a fake ARP request.
             * The second is a fake ARP reply.
             * That works on:
             * Linux systems
             * All windows systems: WIN9X, WINNT, WIN2k, WINXP,...
             * Cisco systems: Router IOS, L3 Switch, PIX FW,...
             */

            dps_build_arp( ARPOP_REQUEST, spoofed_src_ip, poisoned_ip, local_eth_addr, remote_eth );
            dps_write_packet();
            usleep( 50000 );
            dps_build_arp( ARPOP_REPLY, spoofed_src_ip, poisoned_ip, local_eth_addr, remote_eth );
            dps_write_packet();
            usleep( 50000 );

            /* 
             * For the scan packet, we have now:
             * src_port        Source Port Address
             * dst_port        Destination Port Address
             * spoofed_src_ip  Source IP Address
             * target_ip       Destination IP Address
             */

            /* Build the scan packet */
            if( strcmp( cfg.scan_type, "UDP" ) != 0 )
            {
                dps_build_tcp( tcp_control, src_port, dst_port, spoofed_src_ip, target_ip,
                               local_eth_addr, remote_eth );
                current_port->sent_control = tcp_control;

                /* set the filter:
                 * src host target_ip and dst host spoofed_src_ip
                 * and tcp src port dst_port and dst port src_port
                 */
                pcap_cfg.f_code = ( char * ) malloc( 100 );
                sprintf(pcap_cfg.f_code,
                        "src host %s and dst host %s and tcp src port %d and dst port %d\0",
                        libnet_addr2name4( target_ip, LIBNET_DONT_RESOLVE ),
                        libnet_addr2name4( spoofed_src_ip, LIBNET_DONT_RESOLVE),
                        dst_port, src_port );
            }
            else
            {
                dps_build_udp( src_port, dst_port, spoofed_src_ip, target_ip,
                               local_eth_addr, remote_eth );
	       	pcap_cfg.f_code = ( char * ) malloc( 200 );
                sprintf( pcap_cfg.f_code,
                         "src host %s and dst host %s and icmp or "
                         "src host %s and dst host %s and udp src port %d and dst port %d\n",
                         libnet_addr2name4( target_ip, LIBNET_DONT_RESOLVE ),
                         libnet_addr2name4( spoofed_src_ip, LIBNET_DONT_RESOLVE ),
                         libnet_addr2name4( target_ip, LIBNET_DONT_RESOLVE ),

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美色图激情小说| 国产·精品毛片| 亚洲视频免费在线观看| 中文在线一区二区| 日本一区二区在线不卡| 国产日产欧美精品一区二区三区| 精品少妇一区二区三区| 亚洲精品一区二区三区99| 精品捆绑美女sm三区| 久久伊人中文字幕| 中文字幕欧美激情| 亚洲少妇最新在线视频| 亚洲黄色录像片| 亚洲国产日韩一区二区| 日本欧美加勒比视频| 韩国欧美一区二区| 波多野结衣中文字幕一区| 波多野结衣精品在线| 色欧美片视频在线观看在线视频| 在线观看91视频| 日韩午夜av一区| 欧美激情中文字幕| 一区二区三区不卡在线观看| 日韩精品福利网| 国产成人99久久亚洲综合精品| a级高清视频欧美日韩| 在线看日韩精品电影| 欧美一级高清大全免费观看| 国产欧美一区二区三区在线老狼| 国产精品久久久久aaaa樱花 | aaa亚洲精品一二三区| 99re在线视频这里只有精品| 色av成人天堂桃色av| 日韩精品一区二区三区视频播放 | 久久国产精品露脸对白| 国产99久久久国产精品潘金| 91国产成人在线| 欧美mv日韩mv国产| 亚洲精品日产精品乱码不卡| 亚洲大片免费看| 成人黄色免费短视频| 欧美一区二区三区白人| 欧美—级在线免费片| 视频一区在线播放| 不卡视频免费播放| 日韩精品一区二区三区在线| 亚洲欧洲精品一区二区三区不卡| 蜜臀av一区二区在线观看| 99re这里都是精品| 久久九九全国免费| 秋霞影院一区二区| 欧洲精品在线观看| 中文字幕va一区二区三区| 热久久免费视频| 91国偷自产一区二区使用方法| 国产日产欧美一区| 国产在线一区二区| 日韩视频在线永久播放| 天天影视网天天综合色在线播放| 成人黄页在线观看| 中文字幕精品三区| 国产一区不卡在线| 亚洲精品一区在线观看| 日韩高清电影一区| 555夜色666亚洲国产免| 亚洲制服丝袜av| 成人国产精品免费观看视频| 精品福利二区三区| 激情丁香综合五月| 日韩精品中午字幕| 蓝色福利精品导航| 欧美高清性hdvideosex| 亚洲18色成人| 8x8x8国产精品| 日本aⅴ精品一区二区三区| 制服视频三区第一页精品| 亚洲线精品一区二区三区八戒| 在线观看视频一区二区欧美日韩 | 92精品国产成人观看免费| 日本一区二区电影| av在线一区二区| 一区二区三区免费观看| 欧美亚洲国产一区在线观看网站| 亚洲欧洲另类国产综合| 色999日韩国产欧美一区二区| 亚洲人成网站影音先锋播放| 9久草视频在线视频精品| 综合色中文字幕| 欧美三级电影精品| 久久99国产精品麻豆| 精品播放一区二区| 粉嫩aⅴ一区二区三区四区五区| 日本一区二区免费在线观看视频 | 激情文学综合网| 国产农村妇女毛片精品久久麻豆| 高清国产一区二区三区| 亚洲激情成人在线| 欧美日韩国产一区二区三区地区| 亚洲福中文字幕伊人影院| 欧美日韩视频在线一区二区 | 久久久久久久久久久黄色| 国产99一区视频免费| 最新热久久免费视频| 欧美日本国产视频| 国产suv精品一区二区三区| 中文字幕一区不卡| 欧美日韩黄色一区二区| 国精产品一区一区三区mba视频| 国产精品欧美综合在线| 欧美日韩在线观看一区二区| 九九在线精品视频| 亚洲你懂的在线视频| 日韩女同互慰一区二区| 91麻豆.com| 久久99精品国产.久久久久久| 国产精品第13页| 91免费国产在线| 久久99国产精品久久99| 亚洲精品国产第一综合99久久 | 亚洲四区在线观看| 欧美大度的电影原声| 欧美在线短视频| 国产精品综合在线视频| 亚洲国产精品自拍| 国产精品家庭影院| 欧美va亚洲va| 欧美精品少妇一区二区三区| 成人av第一页| 国产乱理伦片在线观看夜一区| 亚洲激情中文1区| 国产精品人妖ts系列视频| 日韩视频免费观看高清完整版 | 91香蕉视频污| 国产一区二三区| 免费成人美女在线观看| 亚洲综合久久久久| 中文字幕一区二区三区乱码在线| 91麻豆精品国产91久久久资源速度| 99视频热这里只有精品免费| 国产精品系列在线观看| 久久精品国产成人一区二区三区| 亚洲国产aⅴ天堂久久| 一区二区三区免费观看| 一区二区三区在线观看国产| 中文字幕亚洲精品在线观看| 欧美韩日一区二区三区| 国产欧美日韩久久| 欧美极品另类videosde| 欧美韩国日本一区| 国产精品国产a级| 中文字幕第一区二区| 中文字幕第一区第二区| 欧美激情一区二区三区蜜桃视频| 久久美女艺术照精彩视频福利播放| 欧美一区二区三区在| 日韩三级av在线播放| 精品国产污网站| 国产亚洲精品福利| 亚洲国产成人午夜在线一区| 久久久噜噜噜久久人人看 | 99久久婷婷国产综合精品电影| 成人午夜激情片| 色婷婷精品久久二区二区蜜臂av | 成人三级伦理片| 成人性生交大片免费看中文| 成人激情图片网| 91网页版在线| 欧美在线免费播放| 日韩午夜在线观看| 国产视频一区二区在线| 最新久久zyz资源站| 亚洲福利电影网| 精品中文av资源站在线观看| 成人午夜视频福利| 色94色欧美sute亚洲13| 欧美一级黄色片| 欧美激情综合在线| 亚洲欧洲制服丝袜| 日本中文在线一区| 国产白丝精品91爽爽久久| 色国产精品一区在线观看| 欧美一区二区啪啪| 欧美激情一二三区| 亚洲综合另类小说| 国产一区二区三区在线观看精品| 国产成人久久精品77777最新版本| 91亚洲精华国产精华精华液| 欧美无砖专区一中文字| www成人在线观看| 亚洲视频一区二区免费在线观看| 亚洲18影院在线观看| 成人永久aaa| 日韩精品中文字幕在线不卡尤物| 国产欧美一区二区在线| 五月婷婷综合网| av不卡在线播放| 精品国产成人系列| 婷婷久久综合九色国产成人| 成人v精品蜜桃久久一区| 在线不卡的av|