chinashiyu / gfw.press.c Goto Github PK
View Code? Open in Web Editor NEWGFW.Press新一代军用级高强度加密抗干扰网络数据高速传输软件C语言版
GFW.Press新一代军用级高强度加密抗干扰网络数据高速传输软件C语言版
gcc -o gfw.press src/client.c src/encrypt.c -ansi -O3 -lssl -lcrypto -lpthread -Wall
src/client.c: In function ‘load_config’:
src/client.c:480:3: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
fscanf(file, "%s", &text[pos]);
^
for windows
https://github.com/tutorde/windows_gfw.press.c
Suggest
be random if someone test the server
系统信息
$ uname -a
Linux RPi 4.9.43-1-ARCH #1 SMP Fri Aug 18 01:18:17 UTC 2017 armv6l GNU/Linux
$ openssl version -a
OpenSSL 1.1.0f 25 May 2017
出错信息大意是有几个结构体没定义
修改以下几行后编译成功(附件:rpib+.txt)
diff --git a/src/client.c b/src/client.c
index 5f5d15a..c1e2b38 100644
--- a/src/client.c
+++ b/src/client.c
@@ -23,6 +23,7 @@
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
diff --git a/src/encrypt.c b/src/encrypt.c
index f576dd1..fbc8f63 100644
--- a/src/encrypt.c
+++ b/src/encrypt.c
@@ -199,7 +199,7 @@ int encrypt(char *key, char *in, int inl, char *out) {
int cipher_len = 0;
- EVP_CIPHER_CTX *ctx = (EVP_CIPHER_CTX *) malloc(sizeof(EVP_CIPHER_CTX));
+ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(ctx);
@@ -229,7 +229,7 @@ int encrypt(char *key, char *in, int inl, char *out) {
free(cipher);
- EVP_CIPHER_CTX_cleanup(ctx);
+ EVP_CIPHER_CTX_free(ctx);
return IV_SIZE + inl;
@@ -335,7 +335,7 @@ int decrypt(char *key, char *in, int inl, char *out) {
int outl = 0;
- EVP_CIPHER_CTX *ctx = (EVP_CIPHER_CTX *) malloc(sizeof(EVP_CIPHER_CTX));
+ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(ctx);
@@ -349,7 +349,7 @@ int decrypt(char *key, char *in, int inl, char *out) {
free(cipher);
- EVP_CIPHER_CTX_cleanup(ctx);
+ EVP_CIPHER_CTX_free(ctx);
if (cipher_len != outl) {
#include <time.h>
/** 缓冲区最小值,128K */
//change here
//static int BUFFER_SIZE_MIN = 1024 * 128;
int recv_len_seed = 30;//start with 30(recv_len_seed=ENCRYPT_SIZE)
int random_load = 0;
int get_random_load(){
return 1024+(rand()+65536);
}
//change here
int get_buffer_size_min(){
//return 16 + (rand() % 16318);//16318 for test maybe 32768 or bigger is better
return 16 + (rand() % random_load);
}
//change here
int get_head_block(){
//return recv_len_seed + (rand() % 16318);//16318 for test maybe 32768 or bigger is better
return recv_len_seed + (rand() % random_load);
}
/**
/**
服务器IO线程
*/
void *thread_io_server(void _io) {
struct IO io = ((struct IO) _io);
//change here
int free_head_temp = 1;
int head_temp_last = 0;
int head_len_temp = 0;
char head_temp;
while (1) {
if(free_head_temp){
int head_block_length = get_head_block();
head_temp = malloc(head_block_length);
/ 接收服务器头数据 /
head_len_temp = recv(io.socket_server, head_temp, head_block_length, MSG_NOSIGNAL);
if (head_len_temp < ENCRYPT_SIZE) {
free(head_temp);
break;
}
}else{
int head_block_length = get_head_block();
char head_temp_temp = malloc(head_block_length);
memcpy(head_temp_temp, &head_temp[head_len_temp-head_temp_last], head_temp_last);
free(head_temp);
head_temp = head_temp_temp;
/ 接收服务器头数据 */
head_len_temp = recv(io.socket_server, &head_temp[head_temp_last], head_block_length-head_temp_last, MSG_NOSIGNAL);
head_len_temp = head_len_temp + head_temp_last;
if (head_len_temp < ENCRYPT_SIZE) {
free(head_temp);
break;
}
}
int head_len = ENCRYPT_SIZE;
int head_else = head_len_temp - head_len;
char head = malloc(ENCRYPT_SIZE + 1);
memcpy(head, head_temp, head_len);
head[ENCRYPT_SIZE] = '\0';
char head_out = malloc(SIZE_SIZE + 1);
if (decrypt(key, head, head_len, head_out) == -1) {
free(head_out);
break;
}
head_out[SIZE_SIZE] = '\0';
free(head);
int sizes = malloc(2 * sizeof(int));
if (get_block_sizes(head_out, sizes) == -1) {
free(head_out);
free(sizes);
break;
}
int data = (int) sizes[0];
int noise = (int) sizes[1];
free(head_out);
free(sizes);
int size = data + noise;
char in = malloc(size + 1);
int _size = 0;
if(head_else > size){
memcpy(in, &head_temp[head_len], size);
head_temp_last = head_else-size;
if(head_temp_last<ENCRYPT_SIZE){
recv_len_seed = ENCRYPT_SIZE;
}else{
recv_len_seed = head_temp_last;
}
free_head_temp = 0;
_size = size;
}else{
if(head_else>0){
memcpy(in, &head_temp[head_len], head_else);
}
//recv_len_seed = ENCRYPT_SIZE;
free(head_temp);
head_temp_last = 0;
free_head_temp = 1;
_size = head_else;
}
for (; _size < size;) {
/ 接收服务器数据 /
head_len = recv(io.socket_server, &in[_size], (size - _size), MSG_NOSIGNAL);
if (head_len < 1) {
break;
}
_size += head_len;
}
if (_size != size) {
free(in);
break;
}
in[size] = '\0';
int outl = data - IV_SIZE;
char * out = malloc(outl + 1);
if (decrypt(key, in, data, out) == -1) {
free(in);
free(out);
break;
}
out[outl] = '\0';
free(in);
/ 转发数据到浏览器 /
int sendl = send(io.socket_agent, out, outl, MSG_NOSIGNAL);
free(out);
if (sendl < 1) {
break;
}
}
if(!free_head_temp){
free(head_temp);
}
pthread_exit(0);
}
/
客户端主程序
*/
int main(int argc, char *argv[]) {
_log("GFW.Press客户端开始运行......");
//change here
random_load = get_random_load();
srand((unsigned)time(NULL));
......
}
dear gfw.press users :
you can give me a little donate so i can fully time codeing
bitshares or bitBTC or bitUSD or bitCNY:
tutor-de
bitcoin:
19Q3S14uQYnQDirZ4f5BFjk4m42asdo2AG
DASH:
Xv6Lj6VMEtcDcCe6DPoNd149nJ44apBXah
ETH:
0xE242DbC096B316b0601878EDa9EC4Fffd58290C2
DOGE:
DNjXHJh3oCmAXCJW7nzaY6uktJLk7EGjgd
LTC:
LLJHTQME5MA98KGrBpnH1M7uFB6qSLiFpV
USDT:
1JAphejVsyAg2UhGT2E4noZJpETj9ZX4o6
check your donate:
https://bitshares.org/wallet/#/account/tutor-de/dashboard
my VPS OS:
Ubuntu 19.10 (GNU/Linux 5.3.0-1018-gcp x86_64)
Linux version 5.3.0-1018-gcp (buildd@lcy01-amd64-010) (gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2)) #19-Ubuntu
my SDK:
openwrt-sdk-19.07.2-x86-64_gcc-7.5.0_musl.Linux-x86_64
meet some problems when i excute "$ make package/gfwpress/compile V=99"........
大爷,测试了下C版的,似乎网络速度比JAVA版的快,但响应似乎有问题,丢包高,通过使用YouTube 推特 等,非专业测试!
{
"ServerHost":"xxx",
"ServerPort":"29811",
"ProxyPort":"3128",
"Password":"xxx"
}
这里的ServerPort和ProxyPort是什么意思?系统开的ProxyPort确实在3128端口监听,ServerPort则没有
对ssl(https)的支持有问题,许多需要https的网盘无法同步或下载,例如MEGA等。
//新添加:
#include <errno.h>
#include <signal.h>
sockaddr_client.sin_port = htons(listen_port);
int tmp = 1;
//设置端口可以重复使用 省得退出后重启需要等一段时间
setsockopt(socket_client, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(int));
int _bind = bind(socket_client, (struct sockaddr *) &sockaddr_client, sizeof(struct sockaddr));
另外如果需要使用 pthread_kill(thread_id, SIGKILL);
请在 makefile 里将 CFLAGS += -ansi 改成 CFLAGS += -D_POSIX_C_SOURCE=199506
完整的代码并没有仔细看,意见仅供参考
我觉得加密方法是绝对安全的。但是连接服务器时,
可以考虑把(密码+端口号)取hash,发送到服务器供服务器验证
如果要单端口多用户 可以(密码+邮箱用户名)取hash,发送到服务器供服务器验证
如果想要更安全可以(密码+邮箱用户名)取hash 再取 hash
或者(密码+邮箱用户名+"gfw.press")取hash
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.