From db0c9e967e8ff3a96b76293fcf3ea5f7108026ff Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 30 Dec 2011 14:57:35 +0100 Subject: fixed ip --- retiolum/hosts/skirfir | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum') diff --git a/retiolum/hosts/skirfir b/retiolum/hosts/skirfir index 880376c9..0214e7a1 100644 --- a/retiolum/hosts/skirfir +++ b/retiolum/hosts/skirfir @@ -1,4 +1,4 @@ -Subnet = 42.0.0.222 +Subnet = 10.243.0.18/32 Subnet = 42:423b:0f94:6b03:7c3c:593e:67e8:c857/128 -----BEGIN RSA PUBLIC KEY----- -- cgit v1.2.3 From 0f5edb5dea18c4eb28d1fda4a106b868a23cc614 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 2 Jan 2012 11:12:36 +0100 Subject: now less routing --- retiolum/scripts/routing/defaultroute.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'retiolum') diff --git a/retiolum/scripts/routing/defaultroute.sh b/retiolum/scripts/routing/defaultroute.sh index a9e227a6..f5a1a465 100755 --- a/retiolum/scripts/routing/defaultroute.sh +++ b/retiolum/scripts/routing/defaultroute.sh @@ -7,7 +7,7 @@ usage() echo "-d deactivate routing" } -defaultroute=$(route -n | grep 'UG[ \t]' | awk '{print $2}') +defaultroute=$(ip route show | grep default | awk '{ print $3 }') tincdir="/etc/tinc/retiolum" if [[ $(id -u) -gt 0 ]]; then @@ -30,17 +30,9 @@ case "$1" in exit 1;; esac - -cat $tincdir/hosts/* | grep Address | cut -b 11- | +cat $tincdir/tinc.conf | grep ConnectTo | cut -b 13- | while read host do - if [ "$(echo $host | sed 's/[0-9]*//g' | sed 's/\.//g')" = '' ]; then - route $command $host gw $defaultroute - else - host -4 $host | grep "has address" | awk '{ print $4 }' | - while read addr - do - route $command $addr gw $defaultroute && echo "$command routing to $addr via $defaultroute" - done - fi + addr=$(cat $tincdir/hosts/$host | grep Address | cut -b 11-) + echo route $command $addr gw $defaultroute done -- cgit v1.2.3 From aaa01e8051d40c4b6660e565f737170e94668504 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 4 Jan 2012 01:23:12 +0100 Subject: //retiolum/scripts/adv_graphgen/parse_tinc_stats: parsing availability correctly --- retiolum/scripts/adv_graphgen/parse_tinc_stats.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'retiolum') diff --git a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py index b8054b0d..54dcc4ab 100755 --- a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py +++ b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf8 -*- - +from BackwardsReader import BackwardsReader import sys,json supernodes= [ "kaah","supernode","euer","pa_sharepoint","oxberg" ] """ TODO: Refactoring needed to pull the edges out of the node structures again, @@ -51,12 +51,19 @@ def generate_stats(nodes): """ jlines = [] try: - f = open(DUMP_FILE,'r') - for line in f: - jlines.append(json.loads(line)) - f.close() + f = BackwardsReader(DUMP_FILE) + lines_to_use = 1000 + while True: + if lines_to_use == 0: break + line = f.readline() + if not line: break + jline = json.loads(line) + if not jline['nodes']: continue + + jlines.append(jline) + lines_to_use -=1 except Exception,e: - pass + sys.stderr.write(str(e)) for k,v in nodes.iteritems(): conns = v.get('to',[]) for c in conns: #sanitize weights -- cgit v1.2.3 From 2005d8b5d1ad24aa781c51154282515ce84ca4d0 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 4 Jan 2012 01:27:58 +0100 Subject: //retiolum..adv_graphgen: add anonymizer functionality we are now able to generate full-detail graphs for the darknet and anonymized graphs for the public web --- retiolum/scripts/adv_graphgen/anonytize.sh | 31 ++++++ retiolum/scripts/adv_graphgen/parse_tinc_anon.py | 135 +++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100755 retiolum/scripts/adv_graphgen/anonytize.sh create mode 100755 retiolum/scripts/adv_graphgen/parse_tinc_anon.py (limited to 'retiolum') diff --git a/retiolum/scripts/adv_graphgen/anonytize.sh b/retiolum/scripts/adv_graphgen/anonytize.sh new file mode 100755 index 00000000..1ebfe972 --- /dev/null +++ b/retiolum/scripts/adv_graphgen/anonytize.sh @@ -0,0 +1,31 @@ +#!/bin/sh +set -euf +cd $(dirname `readlink -f $0`) +GRAPH_SETTER1=dot +GRAPH_SETTER2=circo +GRAPH_SETTER3='neato -Goverlap=prism ' +GRAPH_SETTER4=sfdp +LOG_FILE=/var/log/syslog +TYPE=svg +TYPE2=png +OPENER=/bin/true +DOTFILE=`mktemp` +trap 'rm $DOTFILE' INT TERM +sudo LOG_FILE=$LOG_FILE python tinc_stats.py |\ + python parse_tinc_anon.py> $DOTFILE + + +i=1 +for setter in dot circo 'neato -Goverlap=prism ' sfdp +do + tmpgraph=`mktemp --tmpdir=$1` + $setter -T$TYPE -o $tmpgraph $DOTFILE + chmod go+rx $tmpgraph + mv $tmpgraph $1/retiolum_$i.$TYPE + i=`expr $i + 1` +done +#convert -resize 20% $1/retiolum_1.$TYPE $1/retiolum_1.$TYPE2 +#convert -resize 20% $1/retiolum_2.$TYPE $1/retiolum_2.$TYPE2 +#convert -resize 20% $1/retiolum_3.$TYPE $1/retiolum_3.$TYPE2 +#convert -resize 20% $1/retiolum_4.$TYPE $1/retiolum_4.$TYPE2 +rm $DOTFILE diff --git a/retiolum/scripts/adv_graphgen/parse_tinc_anon.py b/retiolum/scripts/adv_graphgen/parse_tinc_anon.py new file mode 100755 index 00000000..3b0383da --- /dev/null +++ b/retiolum/scripts/adv_graphgen/parse_tinc_anon.py @@ -0,0 +1,135 @@ +#!/usr/bin/python +# -*- coding: utf8 -*- +from BackwardsReader import BackwardsReader +import sys,json +#supernodes= [ "kaah","supernode","euer","pa_sharepoint","oxberg" ] +""" TODO: Refactoring needed to pull the edges out of the node structures again, +it should be easier to handle both structures""" +DUMP_FILE = "/krebs/db/availability" +def write_digraph(nodes): + """ + writes the complete digraph in dot format + """ + print ('digraph retiolum {') + #print (' graph [center rankdir=LR packMode="clust"]') + print (' graph [center packMode="clust"]') + print (' node[shape=circle,style=filled,fillcolor=grey]') + print (' overlap=false') + generate_stats(nodes) + merge_edges(nodes) + nodes = anon_nodes(nodes) + for k,v in nodes.iteritems(): + write_node(k,v) + write_stat_node(nodes) + print ('}') + +def anon_nodes(nodes): + i = "0" + newnodes = {} + for k,v in nodes.iteritems(): + for nodek,node in nodes.iteritems(): + for to in node['to']: + if to['name'] == k: + to['name'] = i + newnodes[i] = v + i = str(int(i)+1) + return newnodes + +def write_stat_node(nodes): + ''' Write a `stats` node in the corner + This node contains infos about the current number of active nodes and connections inside the network + ''' + num_conns = 0 + num_nodes = len(nodes) + for k,v in nodes.iteritems(): + num_conns+= len(v['to']) + node_text = " stats_node [shape=box,label=\"Statistics\\l" + node_text += "Active Nodes: %s\\l" % num_nodes + node_text += "Connections : %s\\l" % num_conns + node_text += "\"" + node_text += ",fillcolor=green" + node_text += "]" + print(node_text) + +def generate_stats(nodes): + """ Generates some statistics of the network and nodes + """ + for k,v in nodes.iteritems(): + conns = v.get('to',[]) + for c in conns: #sanitize weights + if float(c['weight']) > 9000: c['weight'] = str(9001) + elif float(c['weight']) < 0: c['weight'] = str(0) + v['num_conns'] = len(conns) + v['avg_weight'] = get_node_avg_weight(conns) +def get_node_avg_weight(conns): + """ calculates the average weight for the given connections """ + if not conns: + sys.syderr.write("get_node_avg_weight: connection parameter empty") + return 9001 + else: + return sum([float(c['weight']) for c in conns])/len(conns) + +def delete_unused_nodes(nodes): + new_nodes = {} + for k,v in nodes.iteritems(): + if v['external-ip'] == "(null)": + continue + if v.get('to',[]): + new_nodes[k] = v + for k,v in new_nodes.iteritems(): + if not [ i for i in v['to'] if i['name'] in new_nodes]: + #del(new_nodes[k]) + del(k) + return new_nodes +def merge_edges(nodes): + """ merge back and forth edges into one + DESTRUCTS the current structure by deleting "connections" in the nodes + """ + for k,v in nodes.iteritems(): + for con in v.get('to',[]): + for i,secon in enumerate(nodes.get(con['name'],{}).get('to',[])): + if k == secon['name']: + del (nodes[con['name']]['to'][i]) + con['bidirectional'] = True + + +def write_node(k,v): + """ writes a single node and its edges + edges are weightet with the informations inside the nodes provided by + tinc + """ + + node = " "+k #+"[label=\"" + #node += k+"\\l" + #node += "avg weight: %.2f\\l" % v['avg_weight'] + #if v.has_key('num_conns'): + # node += "Conns:"+str(v['num_conns'])+"\\l" + #node +="\"" + #node +=",group=\""+v['external-ip'].replace(".","") + "\"" + #node += "]" + print node + + for con in v.get('to',[]): + label = con['weight'] + w = int(con['weight']) + weight = str(1000 - (((w - 150) * (1000 - 0)) / (1000 -150 )) + 0) + + length = str(float(w)/1500) + #weight = "1000" #str(300/float(con['weight'])) + #weight = str((100/float(con['weight']))) + #weight = str(-1 * (200-100000/int(con['weight']))) + if float(weight) < 0 : + weight= "1" + + #sys.stderr.write(weight + ":"+ length +" %s -> " %k + str(con) + "\n") + edge = " "+k+ " -> " +con['name'] + " [label="+label + " weight="+weight #+ " minlen="+length + if con.get('bidirectional',False): + edge += ",dir=both" + edge += "]" + print edge + +def decode_input(FILE): + return json.load(FILE) +nodes = decode_input(sys.stdin) +nodes = delete_unused_nodes(nodes) +write_digraph(nodes) -- cgit v1.2.3 From 4874151b4e810c2d313c5c955ec8af6446f2984f Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 4 Jan 2012 01:28:25 +0100 Subject: //retiolum/adv_graphgen: add all_the_graphs script as tincd trigger --- retiolum/scripts/adv_graphgen/all_the_graphs.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 retiolum/scripts/adv_graphgen/all_the_graphs.sh (limited to 'retiolum') diff --git a/retiolum/scripts/adv_graphgen/all_the_graphs.sh b/retiolum/scripts/adv_graphgen/all_the_graphs.sh new file mode 100755 index 00000000..36b37f03 --- /dev/null +++ b/retiolum/scripts/adv_graphgen/all_the_graphs.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "`date` begin all graphs" >> /tmp/build_graph +cd $(dirname $(readlink -f $0)) +(./anonytize.sh /srv/http/pub/graphs/retiolum/ && echo "`date` anonytize done" >> /tmp/build_graph)& +(./sanitize.sh /srv/http/priv/graphs/retiolum/ && echo "`date` sanitize done" >> /tmp/build_graph)& -- cgit v1.2.3 From 91d6fc8971483bf8e1fed7d649f966d180e23956 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 4 Jan 2012 01:32:53 +0100 Subject: //retiolum/adv_graphgen/sanitize: be less verbose --- retiolum/scripts/adv_graphgen/sanitize.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'retiolum') diff --git a/retiolum/scripts/adv_graphgen/sanitize.sh b/retiolum/scripts/adv_graphgen/sanitize.sh index 5572b9d9..50f1659f 100755 --- a/retiolum/scripts/adv_graphgen/sanitize.sh +++ b/retiolum/scripts/adv_graphgen/sanitize.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -xeuf +set -euf cd $(dirname `readlink -f $0`) GRAPH_SETTER1=dot GRAPH_SETTER2=circo @@ -21,10 +21,12 @@ do tmpgraph=`mktemp --tmpdir=$1` $setter -T$TYPE -o $tmpgraph $DOTFILE chmod go+rx $tmpgraph - mv $tmpgraph $1retiolum_$i.$TYPE + mv $tmpgraph $1/retiolum_$i.$TYPE i=`expr $i + 1` done + #convert -resize 20% $1/retiolum_1.$TYPE $1/retiolum_1.$TYPE2 #convert -resize 20% $1/retiolum_2.$TYPE $1/retiolum_2.$TYPE2 #convert -resize 20% $1/retiolum_3.$TYPE $1/retiolum_3.$TYPE2 #convert -resize 20% $1/retiolum_4.$TYPE $1/retiolum_4.$TYPE2 +rm $DOTFILE -- cgit v1.2.3