Esempio n. 1
0
    def test_DTE(self):
        vault_file = hny_config.VAULT_FILE + '~test'
        mpw = 'Masterpassw0rd' + str(random.randint(0, 100))
        hv = HoneyVault(vault_file, mpw)
        PW_set = dict((i, hv.dte.decode_pw(pw_encodings))
                      for i, pw_encodings in enumerate(hv.S)
                      if hv.machine_pass_set[i] == '0')
        for i, pw in list(PW_set.items()):
            s = hv.dte.encode_pw(pw)
            tpw = hv.dte.decode_pw(s)
            self.assertEqual(
                tpw, pw, "Encode-decode pw is wrong. {}: {} ----> {}".format(
                    i, pw, tpw))
        print("All encode-decoing test passed")
        return
        hv.add_password(
            {'google.com': 'password' + str(random.randint(0, 1000))})
        ignore = set([hv.get_domain_index('google.com')])

        for i, pw_encodings in enumerate(hv.S):
            if hv.machine_pass_set[i] == '0' and i not in ignore:
                npw = hv.dte.decode_pw(pw_encodings)
                self.assertEqual(
                    PW_set[i], npw,
                    "New passwords changed!!! Expecting: {!r} at {}. Got {!r}".
                    format(PW_set[i], i, npw))
Esempio n. 2
0
def import_vault(*args):
    h_string = """
import existing vault, in given format
./honey_client -import <master-password> <vault_file>
e.g. ./honey_client -import AwesomeS@la vault_file.csv
vault file:
# domain,username?,password
google.com,[email protected],abc234
fb.com,rchatterjee,aadhf;123l
"""
    if len(args) < 2:
        return h_string
    mp = args[0]
    vault_fl = args[1]
    g = lambda l: (l[0], l[-1])
    domain_pw_map = dict([g(a.strip().split())
                          for a in open(vault_fl) if a[0] != '#'])
    hv = HoneyVault(VAULT_FILE, mp)
    hv.add_password(domain_pw_map)
    y = input("""
Check the following sample decoded passwords and make sure your master password
 is correct. Otherwise you might accidentally spoile your whole vault. CAREFUL.
 Ignore if this is the first time you are using this.  SAMPLE PASSWORDS: %s Are
 all of the correct to the best of your knowledge! (y/n)""" % \
              ','.join(hv.get_sample_decoding())
              )
    if y.lower() == 'y':
        hv.save()
        print("""
Successfully saved your vault. 
Now when you are sure the update is correct upload the vault to the 
server. we are not doing automatically because I dont beleive myself
""")
Esempio n. 3
0
def add_pass(*args):
    h_string = """
Add password to your vault. It will automatically initialize the vault.
If you get some error, just delete the static/vault.db (if you dont have any password)
Or download a copy from the server. 
./honey_client -addpass <master-password> <domain> <password>
e.g. ./honey_client -addpass AwesomeS@la google.com 'AmzingP@ss'
"""
    if len(args) < 3:
        return h_string
    mp = args[0]
    domain_pw_map = dict(
        (get_exact_domain(k), v)
        for k, v in zip(args[1::2], args[2::2])
    )

    hv = HoneyVault(VAULT_FILE, mp)
    hv.add_password(domain_pw_map)
    print("""Check the following sample decoded password and make sure your master
password is correct. Otherwise you might accidentally spoile your whole
vault. CAREFUL.  SAMPLE PASSWORDS:\n---> {}\n""".format('\n---> '.join(hv.get_sample_decoding())))
    y = input("Are all of the above passwords look correct to the best of your knowledge! (y/n)")

    if y.lower() == 'y':
        hv.save()
        return """
Successfully saved your vault.  Now when you are sure the update is correct upload the vault to the server. 
we are not doing automatically because I DONT BELEIVE MYSELF"""
    else:
        return "As you wish my lord!"
Esempio n. 4
0
def import_vault(*args):
    h_string = """
import existing vault, in given format
./honey_client -import <master-password> <vault_file>
e.g. ./honey_client -import AwesomeS@la vault_file.csv
vault file:
# domain,username?,password
google.com,[email protected],abc234
fb.com,rchatterjee,aadhf;123l
"""
    if len(args) < 2:
        return h_string
    mp = args[0]
    vault_fl = args[1]
    g = lambda l: (l[0], l[-1])
    domain_pw_map = dict(
        [g(a.strip().split()) for a in open(vault_fl) if a[0] != '#'])
    hv = HoneyVault(VAULT_FILE, mp)
    hv.add_password(domain_pw_map)
    y = input("""
Check the following sample decoded passwords and make sure your master password
 is correct. Otherwise you might accidentally spoile your whole vault. CAREFUL.
 Ignore if this is the first time you are using this.  SAMPLE PASSWORDS: %s Are
 all of the correct to the best of your knowledge! (y/n)""" % \
              ','.join(hv.get_sample_decoding())
              )
    if y.lower() == 'y':
        hv.save()
        print("""
Successfully saved your vault. 
Now when you are sure the update is correct upload the vault to the 
server. we are not doing automatically because I dont beleive myself
""")
Esempio n. 5
0
def add_pass(*args):
    h_string = """
Add password to your vault. It will automatically initialize the vault.
If you get some error, just delete the static/vault.db (if you dont have any password)
Or download a copy from the server. 
./honey_client -addpass <master-password> <domain> <password>
e.g. ./honey_client -addpass AwesomeS@la google.com 'AmzingP@ss'
"""
    if len(args) < 3:
        return h_string
    mp = args[0]
    domain_pw_map = dict(
        (get_exact_domain(k), v) for k, v in zip(args[1::2], args[2::2]))

    hv = HoneyVault(VAULT_FILE, mp)
    hv.add_password(domain_pw_map)
    print(
        """Check the following sample decoded password and make sure your master
password is correct. Otherwise you might accidentally spoile your whole
vault. CAREFUL.  SAMPLE PASSWORDS:\n---> {}\n""".format('\n---> '.join(
            hv.get_sample_decoding())))
    y = input(
        "Are all of the above passwords look correct to the best of your knowledge! (y/n)"
    )

    if y.lower() == 'y':
        hv.save()
        return """
Successfully saved your vault.  Now when you are sure the update is correct upload the vault to the server. 
we are not doing automatically because I DONT BELEIVE MYSELF"""
    else:
        return "As you wish my lord!"
