Skip to content
Browse files

Support for testing SMTP Authentication

  • Loading branch information...
1 parent 7574b64 commit 0a082ce7a58a84c739ff7d87ccd0db8e2fffa641 @jstanden jstanden committed
Showing with 32 additions and 3 deletions.
  1. +2 −1 AppController.h
  2. +29 −1 AppController.m
  3. +1 −1 FakeSMTP.xcodeproj/project.pbxproj
View
3 AppController.h
@@ -18,7 +18,8 @@
IBOutlet id clearLogButton;
IBOutlet id textView;
- BOOL isRunning, isInsideData;
+ BOOL isRunning, isInsideData, isInsideAuth;
+ int authCount;
}
-(IBAction)startStopServer:(id)sender;
View
30 AppController.m
@@ -35,6 +35,8 @@ -(id)init {
isRunning = NO;
isInsideData = NO;
+ isInsideAuth = NO;
+ authCount = 0;
}
return self;
@@ -180,6 +182,22 @@ -(void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
[sock disconnect];
return;
+ } else if([msg length] >= 4 && [[msg substringToIndex:4] isCaseInsensitiveLike:@"EHLO"]) {
+ [self send:@"250-mail.fakemail\r\n" onSocket:sock];
+ [self send:@"250-PIPELINING\r\n" onSocket:sock];
+ [self send:@"250-SIZE 1048576000\r\n" onSocket:sock];
+ [self send:@"250-ETRN\r\n" onSocket:sock];
+ [self send:@"250-AUTH PLAIN LOGIN\r\n" onSocket:sock];
+ [self send:@"250-AUTH=PLAIN LOGIN\r\n" onSocket:sock];
+ [self send:@"250-8BITMIME\r\n" onSocket:sock];
+ [self send:@"250-ENHANCEDSTATUSCODES\r\n" onSocket:sock];
+ [self send:@"250 DSN\r\n" onSocket:sock];
+
+ } else if([msg isCaseInsensitiveLike:@"AUTH LOGIN"]) {
+ isInsideAuth = YES;
+ authCount = 0;
+ [self send:@"334 Who are you again?\r\n" onSocket:sock];
+
} else if([msg length] >= 4 && [[msg substringToIndex:4] isCaseInsensitiveLike:@"HELO"]) {
[self send:@"250 Do I know you?\r\n" onSocket:sock];
@@ -189,10 +207,20 @@ -(void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
} else if([msg length] >= 7 && [[msg substringToIndex:7] isCaseInsensitiveLike:@"RCPT TO"]) {
[self send:@"250 You're friends with _THEM_?!\r\n" onSocket:sock];
- } else if([msg length] >= 4 && [[msg substringToIndex:4] isCaseInsensitiveLike:@"DATA"]) {
+ } else if([msg isCaseInsensitiveLike:@"DATA"]) {
isInsideData = YES;
[self send:@"354 You're going to talk no matter what I say, go ahead.\r\n" onSocket:sock];
+ } else if (isInsideAuth) {
+ if(0 == authCount) {
+ [self send:@"334 Sounds vaguely familiar... What's the secret incantation?\r\n" onSocket:sock];
+ authCount++;
+ } else if(1 == authCount) {
+ [self send:@"235 Klaatu barada niCHUUhhhHUHhhuh? Welcome back.\r\n" onSocket:sock];
+ isInsideAuth = NO;
+ authCount = 0;
+ }
+
} else if (isInsideData) {
// [TODO] Building DATA block
View
2 FakeSMTP.xcodeproj/project.pbxproj
@@ -42,7 +42,7 @@
1B5A387C11336A6C00CC7A11 /* PrefsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrefsController.h; sourceTree = "<group>"; };
1B5A387D11336A6C00CC7A11 /* PrefsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrefsController.m; sourceTree = "<group>"; };
1B740EF51134730300927AD7 /* UserDefaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = UserDefaults.plist; sourceTree = "<group>"; };
- 1BAB3DF6112319A300E1EAB0 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
+ 1BAB3DF6112319A300E1EAB0 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = ../Sparkle.framework; sourceTree = "<group>"; };
1DDD58150DA1D0A300B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };

0 comments on commit 0a082ce

Please sign in to comment.
Something went wrong with that request. Please try again.