Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anonymizer: option to skip SRC_IP (-S)/DST_IP (-D) #236

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions anonymizer/README
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ Anonymization key: 32 characters long string or 32B sized hex string starting wi

Parameters: -k KEY Specify anonymization key.
-f FILE Specify file containg anonymization key.
-S Disable anonymization of SRC_IP.
-D Disable anonymization of DST_IP.
-M Use MurmurHash3 instead of Rijndael cipher.
-d Switch to de-anonymization mode, i.e. do reverse transofmration of the addresses.
21 changes: 20 additions & 1 deletion anonymizer/anonymizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* \author Tomas Jansky <[email protected]>
* \author Martin Zadnik <[email protected]>
* \author Tomas Cejka <[email protected]>
* \date 2024
* \date 2017
*/
/*
* Copyright (C) 2013-2018 CESNET
* Copyright (C) 2013-2024 CESNET
*
* LICENSE TERMS
*
Expand Down Expand Up @@ -71,10 +72,15 @@ trap_module_info_t *module_info = NULL;
PARAM('k', "key", "Specify secret key, the key must be 32 characters long string or 32B sized hex string starting with 0x", required_argument, "string") \
PARAM('f', "file", "Specify file containing secret key, the key must be 32 characters long string or 32B sized hex string starting with 0x", required_argument, "string") \
PARAM('M', "murmur", "Use MurmurHash3 instead of Rijndael cipher.", no_argument, "none") \
PARAM('S', "srcip", "Disable anonymization of SRC_IP.", no_argument, "none") \
PARAM('D', "dstip", "Disable anonymization of DST_IP.", no_argument, "none") \
PARAM('d', "de-anonym", "Switch to de-anonymization mode.", no_argument, "none")

static int stop = 0;

static int disable_src_ip = 0;
static int disable_dst_ip = 0;

TRAP_DEFAULT_SIGNAL_HANDLER(stop = 1);

const char *anon_field_names[] = {"SRC_IP", "DST_IP", "SIP_CALLED_PARTY", "SIP_CALLING_PARTY", "SIP_CALL_ID", "SIP_REQUEST_URI", "SIP_VIA"};
Expand Down Expand Up @@ -331,6 +337,13 @@ int set_fields_present(ur_template_t *tmplt)
int j = 0;

for (i = 0; i < ANON_FIELDS_COUNT; i++) {
// check skip flags for src_ip and dst_ip (-S / -D) and skip these fields
if (disable_src_ip == 1 && strncmp(anon_field_names[i], "SRC_IP", 7) == 0) {
continue;
}
if (disable_dst_ip == 1 && strncmp(anon_field_names[i], "DST_IP", 7) == 0) {
continue;
}
anon_fields[j] = ur_get_id_by_name(anon_field_names[i]);
if (anon_fields[j] != UR_E_INVALID_NAME && ur_is_present(tmplt, anon_fields[j])) {
j++;
Expand Down Expand Up @@ -415,6 +428,12 @@ int main(int argc, char **argv)
case 'd':
mode = DEANONYMIZATION;
break;
case 'S':
disable_src_ip = 1;
break;
case 'D':
disable_dst_ip = 1;
break;
default:
fprintf(stderr, "Invalid arguments.\n");
ret = 1;
Expand Down
Loading