Minor modifications

This commit is contained in:
ValdikSS 2017-12-17 00:28:11 +03:00
parent bfed8638e5
commit 60e87f769a
4 changed files with 9 additions and 9 deletions

View File

@ -9,9 +9,9 @@ TARGET = goodbyedpi.exe
LIBS = -L$(WINDIVERTLIBS) -lWinDivert -lws2_32 LIBS = -L$(WINDIVERTLIBS) -lWinDivert -lws2_32
CC = $(CPREFIX)gcc CC = $(CPREFIX)gcc
CCWINDRES = $(CPREFIX)windres CCWINDRES = $(CPREFIX)windres
CFLAGS = -Wall -I$(WINDIVERTHEADERS) -L$(WINDIVERTLIBS) \ CFLAGS = -Wall -Wextra -I$(WINDIVERTHEADERS) -L$(WINDIVERTLIBS) \
-O2 -pie -fPIE -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -O2 -pie -fPIE -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2
LDFLAGS = -pie LDFLAGS = -Wl,-O1,--sort-common,--as-needed
.PHONY: default all clean .PHONY: default all clean
@ -30,7 +30,7 @@ manifest:
.PRECIOUS: $(TARGET) $(OBJECTS) .PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS) $(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) -Wall $(LIBS) -s -o $@ $(CC) $(OBJECTS) -Wall $(LDFLAGS) $(LIBS) -s -o $@
clean: clean:
-rm -f *.o -rm -f *.o

View File

@ -141,6 +141,8 @@ void dns_cleanup() {
} }
int dns_is_dns_packet(const char *packet_data, const UINT packet_dataLen, const int outgoing) { int dns_is_dns_packet(const char *packet_data, const UINT packet_dataLen, const int outgoing) {
if (packet_dataLen < 16) return FALSE;
if (outgoing && (ntohs(*(const uint16_t*)(packet_data + 2)) & 0xFA00) == 0 && if (outgoing && (ntohs(*(const uint16_t*)(packet_data + 2)) & 0xFA00) == 0 &&
(ntohs(*(const uint32_t*)(packet_data + 6))) == 0) { (ntohs(*(const uint32_t*)(packet_data + 6))) == 0) {
return TRUE; return TRUE;
@ -171,7 +173,6 @@ int dns_handle_outgoing(const uint32_t srcip, const uint16_t srcport,
} }
int dns_handle_incoming(const uint32_t srcip, const uint16_t srcport, int dns_handle_incoming(const uint32_t srcip, const uint16_t srcport,
const uint32_t dstip, const uint16_t dstport,
const char *packet_data, const UINT packet_dataLen, const char *packet_data, const UINT packet_dataLen,
conntrack_info_t *conn_info) { conntrack_info_t *conn_info) {

View File

@ -8,7 +8,6 @@ typedef struct conntrack_info {
} conntrack_info_t; } conntrack_info_t;
int dns_handle_incoming(const uint32_t srcip, const uint16_t srcport, int dns_handle_incoming(const uint32_t srcip, const uint16_t srcport,
const uint32_t dstip, const uint16_t dstport,
const char *packet_data, const UINT packet_dataLen, const char *packet_data, const UINT packet_dataLen,
conntrack_info_t *conn_info); conntrack_info_t *conn_info);

View File

@ -137,7 +137,7 @@ static void deinit_all() {
} }
} }
static void sigint_handler(int sig) { static void sigint_handler(int sig __attribute__((unused))) {
deinit_all(); deinit_all();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -208,7 +208,7 @@ static void change_window_size(const char *pkt, int size) {
/* HTTP method end without trailing space */ /* HTTP method end without trailing space */
static PVOID find_http_method_end(const char *pkt, int offset) { static PVOID find_http_method_end(const char *pkt, int offset) {
int i; unsigned int i;
for (i = 0; i<(sizeof(http_methods) / sizeof(*http_methods)); i++) { for (i = 0; i<(sizeof(http_methods) / sizeof(*http_methods)); i++) {
if (memcmp(pkt, http_methods[i], strlen(http_methods[i])) == 0) { if (memcmp(pkt, http_methods[i], strlen(http_methods[i])) == 0) {
return (char*)pkt + strlen(http_methods[i]) - 1; return (char*)pkt + strlen(http_methods[i]) - 1;
@ -285,6 +285,7 @@ int main(int argc, char *argv[]) {
do_passivedpi = do_host = do_host_removespace \ do_passivedpi = do_host = do_host_removespace \
= do_fragment_https = 1; = do_fragment_https = 1;
https_fragment_size = 40; https_fragment_size = 40;
break;
case '4': case '4':
do_passivedpi = do_host = do_host_removespace = 1; do_passivedpi = do_host = do_host_removespace = 1;
break; break;
@ -354,7 +355,7 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
dns_port = atoi(optarg); dns_port = atoi(optarg);
if (dns_port <= 0 || dns_port > 65535) { if (atoi(optarg) <= 0 || atoi(optarg) > 65535) {
printf("DNS port parameter error!\n"); printf("DNS port parameter error!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -584,7 +585,6 @@ int main(int argc, char *argv[]) {
if (addr.Direction == WINDIVERT_DIRECTION_INBOUND) { if (addr.Direction == WINDIVERT_DIRECTION_INBOUND) {
if (dns_handle_incoming(ppIpHdr->DstAddr, ppUdpHdr->DstPort, if (dns_handle_incoming(ppIpHdr->DstAddr, ppUdpHdr->DstPort,
ppIpHdr->SrcAddr, ppUdpHdr->SrcPort,
packet_data, packet_dataLen, packet_data, packet_dataLen,
&dns_conn_info)) &dns_conn_info))
{ {