From 036bc4ab20209552060fe9ceaea2d3dae019662f Mon Sep 17 00:00:00 2001 From: acoret Date: Sun, 26 Mar 2017 14:32:23 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=A4=9A=E7=BD=91?= =?UTF-8?q?=E5=8D=A1=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE=E5=8C=B9=E9=85=8D?= =?UTF-8?q?IP=E5=9C=B0=E5=9D=80bug,=E5=A4=9A=E7=BD=91=E5=8D=A1=E8=AF=B7?= =?UTF-8?q?=E6=8C=87=E5=AE=9A--device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zdclient.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zdclient.c b/zdclient.c index 8ad341e..c3a505c 100644 --- a/zdclient.c +++ b/zdclient.c @@ -601,6 +601,13 @@ void init_device() dev = alldevs->name; strcpy (dev_if_name, dev); } + else + for(alldevs;alldevs;alldevs=alldevs->next) + if (strcmp(alldevs->name,dev)==0) + { + strcpy (dev_if_name, dev); + break; + } if (dev == NULL) { fprintf(stderr, "Couldn't find default device: %s\n", @@ -629,6 +636,9 @@ void init_device() local_mask = ((struct sockaddr_in *)addrs->netmask)->sin_addr.s_addr; } } + + + #ifdef __linux /* get device basic infomation */ struct ifreq ifr; From 64ed42a455c042cf9b46f6348d996dbd3875576e Mon Sep 17 00:00:00 2001 From: acoret Date: Sun, 2 Apr 2017 02:55:26 +0000 Subject: [PATCH 2/5] version add support muti-netdriver --- zdclient.h | 252 ++++++++++++++++++++++++++--------------------------- 1 file changed, 126 insertions(+), 126 deletions(-) diff --git a/zdclient.h b/zdclient.h index ee97495..46f6d70 100644 --- a/zdclient.h +++ b/zdclient.h @@ -1,128 +1,128 @@ -/* - * ===================================================================================== - * - * Filename: zdclient.h - * - * Description: - * - * Version: 1.0 - * Created: 06/06/2009 03:47:25 PM - * Revision: none - * Compiler: gcc - * - * Author: YOUR NAME (), - * Company: - * - * ===================================================================================== - */ - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - - -#ifndef __linux -//------bsd/apple mac - #include - #include - #include -#endif - -#include -#include -#include "md5.h" - -/* ZDClient Version */ -#define ZDC_VER "0.13" - -/* default snap length (maximum bytes per packet to capture) */ -#define SNAP_LEN 1518 - -/* ethernet headers are always exactly 14 bytes [1] */ -#define SIZE_ETHERNET 14 - -struct eap_header { - uint8_t eapol_v; - uint8_t eapol_t; - uint16_t eapol_length; - uint8_t eap_t; - uint8_t eap_id; - uint16_t eap_length; - uint8_t eap_op; - uint8_t eap_v_length; - uint8_t eap_md5_challenge[16]; -}; - -struct dcba_tailer { - bpf_u_int32 local_ip; - bpf_u_int32 local_mask; - bpf_u_int32 local_gateway; - bpf_u_int32 local_dns; - uint8_t username_md5[16]; - uint8_t client_ver[13]; -}; - -enum EAPType { - EAPOL_START, - EAPOL_LOGOFF, - EAP_REQUEST_IDENTITY, - EAP_RESPONSE_IDENTITY, - EAP_REQUEST_IDENTITY_KEEP_ALIVE, - EAP_RESPONSE_IDENTITY_KEEP_ALIVE, - EAP_REQUETS_MD5_CHALLENGE, - EAP_RESPONSE_MD5_CHALLENGE, - EAP_SUCCESS, - EAP_FAILURE, +/* + * ===================================================================================== + * + * Filename: zdclient.h + * + * Description: + * + * Version: 1.0 + * Created: 06/06/2009 03:47:25 PM + * Revision: none + * Compiler: gcc + * + * Author: YOUR NAME (), + * Company: + * + * ===================================================================================== + */ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + + +#ifndef __linux +//------bsd/apple mac + #include + #include + #include +#endif + +#include +#include +#include "md5.h" + +/* ZDClient Version */ +#define ZDC_VER "0.14" + +/* default snap length (maximum bytes per packet to capture) */ +#define SNAP_LEN 1518 + +/* ethernet headers are always exactly 14 bytes [1] */ +#define SIZE_ETHERNET 14 + +struct eap_header { + uint8_t eapol_v; + uint8_t eapol_t; + uint16_t eapol_length; + uint8_t eap_t; + uint8_t eap_id; + uint16_t eap_length; + uint8_t eap_op; + uint8_t eap_v_length; + uint8_t eap_md5_challenge[16]; +}; + +struct dcba_tailer { + bpf_u_int32 local_ip; + bpf_u_int32 local_mask; + bpf_u_int32 local_gateway; + bpf_u_int32 local_dns; + uint8_t username_md5[16]; + uint8_t client_ver[13]; +}; + +enum EAPType { + EAPOL_START, + EAPOL_LOGOFF, + EAP_REQUEST_IDENTITY, + EAP_RESPONSE_IDENTITY, + EAP_REQUEST_IDENTITY_KEEP_ALIVE, + EAP_RESPONSE_IDENTITY_KEEP_ALIVE, + EAP_REQUETS_MD5_CHALLENGE, + EAP_RESPONSE_MD5_CHALLENGE, + EAP_SUCCESS, + EAP_FAILURE, ERROR, - EAP_REQUEST_MD5_KEEP_ALIVE=250 -}; - -enum STATE { - READY, - STARTED, - ID_AUTHED, - ONLINE -}; - -void send_eap_packet(enum EAPType send_type); -void show_usage(); -char* get_md5_digest(const char* str, size_t len); -void action_by_eap_type(enum EAPType pType, - const struct eap_header *header, - const struct pcap_pkthdr *packetinfo, - const uint8_t *packet); -void send_eap_packet(enum EAPType send_type); -void init_frames(); -void init_info(); -void init_device(); -void init_arguments(int *argc, char ***argv); -int set_device_new_ip(); + EAP_REQUEST_MD5_KEEP_ALIVE=250 +}; + +enum STATE { + READY, + STARTED, + ID_AUTHED, + ONLINE +}; + +void send_eap_packet(enum EAPType send_type); +void show_usage(); +char* get_md5_digest(const char* str, size_t len); +void action_by_eap_type(enum EAPType pType, + const struct eap_header *header, + const struct pcap_pkthdr *packetinfo, + const uint8_t *packet); +void send_eap_packet(enum EAPType send_type); +void init_frames(); +void init_info(); +void init_device(); +void init_arguments(int *argc, char ***argv); +int set_device_new_ip(); void fill_password_md5(uint8_t attach_key[], uint8_t eap_id); -void fill_uname_md5(uint8_t attach_key[], uint8_t eap_id); -int program_running_check(); -void daemon_init(void); -void show_local_info(); -void print_server_info (const uint8_t *packet, uint16_t packetlength); -int code_convert(char *from_charset, char *to_charset, - char *inbuf, size_t inlen, char *outbuf, size_t outlen); - - -void -get_packet(uint8_t *args, const struct pcap_pkthdr *header, - const uint8_t *packet); - - +void fill_uname_md5(uint8_t attach_key[], uint8_t eap_id); +int program_running_check(); +void daemon_init(void); +void show_local_info(); +void print_server_info (const uint8_t *packet, uint16_t packetlength); +int code_convert(char *from_charset, char *to_charset, + char *inbuf, size_t inlen, char *outbuf, size_t outlen); + + +void +get_packet(uint8_t *args, const struct pcap_pkthdr *header, + const uint8_t *packet); + + From 46179279f82fb5bfb1d9e2f0a619e5bb76721e6c Mon Sep 17 00:00:00 2001 From: acoret Date: Wed, 19 Apr 2017 13:07:55 +0800 Subject: [PATCH 3/5] auto remove LOCKFILE --- main.c | 2 ++ zdclient.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index cd77e96..6d99e81 100644 --- a/main.c +++ b/main.c @@ -104,6 +104,8 @@ program_running_check() if ( kill (fl.l_pid, SIGINT) == -1 ) perror("kill"); fprintf (stdout, "&&Info: Kill Signal Sent to PID %d.\n", fl.l_pid); + if (!remove(LOCKFILE)) + fprintf(stdout,"&&Info: LOCKFILE delete failed,please remove it: %s",LOCKFILE); } else fprintf (stderr, "&&Info: NO ZDClient Running.\n"); diff --git a/zdclient.h b/zdclient.h index ee97495..e840faf 100644 --- a/zdclient.h +++ b/zdclient.h @@ -47,7 +47,7 @@ #include "md5.h" /* ZDClient Version */ -#define ZDC_VER "0.13" +#define ZDC_VER "0.14" /* default snap length (maximum bytes per packet to capture) */ #define SNAP_LEN 1518 From de962c35e6f4fcb8f017542598bc25100e928245 Mon Sep 17 00:00:00 2001 From: acoret Date: Wed, 19 Apr 2017 13:32:14 +0800 Subject: [PATCH 4/5] Real commit.Fixed not remove LOCKFILE --- zdclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zdclient.h b/zdclient.h index 3170442..a8c63f3 100644 --- a/zdclient.h +++ b/zdclient.h @@ -47,7 +47,7 @@ #include "md5.h" /* ZDClient Version */ -#define ZDC_VER "0.14" +#define ZDC_VER "0.16" /* default snap length (maximum bytes per packet to capture) */ #define SNAP_LEN 1518 From 74c13e5d14c43f77224ee5d5242faf3f10144b42 Mon Sep 17 00:00:00 2001 From: acoret Date: Thu, 20 Apr 2017 14:40:11 +0800 Subject: [PATCH 5/5] add archlinux PKGBUILD --- PKGBUILD | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 PKGBUILD diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..dae2a7e --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,29 @@ +pkgname='zdcclient' +pkgver='1.6' +pkgrel=1 +pkgdesc="Nettool for school in china,Connect x802.1fixed" +url="git+https://github.com/isombyt/zdcclient.git" +arch=('x86_64' 'i386') +license=('GPL') +source=($pkgname::git://github.com/acoret/zdcclient.git) +gitsource=($pkgname::https://github.com/acoret/zdcclient.git) +makedepends=('libcap' 'make' 'git') +depends=('libcap') + +md5sums=('SKIP') +build() +{ + cd $pkgname + make -j +} +package() +{ + echo 'please edit runzdclient...' + cd $pkgname + install -Dm4755 zdclient ${pkgdir}/usr/local/bin/zdclient + install -Dm0755 runzdclient ${pkgdir}/usr/local/bin/runzdclient +} +post_install() +{ + echo 'please check if /usr/local/bin/runzdclient contain right user and passwd' +}