pas de URLParameter sur le pika wheezy
This commit is contained in:
parent
e63b25278f
commit
076d667d34
3 changed files with 54 additions and 4 deletions
48
dump_creds.py
Executable file
48
dump_creds.py
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash /usr/scripts/python.sh
|
||||
|
||||
import pika
|
||||
import json
|
||||
import sys
|
||||
|
||||
from lc_ldap.shortcuts import lc_ldap_readonly
|
||||
from affich_tools import prompt
|
||||
import lc_ldap.filter2 as filter
|
||||
import config
|
||||
|
||||
rabbit_c = pika.BlockingConnection(config.PARAMS)
|
||||
ch = rabbit_c.channel()
|
||||
ch.queue_declare('CransTicket')
|
||||
|
||||
ldap = lc_ldap_readonly()
|
||||
|
||||
|
||||
f = filter.human_to_ldap(sys.argv[1].decode('utf-8'))
|
||||
adh = ldap.search(f)
|
||||
if len(adh) > 1:
|
||||
print "More than one result"
|
||||
exit()
|
||||
elif not adh:
|
||||
print "Nobody"
|
||||
else:
|
||||
adh = adh[0]
|
||||
adh.display()
|
||||
while True:
|
||||
c = prompt("[O/N]").lower()
|
||||
if c == 'n':
|
||||
exit()
|
||||
elif c == 'o':
|
||||
break
|
||||
|
||||
m = adh.machines()
|
||||
|
||||
to_print = []
|
||||
for machine in m:
|
||||
if u'<automatique>' in machine['macAddress']:
|
||||
continue
|
||||
login = machine['host'][0].split('.', 1)[0]
|
||||
todo = {'login': login, 'macAddress': machine['macAddress'][0].value}
|
||||
if machine.has_key('ipsec'):
|
||||
todo['pass'] = machine['ipsec'][0].value
|
||||
to_print.append(todo)
|
||||
|
||||
ch.basic_publish(exchange='', routing_key='CransTicket', body=json.dumps(to_print))
|
Loading…
Add table
Add a link
Reference in a new issue