Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
Expand All @@ -64,3 +64,5 @@ iOSInjectionProject/

#Test Login Credentials
ChromeChain/ChromeChainConsole/test_files/

Pods/
15 changes: 15 additions & 0 deletions Chromate/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// AppDelegate.h
// Chromate
//
// Created by Terry Lewis on 26/6/17.
// Copyright © 2017 terry1994. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>


@end

39 changes: 39 additions & 0 deletions Chromate/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// AppDelegate.m
// Chromate
//
// Created by Terry Lewis on 26/6/17.
// Copyright © 2017 terry1994. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

static NSString *const kSafariSharedFrameworkPath = @"/System/Library/PrivateFrameworks/SafariShared.framework";
static NSString *const kSafariSharedPath = @"/System/Library/PrivateFrameworks/Safari.framework";

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application

NSBundle *safariSharedBundle = [NSBundle bundleWithPath:kSafariSharedFrameworkPath];
NSLog(@"Load SafariShared: %@", [safariSharedBundle load] ? @"YES" : @"NO");

NSBundle *safariBundle = [NSBundle bundleWithPath:kSafariSharedPath];
NSLog(@"Load Safari: %@", [safariBundle load] ? @"YES" : @"NO");
}


- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}

@end
58 changes: 58 additions & 0 deletions Chromate/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images": [
{
"idiom": "mac",
"size": "16x16",
"scale": "1x"
},
{
"idiom": "mac",
"size": "16x16",
"scale": "2x"
},
{
"idiom": "mac",
"size": "32x32",
"scale": "1x"
},
{
"idiom": "mac",
"size": "32x32",
"scale": "2x"
},
{
"idiom": "mac",
"size": "128x128",
"scale": "1x"
},
{
"idiom": "mac",
"size": "128x128",
"scale": "2x"
},
{
"idiom": "mac",
"size": "256x256",
"scale": "1x"
},
{
"idiom": "mac",
"size": "256x256",
"scale": "2x"
},
{
"idiom": "mac",
"size": "512x512",
"scale": "1x"
},
{
"idiom": "mac",
"size": "512x512",
"scale": "2x"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
849 changes: 849 additions & 0 deletions Chromate/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Chromate/Chromate.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>com.apple.cfnetwork</string>
</array>
</dict>
</plist>
56 changes: 56 additions & 0 deletions Chromate/Common/ChromiumConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// ChromiumConstants.h
// ChromeChain
//
// Created by Terry Lewis on 25/6/17.
// Copyright (c) 2017 terry1994. All rights reserved.
//
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#ifndef ChromiumConstants_h
#define ChromiumConstants_h

// Salt for Symmetric key derivation.
const char kSalt[] = "saltysalt";
// Key size required for 128 bit AES.
const size_t kDerivedKeySizeInBits = 128;
// Constant for Symmetic key derivation.
const unsigned int kEncryptionIterations = 1003;

const size_t kIVBlockSizeAES128 = 16;

const size_t kDerivedKeyLen = kDerivedKeySizeInBits / 8;

// Prefix for cypher text returned by current encryption version. We prefix
// the cypher text with this string so that future data migration can detect
// this and migrate to different encryption without data loss.
const char kEncryptionVersionPrefixv10[] = "v10";

#endif /* ChromiumConstants_h */
14 changes: 14 additions & 0 deletions Chromate/Common/KeychainWriter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Created by Terry Lewis on 26/6/17.
// Copyright (c) 2017 terry1994. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LoginCredential.h"


@interface KeychainWriter : NSObject

+ (BOOL)writeCredentialToKeychain:(LoginCredential *)loginCredential decryptedPassword:(NSString *)decryptedPassword;

@end
37 changes: 37 additions & 0 deletions Chromate/Common/KeychainWriter.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Created by Terry Lewis on 26/6/17.
// Copyright (c) 2017 terry1994. All rights reserved.
//

#import "KeychainWriter.h"
#import "UICKeyChainStore.h"

static NSString *const kCommentString = @"Imported with ChromeChain.";

@implementation KeychainWriter {
}

static NSString *labelForCredential(LoginCredential *loginCredential) {
NSMutableString *result = [[NSMutableString alloc] initWithString:loginCredential.signonRealmURL.host];
if (loginCredential.username != nil && loginCredential.username.length > 0) {
[result appendFormat:@" (%@)", loginCredential.username];
}

return result;
}


+ (BOOL)writeCredentialToKeychain:(LoginCredential *)loginCredential decryptedPassword:(NSString *)decryptedPassword {
UICKeyChainStore *keychain = [UICKeyChainStore keyChainStoreWithServer:loginCredential.signonRealmURL
protocolType:UICKeyChainStoreProtocolTypeHTTPS
authenticationType:UICKeyChainStoreAuthenticationTypeHTMLForm];
keychain.synchronizable = YES;
[keychain setString:decryptedPassword
forKey:loginCredential.username
label:labelForCredential(loginCredential)
comment:kCommentString];

return NO;
}

@end
26 changes: 26 additions & 0 deletions Chromate/Common/LoginCredential.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Created by Terry Lewis on 20/3/17.
// Copyright (c) 2017 terry1994. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <string>


@interface LoginCredential : NSObject

@property(nonatomic, retain, readonly) NSURL *signonRealmURL;
@property(nonatomic, retain, readonly) NSString *username;
@property(nonatomic, retain, readonly) NSData *encryptedPassword;
@property(nonatomic, readonly) std::string encryptedPasswordStr;
@property(nonatomic, readonly, getter=isValid) BOOL valid;

- (instancetype)initWithSignonRealm:(NSString *)origin username:(NSString *)username
encryptedPassword:(NSData *)encryptedPassword;

+ (instancetype)credentialWithSignonRealm:(NSString *)origin username:(NSString *)username
encryptedPassword:(NSData *)encryptedPassword;

- (NSString *)decryptedPassword:(NSString *)cypher;

@end
46 changes: 46 additions & 0 deletions Chromate/Common/LoginCredential.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Created by Terry Lewis on 20/3/17.
// Copyright (c) 2017 terry1994. All rights reserved.
//

#import "LoginCredential.h"
#import <string>
#import <iostream>

@interface LoginCredential () {
}
@property(nonatomic, retain) NSString *password;
@end

@implementation LoginCredential

- (instancetype)initWithSignonRealm:(NSString *)origin username:(NSString *)username
encryptedPassword:(NSData *)encryptedPassword {
self = [super init];
if (self) {
_signonRealmURL = [NSURL URLWithString:origin];
_username = username;
_encryptedPasswordData = encryptedPassword;
_valid = _signonRealmURL != nil && encryptedPassword != nil && encryptedPassword.length > 0;

if (_valid) {
// Explicitly define length in order to ensure (possibly present) null terminators do not truncate encrypted
// strings.
const char *encryptedPasswordBytes = static_cast<const char *>(encryptedPassword.bytes);
_encryptedPasswordString = std::string(encryptedPasswordBytes, encryptedPassword.length);
}
}

return self;
}

+ (instancetype)credentialWithSignonRealm:(NSString *)origin username:(NSString *)username
encryptedPassword:(NSData *)encryptedPassword {
return [[self alloc] initWithSignonRealm:origin username:username encryptedPassword:encryptedPassword];
}

- (NSString *)decryptedPassword:(NSString *)cypher {
return nil;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

@interface LoginStore : NSObject

@property (nonatomic, strong) NSString *path;
@property (nonatomic, copy, readonly) NSArray<LoginCredential *> *credentials;
@property(nonatomic, strong) NSString *path;
@property(nonatomic, copy, readonly) NSArray<LoginCredential *> *credentials;

- (instancetype)initWithPath:(NSString *)path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

#import "LoginStore.h"
#import "FMDB/FMDB.h"
#import "LoginCredential.h"

static NSString *const kTableName = @"logins";
static NSString *const kActionURL = @"action_url";
static NSString *const kActionURL = @"signon_realm";
static NSString *const kUsernameValue = @"username_value";
static NSString *const kPasswordValue = @"password_value";

Expand All @@ -31,24 +30,25 @@ + (instancetype)storeWithPath:(NSString *)path {
return [[self alloc] initWithPath:path];
}

- (BOOL)readData{
if (!_database.open){
- (BOOL)readData {
if (!_database.open) {
return NO;
}

NSString *queryString = [NSString stringWithFormat:@"SELECT * FROM %@", kTableName];
FMResultSet *resultSet = [_database executeQuery:queryString];
NSMutableArray *mutableLoginCredentials = [NSMutableArray array];
while (resultSet.next){
while (resultSet.next) {
NSString *actionURL = [resultSet stringForColumn:kActionURL];
NSString *username = [resultSet stringForColumn:kUsernameValue];
NSData *encPassword = [resultSet dataForColumn:kPasswordValue];

LoginCredential *loginCredential = [LoginCredential credentialWithActionURL:actionURL
username:username
encryptedPassword:encPassword];
LoginCredential *loginCredential = [LoginCredential credentialWithSignonRealm:actionURL
username:username
encryptedPassword:encPassword];
[mutableLoginCredentials addObject:loginCredential];
}
[resultSet close];
_loginCredentials = mutableLoginCredentials;

return [_database close];
Expand Down
Loading