Esempio n. 6
0
    def test_DTE(self):
        vault_file = VAULT_FILE+'~test'
        mpw = 'Masterpassw0rd'+str(random.randint(0,100))
        hv = HoneyVault(vault_file, mpw)
        PW_set = dict((i, hv.dte.decode_pw(pw_encodings)) for i, pw_encodings in \
                  enumerate(hv.S) if hv.machine_pass_set[i]=='0')
        for i, pw in PW_set.items():
            s = hv.dte.encode_pw(pw)
            tpw = hv.dte.decode_pw(s)
            self.assertEqual(tpw, pw, "Encode-decode pw is wrong. {}: {} ----> {}".format(i, pw, tpw))
        print "All encode-decoing test passed"
        return
        hv.add_password({'google.com': 'password' + str(random.randint(0, 1000))})
        ignore = set([hv.get_domain_index('google.com')])

        for i, pw_encodings in enumerate(hv.S):
            if hv.machine_pass_set[i] == '0' and i not in ignore:
                npw = hv.dte.decode_pw(pw_encodings)
                self.assertEqual(PW_set[i], npw, "New passwords changed!!!"\
                    "Expecting: '{}' at {}. Got '{}'".format(PW_set[i], npw))
Esempio n. 7
0
    def test_getpass(self):
        h_string = """Just a test framework for testing getpass
        function.

        """
        vault_file = VAULT_FILE + "~test"
        try:
            os.remove(vault_file)
        except OSError:
            pass
        mpw = 'Masterpassw0rd12'
        hv = HoneyVault(vault_file, mpw)
        u = 'google.com'
        w = hv.get_password([u])[u]
        hv.add_password({u: w})
        ret_pw = hv.get_password([u])[u]
        self.assertEqual(w, ret_pw, "PasswordAddFailed: added=<{}>, returned=<{}>"\
                         .format(w, ret_pw))  # password added correctly.
        v = hv.gen_password(mpw, [u])[u]
        self.assertEqual(v, hv.get_password([u])[u], "PasswordGenFailed: expecting={}, returned={}"\
                         .format(v, hv.get_password([u])[u]))   # password generated correctly.

        d_pws = {
            'asdfadsf.com': 'lkjandfa98w3ufh9 awe98fa',
            'a': 'a',
            '123': 'adf',
            'tt.com': 'thisismymasterpasswordanditiss',
            'fb.com': 'Amazing@#ComplexPassword',
        }
        hv.add_password(d_pws)
        ret_pws = hv.get_password(d_pws.keys())
        for k, v in d_pws.items():
            self.assertEqual(ret_pws[k],v, "Decoding mismatch @ added: {} <--> returned: {}"\
                             .format(v, ret_pws[k]))

        hv.add_password(d_pws)
        ret_pws = hv.get_password(d_pws.keys())
        for k, v in d_pws.items():
            self.assertEqual(ret_pws[k],v, "Decoding mismatch @ added: {} <--> returned: {}"\
                             .format(v, ret_pws[k]))
        os.remove(vault_file)
Esempio n. 8
0
    def test_getpass(self):
        h_string = """Just a test framework for testing getpass
        function.

        """
        vault_file = VAULT_FILE + "~test"
        try:
            os.remove(vault_file)
        except OSError:
            pass;
        mpw = 'Masterpassw0rd12'
        hv = HoneyVault(vault_file, mpw)
        u = 'google.com'
        w = hv.get_password([u])[u]
        hv.add_password({u: w})
        ret_pw = hv.get_password([u])[u]
        self.assertEqual(w, ret_pw, "PasswordAddFailed: added=<{}>, returned=<{}>"\
                         .format(w, ret_pw))  # password added correctly.
        v = hv.gen_password(mpw, [u])[u]
        self.assertEqual(v, hv.get_password([u])[u], "PasswordGenFailed: expecting={}, returned={}"\
                         .format(v, hv.get_password([u])[u]))   # password generated correctly.
        
        d_pws = {
            'asdfadsf.com': 'lkjandfa98w3ufh9 awe98fa',
            'a': 'a',
            '123': 'adf',
            'tt.com': 'thisismymasterpasswordanditiss',
            'fb.com': 'Amazing@#ComplexPassword',
           }
        hv.add_password(d_pws)
        ret_pws = hv.get_password(d_pws.keys())
        for k,v in d_pws.items():
            self.assertEqual(ret_pws[k],v, "Decoding mismatch @ added: {} <--> returned: {}"\
                             .format(v, ret_pws[k]))
    
        hv.add_password(d_pws)
        ret_pws = hv.get_password(d_pws.keys())
        for k,v in d_pws.items():
            self.assertEqual(ret_pws[k],v, "Decoding mismatch @ added: {} <--> returned: {}"\
                             .format(v, ret_pws[k]))
        os.remove(vault_file)