Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added signal_party Challenge #22

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ docker compose down
|[B4nner](challenges/B4nner)|Linux|Easy|True
|[B4nner_2](challenges/B4nner_2)|Linux|Medium|True
|[G0t_A_IO](challenges/G0t_A_IO)|OSINT|Easy|False
|[signal_party](challenges/signal_party)|Revers|Easy|False

> This table will be updated everytime i add a challenge to the repo

Expand Down
20 changes: 20 additions & 0 deletions challenges/signal_party/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Signal_Party

- **`Author:`** [SlyPex](https://github.com/SlyPex)
- **`CTF:`** [AlphaCTF2K24](https://github.com/Spidey-y/AlphaCTF2k24)
- **`Categorie:`** Reverse
- **`Difficulty:`** Easy

## Description

>
Me and my friends decided to host a party.
It was full of signals.

**Note** : Regex : `AlphaCTF{[^SI023468]+}`.

Wrap the decoded string with AlphaCTF{}.

## Solution

Solution of the challenge can be found [here](solution/).
29 changes: 29 additions & 0 deletions challenges/signal_party/challenge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "signal_party"
author: "SlyPex"
author_link: "https://github.com/SlyPex"

category: reverse

difficulty: easy

description: |
> Me and my friends decided to host a party.
It was full of signals.
**Note** : Regex : AlphaCTF{[^SI023468]+}.
Wrap the decoded string with AlphaCTF{}.

**Author** : SlyPex
flags:
- AlphaCTF{YOU_R_REALLY_A_519NAL_PLAY9ROUND_MA57ER}

tags:
- Reverse
- Easy

value: 500
extra:
initial: 500
decay: 35
minimum: 50
state: hidden
version: "0.1"
Binary file added challenges/signal_party/challenge/chall
Binary file not shown.
69 changes: 69 additions & 0 deletions challenges/signal_party/challenge/chall.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
#include<unistd.h>
#include<sys/types.h>

FILE *output;

void encrypt(int sig){
fputc(sig + 0x7F, output);
}

int main (int argc, char *argv[])
{
pid_t pid = getpid();
char c;
FILE *flag = fopen("flag.txt","r");
if ( flag == NULL ){
printf("Could not open file.\n");
return 1;
}
output = fopen("output","w");

signal(SIGSYS,encrypt);
signal(SIGPOLL,encrypt);
signal(SIGWINCH,encrypt);
signal(SIGVTALRM,encrypt);
signal(SIGXCPU,encrypt);
signal(SIGTTOU,encrypt);
signal(SIGTSTP,encrypt);
signal(SIGCHLD,encrypt);
signal(SIGTERM,encrypt);
signal(SIGPIPE,encrypt);
signal(SIGSEGV,encrypt);
signal(SIGFPE,encrypt);
signal(SIGABRT,encrypt);
signal(SIGILL,encrypt);
signal(SIGINT,encrypt);
signal(SIGHUP,encrypt);
signal(SIGQUIT,encrypt);
signal(SIGTRAP,encrypt);
signal(SIGBUS,encrypt);
signal(SIGUSR1,encrypt);
signal(SIGUSR2,encrypt);
signal(SIGALRM,encrypt);
signal(SIGSTKFLT,encrypt);
signal(SIGCONT,encrypt);
signal(SIGTTIN,encrypt);
signal(SIGURG,encrypt);
signal(SIGXFSZ,encrypt);
signal(SIGPROF,encrypt);
signal(SIGIO,encrypt);
signal(SIGPWR,encrypt);

while ((c = fgetc(flag))!= EOF)
{
if ((int)c > 64 )
{
kill(pid,(int)c % 32);
}else if((int)c < 58){
kill(pid,(int)c % 32 % 5 + 27);
}
}

fclose(flag);
fclose(output);

return 0;
}
1 change: 1 addition & 0 deletions challenges/signal_party/challenge/flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
YOU_R_REALLY_A_519NAL_PLAY9ROUND_MA57ER
1 change: 1 addition & 0 deletions challenges/signal_party/challenge/output
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
����������������������������������������
38 changes: 38 additions & 0 deletions challenges/signal_party/solution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Signal_Party

## Write-up

> i'll probably change this write-up

You only have to reverse the binary, and using the extra information given in the challenge description we get this :

```python
from string import ascii_uppercase,digits

# Possible Charcters For The Flag : AlphaCTF{[^SI023468]+}.
letters = ascii_uppercase + digits + '_'
# Removing non-included letters
letters = [letter for letter in letters if letter not in 'SI023468']

# Building the dictionary where each letter from letters list matches its encrypted value
transformer = {}
for letter in letters:
if ord(letter) > 64:
transformer[ord(letter) % 32] = letter
elif ord(letter) < 58:
transformer[(ord(letter) % 32)% 5 + 27] = letter

# Getting the values of the Encrypted chars [output file].
f = open("output", "rb")
encoded_flag = f.read()[:-1] # Remove the new line char
flag = 'AlphaCTF{'

for char in encoded_flag:
flag += transformer[char - 0x7F]

flag += '}'
print(flag)
```

## Flag
`AlphaCTF{YOU_R_REALLY_A_519NAL_PLAY9ROUND_MA57ER}`
1 change: 1 addition & 0 deletions challenges/signal_party/solution/output
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
����������������������������������������
25 changes: 25 additions & 0 deletions challenges/signal_party/solution/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from string import ascii_uppercase,digits

# Possible Charcters For The Flag : AlphaCTF{[^SI023468]+}.
letters = ascii_uppercase + digits + '_'
# Removing non-included letters
letters = [letter for letter in letters if letter not in 'SI023468']

# Building the dictionary where each letter from letters list matches its encrypted value
transformer = {}
for letter in letters:
if ord(letter) > 64:
transformer[ord(letter) % 32] = letter
elif ord(letter) < 58:
transformer[(ord(letter) % 32)% 5 + 27] = letter

# Getting the values of the Encrypted chars [output file].
f = open("output", "rb")
encoded_flag = f.read()[:-1] # Remove the new line char
flag = 'AlphaCTF{'

for char in encoded_flag:
flag += transformer[char - 0x7F]

flag += '}'
print(flag)