Skip to content

Commit a40d8d9

Browse files
committed
Update 1.3
Add main.m
1 parent 138f1af commit a40d8d9

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

JamWiFi.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
D736EDA722E4CC630015707A /* ANBeaconPart.m in Sources */ = {isa = PBXBuildFile; fileRef = D736ED9522E4CC620015707A /* ANBeaconPart.m */; };
2727
D736EDA822E4CC630015707A /* ANBeaconFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = D736ED9622E4CC620015707A /* ANBeaconFrame.m */; };
2828
D775909E22E50F020033BBE3 /* Apple80211.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D775909D22E50F020033BBE3 /* Apple80211.framework */; };
29+
D7807DB122E5301A007595DC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D7807DB022E53019007595DC /* main.m */; };
2930
D7F803D422E12E5D00E3E380 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAB94BCE15C0557A0031197A /* AppKit.framework */; };
3031
FAB94BCC15C0557A0031197A /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAB94BCB15C0557A0031197A /* Cocoa.framework */; };
3132
FAB94C0915C05BB10031197A /* CoreWLAN.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAB94C0815C05BB10031197A /* CoreWLAN.framework */; };
@@ -89,6 +90,7 @@
8990
D736ED9622E4CC620015707A /* ANBeaconFrame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ANBeaconFrame.m; sourceTree = "<group>"; };
9091
D775909D22E50F020033BBE3 /* Apple80211.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Apple80211.framework; path = ../../../../../../System/Library/PrivateFrameworks/Apple80211.framework; sourceTree = "<group>"; };
9192
D77590A122E50F900033BBE3 /* CarbonAppProcess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CarbonAppProcess.h; sourceTree = "<group>"; };
93+
D7807DB022E53019007595DC /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
9294
FAB94BC715C0557A0031197A /* JamWiFi.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JamWiFi.app; sourceTree = BUILT_PRODUCTS_DIR; };
9395
FAB94BCB15C0557A0031197A /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
9496
FAB94BCE15C0557A0031197A /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
@@ -122,6 +124,7 @@
122124
D736ED7222E4CC620015707A /* JamWiFi */ = {
123125
isa = PBXGroup;
124126
children = (
127+
D7807DB022E53019007595DC /* main.m */,
125128
D736ED7622E4CC620015707A /* JWListView.swift */,
126129
D736ED7822E4CC620015707A /* JWTrafficGatherer.swift */,
127130
D736ED7922E4CC620015707A /* JWClient.swift */,
@@ -321,6 +324,7 @@
321324
D736ED9F22E4CC630015707A /* CarbonAppProcess.m in Sources */,
322325
D736EDA622E4CC630015707A /* HelperFunc.m in Sources */,
323326
D736ED9922E4CC630015707A /* JWTrafficGatherer.swift in Sources */,
327+
D7807DB122E5301A007595DC /* main.m in Sources */,
324328
D736EDA822E4CC630015707A /* ANBeaconFrame.m in Sources */,
325329
D736ED9822E4CC630015707A /* JWListView.swift in Sources */,
326330
D736EDA022E4CC630015707A /* JWClientKiller.swift in Sources */,

JamWiFi/JWAppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var _bind: bindFunc?
4040
var _scan: scanFunc?
4141
var _close: closeFunc?
4242

43-
@NSApplicationMain
43+
//@NSApplicationMain
4444
class JWAppDelegate: NSObject, NSApplicationDelegate {
4545

4646
@IBOutlet weak var window: NSWindow!
@@ -53,7 +53,7 @@ class JWAppDelegate: NSObject, NSApplicationDelegate {
5353

5454
func applicationDidFinishLaunching(_ aNotification: Notification) {
5555
// Insert code here to initialize your application
56-
56+
print("JWDelegate: Launch Complete.")
5757

5858
if let handle = dlopen(nil, RTLD_LAZY) {
5959
//if let handle = dlopen("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Apple80211", RTLD_LAZY) {

JamWiFi/main.m

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// main.m
3+
// JamWiFi
4+
//
5+
// Created by Alex Nichol on 7/25/12.
6+
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
#import <ServiceManagement/ServiceManagement.h>
11+
#import <Security/Authorization.h>
12+
#import <CoreWLAN/CoreWLAN.h>
13+
14+
#import "HelperFunc.h"
15+
#import "JamWiFi-Swift.h"
16+
17+
int main(int argc, char *argv[]) {
18+
19+
@autoreleasepool {
20+
21+
NSLog(@"Main.m: Initializing..");
22+
23+
if (geteuid()) {
24+
OSStatus myStatus;
25+
AuthorizationFlags myFlags = kAuthorizationFlagDefaults;
26+
AuthorizationRef myAuthorizationRef;
27+
28+
myStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, myFlags, &myAuthorizationRef);
29+
if (myStatus != errAuthorizationSuccess) return myStatus;
30+
31+
AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
32+
AuthorizationRights myRights = {1, &myItems};
33+
myFlags = kAuthorizationFlagDefaults |
34+
kAuthorizationFlagInteractionAllowed |
35+
kAuthorizationFlagPreAuthorize |
36+
kAuthorizationFlagExtendRights;
37+
myStatus = AuthorizationCopyRights(myAuthorizationRef, &myRights, NULL, myFlags, NULL );
38+
39+
40+
if (myStatus != errAuthorizationSuccess) {
41+
runAlert(@"Cannot run without admin privileges", @"This program cannot tap into the wireless network stack without administrator access.");
42+
return 1;
43+
}
44+
45+
46+
const char * myToolPath = [[[NSBundle mainBundle] executablePath] UTF8String];
47+
char * myArguments[] = {NULL};
48+
49+
myFlags = kAuthorizationFlagDefaults;
50+
myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, myToolPath, myFlags, myArguments,
51+
NULL);
52+
AuthorizationFree(myAuthorizationRef, kAuthorizationFlagDefaults);
53+
exit(0);
54+
}
55+
//NSApplication.sharedApplication.delegate = JWAppDelegate.new;
56+
//[NSApp setDelegate:JWAppDelegate.new];
57+
58+
return NSApplicationMain(argc, (const char **)argv);
59+
}
60+
}

0 commit comments

Comments
 (0)