Skip to content

Commit

Permalink
update tools
Browse files Browse the repository at this point in the history
  • Loading branch information
0x90 committed Sep 25, 2015
1 parent 65297ad commit 105570f
Show file tree
Hide file tree
Showing 8 changed files with 1,722 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 80211client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
说明:使用libpcap编写的非官方校园网802.1x客户端.包括一个libpcap构造发送接收TCP/UDP数据包例子供参考.

参考了https://github.com/liuqun/openwrt-clients/tree/master/scut
19 changes: 19 additions & 0 deletions 80211client/linux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CC = gcc
CFLAGS = -g
OBJECTS = main.o watcher.o

.c.o:
$(CC) $(CFLAGS) -c -o $@ $<

all:main

main : $(OBJECTS)
gcc -o $@ $^ -lpcap

main.o : main.c
watcher.o : watcher.c data.h

clean:
rm -f main $(OBJECTS)

.PHONY : clean all
70 changes: 70 additions & 0 deletions 80211client/linux/data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
typedef struct ether_header
{
unsigned char eh_dst[6]; //目的地址
unsigned char eh_src[6]; //源地址
unsigned short eh_type; //eh_type的值需要考察上一层的协议,如果为ip则为0x0800
}ether_header;

typedef struct ip_hdr
{
unsigned char h_verlen; //IP类型为IPv4+ip头部长度(按4字节对齐)
// unsigned char version:4; //一般IP类型为IPv4,4表示4位
unsigned char tos; //服务类型
unsigned short total_len; //总长度(包含IP数据头,TCP数据头以及数据)
unsigned short ident; //识别码,ID定义单独IP,
unsigned short frag_and_flags;//标志位偏移量
unsigned char ttl; //生存时间
unsigned char protocol; //协议类型
unsigned short checksum; //检查和
unsigned long sourceIP; //源IP地址
unsigned long destIP; //目的IP地址
}ip_header;


typedef struct tcp_header
{
unsigned short th_sport; //源端口
unsigned short th_dport; //目的端口
unsigned int th_seq; //序列号
unsigned int th_ack; //确认号
//0000,0000 00,000010
unsigned char th_lenres; //4 位TCP首部+6位保留的前 4 位
unsigned char th_flag; //6位保留的前后2 位+标志位
unsigned short th_win; //窗口大小
unsigned short th_sum; //检验和
unsigned short th_urp; //紧急指针
}tcp_header;

typedef struct udp_header
{
uint16_t source; /* source port,等价于unsigned short */
uint16_t dest; /* destination port */
uint16_t len; /* udp length */
uint16_t checkl; /* udp checksum */
}udp_header;

typedef struct psd_header
{
unsigned long saddr; //源地址
unsigned long daddr; //目的地址
char mbz; //置空
char ptcl; //协议类型
unsigned short tcpl; //数据包长度
}psd_header;

#define IPTCPSIZE 58

typedef struct x802_header
{
u_char version;//802.1x版本号
u_char type;//eap的类型0--eap,1--eapol
u_short len;//eap数据包长度,包括首部
}x802_header;

typedef struct eap_header
{
u_char code;//request--1,respond--2
u_char id;//数据id
u_short len;//eap数据包长度,包括首部
u_char type;//1--identity,--md5-challenge,3--legacy_Nak
}eap_header;//大小为6
30 changes: 30 additions & 0 deletions 80211client/linux/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include<stdint.h>
#include <stdlib.h>

#include<unistd.h>
#include<string.h>
//#include "data.h"
/*child function*/
int auth802x(char *DeviceName);

int main(int argc,char *argv[]){
char *DeviceName;


/*check root privilige*/
if(getuid()!=0){
fprintf(stderr,"Sorry,it is unroot.\n");
exit(-1);
}
if(argc!=2){
fprintf(stderr,"Command is Illegal\n");
fprintf(stderr," %s Interface_Of_Wan\n",argv[0]);
exit(-1);
}
DeviceName = argv[1];
printf("%s",DeviceName);
auth802x(DeviceName);

return 0;
}
Loading

0 comments on commit 105570f

Please sign in to comment.