?? dps.h
字號(hào):
/*
* Dynamic Port Scanner (DPS)
* dps.h -- DPS includes, structures, and prototypes
*
* 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
*
*/
#ifndef _DPS_H_
#define _DPS_H_
/*
* All Includes
*/
#include <pcap.h>
#include <libnet.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
/*
* MACRO Definitions
*/
#define VERSION "1.1"
#define BANNER "Dynamic Port Scanner [DPS] version "VERSION
#define COPYRIGHT "Copyright (c) 2006 - 2008 AR <ar@securebits.org> "
#define SNAPLEN 100 /* We'll never exceed this */
#define PROMISC 1 /* Promiscous Mode */
#define TIMEOUT 100 /* Milliseconds -- pcap sniffing timeout */
#define SCAN_TIMEOUT 2 /* Seconds -- scanning timeout */
#define PING_TIMEOUT 2 /* Seconds -- pinging timeout */
#define ARP_TIMEOUT 1 /* Seconds -- ARP timeout */
#define HRD_ADDR_LENGTH 6 /* Length of MAC Address (byte) */
#define PRO_ADDR_LENGTH 4 /* Length of IP Address (byte) */
#define SEQ 0XA1B2C3D4 /* TCP sequence number (arbitrary) */
#define ACK 0XF9E8D7C6 /* TCP acknowledgement number (arbitrary) */
#define WIN 23468 /* TCP window size */
#define TOS 0 /* IP Type-Of-Service */
#define TTL 64 /* IP Time-To-Live */
#define ID 242 /* IP or ICMP identification number */
#define TCPIP_LEN 0X28 /* size of TCP_IP packet */
#define UDPIP_LEN 0X1C /* size of UDP_IP packet */
#define ICMPIP_LEN 0X1C /* size of ICMP_IP (ping) packet */
#define PORT_OPEN 0X01 /* denotes open port */
#define PORT_CLOSED 0X02 /* denotes closed port */
#define PORT_FILTERED 0X04 /* denotes filtered (firewalled) port */
#define PORT_UNFILTERED 0X08 /* denotes unfiltered port */
#define SCAN_NULL 0X00 /* TCP NULL Scan [______] */
#define SCAN_FIN 0X01 /* TCP FIN Scan [_____F] */
#define SCAN_SYN 0X02 /* TCP SYN Scan [____S_] */
#define SCAN_PSH 0X08 /* TCP PSH Scan [__P___] */
#define SCAN_ACK 0X10 /* TCP ACK Scan [_A____] */
#define SCAN_URG 0X20 /* TCP URG Scan [U_____] */
#define SCAN_XMAS 0X29 /* TCP XMAS Scan [U_P__F] */
#define SCAN_XMAS1 0X09 /* TCP XMAS1 Scan [__P__F] */
#define SCAN_XMAS2 0X21 /* TCP XMAS2 Scan [U____F] */
#define SCAN_XMAS3 0X28 /* TCP XMAS3 Scan [U_P___] */
/*
* Structure Definitions
*/
/* DPS Config Structure */
struct {
char *scan_type;
char *port_list;
char *source_ports;
char *source_ips;
char *device;
int timeout;
int resolve;
int ping;
int windows;
int verbosity;
char *target_ips;
}cfg;
/* Libnet Config Structure */
struct {
libnet_t *l; /* Libnet Handle */
libnet_ptag_t tcp; /* TCP header for TCP scan packet */
libnet_ptag_t udp; /* UDP header for UDP scan packet */
libnet_ptag_t icmp; /* ICMP header for PINGing */
libnet_ptag_t ip; /* IP header for "all of the above" */
libnet_ptag_t arp; /* ARP header for ARP poisoning */
libnet_ptag_t eth; /* Ethernet header for "All of the Above" */
libnet_plist_t *plist; /* list of ports to scan */
char l_errbuf[LIBNET_ERRBUF_SIZE];
}libnet_cfg;
/* Libpcap Config Structure */
struct {
pcap_t *p; /* PCAP handle */
bpf_u_int32 local_net; /* Local Network Address */
bpf_u_int32 netmask; /* Subnet Mask */
struct bpf_program f_program; /* Program for BPF code */
char *f_code; /* Filter code */
char p_errbuf[PCAP_ERRBUF_SIZE];
}pcap_cfg;
/* Results Linked-List */
struct result{
struct port_data *data; /* points to port_data LL */
int counter; /* port counter */
int open; /* number of open ports */
int closed; /* number of closed ports */
int filtered; /* number of filtered ports */
int unfiltered; /* number of unfiltered ports */
int open_filtered;/* number of open|filtered ports */
}result;
struct port_data{
u_int32_t spoofed_ip; /* used spoofed IP */
u_int16_t port; /* scanned port */
u_int8_t sent_control; /* sent control flags */
u_int8_t recv_control; /* recieved control flags */
u_int8_t status; /* status of the port */
u_int8_t status_win; /* status of the port on windows */
struct port_data *next; /* next element in the LL */
};
/*
* Global Variables
*/
u_int32_t local_ip_addr;
u_int32_t target_ip;
u_int32_t default_gateway;
u_int8_t *local_eth_addr;
u_int8_t *remote_eth;
u_int8_t tcp_control;
time_t scan_time;
char scan_type_str[50];
/*
* Function Prototypes
*/
void dps_init();
void dps_usage( char * );
void dps_scan();
void dps_build_arp( int, u_int32_t, u_int32_t,
u_int8_t *, u_int8_t * );
void dps_build_tcp( u_int8_t, u_int16_t, u_int16_t, u_int32_t,
u_int32_t, u_int8_t *, u_int8_t * );
void dps_build_udp( u_int16_t, u_int16_t, u_int32_t,
u_int32_t, u_int8_t *, u_int8_t * );
void dps_build_icmp( u_int32_t, u_int32_t, u_int8_t *, u_int8_t * );
int dps_ping();
void dps_write_packet();
void dps_set_filter( struct bpf_program );
void dps_print();
void dps_cleanup();
int dps_catch_signal( int, void( * )() );
void dps_signal_handler();
u_int32_t get_default_gateway();
u_int8_t *get_macOfip( u_int32_t);
u_int32_t generate_random_ip( u_int32_t, u_int32_t );
u_int16_t generate_random_port( int );
char *b_search( u_int16_t );
#endif /* _DPS_H_ */
/* EOF */
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -