Skip to content

Commit

Permalink
Add support for AWS keys reading
Browse files Browse the repository at this point in the history
  • Loading branch information
alxchk committed May 23, 2017
1 parent b11a71b commit 6e5063b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Linux/lazagne/config/manageModules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from lazagne.softwares.sysadmin.filezilla import Filezilla
from lazagne.softwares.sysadmin.env_variable import Env_variable
from lazagne.softwares.sysadmin.shadow import Shadow
from lazagne.softwares.sysadmin.aws import Aws
# chats
from lazagne.softwares.chats.pidgin import Pidgin
from lazagne.softwares.chats.jitsi import Jitsi
Expand Down Expand Up @@ -52,6 +53,7 @@ def get_modules():
Opera(),
Pidgin(),
Shadow(),
Aws(),
SQLDeveloper(),
Squirrel(),
Wifi(),
Expand Down
44 changes: 44 additions & 0 deletions Linux/lazagne/softwares/sysadmin/aws.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from lazagne.config.constant import *
from lazagne.config.write_output import print_debug
from lazagne.config.moduleInfo import ModuleInfo
from lazagne.config import homes
from ConfigParser import ConfigParser

import os

class Aws(ModuleInfo):
def __init__(self):
options = {'command': '-W', 'action': 'store_true', 'dest': 'aws', 'help': 'aws'}
suboptions = []
ModuleInfo.__init__(self, 'aws', 'sysadmin', options, suboptions)

def get_paths(self):
return homes.get(file=os.path.join('.aws', 'credentials'))

def get_creds(self, path):
try:
parser = ConfigParser()
parser.read(path)
except:
return

for section in parser.sections():
try:
key = parser.get(section, 'aws_access_key_id')
secret = parser.get(section, 'aws_secret_access_key')
yield section, key, secret
except:
continue

def run(self, software_name=None):
all_passwords = []
for path in self.get_paths():
for section, key, secret in self.get_creds(path):
all_passwords.append({
'ID': key,
'KEY': secret,
'Service': 'AWS',
'Name': section
})

return all_passwords

0 comments on commit 6e5063b

Please sign in to comment.