Skip to content

Commit

Permalink
Merge pull request #7 from mwrlabs/develop
Browse files Browse the repository at this point in the history
V1.0.3
  • Loading branch information
marco-lancini authored May 5, 2017
2 parents 9874fab + f8683a4 commit eb973c6
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 99 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ All notable changes to this project will be documented in this file.
#### Removed


## [1.0.2] - 2017-03-21

## [1.0.3] - 2017-05-05
#### Added
- Move `list_apps` to `Utils`

#### Fixed
- Prepend to responses string so messages appear at top of screen



## [1.0.2] - 2017-03-21
#### Fixed
- Communication with Needle Core



## [1.0.1] - 2017-03-15

#### Fixed
- Communication with Needle Core
- Naming convention
Expand Down
30 changes: 15 additions & 15 deletions needle-agent/needleAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
A9A27A4F1E5DD04B0014E1A7 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9A27A4E1E5DD04B0014E1A7 /* MobileCoreServices.framework */; };
A9A27A521E5DD1350014E1A7 /* FBApplicationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A9A27A501E5DD1350014E1A7 /* FBApplicationInfo.h */; };
A9A27A531E5DD1350014E1A7 /* LSApplicationProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A9A27A511E5DD1350014E1A7 /* LSApplicationProxy.h */; };
A9B294EF1E9BACC200ACCCA6 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B294EE1E9BACC200ACCCA6 /* Utils.h */; };
A9B294F11E9BACD000ACCCA6 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B294F01E9BACD000ACCCA6 /* Utils.m */; };
A9C7110D1E65DD4D0084103A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9C7110C1E65DD4D0084103A /* Assets.xcassets */; };
A9C7110F1E65E8DD0084103A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9C7110E1E65E8D60084103A /* Foundation.framework */; };
A9CFE9511E5DA69B006D6E08 /* LSApplicationWorkspace.h in Headers */ = {isa = PBXBuildFile; fileRef = A9CFE9501E5DA69B006D6E08 /* LSApplicationWorkspace.h */; };
Expand Down Expand Up @@ -45,6 +47,8 @@
A9A27A4E1E5DD04B0014E1A7 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
A9A27A501E5DD1350014E1A7 /* FBApplicationInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBApplicationInfo.h; sourceTree = "<group>"; };
A9A27A511E5DD1350014E1A7 /* LSApplicationProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LSApplicationProxy.h; sourceTree = "<group>"; };
A9B294EE1E9BACC200ACCCA6 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = "<group>"; };
A9B294F01E9BACD000ACCCA6 /* Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utils.m; sourceTree = "<group>"; };
A9C7110C1E65DD4D0084103A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A9C7110E1E65E8D60084103A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
A9CEF2D81E607515006A827E /* Xcode.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; name = Xcode.app; path = ../../../../../../../../Applications/Xcode.app; sourceTree = "<group>"; };
Expand Down Expand Up @@ -136,16 +140,18 @@
children = (
A90CB6A11E66EA71009FEA35 /* PrivateInterfaces */,
A93B0E0A1E157C0C002AAAA8 /* OpcodeProtocol.h */,
A974E21D1E68608D00F60BEF /* OpcodeSTOP.m */,
A974E21F1E6861A500F60BEF /* OpcodeLIST_APPS.m */,
A974E2211E68732600F60BEF /* OpcodeOS_VERSION.m */,
A974E21D1E68608D00F60BEF /* OpcodeSTOP.m */,
);
name = Opcodes;
sourceTree = "<group>";
};
A99C83C91E14528B00D7D13C /* Handlers */ = {
isa = PBXGroup;
children = (
A9B294EE1E9BACC200ACCCA6 /* Utils.h */,
A9B294F01E9BACD000ACCCA6 /* Utils.m */,
E91E39221D5B4BC600720D62 /* MWRCommandHandler.h */,
E91E39231D5B4BC600720D62 /* MWRCommandHandler.m */,
);
Expand Down Expand Up @@ -206,6 +212,7 @@
A9A27A531E5DD1350014E1A7 /* LSApplicationProxy.h in Headers */,
A9CFE9511E5DA69B006D6E08 /* LSApplicationWorkspace.h in Headers */,
A974E21B1E685B4100F60BEF /* OpcodeProtocol.h in Headers */,
A9B294EF1E9BACC200ACCCA6 /* Utils.h in Headers */,
A9A27A521E5DD1350014E1A7 /* FBApplicationInfo.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -345,6 +352,7 @@
E9B171FA1D548F6A00DB3B60 /* AppDelegate.m in Sources */,
E91E39331D66094B00720D62 /* MWRAsyncSocket.m in Sources */,
E91B6FD21D587B44000A2939 /* MWRServerViewController.m in Sources */,
A9B294F11E9BACD000ACCCA6 /* Utils.m in Sources */,
E9B171F71D548F6A00DB3B60 /* main.m in Sources */,
A974E2201E6861A500F60BEF /* OpcodeLIST_APPS.m in Sources */,
E91E39241D5B4BC600720D62 /* MWRCommandHandler.m in Sources */,
Expand All @@ -371,11 +379,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = (
arm64,
armv7,
armv7s,
);
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
Expand Down Expand Up @@ -414,24 +418,20 @@
HEADER_SEARCH_PATHS = "";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos10.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = "arm64 armv7 armv7s";
VALID_ARCHS = "arm64 armv7";
};
name = Debug;
};
E9B172181D548F6A00DB3B60 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = (
arm64,
armv7,
armv7s,
);
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
Expand Down Expand Up @@ -464,13 +464,13 @@
HEADER_SEARCH_PATHS = "";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos10.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VALID_ARCHS = "arm64 armv7 armv7s";
VALID_ARCHS = "arm64 armv7";
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion needle-agent/needleAgent/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef Constants_h
#define Constants_h

