-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubmitViewController.m
executable file
·109 lines (87 loc) · 2.97 KB
/
SubmitViewController.m
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
75
76
77
78
79
80
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
//
// SubmitViewController.m
// iPentestCTF
//
// Created by Daniel on 16/03/2015.
// Copyright (c) 2015 Daniel Reece. All rights reserved.
//
#import "SubmitViewController.h"
@interface SubmitViewController ()
@end
@implementation SubmitViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
_flagField.tag = 0;
_usernameField.tag = 1;
_passwordField.tag = 2;
_flagField.delegate = self;
_usernameField.delegate = self;
_passwordField.delegate = self;
}
- (IBAction)pasteButton:(id)sender {
//copy clipboard contents
UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard];
NSString *string = [appPasteBoard string];
//log clipboard
NSLog(string, nil);
[_flagField setText:string];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
[super touchesBegan:touches withEvent:event];
}
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
switch(textField.tag) {
case 0:
if ([_flagField.text isEqual: @"flag"]){
_flagField.text = @"";
}
_flagField.secureTextEntry = YES;
break;
case 1:
if ([_usernameField.text isEqual: @"username"]){
_usernameField.text = @"";
}
_usernameField.secureTextEntry = NO;
break;
case 2:
if ([_passwordField.text isEqual: @"password"]){
_passwordField.text = @"";
}
_passwordField.secureTextEntry = YES;
break;
default:
break;
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
if ([_flagField.text isEqual: @""]){
_flagField.text = @"flag";
_flagField.secureTextEntry = NO;
}
if ([_usernameField.text isEqual: @""]){
_usernameField.text = @"username";
}
if ([_passwordField.text isEqual: @""]){
_passwordField.text = @"password";
_passwordField.secureTextEntry = NO;
}
}
- (IBAction)submitButton:(id)sender {
NSString *flag = _flagField.text;
NSString *username = _usernameField.text;
NSString *password = _passwordField.text;
NSString *apiURL = [[NSString alloc] initWithFormat:@"http://hiburn8.org/ctf/api.php?submit&flag=%@&username=%@&password=%@", flag, username, password];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:apiURL]];
[request setHTTPMethod:@"GET"];
// [[NSURLConnection alloc] initWithRequest:request delegate:self];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *notification = [[NSString alloc] initWithData:respData encoding:NSUTF8StringEncoding];
_NoticationLabel.text = notification;
}
@end