Add feature to create single hop circuits
This commit is contained in:
parent
8c3240fb5e
commit
8f19f65e85
9 changed files with 67 additions and 14 deletions
|
@ -72,4 +72,21 @@ tor_guards_full:
|
||||||
tor3 -f /etc/torrc_guard_6, \
|
tor3 -f /etc/torrc_guard_6, \
|
||||||
tor3 -f /etc/torrc_guard_7, \
|
tor3 -f /etc/torrc_guard_7, \
|
||||||
tor3 -f /etc/torrc_guard_8, \
|
tor3 -f /etc/torrc_guard_8, \
|
||||||
tor3 -f /etc/torrc_simple
|
tor3 -f /etc/torrc_simple
|
||||||
|
|
||||||
|
tor_relays_small:
|
||||||
|
./run-3 \
|
||||||
|
1 . \
|
||||||
|
orig-client 600 100 100, \
|
||||||
|
orig-client 600 100 100, \
|
||||||
|
orig-client 600 100 100 . \
|
||||||
|
orig-server, \
|
||||||
|
orig-server, \
|
||||||
|
orig-server . \
|
||||||
|
tor3 -f /etc/torrc_simple, \
|
||||||
|
tor2 -f /etc/torrc_simple, \
|
||||||
|
tor2 -f /etc/torrc_simple . \
|
||||||
|
tor3 -f /etc/torrc_simple, \
|
||||||
|
tor2 -f /etc/torrc_simple, \
|
||||||
|
tor2 -f /etc/torrc_single_hop
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
mkdir -p $1/{log,shared}
|
mkdir -p $1/{log,shared}
|
||||||
cd $1/shared
|
cd $1/shared
|
||||||
torecho > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log
|
torecho -n > ../log/server-udpecho-stdout.log 2> ../log/server-udpecho-stderr.log
|
||||||
|
|
|
@ -14,8 +14,11 @@ int main(int argc, char** argv) {
|
||||||
struct donar_params dp = {0};
|
struct donar_params dp = {0};
|
||||||
donar_init_params (&dp);
|
donar_init_params (&dp);
|
||||||
|
|
||||||
while ((dp.opt = getopt(argc, argv, "vcse:r:o:a:bhl:d:f:i:")) != -1) {
|
while ((dp.opt = getopt(argc, argv, "nvcse:r:o:a:bhl:d:f:i:")) != -1) {
|
||||||
switch(dp.opt) {
|
switch(dp.opt) {
|
||||||
|
case 'n':
|
||||||
|
dp.tof |= TOR_ONION_FLAG_NON_ANONYMOUS;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
dp.verbose++;
|
dp.verbose++;
|
||||||
break;
|
break;
|
||||||
|
@ -82,7 +85,7 @@ int main(int argc, char** argv) {
|
||||||
in_error:
|
in_error:
|
||||||
dp.errored = 1;
|
dp.errored = 1;
|
||||||
fprintf(stderr, "Usage as client : %s -c -a <algo> -o <onion service file> [-h] [-b] [-i <bound ip>] [-f <dump packets>] [-l <links>] [-d <fresh>,<red>] [-e <exposed udp port>]* [-r <remote udp port>]*\n", argv[0]);
|
fprintf(stderr, "Usage as client : %s -c -a <algo> -o <onion service file> [-h] [-b] [-i <bound ip>] [-f <dump packets>] [-l <links>] [-d <fresh>,<red>] [-e <exposed udp port>]* [-r <remote udp port>]*\n", argv[0]);
|
||||||
fprintf(stderr, "Usage as server : %s -s -a <algo> [-h] [-b] [-i <bound ip>] [-l <links>] [-f <dump_packets>] [-d <fresh>,<red>] [-e <exposed udp port>]* [-r <remote udp port>]*\n\n", argv[0]);
|
fprintf(stderr, "Usage as server : %s -s -a <algo> [-h] [-b] [-n] [-i <bound ip>] [-l <links>] [-f <dump_packets>] [-d <fresh>,<red>] [-e <exposed udp port>]* [-r <remote udp port>]*\n\n", argv[0]);
|
||||||
fprintf(stderr, "Passed parameters: client=%d, server=%d, algo=%s, exposed_ports=%d, remote_ports=%d, onion_file=%s, links=%d, duplication=%d,%d\n",
|
fprintf(stderr, "Passed parameters: client=%d, server=%d, algo=%s, exposed_ports=%d, remote_ports=%d, onion_file=%s, links=%d, duplication=%d,%d\n",
|
||||||
dp.is_client, dp.is_server, dp.algo, dp.exposed_ports->len, dp.remote_ports->len, dp.onion_file, dp.links, dp.fresh_data, dp.redundant_data);
|
dp.is_client, dp.is_server, dp.algo, dp.exposed_ports->len, dp.remote_ports->len, dp.onion_file, dp.links, dp.fresh_data, dp.redundant_data);
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
#include "net_tools.h"
|
#include "net_tools.h"
|
||||||
#include "evt_core.h"
|
#include "evt_core.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
#include "tor_ctl.h"
|
||||||
|
|
||||||
struct donar_params {
|
struct donar_params {
|
||||||
int opt, is_server, is_client, is_waiting_bootstrap, is_healing, errored, verbose, links, fresh_data, redundant_data;
|
int opt, is_server, is_client, is_waiting_bootstrap, is_healing, errored, verbose, links, fresh_data, redundant_data;
|
||||||
char *bound_ip, *port, *onion_file, *algo, *capture_file;
|
char *bound_ip, *port, *onion_file, *algo, *capture_file;
|
||||||
GPtrArray *remote_ports, *exposed_ports;
|
GPtrArray *remote_ports, *exposed_ports;
|
||||||
|
enum TOR_ONION_FLAGS tof;
|
||||||
};
|
};
|
||||||
|
|
||||||
void signal_init(struct evt_core_ctx* evts);
|
void signal_init(struct evt_core_ctx* evts);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "donar_server.h"
|
#include "donar_server.h"
|
||||||
|
|
||||||
void create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t* ports, int ports_count) {
|
void create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t* ports, int ports_count, enum TOR_ONION_FLAGS tof) {
|
||||||
tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count);
|
tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count);
|
||||||
tor_os_read (tos);
|
tor_os_read (tos);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ void create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_
|
||||||
fprintf(stderr, "Unable to open Tor Socket\n");
|
fprintf(stderr, "Unable to open Tor Socket\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
err = tor_ctl_add_onion (tctl, tos, ports);
|
err = tor_ctl_add_onion (tctl, tos, ports, tof);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err);
|
fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -73,7 +73,7 @@ void donar_server(struct donar_server_ctx* ctx, struct donar_params* dp) {
|
||||||
for (uint16_t i = 0; i < PORT_SIZE ; i++) {
|
for (uint16_t i = 0; i < PORT_SIZE ; i++) {
|
||||||
ctx->ports[i] = 7500 + i;
|
ctx->ports[i] = 7500 + i;
|
||||||
}
|
}
|
||||||
create_onion_services (&(ctx->tos), &(ctx->tctl), ctx->ports, PORT_SIZE);
|
create_onion_services (&(ctx->tos), &(ctx->tctl), ctx->ports, PORT_SIZE, dp->tof);
|
||||||
printf("--- Onion services created\n");
|
printf("--- Onion services created\n");
|
||||||
|
|
||||||
init_tcp_servers(ctx);
|
init_tcp_servers(ctx);
|
||||||
|
|
|
@ -30,7 +30,7 @@ int tor_ctl_connect(struct tor_ctl* ctx, char* addr, char* service) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port) {
|
int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port, enum TOR_ONION_FLAGS flags) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
char buffer1[1024] = {0};
|
char buffer1[1024] = {0};
|
||||||
char buffer2[1024] = {0};
|
char buffer2[1024] = {0};
|
||||||
|
@ -51,7 +51,14 @@ int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* por
|
||||||
|
|
||||||
/* Complete by creating new onion services */
|
/* Complete by creating new onion services */
|
||||||
for (int i = tos->filled; i < tos->size; i++) {
|
for (int i = tos->filled; i < tos->size; i++) {
|
||||||
fprintf(ctx->wsock, "add_onion NEW:ED25519-V3 Port=%d\n", port[i]);
|
if (flags == TOR_ONION_FLAG_NONE)
|
||||||
|
fprintf(ctx->wsock, "add_onion NEW:ED25519-V3 Port=%d\n", port[i]);
|
||||||
|
else {
|
||||||
|
fprintf(ctx->wsock, "add_onion NEW:ED25519-V3 Port=%d Flags=", port[i]);
|
||||||
|
if (flags & TOR_ONION_FLAG_NON_ANONYMOUS)
|
||||||
|
fprintf(ctx->wsock, "NonAnonymous,");
|
||||||
|
fprintf(ctx->wsock, "\n");
|
||||||
|
}
|
||||||
//fprintf(ctx->wsock, "add_onion NEW:RSA1024 Port=%d\n", port[i]);
|
//fprintf(ctx->wsock, "add_onion NEW:RSA1024 Port=%d\n", port[i]);
|
||||||
|
|
||||||
fscanf(ctx->rsock, "%d", &err);
|
fscanf(ctx->rsock, "%d", &err);
|
||||||
|
|
|
@ -14,6 +14,11 @@ struct tor_ctl {
|
||||||
FILE* wsock;
|
FILE* wsock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TOR_ONION_FLAGS {
|
||||||
|
TOR_ONION_FLAG_NONE = 0,
|
||||||
|
TOR_ONION_FLAG_NON_ANONYMOUS = 1 << 0
|
||||||
|
};
|
||||||
|
|
||||||
int tor_ctl_connect(struct tor_ctl* ctx, char* addr, char* service);
|
int tor_ctl_connect(struct tor_ctl* ctx, char* addr, char* service);
|
||||||
int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port);
|
int tor_ctl_add_onion(struct tor_ctl* ctx, struct tor_os_str* tos, uint16_t* port, enum TOR_ONION_FLAGS flags);
|
||||||
void tor_ctl_close(struct tor_ctl* ctx);
|
void tor_ctl_close(struct tor_ctl* ctx);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "net_tools.h"
|
#include "net_tools.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
|
|
||||||
void te_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t* ports, int ports_count) {
|
void te_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint16_t* ports, int ports_count, enum TOR_ONION_FLAGS tof) {
|
||||||
tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count);
|
tor_os_create (tos, "onion_services.pub", "onion_services.txt", ports_count);
|
||||||
tor_os_read (tos);
|
tor_os_read (tos);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ void te_create_onion_services(struct tor_os_str* tos, struct tor_ctl* tctl, uint
|
||||||
fprintf(stderr, "Unable to open Tor Socket\n");
|
fprintf(stderr, "Unable to open Tor Socket\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
err = tor_ctl_add_onion (tctl, tos, ports);
|
err = tor_ctl_add_onion (tctl, tos, ports, tof);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err);
|
fprintf(stderr, "Unable to create Onion Services (error: %d)\n", err);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -83,14 +83,26 @@ int main(int argc, char** argv) {
|
||||||
setvbuf(stdout, NULL, _IONBF, 0);
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
printf("~ torecho ~\n");
|
printf("~ torecho ~\n");
|
||||||
|
|
||||||
int tcp_serv_sock = 0, err;
|
int tcp_serv_sock = 0, err, opt;
|
||||||
struct evt_core_ctx evts = {0};
|
struct evt_core_ctx evts = {0};
|
||||||
uint16_t ports[] = {7500};
|
uint16_t ports[] = {7500};
|
||||||
int ports_count = sizeof(ports[0]) / sizeof(ports);
|
int ports_count = sizeof(ports[0]) / sizeof(ports);
|
||||||
struct tor_os_str tos;
|
struct tor_os_str tos;
|
||||||
struct tor_ctl tctl;
|
struct tor_ctl tctl;
|
||||||
|
enum TOR_ONION_FLAGS tof = TOR_ONION_FLAG_NONE;
|
||||||
char url[1024];
|
char url[1024];
|
||||||
|
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "n")) != -1) {
|
||||||
|
switch(opt) {
|
||||||
|
case 'n':
|
||||||
|
tof |= TOR_ONION_FLAG_NON_ANONYMOUS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 1. Register categories
|
// 1. Register categories
|
||||||
struct evt_core_cat tcp_co = {
|
struct evt_core_cat tcp_co = {
|
||||||
.app_ctx = NULL,
|
.app_ctx = NULL,
|
||||||
|
@ -116,7 +128,7 @@ int main(int argc, char** argv) {
|
||||||
printf("--- Categories created\n");
|
printf("--- Categories created\n");
|
||||||
|
|
||||||
// 2. Create or load onion services
|
// 2. Create or load onion services
|
||||||
te_create_onion_services (&tos, &tctl, ports, ports_count);
|
te_create_onion_services (&tos, &tctl, ports, ports_count, tof);
|
||||||
printf("--- Onion services created\n");
|
printf("--- Onion services created\n");
|
||||||
|
|
||||||
// 3. Create TCP server
|
// 3. Create TCP server
|
||||||
|
|
7
torrc_single_hop
Normal file
7
torrc_single_hop
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
ControlPort 9051
|
||||||
|
SOCKSPort 0
|
||||||
|
UseEntryGuards 0
|
||||||
|
SafeLogging 0
|
||||||
|
HiddenServiceNonAnonymousMode 1
|
||||||
|
HiddenServiceSingleHopMode 1
|
||||||
|
#Log INFO stdout
|
Loading…
Reference in a new issue