#define AGENT_VERSION @"1.0.2"
#define AGENT_VERSION @"1.0.3"
#define DEFAULT_PORT @"4444"

#define AGENT_NAME @"Needle Agent"
Expand Down
3 changes: 2 additions & 1 deletion needle-agent/needleAgent/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand All @@ -34,6 +34,7 @@
<true/>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>voip</string>
</array>
<key>UILaunchStoryboardName</key>
Expand Down
4 changes: 2 additions & 2 deletions needle-agent/needleAgent/MWRServerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ -(void)updateLogs:(NSString *)message
{
dispatch_async(dispatch_get_main_queue(), ^{
// Prepend to responses string so messages appear at top of screen
[self.responsesString
appendString:[NSString stringWithFormat:@"> %@\n", message]];
self.responsesString = [NSString stringWithFormat:@"> %@\n%@", message, self.responsesString];

// Update UILabel with new responses
self.responsesLabel.text = self.responsesString;
});
Expand Down
56 changes: 9 additions & 47 deletions needle-agent/needleAgent/OpcodeLIST_APPS.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
//

#import "OpcodeProtocol.h"
#import "LSApplicationWorkspace.h"
#import "FBApplicationInfo.h"
#import "LSApplicationProxy.h"

@interface OpcodeLIST_APPS : NSObject <OPCODE>
@end
Expand All @@ -16,53 +13,18 @@ @implementation OpcodeLIST_APPS

+(NSString *)run:(NSArray *)args
{
NSString *res = [self listApplications];
NSLog(@"RES: %@", res);
NSString * responseString = [NSString stringWithFormat:@"%@%@", res, COMMAND_OUTPUT_END];
return responseString;
}

+ (NSString *)listApplications
{
NSMutableDictionary *all_apps = [NSMutableDictionary new];
NSDictionary *bundleInfo = nil;

LSApplicationWorkspace *applicationWorkspace = [LSApplicationWorkspace defaultWorkspace];
NSArray *proxies = [applicationWorkspace allApplications];

for (FBApplicationInfo *proxy in proxies)
{
NSString *appType = [proxy performSelector:@selector(applicationType)];

if ([appType isEqualToString:@"User"] && proxy.bundleContainerURL && proxy.bundleURL)
{
NSString *itemName = ((LSApplicationProxy*)proxy).itemName;
if (!itemName)
{
itemName = ((LSApplicationProxy*)proxy).localizedName;
}

bundleInfo = @{
@"BundleURL": [proxy.bundleURL absoluteString],
@"BundleContainer": [proxy.bundleContainerURL absoluteString],
@"DataContainer": [proxy.dataContainerURL absoluteString],
@"DisplayName": itemName,
@"BundleIdentifier": proxy.bundleIdentifier,
@"BundleVersion": proxy.bundleVersion,
@"BundleURL": [proxy.bundleURL absoluteString],
@"Entitlements": proxy.entitlements,
@"SDKVersion": proxy.sdkVersion,
@"MinimumOS": ((LSApplicationProxy*)proxy).minimumSystemVersion,
@"TeamID": ((LSApplicationProxy*)proxy).teamID,
};
all_apps[proxy.bundleIdentifier] = bundleInfo;
}
}
// Get list of apps
NSMutableDictionary *allApps = [Utils listApplications];

// Convert it to JSON
NSError * err;
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:all_apps options:0 error:&err];
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:allApps options:0 error:&err];
NSString *res = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"RES: %@", res);

