Skip to content
Snippets Groups Projects
Verified Commit 0169d505 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Update for import of new routers

• Update the scripts to be more up to date.
• Import the remaining script to the repository.
• Not reviewed ‒ single-purpose scripts run manually.
parent 147ee5ac
No related merge requests found
#!/usr/bin/python2
#
# Ucollect - small utility for real-time analysis of network data
# Copyright (C) 2013 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from twisted.internet import protocol, reactor
from twisted.protocols import basic
import re
import pgdb
import ConfigParser
import atsha204
import sys
# Command for challenge-response auth. It is "auth ID Challenge Response" or "half ..."
auth = re.compile(r'^\s*(auth|half)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s*$', re.IGNORECASE)
if len(sys.argv) != 2:
print "./authenticator.py config_file"
sys.exit(1)
config_data = ConfigParser.RawConfigParser()
with open(sys.argv[1]) as f:
config_data.readfp(f, sys.argv[1])
db = pgdb.connect(database=config_data.get('main', 'db'), user=config_data.get('main', 'dbuser'), password=config_data.get('main', 'dbpasswd'))
cursor = db.cursor()
for s in ['a']:
cursor.execute("SELECT name, passwd, slot_id FROM clients WHERE name LIKE '0000000" + s + "%'")
log_info = cursor.fetchone()
challenge = ('EF' * 32).decode('hex')
while log_info:
print(log_info[0] + ' ' + atsha204.hmac(log_info[2], log_info[0].decode('hex'), log_info[1].decode('hex'), challenge).encode('hex'))
log_info = cursor.fetchone()
......@@ -12,15 +12,19 @@ for my $level (@levels) {
}
print Dumper \@groups;
$dbh->do('INSERT INTO groups (name) VALUES (?)', undef, $_) for @groups;
#$dbh->do('INSERT INTO groups (name) VALUES (?)', undef, $_) for @groups;
my $ids = $dbh->selectall_arrayref("SELECT id FROM clients WHERE name LIKE '00000006%'");
my $ids = $dbh->selectall_arrayref("SELECT id FROM clients WHERE name LIKE '0000000a%'");
for my $id_row (@$ids) {
my ($id) = @$id_row;
#$dbh->do('INSERT INTO group_members (client, in_group) SELECT ?, id FROM groups WHERE name = ?', undef, $id, 'all');
for my $level (@levels) {
my $rand = 1 + int(rand($level));
print "$id into $level-$rand\n";
die "Rand wrong" if $rand > $level;
$dbh->do('INSERT INTO group_members (client, in_group) SELECT ?, id FROM groups WHERE name = ?', undef, $id, "rand-$level-$rand");
}
}
$dbh->commit;
......@@ -6,7 +6,7 @@ $/ = "\n\n";
my @input = <STDIN>;
my $slot = 0;
my $tag = 'turris-test';
my $tag = 'omnia-proto';
my $start = 3;
print "BEGIN;\n";
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment