patching socks5

This commit is contained in:
Quentin 2020-02-21 15:26:28 +01:00
parent 4463100e1d
commit e3653112a6
3 changed files with 12 additions and 9 deletions

View file

@ -77,7 +77,6 @@ union abstract_packet {
} fmt; } fmt;
}; };
#pragma pack(1)
struct buffer_packet { struct buffer_packet {
enum BP_MODE mode; enum BP_MODE mode;
uint8_t ap_count; uint8_t ap_count;
@ -87,7 +86,6 @@ struct buffer_packet {
char ip[6000]; char ip[6000];
}; };
#pragma pack(1)
struct udp_target { struct udp_target {
struct sockaddr_in addr; struct sockaddr_in addr;
socklen_t addrlen; socklen_t addrlen;

View file

@ -57,15 +57,15 @@ void socks5_create_dns_client(struct evt_core_ctx* ctx, char* proxy_host, char*
s5ctx->cr.cmd = CMD_CONNECT; s5ctx->cr.cmd = CMD_CONNECT;
s5ctx->cr.rsv = 0x00; s5ctx->cr.rsv = 0x00;
s5ctx->cr.atyp = ATYP_DOMAINNAME; s5ctx->cr.atyp = ATYP_DOMAINNAME;
s5ctx->cr.dst_addr_len = domainLength; s5ctx->cr.dest_addr.dns.len = domainLength;
s5ctx->cr.dst_addr = addr; strcpy((char*)&s5ctx->cr.dest_addr.dns.str, addr);
s5ctx->cr.port = htons(port); s5ctx->cr.port = htons(port);
// 3.3 Generate client request buffer // 3.3 Generate client request buffer
s5ctx->cr_size = 0; s5ctx->cr_size = 0;
fill_buffer(&s5ctx->cr_size, s5ctx->cr_buffer, &s5ctx->cr, 5*sizeof(uint8_t)); fill_buffer2(&s5ctx->cr_size, s5ctx->cr_buffer, &s5ctx->cr, &s5ctx->cr.dest_addr.dns.str);
fill_buffer(&s5ctx->cr_size, s5ctx->cr_buffer, s5ctx->cr.dst_addr, s5ctx->cr.dst_addr_len*sizeof(char)); fill_buffer(&s5ctx->cr_size, s5ctx->cr_buffer, &s5ctx->cr.dest_addr.dns.str, s5ctx->cr.dest_addr.dns.len);
fill_buffer(&s5ctx->cr_size, s5ctx->cr_buffer, &s5ctx->cr.port, sizeof(uint16_t)); fill_buffer2(&s5ctx->cr_size, s5ctx->cr_buffer, &s5ctx->cr.port, &s5ctx->cr + 1);
reg_fdinfo = evt_core_add_fd (ctx, &fdinfo); reg_fdinfo = evt_core_add_fd (ctx, &fdinfo);
} }
@ -430,7 +430,9 @@ send_hs_error:
} }
int on_socks5_server_recv_client_req(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { int on_socks5_server_recv_client_req(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
struct socks5_ctx* s5ctx = fdinfo->other;
if (s5ctx->cr_cursor )
return EVT_CORE_FD_UNFINISHED; return EVT_CORE_FD_UNFINISHED;
} }

View file

@ -78,27 +78,30 @@ static char* rep_msg[] = {
* https://tools.ietf.org/html/rfc1928 * https://tools.ietf.org/html/rfc1928
*/ */
#pragma pack(1)
struct client_handshake { struct client_handshake {
uint8_t ver; uint8_t ver;
uint8_t nmethods; uint8_t nmethods;
uint8_t methods[255]; uint8_t methods[255];
}; };
#pragma pack(1)
struct server_handshake { struct server_handshake {
uint8_t ver; uint8_t ver;
uint8_t method; uint8_t method;
}; };
#pragma pack(1)
struct client_request { struct client_request {
uint8_t ver; uint8_t ver;
uint8_t cmd; uint8_t cmd;
uint8_t rsv; uint8_t rsv;
uint8_t atyp; uint8_t atyp;
uint8_t dst_addr_len; union socks5_addr dest_addr;
char* dst_addr;
uint16_t port; uint16_t port;
}; };
#pragma pack(1)
struct server_reply { struct server_reply {
uint8_t ver; uint8_t ver;
uint8_t rep; uint8_t rep;