// Return output
NSString * responseString = [NSString stringWithFormat:@"%@%@", res, COMMAND_OUTPUT_END];
return responseString;
}

@end
Expand Down
2 changes: 2 additions & 0 deletions needle-agent/needleAgent/OpcodeProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

#import <Foundation/Foundation.h>
#import "Constants.h"
#import "Utils.h"

@protocol OPCODE <NSObject>

@required
+(NSString *)run:(NSArray *)args;

@end
17 changes: 17 additions & 0 deletions needle-agent/needleAgent/Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Utils.h
// needleAgent
//
#import <Foundation/Foundation.h>


@interface Utils : NSObject

+ (NSData *)listApplications;

+(BOOL)copyFile:(NSString *)infile into:(NSString *)outfile;

@end



81 changes: 81 additions & 0 deletions needle-agent/needleAgent/Utils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// Utils.m
// needleAgent
//
#import "Utils.h"

// LIST_APPS
#import "LSApplicationWorkspace.h"
#import "FBApplicationInfo.h"
#import "LSApplicationProxy.h"

@implementation Utils


+ (NSMutableDictionary *)listApplications
{
NSMutableDictionary *all_apps = [NSMutableDictionary new];
NSDictionary *bundleInfo = nil;

LSApplicationWorkspace *applicationWorkspace = [LSApplicationWorkspace defaultWorkspace];
NSArray *proxies = [applicationWorkspace allApplications];

for (FBApplicationInfo *proxy in proxies)
{
NSString *appType = [proxy performSelector:@selector(applicationType)];

if ([appType isEqualToString:@"User"] && proxy.bundleContainerURL && proxy.bundleURL)
{
NSString *itemName = ((LSApplicationProxy*)proxy).itemName;
if (!itemName)
{
itemName = ((LSApplicationProxy*)proxy).localizedName;
}

bundleInfo = @{
@"BundleURL": [proxy.bundleURL absoluteString],
@"BundleContainer": [proxy.bundleContainerURL absoluteString],
@"DataContainer": [proxy.dataContainerURL absoluteString],
@"DisplayName": itemName,
@"BundleIdentifier": proxy.bundleIdentifier,
@"BundleVersion": proxy.bundleVersion,
@"BundleURL": [proxy.bundleURL absoluteString],
@"Entitlements": proxy.entitlements,
@"SDKVersion": proxy.sdkVersion,
@"MinimumOS": ((LSApplicationProxy*)proxy).minimumSystemVersion,
@"TeamID": ((LSApplicationProxy*)proxy).teamID,
};
all_apps[proxy.bundleIdentifier] = bundleInfo;
}
}

return all_apps;
}


+(BOOL)copyFile:(NSString *)infile into:(NSString *)outfile;
{
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
if(![fileManager createDirectoryAtPath:[outfile stringByDeletingLastPathComponent]
withIntermediateDirectories:YES attributes:nil error:NULL])
{
NSLog(@"Failed to create directory at path: %@", [outfile stringByDeletingLastPathComponent]);
return NO;
}

if ([fileManager fileExistsAtPath:outfile])
{
[fileManager removeItemAtPath:outfile error:nil];
}

if(![fileManager copyItemAtPath:infile toPath:outfile error:&error])
{
NSLog(@"Failed to copy item: %@ to %@", infile, outfile);
NSLog(@"Copy file error: %@", error.localizedDescription);
return NO;
}
return YES;
}

@end
Binary file modified release/NeedleAgent.deb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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>application-identifier</key>
<string>U38MMB3T7J.mwr.needle.agent</string>
<key>keychain-access-groups</key>
<array>
<string>U38MMB3T7J.mwr.needle.agent</string>
</array>
</dict>
</plist>
Binary file modified release/NeedleAgent/Applications/needleAgent.app/Assets.car
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dict>
<key>Info.plist</key>
<data>
9Tsjb7n3tpU4ISFtc60sJoBiin0=
Zv7ex/fkuUkTFwlrXNR/f0Zi4sQ=
</data>
</dict>
<key>files2</key>
Expand Down
Binary file modified release/NeedleAgent/Applications/needleAgent.app/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit eb973c6

Please sign in to comment.