www.pudn.com > QQ_Sniffer.rar > myCrack.h


#pragma once 
#pragma pack(1)  
// following cmdcode and macros partly come from Gaim's HH and Shufeng Tan's Net-HH 
#define MAX_P_LEN      1600         
#define LEN_TCP_HEADER    9         
#define LEN_UDP_HEADER    7         
#define LEN_TAIL          1         
#define LEN_TEA_KEY			16 
#define MIN_P_LEN     LEN_UDP_HEADER+LEN_TAIL+4   
 
#define HH_BEGIN_TAG      2 
#define HH_END_TAG        3 
#define LEN_HHNO          4      // just sizeof(unsigned int) 
 
#define HH_CMD_LOGOUT               0x0001 
#define HH_CMD_KEEP_ALIVE           0x0002  
#define HH_CMD_REG_NEW_ID_2         0x0003  
#define HH_CMD_UPDATE_INFO          0x0004  
#define HH_CMD_SEARCH_USER          0x0005  
#define HH_CMD_GET_USER_INFO        0x0006 
#define HH_CMD_ADD_FRIEND_WO_AUTH   0x0009 
#define HH_CMD_DEL_FRIEND           0x000a 
#define HH_CMD_BUDDY_AUTH           0x000b 
#define HH_CMD_CHANGE_ONLINE_STATUS 0x000d 
#define HH_CMD_REG_NEW_ID_1         0x0011 
#define HH_CMD_ACK_SYS_MSG          0x0012 
#define HH_CMD_SEND_IM              0x0016  
#define HH_CMD_RECV_IM              0x0017  
//#define HH_CMD_UNKNOW				0x001a  δ֪×÷Óà 
#define HH_CMD_REMOVE_SELF          0x001c  
#define HH_CMD_CELL_PHONE_1         0x0021  
#define HH_CMD_LOGIN                0x0022  
#define HH_CMD_GET_FRIENDS_LIST     0x0026  
#define HH_CMD_GET_FRIENDS_ONLINE   0x0027  
#define HH_CMD_CELL_PHONE_2         0x0029  
#define HH_CMD_GROUP_CMD            0x0030  
#define HH_CMD_PRE_LOGIN            0x0062  
#define HH_CMD_RECV_MSG_SYS         0x0080  
#define HH_CMD_RECV_MSG_FRIEND_CHANGE_STATUS  0x0081  
 
 
#define C2S 1  // client to server packet. 
#define S2C 0  // server to client packet. 
 
#define HH_DIC_CRACK				0	//×Öµä 
#define HH_LOWER_CRACK				1	//Сд×Öĸ 
#define HH_NUM_CRACK				2	//Êý×Ö 
#define HH_UPPER_CRACK				4	//´óд×Öĸ 
#define HH_SYMBOL_CRACK				8	//ÌØÊâ·ûºÅ 
 
 
#define MAX_PASS_LEN 16 
 
#define PWLENGTH 63	 
 
#define RECORD_GAP 0x00800000 
 
//TCPF, Text Chatting Protocol Family 
typedef struct hh_udp_header 
{ 
    u_char    begin_tag;    //always 0x02 till now 
    u_short   sender_ver;     
    u_short   hh_cmd;        
 
    u_short   sq_no;         
 
    u_char    data[1];      //following are data. 
}hh_udp_header; 
 
 
typedef struct hh_tcp_header 
{ 
    u_short   p_len;        //packet len, only tcp has it. 
    hh_udp_header quh; 
 
}hh_tcp_header; 
 
 
typedef struct hh_login_data 
{ 
    u_int     hh_no;                  
    u_char    key[LEN_TEA_KEY];       
    u_char    data[1];                
}hh_login_data; 
 
typedef struct hh_workkey 
{ 
	byte	  state; //0£¬init£¬1require£¬2ack 
	u_char    key1[LEN_TEA_KEY];  
	u_char    key2[LEN_TEA_KEY];  
	char	  hh_password[MAX_PASS_LEN]; 
	u_int	  hhnumber; 
} hh_workkey; 
 
typedef struct hh_state 
{ 
	struct tuple4	addr; 
	u_char			proto; 
 
	byte	  state; //0£¬³õʼ״̬£¬1µÇ¼ÇëÇó״̬£¬2µÇ¼ȷÈÏ״̬ 
	u_char    key1[LEN_TEA_KEY]; //µ±1 ´æ  
	u_char    key2[LEN_TEA_KEY]; //µ±1 ´æ  
	char	  hh_password[MAX_PASS_LEN]; 
	u_int	  hh_number; 
 
	hh_state *		prev; 
	hh_state *		next; 
} hh_state; 
 
//extern hh_workkey			hhworkkey; 
 
class CMyCrack 
{ 
public: 
	unsigned short	parse_buffer( const u_char * buffer, const size_t buflen, FILE* pipe); 
	u_int			validpass();
	u_int			crack_hh_login( const u_char * data, const u_int len, void* reserved); 
	void			setaddr(struct tuple4 addr, u_char proto); 
	void			setcrkmode(char mode); 
private: 
	int				initial_table(int charfield);
	int				update_pass();
	int				update_pass_dic(FILE* fp);
	int				buf_crack( char* buffile);
	int				hh_crack(char crkmode,  unsigned char* data ); 
public: 
	CMyCrack(); 
	~CMyCrack(); 
public: 
	struct tuple4	ip_addr;  
	u_char			ip_proto; 
 
	unsigned char		inikey1[LEN_TEA_KEY], inikey2[LEN_TEA_KEY];//, workkey[LEN_TEA_KEY]; 
	 
	unsigned char		hh_plain_text[MAX_P_LEN]; 
	unsigned int		hh_len_plain; 
 
 
	int				pass_i[PWLENGTH];
	char			crkmod;
	char			password[PWLENGTH+1];
	unsigned int	pwwidth;
	 
}; 
hh_udp_header * format_hh_udp_header(hh_udp_header * h); 
 
void outputBinary ( const u_char * byteArray, const size_t byteArrayLen, FILE* pipe); 
int outputtext( const u_char* hh_plain_text, const size_t hh_len_plain, int direct, FILE* pipe );