Skip to content

Commit

Permalink
Merge pull request #376 from Psiphon-Labs/master
Browse files Browse the repository at this point in the history
Merge master into staging-client
  • Loading branch information
adam-p authored May 17, 2017
2 parents 9843847 + 318bfdf commit 87ae887
Show file tree
Hide file tree
Showing 10 changed files with 312 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
6685BDD41E2EBB1000F0E414 /* GoPsi.objc.h in Headers */ = {isa = PBXBuildFile; fileRef = 6685BDD21E2EBB1000F0E414 /* GoPsi.objc.h */; };
6685BDD51E2EBB1000F0E414 /* Universe.objc.h in Headers */ = {isa = PBXBuildFile; fileRef = 6685BDD31E2EBB1000F0E414 /* Universe.objc.h */; };
6685BDD91E300AC200F0E414 /* strip-frameworks.sh in Resources */ = {isa = PBXBuildFile; fileRef = 6685BDD81E300AC200F0E414 /* strip-frameworks.sh */; };
66BAD3351E525FBC00CD06DE /* JailbreakCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 66BAD3331E525FBC00CD06DE /* JailbreakCheck.h */; settings = {ATTRIBUTES = (Public, ); }; };
66BAD3361E525FBC00CD06DE /* JailbreakCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BAD3341E525FBC00CD06DE /* JailbreakCheck.m */; };
66BDB02A1DA6BFCC0079384C /* PsiphonTunnel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66BDB0201DA6BFCC0079384C /* PsiphonTunnel.framework */; };
66BDB02F1DA6BFCC0079384C /* PsiphonTunnelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BDB02E1DA6BFCC0079384C /* PsiphonTunnelTests.m */; };
66BDB0311DA6BFCC0079384C /* PsiphonTunnel.h in Headers */ = {isa = PBXBuildFile; fileRef = 66BDB0231DA6BFCC0079384C /* PsiphonTunnel.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -74,6 +76,8 @@
6685BDD21E2EBB1000F0E414 /* GoPsi.objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GoPsi.objc.h; path = PsiphonTunnel/Psi.framework/Versions/A/Headers/GoPsi.objc.h; sourceTree = "<group>"; };
6685BDD31E2EBB1000F0E414 /* Universe.objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Universe.objc.h; path = PsiphonTunnel/Psi.framework/Versions/A/Headers/Universe.objc.h; sourceTree = "<group>"; };
6685BDD81E300AC200F0E414 /* strip-frameworks.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = "strip-frameworks.sh"; path = "scripts/strip-frameworks.sh"; sourceTree = "<group>"; };
66BAD3331E525FBC00CD06DE /* JailbreakCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JailbreakCheck.h; sourceTree = "<group>"; };
66BAD3341E525FBC00CD06DE /* JailbreakCheck.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JailbreakCheck.m; sourceTree = "<group>"; };
66BDB0201DA6BFCC0079384C /* PsiphonTunnel.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PsiphonTunnel.framework; sourceTree = BUILT_PRODUCTS_DIR; };
66BDB0231DA6BFCC0079384C /* PsiphonTunnel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PsiphonTunnel.h; sourceTree = "<group>"; };
66BDB0241DA6BFCC0079384C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -143,6 +147,15 @@
name = Psi;
sourceTree = "<group>";
};
66BAD3321E525FBC00CD06DE /* JailbreakCheck */ = {
isa = PBXGroup;
children = (
66BAD3331E525FBC00CD06DE /* JailbreakCheck.h */,
66BAD3341E525FBC00CD06DE /* JailbreakCheck.m */,
);
path = JailbreakCheck;
sourceTree = "<group>";
};
66BDB0161DA6BFCC0079384C = {
isa = PBXGroup;
children = (
Expand All @@ -166,6 +179,7 @@
66BDB0221DA6BFCC0079384C /* PsiphonTunnel */ = {
isa = PBXGroup;
children = (
66BAD3321E525FBC00CD06DE /* JailbreakCheck */,
662659241DD270E900872F6C /* Reachability */,
66BDB04A1DC26CCC0079384C /* json-framework */,
66BDB0231DA6BFCC0079384C /* PsiphonTunnel.h */,
Expand Down Expand Up @@ -223,6 +237,7 @@
buildActionMask = 2147483647;
files = (
6685BDCB1E2E882800F0E414 /* ref.h in Headers */,
66BAD3351E525FBC00CD06DE /* JailbreakCheck.h in Headers */,
4E89F7FF1E2ED3CE00005F4C /* LookupIPv6.h in Headers */,
662659271DD270E900872F6C /* Reachability.h in Headers */,
66BDB05D1DC26CCC0079384C /* SBJson4StreamParser.h in Headers */,
Expand Down Expand Up @@ -349,6 +364,7 @@
66BDB0661DC26CCC0079384C /* SBJson4StreamWriterState.m in Sources */,
66BDB05C1DC26CCC0079384C /* SBJson4Parser.m in Sources */,
4E89F7FE1E2ED3CE00005F4C /* LookupIPv6.c in Sources */,
66BAD3361E525FBC00CD06DE /* JailbreakCheck.m in Sources */,
66BDB0681DC26CCC0079384C /* SBJson4Writer.m in Sources */,
66BDB0621DC26CCC0079384C /* SBJson4StreamTokeniser.m in Sources */,
66BDB0441DA6C7DD0079384C /* PsiphonTunnel.m in Sources */,
Expand Down Expand Up @@ -477,6 +493,7 @@
66BDB0351DA6BFCC0079384C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = Q6HLNEX92A;
Expand All @@ -501,6 +518,7 @@
66BDB0361DA6BFCC0079384C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = Q6HLNEX92A;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// JailbreakCheck.h
// JailbreakCheck
//

/*
* Copyright (c) 2017, Psiphon Inc.
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

@interface JailbreakCheck : NSObject

+ (BOOL)isDeviceJailbroken;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Adapted from https://github.com/olxios/JailbreakCheck
/*
MIT License
Copyright (c) 2016 olxios
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/


#import <Foundation/Foundation.h>
#import "UIKit/UIKit.h"
#import <sys/stat.h>
#import "JailbreakCheck.h"


@implementation JailbreakCheck


BOOL checkReadWritePermissions()
{
// UIApplication:sharedApplication is disallowed in an application exetension
// (such as would be used by a whole-device Psiphon VPN). We may re-enable
// this code later, but leave it out for now to avoid confusion.
/*
if([[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"cydia://package/com.com.com"]])
{
return TRUE;
}
NSError *error;
NSString *stringToBeWritten = @"0";
[stringToBeWritten writeToFile:@"/private/jailbreak.test"
atomically:YES
encoding:NSUTF8StringEncoding error:&error];
if (error == nil)
{
return TRUE;
}
*/

return FALSE;
}

BOOL checkJailbreakSymLink(NSString *checkPath)
{
struct stat s;

if (lstat([checkPath UTF8String], &s) == 0)
{
if (S_ISLNK(s.st_mode) == 1)
{
return TRUE;
}
}

return FALSE;
}

BOOL checkJailbreakSymlinks()
{
NSArray *linksChecks = @[@"/Applications",
@"/usr/libexec",
@"/usr/share",
@"/Library/Wallpaper",
@"/usr/include"];

for (NSString *checkPath in linksChecks)
{
if (checkJailbreakSymLink(checkPath)) {
return TRUE;
}
}

return FALSE;
}

BOOL checkJailbreakFile(NSString *checkPath)
{
struct stat s;

if (stat([checkPath UTF8String], &s) == 0)
{
return TRUE;
}

return FALSE;
}

BOOL checkJailbreakFiles()
{
NSArray *fileChecks = @[@"/bin/bash",
@"/etc/apt",
@"/usr/sbin/sshd",
@"/Library/MobileSubstrate/MobileSubstrate.dylib",
@"/Applications/Cydia.app",
@"/bin/sh",
@"/var/cache/apt",
@"/var/tmp/cydia.log"];

for (NSString *checkPath in fileChecks)
{
if (checkJailbreakFile(checkPath)) {
return TRUE;
}
}

return FALSE;
}

+ (BOOL)isDeviceJailbroken
{
return
checkJailbreakSymlinks()
|| checkJailbreakFiles()
|| checkReadWritePermissions();
}

@end
12 changes: 6 additions & 6 deletions MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#import <UIKit/UIKit.h>
#import "Reachability.h"
#import "JailbreakCheck.h"


//! Project version number for PsiphonTunnel.
Expand Down Expand Up @@ -52,24 +53,24 @@ FOUNDATION_EXPORT const unsigned char PsiphonTunnelVersionString[];
- `PropagationChannelId`
- `SponsorId`
- Remote server list functionality is not strictly required, but absence greatly undermines circumvention ability.
- `RemoteServerListUrl`
- `RemoteServerListURLs`
- `RemoteServerListSignaturePublicKey`
- Obfuscated server list functionality is also not strictly required, but aids circumvention ability.
- `ObfuscatedServerListRootURL`
- `ObfuscatedServerListRootURLs`
- `RemoteServerListSignaturePublicKey`: This is the same field as above. It is required if either `RemoteServerListURLs` or `ObfuscatedServerListRootURLs` is supplied.
Optional fields (if you don't need them, don't set them):
- `DataStoreDirectory`: If not set, the library will use a sane location. Override if the client wants to restrict where operational data is kept. If overridden, the directory must already exist and be writable.
- `RemoteServerListDownloadFilename`: If not set, the library will use a sane location. Override if the client wants to restrict where operational data is kept.
- `ObfuscatedServerListDownloadDirectory`: If not set, the library will use a sane location. Override if the client wants to restrict where operational data is kept. If overridden, the directory must already exist and be writable.
- `ClientPlatform`: Should not be set by most library consumers.
- `UpstreamProxyUrl`
- `EmitDiagnosticNotices`
- `EgressRegion`
- `EstablishTunnelTimeoutSeconds`
- Should only be set if the Psiphon library is handling upgrade downloading (which it usually is _not_):
- `UpgradeDownloadUrl`
- `UpgradeDownloadURLs`
- `UpgradeDownloadClientVersionHeader`
- `UpgradeDownloadFilename`
- `UpgradeDownloadFilename`: Will be set to a sane default if not supplied.
- Only set if disabling timeouts (for very slow network connections):
- `TunnelConnectTimeoutSeconds`
- `TunnelPortForwardDialTimeoutSeconds`
Expand All @@ -83,7 +84,6 @@ FOUNDATION_EXPORT const unsigned char PsiphonTunnelVersionString[];
- `LocalHttpProxyPort`
- `LocalSocksProxyPort`
- `TunnelWholeDevice`: For stats purposes, but must be accurate. Defaults to 0 (false).
@endcode
@note All other config fields must not be set.
Expand Down
Loading

0 comments on commit 87ae887

Please sign in to comment.