├── .gitignore ├── AUCapture.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── swiftpm │ │ └── Package.resolved └── xcuserdata │ └── katsumi.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── AUCapture ├── AUCapture.entitlements ├── AppDelegate.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── FileWatcher.swift ├── Info.plist ├── SceneDelegate.swift ├── ViewController.swift └── silence.wav ├── PacketTunnel ├── ByteBuffer.swift ├── Checksum.swift ├── IPPacket.swift ├── Info.plist ├── PacketTunnel.entitlements ├── PacketTunnelProvider.swift ├── TCPSession.swift └── UDPSession.swift ├── README.md └── Shared ├── AppGroup.swift └── Util.swift /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/b0012e4930d0a8c350254a3caeedf7441ea286a3/Global/macOS.gitignore 2 | 3 | # General 4 | .DS_Store 5 | .AppleDouble 6 | .LSOverride 7 | 8 | # Icon must end with two \r 9 | Icon 10 | 11 | # Thumbnails 12 | ._* 13 | 14 | # Files that might appear in the root of a volume 15 | .DocumentRevisions-V100 16 | .fseventsd 17 | .Spotlight-V100 18 | .TemporaryItems 19 | .Trashes 20 | .VolumeIcon.icns 21 | .com.apple.timemachine.donotpresent 22 | 23 | # Directories potentially created on remote AFP share 24 | .AppleDB 25 | .AppleDesktop 26 | Network Trash Folder 27 | Temporary Items 28 | .apdisk 29 | 30 | 31 | ### https://raw.github.com/github/gitignore/b0012e4930d0a8c350254a3caeedf7441ea286a3/Swift.gitignore 32 | 33 | # Xcode 34 | # 35 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 36 | 37 | ## User settings 38 | xcuserdata/ 39 | 40 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 41 | *.xcscmblueprint 42 | *.xccheckout 43 | 44 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 45 | build/ 46 | DerivedData/ 47 | *.moved-aside 48 | *.pbxuser 49 | !default.pbxuser 50 | *.mode1v3 51 | !default.mode1v3 52 | *.mode2v3 53 | !default.mode2v3 54 | *.perspectivev3 55 | !default.perspectivev3 56 | 57 | ## Obj-C/Swift specific 58 | *.hmap 59 | 60 | ## App packaging 61 | *.ipa 62 | *.dSYM.zip 63 | *.dSYM 64 | 65 | ## Playgrounds 66 | timeline.xctimeline 67 | playground.xcworkspace 68 | 69 | # Swift Package Manager 70 | # 71 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 72 | # Packages/ 73 | # Package.pins 74 | # Package.resolved 75 | # *.xcodeproj 76 | # 77 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 78 | # hence it is not needed unless you have added a package configuration file to your project 79 | # .swiftpm 80 | 81 | .build/ 82 | 83 | # CocoaPods 84 | # 85 | # We recommend against adding the Pods directory to your .gitignore. However 86 | # you should judge for yourself, the pros and cons are mentioned at: 87 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 88 | # 89 | # Pods/ 90 | # 91 | # Add this line if you want to avoid checking in source code from the Xcode workspace 92 | # *.xcworkspace 93 | 94 | # Carthage 95 | # 96 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 97 | # Carthage/Checkouts 98 | 99 | Carthage/Build/ 100 | 101 | # Accio dependency management 102 | Dependencies/ 103 | .accio/ 104 | 105 | # fastlane 106 | # 107 | # It is recommended to not store the screenshots in the git repo. 108 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 109 | # For more information about the recommended setup visit: 110 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 111 | 112 | fastlane/report.xml 113 | fastlane/Preview.html 114 | fastlane/screenshots/**/*.png 115 | fastlane/test_output 116 | 117 | # Code Injection 118 | # 119 | # After new code Injection tools there's a generated folder /iOSInjectionProject 120 | # https://github.com/johnno1962/injectionforxcode 121 | 122 | iOSInjectionProject/ 123 | 124 | 125 | -------------------------------------------------------------------------------- /AUCapture.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 52; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1420997626E4F9FF003B1C62 /* silence.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1420997526E4F9FF003B1C62 /* silence.wav */; }; 11 | 1420997826E4FA29003B1C62 /* FileWatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1420997726E4FA29003B1C62 /* FileWatcher.swift */; }; 12 | 14717CA926F5089C00C8F3E8 /* AppGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14717CA826F5089C00C8F3E8 /* AppGroup.swift */; }; 13 | 14717CAA26F508AC00C8F3E8 /* AppGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14717CA826F5089C00C8F3E8 /* AppGroup.swift */; }; 14 | 14717CAB26F5091D00C8F3E8 /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E749A26E25C5F0070330E /* Util.swift */; }; 15 | 14717CAD26F50E7600C8F3E8 /* AmongUsProtocol in Frameworks */ = {isa = PBXBuildFile; productRef = 14717CAC26F50E7600C8F3E8 /* AmongUsProtocol */; }; 16 | 149E747126E24EB70070330E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E747026E24EB70070330E /* AppDelegate.swift */; }; 17 | 149E747326E24EB70070330E /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E747226E24EB70070330E /* SceneDelegate.swift */; }; 18 | 149E747526E24EB70070330E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E747426E24EB70070330E /* ViewController.swift */; }; 19 | 149E747826E24EB70070330E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 149E747626E24EB70070330E /* Main.storyboard */; }; 20 | 149E747A26E24EB80070330E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 149E747926E24EB80070330E /* Assets.xcassets */; }; 21 | 149E747D26E24EB80070330E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 149E747B26E24EB80070330E /* LaunchScreen.storyboard */; }; 22 | 149E748B26E24FA60070330E /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 149E748A26E24FA60070330E /* NetworkExtension.framework */; }; 23 | 149E748E26E24FA60070330E /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E748D26E24FA60070330E /* PacketTunnelProvider.swift */; }; 24 | 149E749326E24FA60070330E /* PacketTunnel.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 149E748826E24FA60070330E /* PacketTunnel.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 25 | 149E749926E256760070330E /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 149E748A26E24FA60070330E /* NetworkExtension.framework */; }; 26 | 149E749B26E25C5F0070330E /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E749A26E25C5F0070330E /* Util.swift */; }; 27 | 149E749E26E265060070330E /* TCPSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E749C26E265060070330E /* TCPSession.swift */; }; 28 | 149E749F26E265060070330E /* UDPSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E749D26E265060070330E /* UDPSession.swift */; }; 29 | 149E74A126E265E60070330E /* ByteBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E74A026E265E60070330E /* ByteBuffer.swift */; }; 30 | 149E74A326E266F70070330E /* IPPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E74A226E266F70070330E /* IPPacket.swift */; }; 31 | 149E74CB26E28DF10070330E /* Checksum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149E74CA26E28DF10070330E /* Checksum.swift */; }; 32 | /* End PBXBuildFile section */ 33 | 34 | /* Begin PBXContainerItemProxy section */ 35 | 149E749126E24FA60070330E /* PBXContainerItemProxy */ = { 36 | isa = PBXContainerItemProxy; 37 | containerPortal = 149E746526E24EB70070330E /* Project object */; 38 | proxyType = 1; 39 | remoteGlobalIDString = 149E748726E24FA60070330E; 40 | remoteInfo = PacketTunnel; 41 | }; 42 | /* End PBXContainerItemProxy section */ 43 | 44 | /* Begin PBXCopyFilesBuildPhase section */ 45 | 149E749726E24FA60070330E /* Embed App Extensions */ = { 46 | isa = PBXCopyFilesBuildPhase; 47 | buildActionMask = 2147483647; 48 | dstPath = ""; 49 | dstSubfolderSpec = 13; 50 | files = ( 51 | 149E749326E24FA60070330E /* PacketTunnel.appex in Embed App Extensions */, 52 | ); 53 | name = "Embed App Extensions"; 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXCopyFilesBuildPhase section */ 57 | 58 | /* Begin PBXFileReference section */ 59 | 1420997526E4F9FF003B1C62 /* silence.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = silence.wav; sourceTree = ""; }; 60 | 1420997726E4FA29003B1C62 /* FileWatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileWatcher.swift; sourceTree = ""; }; 61 | 14717CA826F5089C00C8F3E8 /* AppGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppGroup.swift; sourceTree = ""; }; 62 | 149E746D26E24EB70070330E /* AUCapture.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AUCapture.app; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 149E747026E24EB70070330E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 64 | 149E747226E24EB70070330E /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 65 | 149E747426E24EB70070330E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 66 | 149E747726E24EB70070330E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 67 | 149E747926E24EB80070330E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 68 | 149E747C26E24EB80070330E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 69 | 149E747E26E24EB80070330E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | 149E748826E24FA60070330E /* PacketTunnel.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = PacketTunnel.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | 149E748A26E24FA60070330E /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; }; 72 | 149E748D26E24FA60070330E /* PacketTunnelProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PacketTunnelProvider.swift; sourceTree = ""; }; 73 | 149E748F26E24FA60070330E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 74 | 149E749026E24FA60070330E /* PacketTunnel.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PacketTunnel.entitlements; sourceTree = ""; }; 75 | 149E749826E256760070330E /* AUCapture.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AUCapture.entitlements; sourceTree = ""; }; 76 | 149E749A26E25C5F0070330E /* Util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = ""; }; 77 | 149E749C26E265060070330E /* TCPSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TCPSession.swift; sourceTree = ""; }; 78 | 149E749D26E265060070330E /* UDPSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UDPSession.swift; sourceTree = ""; }; 79 | 149E74A026E265E60070330E /* ByteBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ByteBuffer.swift; sourceTree = ""; }; 80 | 149E74A226E266F70070330E /* IPPacket.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPPacket.swift; sourceTree = ""; }; 81 | 149E74CA26E28DF10070330E /* Checksum.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Checksum.swift; sourceTree = ""; }; 82 | /* End PBXFileReference section */ 83 | 84 | /* Begin PBXFrameworksBuildPhase section */ 85 | 149E746A26E24EB70070330E /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | 149E749926E256760070330E /* NetworkExtension.framework in Frameworks */, 90 | 14717CAD26F50E7600C8F3E8 /* AmongUsProtocol in Frameworks */, 91 | ); 92 | runOnlyForDeploymentPostprocessing = 0; 93 | }; 94 | 149E748526E24FA60070330E /* Frameworks */ = { 95 | isa = PBXFrameworksBuildPhase; 96 | buildActionMask = 2147483647; 97 | files = ( 98 | 149E748B26E24FA60070330E /* NetworkExtension.framework in Frameworks */, 99 | ); 100 | runOnlyForDeploymentPostprocessing = 0; 101 | }; 102 | /* End PBXFrameworksBuildPhase section */ 103 | 104 | /* Begin PBXGroup section */ 105 | 14717CA726F5089000C8F3E8 /* Shared */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 14717CA826F5089C00C8F3E8 /* AppGroup.swift */, 109 | 149E749A26E25C5F0070330E /* Util.swift */, 110 | ); 111 | path = Shared; 112 | sourceTree = ""; 113 | }; 114 | 149E746426E24EB70070330E = { 115 | isa = PBXGroup; 116 | children = ( 117 | 149E746F26E24EB70070330E /* AUCapture */, 118 | 149E748C26E24FA60070330E /* PacketTunnel */, 119 | 14717CA726F5089000C8F3E8 /* Shared */, 120 | 149E748926E24FA60070330E /* Frameworks */, 121 | 149E746E26E24EB70070330E /* Products */, 122 | ); 123 | sourceTree = ""; 124 | }; 125 | 149E746E26E24EB70070330E /* Products */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 149E746D26E24EB70070330E /* AUCapture.app */, 129 | 149E748826E24FA60070330E /* PacketTunnel.appex */, 130 | ); 131 | name = Products; 132 | sourceTree = ""; 133 | }; 134 | 149E746F26E24EB70070330E /* AUCapture */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 149E747026E24EB70070330E /* AppDelegate.swift */, 138 | 149E747226E24EB70070330E /* SceneDelegate.swift */, 139 | 149E747426E24EB70070330E /* ViewController.swift */, 140 | 1420997726E4FA29003B1C62 /* FileWatcher.swift */, 141 | 1420997526E4F9FF003B1C62 /* silence.wav */, 142 | 149E747626E24EB70070330E /* Main.storyboard */, 143 | 149E747B26E24EB80070330E /* LaunchScreen.storyboard */, 144 | 149E747926E24EB80070330E /* Assets.xcassets */, 145 | 149E749826E256760070330E /* AUCapture.entitlements */, 146 | 149E747E26E24EB80070330E /* Info.plist */, 147 | ); 148 | path = AUCapture; 149 | sourceTree = ""; 150 | }; 151 | 149E748926E24FA60070330E /* Frameworks */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 149E748A26E24FA60070330E /* NetworkExtension.framework */, 155 | ); 156 | name = Frameworks; 157 | sourceTree = ""; 158 | }; 159 | 149E748C26E24FA60070330E /* PacketTunnel */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | 149E748D26E24FA60070330E /* PacketTunnelProvider.swift */, 163 | 149E74A226E266F70070330E /* IPPacket.swift */, 164 | 149E74CA26E28DF10070330E /* Checksum.swift */, 165 | 149E749C26E265060070330E /* TCPSession.swift */, 166 | 149E749D26E265060070330E /* UDPSession.swift */, 167 | 149E74A026E265E60070330E /* ByteBuffer.swift */, 168 | 149E749026E24FA60070330E /* PacketTunnel.entitlements */, 169 | 149E748F26E24FA60070330E /* Info.plist */, 170 | ); 171 | path = PacketTunnel; 172 | sourceTree = ""; 173 | }; 174 | /* End PBXGroup section */ 175 | 176 | /* Begin PBXNativeTarget section */ 177 | 149E746C26E24EB70070330E /* AUCapture */ = { 178 | isa = PBXNativeTarget; 179 | buildConfigurationList = 149E748126E24EB80070330E /* Build configuration list for PBXNativeTarget "AUCapture" */; 180 | buildPhases = ( 181 | 149E746926E24EB70070330E /* Sources */, 182 | 149E746A26E24EB70070330E /* Frameworks */, 183 | 149E746B26E24EB70070330E /* Resources */, 184 | 149E749726E24FA60070330E /* Embed App Extensions */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | 149E749226E24FA60070330E /* PBXTargetDependency */, 190 | ); 191 | name = AUCapture; 192 | packageProductDependencies = ( 193 | 14717CAC26F50E7600C8F3E8 /* AmongUsProtocol */, 194 | ); 195 | productName = AUCapture; 196 | productReference = 149E746D26E24EB70070330E /* AUCapture.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | 149E748726E24FA60070330E /* PacketTunnel */ = { 200 | isa = PBXNativeTarget; 201 | buildConfigurationList = 149E749426E24FA60070330E /* Build configuration list for PBXNativeTarget "PacketTunnel" */; 202 | buildPhases = ( 203 | 149E748426E24FA60070330E /* Sources */, 204 | 149E748526E24FA60070330E /* Frameworks */, 205 | 149E748626E24FA60070330E /* Resources */, 206 | ); 207 | buildRules = ( 208 | ); 209 | dependencies = ( 210 | ); 211 | name = PacketTunnel; 212 | packageProductDependencies = ( 213 | ); 214 | productName = PacketTunnel; 215 | productReference = 149E748826E24FA60070330E /* PacketTunnel.appex */; 216 | productType = "com.apple.product-type.app-extension"; 217 | }; 218 | /* End PBXNativeTarget section */ 219 | 220 | /* Begin PBXProject section */ 221 | 149E746526E24EB70070330E /* Project object */ = { 222 | isa = PBXProject; 223 | attributes = { 224 | LastSwiftUpdateCheck = 1250; 225 | LastUpgradeCheck = 1250; 226 | TargetAttributes = { 227 | 149E746C26E24EB70070330E = { 228 | CreatedOnToolsVersion = 12.5.1; 229 | }; 230 | 149E748726E24FA60070330E = { 231 | CreatedOnToolsVersion = 12.5.1; 232 | }; 233 | }; 234 | }; 235 | buildConfigurationList = 149E746826E24EB70070330E /* Build configuration list for PBXProject "AUCapture" */; 236 | compatibilityVersion = "Xcode 9.3"; 237 | developmentRegion = en; 238 | hasScannedForEncodings = 0; 239 | knownRegions = ( 240 | en, 241 | Base, 242 | ); 243 | mainGroup = 149E746426E24EB70070330E; 244 | packageReferences = ( 245 | 149E760526E3AE5F0070330E /* XCRemoteSwiftPackageReference "AmongUsProtocol" */, 246 | ); 247 | productRefGroup = 149E746E26E24EB70070330E /* Products */; 248 | projectDirPath = ""; 249 | projectRoot = ""; 250 | targets = ( 251 | 149E746C26E24EB70070330E /* AUCapture */, 252 | 149E748726E24FA60070330E /* PacketTunnel */, 253 | ); 254 | }; 255 | /* End PBXProject section */ 256 | 257 | /* Begin PBXResourcesBuildPhase section */ 258 | 149E746B26E24EB70070330E /* Resources */ = { 259 | isa = PBXResourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | 149E747D26E24EB80070330E /* LaunchScreen.storyboard in Resources */, 263 | 149E747A26E24EB80070330E /* Assets.xcassets in Resources */, 264 | 1420997626E4F9FF003B1C62 /* silence.wav in Resources */, 265 | 149E747826E24EB70070330E /* Main.storyboard in Resources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | 149E748626E24FA60070330E /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXResourcesBuildPhase section */ 277 | 278 | /* Begin PBXSourcesBuildPhase section */ 279 | 149E746926E24EB70070330E /* Sources */ = { 280 | isa = PBXSourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | 14717CA926F5089C00C8F3E8 /* AppGroup.swift in Sources */, 284 | 14717CAB26F5091D00C8F3E8 /* Util.swift in Sources */, 285 | 149E747526E24EB70070330E /* ViewController.swift in Sources */, 286 | 149E747126E24EB70070330E /* AppDelegate.swift in Sources */, 287 | 1420997826E4FA29003B1C62 /* FileWatcher.swift in Sources */, 288 | 149E747326E24EB70070330E /* SceneDelegate.swift in Sources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | 149E748426E24FA60070330E /* Sources */ = { 293 | isa = PBXSourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | 149E749F26E265060070330E /* UDPSession.swift in Sources */, 297 | 149E74CB26E28DF10070330E /* Checksum.swift in Sources */, 298 | 149E749E26E265060070330E /* TCPSession.swift in Sources */, 299 | 149E74A126E265E60070330E /* ByteBuffer.swift in Sources */, 300 | 149E74A326E266F70070330E /* IPPacket.swift in Sources */, 301 | 149E748E26E24FA60070330E /* PacketTunnelProvider.swift in Sources */, 302 | 149E749B26E25C5F0070330E /* Util.swift in Sources */, 303 | 14717CAA26F508AC00C8F3E8 /* AppGroup.swift in Sources */, 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | /* End PBXSourcesBuildPhase section */ 308 | 309 | /* Begin PBXTargetDependency section */ 310 | 149E749226E24FA60070330E /* PBXTargetDependency */ = { 311 | isa = PBXTargetDependency; 312 | target = 149E748726E24FA60070330E /* PacketTunnel */; 313 | targetProxy = 149E749126E24FA60070330E /* PBXContainerItemProxy */; 314 | }; 315 | /* End PBXTargetDependency section */ 316 | 317 | /* Begin PBXVariantGroup section */ 318 | 149E747626E24EB70070330E /* Main.storyboard */ = { 319 | isa = PBXVariantGroup; 320 | children = ( 321 | 149E747726E24EB70070330E /* Base */, 322 | ); 323 | name = Main.storyboard; 324 | sourceTree = ""; 325 | }; 326 | 149E747B26E24EB80070330E /* LaunchScreen.storyboard */ = { 327 | isa = PBXVariantGroup; 328 | children = ( 329 | 149E747C26E24EB80070330E /* Base */, 330 | ); 331 | name = LaunchScreen.storyboard; 332 | sourceTree = ""; 333 | }; 334 | /* End PBXVariantGroup section */ 335 | 336 | /* Begin XCBuildConfiguration section */ 337 | 149E747F26E24EB80070330E /* Debug */ = { 338 | isa = XCBuildConfiguration; 339 | buildSettings = { 340 | ALWAYS_SEARCH_USER_PATHS = NO; 341 | CLANG_ANALYZER_NONNULL = YES; 342 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 343 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 344 | CLANG_CXX_LIBRARY = "libc++"; 345 | CLANG_ENABLE_MODULES = YES; 346 | CLANG_ENABLE_OBJC_ARC = YES; 347 | CLANG_ENABLE_OBJC_WEAK = YES; 348 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 349 | CLANG_WARN_BOOL_CONVERSION = YES; 350 | CLANG_WARN_COMMA = YES; 351 | CLANG_WARN_CONSTANT_CONVERSION = YES; 352 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 353 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 354 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INFINITE_RECURSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 360 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 361 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 364 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 365 | CLANG_WARN_STRICT_PROTOTYPES = YES; 366 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 367 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 368 | CLANG_WARN_UNREACHABLE_CODE = YES; 369 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 370 | COPY_PHASE_STRIP = NO; 371 | DEBUG_INFORMATION_FORMAT = dwarf; 372 | ENABLE_STRICT_OBJC_MSGSEND = YES; 373 | ENABLE_TESTABILITY = YES; 374 | GCC_C_LANGUAGE_STANDARD = gnu11; 375 | GCC_DYNAMIC_NO_PIC = NO; 376 | GCC_NO_COMMON_BLOCKS = YES; 377 | GCC_OPTIMIZATION_LEVEL = 0; 378 | GCC_PREPROCESSOR_DEFINITIONS = ( 379 | "DEBUG=1", 380 | "$(inherited)", 381 | ); 382 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 383 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 384 | GCC_WARN_UNDECLARED_SELECTOR = YES; 385 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 386 | GCC_WARN_UNUSED_FUNCTION = YES; 387 | GCC_WARN_UNUSED_VARIABLE = YES; 388 | IPHONEOS_DEPLOYMENT_TARGET = 14.5; 389 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 390 | MTL_FAST_MATH = YES; 391 | ONLY_ACTIVE_ARCH = YES; 392 | SDKROOT = iphoneos; 393 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 394 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 395 | }; 396 | name = Debug; 397 | }; 398 | 149E748026E24EB80070330E /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ALWAYS_SEARCH_USER_PATHS = NO; 402 | CLANG_ANALYZER_NONNULL = YES; 403 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 404 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 405 | CLANG_CXX_LIBRARY = "libc++"; 406 | CLANG_ENABLE_MODULES = YES; 407 | CLANG_ENABLE_OBJC_ARC = YES; 408 | CLANG_ENABLE_OBJC_WEAK = YES; 409 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 410 | CLANG_WARN_BOOL_CONVERSION = YES; 411 | CLANG_WARN_COMMA = YES; 412 | CLANG_WARN_CONSTANT_CONVERSION = YES; 413 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 414 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 415 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 416 | CLANG_WARN_EMPTY_BODY = YES; 417 | CLANG_WARN_ENUM_CONVERSION = YES; 418 | CLANG_WARN_INFINITE_RECURSION = YES; 419 | CLANG_WARN_INT_CONVERSION = YES; 420 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 421 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 422 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 423 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 424 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 425 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 426 | CLANG_WARN_STRICT_PROTOTYPES = YES; 427 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 428 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 429 | CLANG_WARN_UNREACHABLE_CODE = YES; 430 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 431 | COPY_PHASE_STRIP = NO; 432 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 433 | ENABLE_NS_ASSERTIONS = NO; 434 | ENABLE_STRICT_OBJC_MSGSEND = YES; 435 | GCC_C_LANGUAGE_STANDARD = gnu11; 436 | GCC_NO_COMMON_BLOCKS = YES; 437 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 438 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 439 | GCC_WARN_UNDECLARED_SELECTOR = YES; 440 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 441 | GCC_WARN_UNUSED_FUNCTION = YES; 442 | GCC_WARN_UNUSED_VARIABLE = YES; 443 | IPHONEOS_DEPLOYMENT_TARGET = 14.5; 444 | MTL_ENABLE_DEBUG_INFO = NO; 445 | MTL_FAST_MATH = YES; 446 | SDKROOT = iphoneos; 447 | SWIFT_COMPILATION_MODE = wholemodule; 448 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 449 | VALIDATE_PRODUCT = YES; 450 | }; 451 | name = Release; 452 | }; 453 | 149E748226E24EB80070330E /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 457 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 458 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 459 | CODE_SIGN_ENTITLEMENTS = AUCapture/AUCapture.entitlements; 460 | CODE_SIGN_STYLE = Automatic; 461 | DEVELOPMENT_TEAM = 27AEDK3C9F; 462 | INFOPLIST_FILE = AUCapture/Info.plist; 463 | LD_RUNPATH_SEARCH_PATHS = ( 464 | "$(inherited)", 465 | "@executable_path/Frameworks", 466 | ); 467 | PRODUCT_BUNDLE_IDENTIFIER = com.kishikawakatsumi.AUCapture; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | SWIFT_VERSION = 5.0; 470 | TARGETED_DEVICE_FAMILY = "1,2"; 471 | }; 472 | name = Debug; 473 | }; 474 | 149E748326E24EB80070330E /* Release */ = { 475 | isa = XCBuildConfiguration; 476 | buildSettings = { 477 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 478 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 479 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 480 | CODE_SIGN_ENTITLEMENTS = AUCapture/AUCapture.entitlements; 481 | CODE_SIGN_STYLE = Automatic; 482 | DEVELOPMENT_TEAM = 27AEDK3C9F; 483 | INFOPLIST_FILE = AUCapture/Info.plist; 484 | LD_RUNPATH_SEARCH_PATHS = ( 485 | "$(inherited)", 486 | "@executable_path/Frameworks", 487 | ); 488 | PRODUCT_BUNDLE_IDENTIFIER = com.kishikawakatsumi.AUCapture; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | SWIFT_VERSION = 5.0; 491 | TARGETED_DEVICE_FAMILY = "1,2"; 492 | }; 493 | name = Release; 494 | }; 495 | 149E749526E24FA60070330E /* Debug */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements; 499 | CODE_SIGN_STYLE = Automatic; 500 | DEVELOPMENT_TEAM = 27AEDK3C9F; 501 | INFOPLIST_FILE = PacketTunnel/Info.plist; 502 | LD_RUNPATH_SEARCH_PATHS = ( 503 | "$(inherited)", 504 | "@executable_path/Frameworks", 505 | "@executable_path/../../Frameworks", 506 | ); 507 | PRODUCT_BUNDLE_IDENTIFIER = com.kishikawakatsumi.AUCapture.PacketTunnel; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | SKIP_INSTALL = YES; 510 | SWIFT_VERSION = 5.0; 511 | TARGETED_DEVICE_FAMILY = "1,2"; 512 | }; 513 | name = Debug; 514 | }; 515 | 149E749626E24FA60070330E /* Release */ = { 516 | isa = XCBuildConfiguration; 517 | buildSettings = { 518 | CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements; 519 | CODE_SIGN_STYLE = Automatic; 520 | DEVELOPMENT_TEAM = 27AEDK3C9F; 521 | INFOPLIST_FILE = PacketTunnel/Info.plist; 522 | LD_RUNPATH_SEARCH_PATHS = ( 523 | "$(inherited)", 524 | "@executable_path/Frameworks", 525 | "@executable_path/../../Frameworks", 526 | ); 527 | PRODUCT_BUNDLE_IDENTIFIER = com.kishikawakatsumi.AUCapture.PacketTunnel; 528 | PRODUCT_NAME = "$(TARGET_NAME)"; 529 | SKIP_INSTALL = YES; 530 | SWIFT_VERSION = 5.0; 531 | TARGETED_DEVICE_FAMILY = "1,2"; 532 | }; 533 | name = Release; 534 | }; 535 | /* End XCBuildConfiguration section */ 536 | 537 | /* Begin XCConfigurationList section */ 538 | 149E746826E24EB70070330E /* Build configuration list for PBXProject "AUCapture" */ = { 539 | isa = XCConfigurationList; 540 | buildConfigurations = ( 541 | 149E747F26E24EB80070330E /* Debug */, 542 | 149E748026E24EB80070330E /* Release */, 543 | ); 544 | defaultConfigurationIsVisible = 0; 545 | defaultConfigurationName = Release; 546 | }; 547 | 149E748126E24EB80070330E /* Build configuration list for PBXNativeTarget "AUCapture" */ = { 548 | isa = XCConfigurationList; 549 | buildConfigurations = ( 550 | 149E748226E24EB80070330E /* Debug */, 551 | 149E748326E24EB80070330E /* Release */, 552 | ); 553 | defaultConfigurationIsVisible = 0; 554 | defaultConfigurationName = Release; 555 | }; 556 | 149E749426E24FA60070330E /* Build configuration list for PBXNativeTarget "PacketTunnel" */ = { 557 | isa = XCConfigurationList; 558 | buildConfigurations = ( 559 | 149E749526E24FA60070330E /* Debug */, 560 | 149E749626E24FA60070330E /* Release */, 561 | ); 562 | defaultConfigurationIsVisible = 0; 563 | defaultConfigurationName = Release; 564 | }; 565 | /* End XCConfigurationList section */ 566 | 567 | /* Begin XCRemoteSwiftPackageReference section */ 568 | 149E760526E3AE5F0070330E /* XCRemoteSwiftPackageReference "AmongUsProtocol" */ = { 569 | isa = XCRemoteSwiftPackageReference; 570 | repositoryURL = "https://github.com/kishikawakatsumi/AmongUsProtocol.git"; 571 | requirement = { 572 | kind = upToNextMajorVersion; 573 | minimumVersion = 0.2.2; 574 | }; 575 | }; 576 | /* End XCRemoteSwiftPackageReference section */ 577 | 578 | /* Begin XCSwiftPackageProductDependency section */ 579 | 14717CAC26F50E7600C8F3E8 /* AmongUsProtocol */ = { 580 | isa = XCSwiftPackageProductDependency; 581 | package = 149E760526E3AE5F0070330E /* XCRemoteSwiftPackageReference "AmongUsProtocol" */; 582 | productName = AmongUsProtocol; 583 | }; 584 | /* End XCSwiftPackageProductDependency section */ 585 | }; 586 | rootObject = 149E746526E24EB70070330E /* Project object */; 587 | } 588 | -------------------------------------------------------------------------------- /AUCapture.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AUCapture.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AUCapture.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "AmongUsProtocol", 6 | "repositoryURL": "https://github.com/kishikawakatsumi/AmongUsProtocol.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "5afa79df119e8c5d446781be207bb449ef89cc3a", 10 | "version": "0.2.2" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /AUCapture.xcodeproj/xcuserdata/katsumi.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AUCapture.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | PacketTunnel.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /AUCapture/AUCapture.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.networking.networkextension 6 | 7 | packet-tunnel-provider 8 | 9 | com.apple.security.application-groups 10 | 11 | group.com.kishikawakatsumi.AUCapture 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /AUCapture/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import AVFoundation 3 | import AmongUsProtocol 4 | 5 | @main 6 | class AppDelegate: UIResponder, UIApplicationDelegate, FileWatcherDelegate, UNUserNotificationCenterDelegate { 7 | var fileWatcher: FileWatcher? 8 | var audioPlayer: AVAudioPlayer? 9 | 10 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 11 | try! AVAudioSession.sharedInstance().setCategory(.playback, options: .mixWithOthers) 12 | self.audioPlayer = try! AVAudioPlayer( 13 | contentsOf: Bundle.main.url(forResource: "silence", withExtension: "wav")! 14 | ) 15 | self.audioPlayer?.numberOfLoops = -1 16 | self.audioPlayer?.volume = 0.00; 17 | self.audioPlayer?.play() 18 | 19 | let container = AppGroup.container 20 | let fileCoordinator = NSFileCoordinator() 21 | fileCoordinator.coordinate(writingItemAt: container, options: [], error: nil) { (directory) in 22 | let file = directory.appendingPathComponent("capture_state") 23 | let fileManager = FileManager() 24 | fileManager.createFile(atPath: file.path, contents: Data(), attributes: nil) 25 | 26 | fileWatcher = try? FileWatcher(url: file) 27 | fileWatcher?.delegate = self 28 | } 29 | 30 | return true 31 | } 32 | 33 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 34 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 35 | } 36 | 37 | func fileWatcherDidChange(fileWatcher: FileWatcher) { 38 | let container = AppGroup.container 39 | let file = container.appendingPathComponent("capture_state") 40 | let fileCoordinator = NSFileCoordinator() 41 | fileCoordinator.coordinate(readingItemAt: file, options: [], error: nil) { (file) in 42 | guard let text = try? String(contentsOf: file) else { return } 43 | print(text) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /AUCapture/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /AUCapture/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /AUCapture/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /AUCapture/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /AUCapture/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /AUCapture/FileWatcher.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol FileWatcherDelegate: AnyObject { 4 | func fileWatcherDidChange(fileWatcher: FileWatcher) 5 | } 6 | 7 | final class FileWatcher { 8 | let url: URL 9 | 10 | let fileHandle: FileHandle 11 | let source: DispatchSourceFileSystemObject 12 | 13 | weak var delegate: FileWatcherDelegate? 14 | 15 | init(url: URL) throws { 16 | self.url = url 17 | self.fileHandle = try FileHandle(forReadingFrom: url) 18 | 19 | source = DispatchSource.makeFileSystemObjectSource( 20 | fileDescriptor: fileHandle.fileDescriptor, 21 | eventMask: .extend, 22 | queue: DispatchQueue.main 23 | ) 24 | 25 | source.setEventHandler { 26 | let event = self.source.data 27 | self.process(event: event) 28 | } 29 | 30 | source.setCancelHandler { 31 | try? self.fileHandle.close() 32 | } 33 | 34 | _ = try? fileHandle.seekToEnd() 35 | source.resume() 36 | } 37 | 38 | deinit { 39 | source.cancel() 40 | } 41 | 42 | func process(event: DispatchSource.FileSystemEvent) { 43 | guard event.contains(.extend) else { 44 | return 45 | } 46 | delegate?.fileWatcherDidChange(fileWatcher: self) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /AUCapture/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UIApplicationSupportsIndirectInputEvents 43 | 44 | UIBackgroundModes 45 | 46 | audio 47 | 48 | UILaunchStoryboardName 49 | LaunchScreen 50 | UIMainStoryboardFile 51 | Main 52 | UIRequiredDeviceCapabilities 53 | 54 | armv7 55 | 56 | UISupportedInterfaceOrientations 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationLandscapeLeft 60 | UIInterfaceOrientationLandscapeRight 61 | 62 | UISupportedInterfaceOrientations~ipad 63 | 64 | UIInterfaceOrientationPortrait 65 | UIInterfaceOrientationPortraitUpsideDown 66 | UIInterfaceOrientationLandscapeLeft 67 | UIInterfaceOrientationLandscapeRight 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /AUCapture/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 4 | var window: UIWindow? 5 | } 6 | -------------------------------------------------------------------------------- /AUCapture/ViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Combine 3 | import NetworkExtension 4 | 5 | final class ViewController: UITableViewController { 6 | private var manager: NETunnelProviderManager? 7 | private var cancellables = [AnyCancellable]() 8 | 9 | @IBOutlet private var toggle: UISwitch! 10 | @IBOutlet private var spinner: UIActivityIndicatorView! 11 | @IBOutlet private var statusLabel: UILabel! 12 | 13 | @IBOutlet private var launchAmongUsCell: UITableViewCell! 14 | @IBOutlet private var launchAmongUsLabel: UILabel! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | NotificationCenter.default.publisher(for: .NEVPNStatusDidChange) 20 | .receive(on: DispatchQueue.main) 21 | .sink { [weak self] _ in 22 | guard let status = self?.manager?.connection.status else { 23 | return 24 | } 25 | 26 | switch status { 27 | case .invalid: 28 | self?.toggle.isEnabled = true 29 | self?.toggle.isOn = false 30 | 31 | self?.spinner.stopAnimating() 32 | self?.statusLabel.text = "Invalid" 33 | case .disconnected: 34 | self?.toggle.isEnabled = true 35 | self?.toggle.isOn = false 36 | 37 | self?.spinner.stopAnimating() 38 | self?.statusLabel.text = "Disconnected" 39 | case .connecting: 40 | self?.toggle.isEnabled = false 41 | self?.toggle.isOn = true 42 | 43 | self?.spinner.startAnimating() 44 | self?.statusLabel.text = "Connecting..." 45 | case .connected: 46 | self?.toggle.isEnabled = true 47 | self?.toggle.isOn = true 48 | 49 | self?.spinner.stopAnimating() 50 | self?.statusLabel.text = "Connected" 51 | case .reasserting: 52 | self?.toggle.isEnabled = false 53 | 54 | self?.spinner.startAnimating() 55 | self?.statusLabel.text = "Reasserting..." 56 | case .disconnecting: 57 | self?.toggle.isEnabled = false 58 | 59 | self?.spinner.startAnimating() 60 | self?.statusLabel.text = "Disconnecting..." 61 | @unknown default: 62 | self?.toggle.isEnabled = true 63 | self?.toggle.isOn = false 64 | 65 | self?.spinner.stopAnimating() 66 | self?.statusLabel.text = "Unknown" 67 | } 68 | } 69 | .store(in: &cancellables) 70 | } 71 | 72 | private func installProfile() { 73 | NETunnelProviderManager.loadAllFromPreferences { [self] (managers, error) in 74 | if let error = error { 75 | presentError(error) 76 | return 77 | } 78 | 79 | self.manager = managers?.first ?? NETunnelProviderManager() 80 | 81 | self.manager?.loadFromPreferences { [self] (error) in 82 | if let error = error { 83 | presentError(error) 84 | return 85 | } 86 | 87 | let tunnelProtocol = NETunnelProviderProtocol() 88 | tunnelProtocol.serverAddress = "localhost" 89 | tunnelProtocol.providerBundleIdentifier = "com.kishikawakatsumi.AUCapture.PacketTunnel" 90 | tunnelProtocol.disconnectOnSleep = false 91 | 92 | self.manager?.protocolConfiguration = tunnelProtocol 93 | self.manager?.localizedDescription = "AUCapture" 94 | self.manager?.isEnabled = true 95 | 96 | if let status = self.manager?.connection.status { 97 | self.toggle.isOn = status == .connected 98 | } 99 | 100 | self.manager?.saveToPreferences { (error) in 101 | if let error = error { 102 | presentError(error) 103 | return 104 | } 105 | 106 | self.manager?.loadFromPreferences { (error) in 107 | if let error = error { 108 | presentError(error) 109 | return 110 | } 111 | 112 | self.startVPNTunnel() 113 | } 114 | } 115 | } 116 | } 117 | } 118 | 119 | @IBAction 120 | private func toggle(_ sender: UISwitch) { 121 | if sender.isOn { 122 | installProfile() 123 | } else { 124 | manager?.connection.stopVPNTunnel() 125 | } 126 | } 127 | 128 | private func startVPNTunnel() { 129 | do { 130 | try self.manager?.connection.startVPNTunnel() 131 | } catch { 132 | presentError(error) 133 | } 134 | } 135 | 136 | private func presentError(_ error: Error) { 137 | let alertController = UIAlertController(title: String(describing: type(of: error)), message: error.localizedDescription, preferredStyle: .alert) 138 | alertController.addAction(UIAlertAction(title: "Dismiss", style: .default) { _ in 139 | alertController.dismiss(animated: true) 140 | }) 141 | present(alertController, animated: true) 142 | } 143 | 144 | private func launchDiscord() { 145 | launchApp(with: "com.hammerandchisel.discord") 146 | } 147 | 148 | private func launchAmongUs() { 149 | launchApp(with: "com.innersloth.amongus") 150 | } 151 | 152 | @discardableResult 153 | private func launchApp(with bundleIdentifier: String) -> Bool { 154 | guard let obj = objc_getClass(["Workspace", "Application", "LS"].reversed().joined()) as? NSObject else { return false } 155 | let workspace = obj.perform(Selector((["Workspace", "default"].reversed().joined())))?.takeUnretainedValue() as? NSObject 156 | return workspace?.perform(Selector(([":", "ID", "Bundle", "With", "Application", "open"].reversed().joined())), with: bundleIdentifier) != nil 157 | } 158 | 159 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 160 | switch indexPath { 161 | case [1, 0]: 162 | launchAmongUs() 163 | default: 164 | break 165 | } 166 | 167 | tableView.deselectRow(at: indexPath, animated: true) 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /AUCapture/silence.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kishikawakatsumi/AUCapture/30831a882703798078058df3c00b80cf8650f0b0/AUCapture/silence.wav -------------------------------------------------------------------------------- /PacketTunnel/ByteBuffer.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class ByteBuffer { 4 | let data: Data 5 | let littleEndian: Bool 6 | 7 | private var offset = 0 8 | var position: Int { offset } 9 | var availableBytes: Int { data.count - offset } 10 | 11 | init(_ data: Data, littleEndian: Bool = true) { 12 | self.data = data 13 | self.littleEndian = littleEndian 14 | } 15 | 16 | func read(_ type: T.Type) -> T { 17 | let size = MemoryLayout.size 18 | let value = data[offset..<(offset + size)].to(type: type) 19 | offset += size 20 | return value 21 | } 22 | 23 | func read(_ type: T.Type) -> T { 24 | let size = MemoryLayout.size 25 | let value = data[offset..<(offset + size)].to(type: type) 26 | offset += size 27 | return littleEndian ? value.littleEndian : value.bigEndian 28 | } 29 | 30 | func read(_ type: Data.Type, count: Int) -> Data { 31 | let value = data[offset..<(offset + count)] 32 | offset += count 33 | return Data(value) 34 | } 35 | } 36 | 37 | public protocol BinaryReadable { 38 | var littleEndian: Self { get } 39 | var bigEndian: Self { get } 40 | } 41 | extension UInt8: BinaryReadable { 42 | public var littleEndian: UInt8 { return self } 43 | public var bigEndian: UInt8 { return self } 44 | } 45 | extension UInt16: BinaryReadable {} 46 | extension UInt32: BinaryReadable {} 47 | extension UInt64: BinaryReadable {} 48 | -------------------------------------------------------------------------------- /PacketTunnel/Checksum.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class Checksum { 4 | static func computeChecksum(_ data: Data, from start: Int = 0, to end: Int? = nil, withPseudoHeaderChecksum initChecksum: UInt32 = 0) -> UInt16 { 5 | return toChecksum(computeChecksumUnfold(data, from: start, to: end, withPseudoHeaderChecksum: initChecksum)) 6 | } 7 | 8 | static func validateChecksum(_ payload: Data, from start: Int = 0, to end: Int? = nil) -> Bool { 9 | let cs = computeChecksumUnfold(payload, from: start, to: end) 10 | return toChecksum(cs) == 0 11 | } 12 | 13 | static func computeChecksumUnfold(_ data: Data, from start: Int = 0, to end: Int? = nil, withPseudoHeaderChecksum initChecksum: UInt32 = 0) -> UInt32 { 14 | let buffer = ByteBuffer(data) 15 | _ = buffer.read(Data.self, count: start) 16 | var result: UInt32 = initChecksum 17 | var end = end 18 | if end == nil { 19 | end = data.count 20 | } 21 | var counter = 0 22 | while buffer.position + 2 <= end! { 23 | let value = buffer.read(UInt16.self) 24 | result += UInt32(value) 25 | counter += 1 26 | } 27 | print(counter) 28 | 29 | if buffer.position != end! { 30 | // data is of odd size 31 | // Intel and ARM are both litten endian 32 | // so just add it 33 | let value = buffer.read(UInt8.self) 34 | result += UInt32(value) 35 | } 36 | return result 37 | } 38 | 39 | static func toChecksum(_ checksum: UInt32) -> UInt16 { 40 | var result = checksum 41 | while (result) >> 16 != 0 { 42 | result = result >> 16 + result & 0xFFFF 43 | } 44 | return ~UInt16(result) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /PacketTunnel/IPPacket.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | struct IPPacket { 4 | var version: IPVersion = .ipv4 5 | var headerLength: UInt8 = 20 6 | var typeOfService: UInt8 = 0 7 | var length: UInt16 8 | var id: UInt16 9 | var offset: UInt16 = 0 10 | var timeToLive: UInt8 = 64 11 | var proto: Protocol 12 | var checksum: UInt16 13 | 14 | var source: String { sourceAddr.asString } 15 | private var sourceAddr: in_addr 16 | var destination: String { destAddr.asString } 17 | private var destAddr: in_addr 18 | 19 | var sourcePort: UInt16 20 | var destinationPort: UInt16 21 | 22 | var packetData: Data 23 | var payload: Data 24 | 25 | init(proto: Protocol, source: String, destination: String, sourcePort: UInt16, destinationPort: UInt16, payload: Data) { 26 | self.proto = proto 27 | 28 | sourceAddr = in_addr(string: source) 29 | destAddr = in_addr(string: destination) 30 | 31 | self.sourcePort = sourcePort 32 | self.destinationPort = destinationPort 33 | 34 | id = 0 35 | checksum = 0 36 | 37 | let bytesLength = payload.count + 8 38 | packetData = Data(count: Int(headerLength) + bytesLength) 39 | self.payload = payload 40 | 41 | length = UInt16(packetData.count) 42 | 43 | // set header 44 | setPayloadWithUInt8(headerLength / 4 + version.rawValue << 4, at: 0) 45 | setPayloadWithUInt8(typeOfService, at: 1) 46 | setPayloadWithUInt16(length, at: 2) 47 | setPayloadWithUInt16(id, at: 4) 48 | setPayloadWithUInt16(offset, at: 6) 49 | setPayloadWithUInt8(timeToLive, at: 8) 50 | setPayloadWithUInt8(proto.rawValue, at: 9) 51 | 52 | // clear checksum bytes 53 | resetPayloadAt(10, length: 2) 54 | 55 | setPayloadWithUInt32(sourceAddr.s_addr, at: 12, swap: false) 56 | setPayloadWithUInt32(destAddr.s_addr, at: 16, swap: false) 57 | 58 | // let TCP or UDP packet build 59 | buildSegment(computePseudoHeaderChecksum()) 60 | 61 | setPayloadWithUInt16(Checksum.computeChecksum(packetData, from: 0, to: Int(headerLength)), at: 10, swap: false) 62 | } 63 | 64 | init?(_ packet: Data) { 65 | packetData = packet 66 | let buffer = ByteBuffer(packet, littleEndian: false) 67 | 68 | let vhl = buffer.read(UInt8.self) 69 | guard let version = IPVersion(rawValue: vhl >> 4) else { return nil } 70 | self.version = version 71 | 72 | headerLength = vhl & 0x0F * 4 73 | guard buffer.availableBytes >= headerLength else { return nil } 74 | 75 | typeOfService = buffer.read(UInt8.self) 76 | 77 | length = buffer.read(UInt16.self) 78 | guard buffer.data.count == length else { return nil } 79 | 80 | id = buffer.read(UInt16.self) 81 | offset = buffer.read(UInt16.self) 82 | timeToLive = buffer.read(UInt8.self) 83 | 84 | guard let proto = Protocol(rawValue: buffer.read(UInt8.self)) else { return nil } 85 | self.proto = proto 86 | 87 | checksum = buffer.read(UInt16.self) 88 | 89 | sourceAddr = buffer.read(in_addr.self) 90 | destAddr = buffer.read(in_addr.self) 91 | 92 | switch proto { 93 | case .tcp: 94 | payload = buffer.data[Int(headerLength).. UInt32 { 149 | var result: UInt32 = 0 150 | result += sourceAddr.s_addr >> 16 + sourceAddr.s_addr & 0xffff 151 | result += destAddr.s_addr >> 16 + destAddr.s_addr & 0xffff 152 | result += UInt32(proto.rawValue) << 8 153 | switch proto { 154 | case .udp: 155 | result += CFSwapInt32(UInt32(payload.count + 8)) 156 | default: 157 | break 158 | } 159 | return result 160 | } 161 | 162 | private mutating func buildSegment(_ pseudoHeaderChecksum: UInt32) { 163 | let offset = Int(headerLength) 164 | 165 | var sourcePort = sourcePort.bigEndian 166 | withUnsafeBytes(of: &sourcePort) { 167 | packetData.replaceSubrange(offset..<(offset + 2), with: $0) 168 | } 169 | var destinationPort = destinationPort.bigEndian 170 | withUnsafeBytes(of: &destinationPort) { 171 | packetData.replaceSubrange(offset + 2..<(offset + 4), with: $0) 172 | } 173 | 174 | var length = NSSwapHostShortToBig(UInt16(payload.count + 8)) 175 | withUnsafeBytes(of: &length) { 176 | packetData.replaceSubrange(offset + 4.. Data 234 | static func +=(lhs: inout Data, rhs: Self) 235 | } 236 | 237 | extension BinaryConvertible { 238 | static func +(lhs: Data, rhs: Self) -> Data { 239 | var value = rhs 240 | let data = withUnsafePointer(to: &value) { 241 | Data(buffer: UnsafeBufferPointer(start: $0, count: 1)) 242 | } 243 | return lhs + data 244 | } 245 | 246 | static func +=(lhs: inout Data, rhs: Self) { 247 | lhs = lhs + rhs 248 | } 249 | } 250 | 251 | extension UInt8: BinaryConvertible {} 252 | extension UInt16: BinaryConvertible {} 253 | extension UInt32: BinaryConvertible {} 254 | extension UInt64: BinaryConvertible {} 255 | extension Int8: BinaryConvertible {} 256 | extension Int16: BinaryConvertible {} 257 | extension Int32: BinaryConvertible {} 258 | extension Int64: BinaryConvertible {} 259 | extension Int: BinaryConvertible {} 260 | -------------------------------------------------------------------------------- /PacketTunnel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | PacketTunnel 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | NSExtension 24 | 25 | NSExtensionPointIdentifier 26 | com.apple.networkextension.packet-tunnel 27 | NSExtensionPrincipalClass 28 | $(PRODUCT_MODULE_NAME).PacketTunnelProvider 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /PacketTunnel/PacketTunnel.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.networking.networkextension 6 | 7 | packet-tunnel-provider 8 | 9 | com.apple.security.application-groups 10 | 11 | group.com.kishikawakatsumi.AUCapture 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /PacketTunnel/PacketTunnelProvider.swift: -------------------------------------------------------------------------------- 1 | import NetworkExtension 2 | 3 | class PacketTunnelProvider: NEPacketTunnelProvider { 4 | private var tcpSessions = [String: TCPSession]() 5 | private var udpSessions = [String: UDPSession]() 6 | 7 | override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) { 8 | let ip = "10.10.10.10" 9 | let subnetMask = "255.255.255.0" 10 | 11 | let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1") 12 | let ipv4Settings = NEIPv4Settings(addresses: [ip], subnetMasks: [subnetMask]) 13 | 14 | ipv4Settings.includedRoutes = [NEIPv4Route.default()] 15 | ipv4Settings.excludedRoutes = [ 16 | NEIPv4Route(destinationAddress: "10.0.0.0", subnetMask: "255.0.0.0"), 17 | NEIPv4Route(destinationAddress: "127.0.0.0", subnetMask: "255.0.0.0"), 18 | NEIPv4Route(destinationAddress: "192.168.0.0", subnetMask: "255.255.0.0"), 19 | ] 20 | settings.ipv4Settings = ipv4Settings 21 | 22 | let dnsSettings = NEDNSSettings(servers: ["8.8.8.8", "8.8.4.4"]) 23 | dnsSettings.matchDomains = [""] 24 | settings.dnsSettings = dnsSettings 25 | 26 | setTunnelNetworkSettings(settings) { [weak self] error in 27 | guard let self = self else { return } 28 | 29 | completionHandler(error) 30 | if let error = error { 31 | NSLog("Tunnel network settings error: \(error)") 32 | } else { 33 | self.localPacketsToServer() 34 | } 35 | } 36 | } 37 | 38 | override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) { 39 | completionHandler() 40 | } 41 | 42 | private func localPacketsToServer() { 43 | packetFlow.readPacketObjects { [weak self] (packets) in 44 | defer { self?.localPacketsToServer() } 45 | guard let self = self else { return } 46 | 47 | packets.forEach { (packet) in 48 | if let ipPacket = IPPacket(packet.data) { 49 | switch ipPacket.proto { 50 | case .tcp: 51 | self.handleTCPPacket(ipPacket) 52 | case .udp: 53 | self.sendUDPPacket(ipPacket) 54 | case .icmp: 55 | break 56 | } 57 | } 58 | } 59 | } 60 | } 61 | 62 | private func handleTCPPacket(_ packet: IPPacket) { 63 | // For now, for the sake of simplicity, TCP packets are not handled. 64 | } 65 | 66 | private func sendUDPPacket(_ packet: IPPacket) { 67 | let key = "\(packet.source):\(packet.sourcePort) => \(packet.destination):\(packet.destinationPort)" 68 | NSLog("SEND: \(key) \(packet.payload.hex)") 69 | sendPacketDump(packet.payload) 70 | 71 | if let session = self.udpSessions[key] { 72 | session.send(packet.payload) 73 | } else { 74 | let session = UDPSession( 75 | host: packet.destination, 76 | port: packet.destinationPort, 77 | payload: packet.payload 78 | ) 79 | session.onReceive = { [weak self] (data) in 80 | guard let self = self else { return } 81 | 82 | let packet = IPPacket( 83 | proto: packet.proto, 84 | source: packet.destination, 85 | destination: packet.source, 86 | sourcePort: packet.destinationPort, 87 | destinationPort: packet.sourcePort, 88 | payload: data 89 | ) 90 | 91 | NSLog("RECV: \(packet.source):\(packet.sourcePort) => \(packet.destination):\(packet.destinationPort) \(data.hex)") 92 | sendPacketDump(data) 93 | 94 | self.packetFlow.writePacketObjects([ 95 | NEPacket( 96 | data: packet.packetData, 97 | protocolFamily: sa_family_t(AF_INET) 98 | ) 99 | ]) 100 | } 101 | session.onError = { (error) in 102 | NSLog("UDP Error: \(error)") 103 | } 104 | 105 | self.udpSessions[key] = session 106 | } 107 | } 108 | } 109 | 110 | private func sendPacketDump(_ data: Data) { 111 | let container = AppGroup.container 112 | let file = container.appendingPathComponent("capture_state") 113 | let fileCoordinator = NSFileCoordinator() 114 | fileCoordinator.coordinate(writingItemAt: file, options: [], error: nil) { (file) in 115 | try? data.hex.write(to: file, atomically: false, encoding: .utf8) 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /PacketTunnel/TCPSession.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Network 3 | 4 | class TCPSession { 5 | let host: String 6 | let port: UInt16 7 | let payload: Data 8 | 9 | var onReceive: (Data) -> Void = { _ in } 10 | var onError: (Error) -> Void = { _ in } 11 | 12 | private let connection: NWConnection 13 | private let queue = DispatchQueue(label: "") 14 | 15 | init(host: String, port: UInt16, payload: Data) { 16 | self.host = host 17 | self.port = port 18 | self.payload = payload 19 | connection = NWConnection(host: NWEndpoint.Host(host), port: NWEndpoint.Port(rawValue: port)!, using: .tcp) 20 | connect() 21 | } 22 | 23 | func send(_ payload: Data) { 24 | connection.send(content: payload, completion: .contentProcessed({ [weak self] (error) in 25 | if let error = error { 26 | self?.onError(error) 27 | } 28 | })) 29 | } 30 | 31 | private func connect() { 32 | let payload = self.payload 33 | connection.stateUpdateHandler = { [weak self] (state) in 34 | switch (state) { 35 | case .setup, .waiting, .preparing: 36 | break 37 | case .ready: 38 | self?.send(payload) 39 | case .failed(let error): 40 | self?.onError(error) 41 | case .cancelled: 42 | break 43 | @unknown default: 44 | break 45 | } 46 | } 47 | 48 | connection.start(queue: queue) 49 | receive() 50 | } 51 | 52 | private func receive() { 53 | connection.receiveMessage(completion: { [weak self] (data, context, isComplete, error) in 54 | if let data = data { 55 | self?.onReceive(data) 56 | } 57 | if let error = error { 58 | self?.onError(error) 59 | } 60 | self?.receive() 61 | }) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /PacketTunnel/UDPSession.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Network 3 | 4 | class UDPSession { 5 | let host: String 6 | let port: UInt16 7 | let payload: Data 8 | 9 | var onReceive: (Data) -> Void = { _ in } 10 | var onError: (Error) -> Void = { _ in } 11 | 12 | private let connection: NWConnection 13 | private let queue = DispatchQueue(label: "") 14 | 15 | init(host: String, port: UInt16, payload: Data) { 16 | self.host = host 17 | self.port = port 18 | self.payload = payload 19 | connection = NWConnection(host: NWEndpoint.Host(host), port: NWEndpoint.Port(rawValue: port)!, using: .udp) 20 | connect() 21 | } 22 | 23 | func send(_ payload: Data) { 24 | connection.send(content: payload, completion: .contentProcessed({ [weak self] (error) in 25 | if let error = error { 26 | self?.onError(error) 27 | } 28 | })) 29 | } 30 | 31 | private func connect() { 32 | let payload = self.payload 33 | connection.stateUpdateHandler = { [weak self] (state) in 34 | switch (state) { 35 | case .setup, .waiting, .preparing: 36 | break 37 | case .ready: 38 | self?.send(payload) 39 | case .failed(let error): 40 | self?.onError(error) 41 | case .cancelled: 42 | break 43 | @unknown default: 44 | break 45 | } 46 | } 47 | 48 | connection.start(queue: queue) 49 | receive() 50 | } 51 | 52 | private func receive() { 53 | connection.receiveMessage(completion: { [weak self] (data, context, isComplete, error) in 54 | if let data = data { 55 | self?.onReceive(data) 56 | } 57 | if let error = error { 58 | self?.onError(error) 59 | } 60 | self?.receive() 61 | }) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AUCapture 2 | 3 | A packet capture app without remote VPN server. A demonstration for how to use `NEPacketTunnelProvider` and `NetworkExtension.framwork`. 4 | 5 | ## How to build 6 | 7 | 1. Open this xcodeproj with XCode, select `AUCapture` target, in `General > Identity` section, change `Bundle Identifier` to your Bundle ID. 8 | 9 | 1. Do the same thing for `PacketTunnel` target. 10 | 11 | 1. Change the App Group of both targets to yours. 12 | 13 | [Presentation at iOSDC 2021](https://speakerdeck.com/kishikawakatsumi/network-extensiondeiosdebaisushang-dedong-kupaketutokiyaputiyawozuo-ru) 14 | 15 | ※スライドに使ったコードよりシンプルにしているので、UIやTCPのエミュレーションは省いています。もし同じものを試したい場合はIssueなどでリクエストしてください🙏🏻(整理しきれてない部分もあるのでリクエストがあればできるだけ急いでまとめます。) 16 | 17 | 18 | If you can run it correctly, the Xcode console will look like the following. 19 | 20 | Screen Shot 21 | -------------------------------------------------------------------------------- /Shared/AppGroup.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | enum AppGroup { 4 | static let identifier = "group.com.kishikawakatsumi.AUCapture" 5 | static let container: URL = { 6 | guard let container = FileManager().containerURL(forSecurityApplicationGroupIdentifier: identifier) else { 7 | preconditionFailure() 8 | } 9 | return container 10 | }() 11 | } 12 | -------------------------------------------------------------------------------- /Shared/Util.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Data { 4 | func to(type: T.Type) -> T { 5 | withUnsafeBytes { 6 | let bytes = $0.bindMemory(to: T.self).baseAddress! 7 | return bytes.pointee 8 | } 9 | } 10 | } 11 | 12 | extension Data { 13 | init?(hex: String) { 14 | let len = hex.count / 2 15 | var data = Data(capacity: len) 16 | for i in 0.. [SubSequence] { 36 | guard !isEmpty else { return [] } 37 | return [prefix(size)] + dropFirst(size).chunks(ofSize: size) 38 | } 39 | } 40 | --------------------------------------------------------------------------------