Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fstrings (#13)
* 32Bit Fstrings * Move Demo to 32Bit * First Format Strings Target Done * Trget 1 Added * first Challenge Added
- Loading branch information
Showing
6 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM ghcr.io/coventryuniversity/6048builder as ClientBuilder | ||
|
||
RUN apt install -y --no-install-recommends python3 python3-jinja2 | ||
|
||
ADD src /opt | ||
|
||
WORKDIR /opt | ||
|
||
#We want to rebuld this each time | ||
#ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache | ||
|
||
RUN python3 /opt/process.py && gcc -fno-stack-protector /opt/target.c -o /opt/target | ||
|
||
FROM ghcr.io/coventryuniversity/6048server | ||
COPY --from=ClientBuilder /opt/target /home/cueh/target | ||
|
||
ADD runserver.sh /opt/ | ||
|
||
CMD ["/bin/bash", "/opt/runserver.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
echo "Starting Remote Service on port 1337" | ||
|
||
/opt/server /home/cueh/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import logging | ||
import random | ||
import string | ||
|
||
import jinja2 | ||
|
||
def create_target(): | ||
""" | ||
Create the Target C File | ||
@param seed: Seed for the target, between 0 and 32 | ||
""" | ||
|
||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath=".")) | ||
|
||
template = env.get_template("target.jinja2") | ||
|
||
username = random.choice(["Zaphod", | ||
"Ford", | ||
"Arthur", | ||
"Tricia"]) | ||
|
||
logging.debug("User is %s", username) | ||
password = "".join(random.choice(string.ascii_letters) for x in range(16)) | ||
logging.debug("Password is %s", password) | ||
|
||
result = template.render(username = username, | ||
password = password) | ||
|
||
with open("target.c", "w") as fd: | ||
fd.write(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
create_target() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
int BUFFER = 32; | ||
|
||
|
||
int main(int argc, char* argv[]){ | ||
setvbuf(stdout, NULL, _IONBF, 0); | ||
char username[16] = "{{ username }}"; | ||
char password[32] = "{{ password }}"; | ||
int attempts = 3; | ||
char user[BUFFER]; | ||
char pass[BUFFER]; | ||
|
||
/* Main Function*/ | ||
while (attempts > 0){ | ||
//Get Data | ||
printf("Enter Username >"); | ||
scanf("%32s", user); | ||
printf("Enter Password >"); | ||
scanf("%32s", pass); | ||
|
||
//Compare user | ||
if(strcmp(username, user)){ | ||
printf("Incorrect Username "); | ||
printf(user); | ||
printf("\n"); | ||
attempts -= 1; | ||
} | ||
else{ | ||
//Compare Password | ||
if(strcmp(pass, password)){ | ||
//A Non Zero == Fail | ||
printf("Access Denied\n"); | ||
attempts -= 1; | ||
} | ||
else{ | ||
printf("Access Granted\n"); | ||
return 1; | ||
} | ||
} | ||
printf("\n%d Attempts Remain\n", attempts); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: "3.7" | ||
|
||
services: | ||
server: | ||
build: | ||
context: builder | ||
args: | ||
CACHE: "$(date)" | ||
ports: | ||
- "1337:1337" | ||
# - "22:22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
int BUFFER = 32; | ||
|
||
|
||
int main(int argc, char* argv[]){ | ||
setvbuf(stdout, NULL, _IONBF, 0); | ||
char username[32] = "Someone"; //0-16 Letter Username | ||
char password[32] = "sECcuzDyeFmiXXbN"; // 0-16 Letter Password | ||
int attempts = 3; | ||
char user[BUFFER]; | ||
char pass[BUFFER]; | ||
|
||
/* Main Function*/ | ||
while (attempts > 0){ | ||
//Get Data | ||
printf("Enter Username >"); | ||
scanf("%32s", user); | ||
printf("Enter Password >"); | ||
scanf("%32s", pass); | ||
|
||
//Compare user | ||
if(strcmp(username, user)){ | ||
printf("Incorrect Username "); | ||
printf(user); | ||
printf("\n"); | ||
attempts -= 1; | ||
} | ||
else{ | ||
//Compare Password | ||
if(strcmp(pass, password)){ | ||
//A Non Zero == Fail | ||
printf("Access Denied\n"); | ||
attempts -= 1; | ||
} | ||
else{ | ||
printf("Access Granted\n"); | ||
return 1; | ||
} | ||
} | ||
printf("\n%d Attempts Remain\n", attempts); | ||
} | ||
return 0; | ||
} |