forked from emsal0/Socksify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocksify.c
35 lines (30 loc) · 850 Bytes
/
socksify.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//socksify.c
#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include "connect_socks.h"
#include "parse_arg.h"
int main(int argc, char** argv) {
if (argc!=4) {
perror("Usage: socksify \"<command>\" socks_host socks_port\n");
return 1;
}
set_socks_info(argv[2],argv[3]);
printf("Socks info set: %s, %s.\n",socks_host,socks_port);
char * arglist[256];
char * envlist[256];
char host[256];
char port[256];
snprintf(host,256,"SOCKS_HOST=%s",argv[2]);
snprintf(port,256,"SOCKS_PORT=%s",argv[3]);
envlist[0] = "LD_PRELOAD=./libmyconnect.so";
envlist[1] = host;
envlist[2] = port;
envlist[3] = NULL;
get_arglist(argv[1],arglist);
execvpe(get_cmd(argv[1]),arglist,envlist);
printf("exec'd\n");
return 0;
}