Digit CTC Discussion

Status
Not open for further replies.

Tron91

In the zone
This is the code for the decipher:

#include "stdio.h"


int shift = 1;
int key_size = 0;
int readbyte;
int key;
int last_key;
int key_no = 0;

FILE *in, *out, *k;

int main(int argc, char* argv[])
{
if(argc < 4)
{
printf("Usage:\n\tdeciphermp key_file input_file output_file\n");
return 1; // Fast exit
}

// Validate the key first
if((in = fopen(argv[1], "r")) == NULL)
{
printf("Error::Can't open key!\n");
return 1; // Goofed up
}

while((readbyte = getc(in)) != EOF)
{
if(readbyte >= 'A' && readbyte <= 'Z')
{
if(key_size != 0)
{
if(last_key == readbyte)
{
printf("Error::Invalid key!\n");
fclose(in);
return 1; // Goofed up
}
}

last_key = readbyte;
key_size++;
}
else
{
printf("Error::Invalid key!\n");
fclose(in);
return 1; // Goofed up
}
}

fclose(in);
if((k = fopen(argv[1], "r")) == NULL)
{
printf("Error::Can't open key!\n");
return 1; // Goofed up
}

while((key = getc(k)) != EOF)
{
key = key - 64;
if(key_no != 0 && key_no != key_size - 1)
{
if(key_no % 2 == 1)
{
if((in = fopen("odd.tmp", "r")) == NULL)
{
printf("Error::Can't open temporary files!\n");
fclose(k);
return 1;
}

if((out = fopen("even.tmp", "w")) == NULL)
{
printf("Error::Can't create temporary files!\n");
fclose(in);
fclose(k);
return 1;
}
}
else
{
if((in = fopen("even.tmp", "r")) == NULL)
{
printf("Error::Can't open temporary files!\n");
fclose(k);
return 1;
}

if((out = fopen("odd.tmp", "w")) == NULL)
{
printf("Error::Can't create temporary files!\n");
fclose(in);
fclose(k);
return 1;
}
}
}

if(key_no == 0)
{
if((in = fopen(argv[2], "r")) == NULL)
{
printf("Error::Can't open input file!\n");
fclose(k);
return 1;
}

if((out = fopen("odd.tmp", "w")) == NULL)
{
printf("Error::Can't create temporary files!\n");
fclose(in);
fclose(k);
return 1;
}
}

if(key_no == key_size - 1)
{
if(key_size % 2 == 0)
{
if((in = fopen("odd.tmp", "r")) == NULL)
{
printf("Error::Can't open temporary files!\n");
fclose(k);
return 1;
}
}
else
{
if((in = fopen("even.tmp", "r")) == NULL)
{
printf("Error::Can't open temporary files!\n");
fclose(k);
return 1;
}
}

if((out = fopen(argv[3], "w")) == NULL)
{
printf("Error::Can't create output file!\n");
fclose(in);
fclose(k);
return 1;
}
}

while((readbyte = getc(in)) != EOF)
{
if(readbyte >= 'a' && readbyte <= 'z')
{
readbyte = readbyte - shift;
shift++;
if(readbyte < 'a')
readbyte = readbyte + 26;

if(shift > key)
shift = 1;
}
/*else
{
shift++;
if(shift > key) //including this snippet will make the cipher take whitespaces in the block.
shift = 1; //this snippet is for cipherw.exe and not for cipher.exe
}*/
putc(readbyte, out);
}

fclose(in);
fclose(out);
key_no++;
}

fclose(k);
_unlink("odd.tmp");
_unlink("even.tmp");

return 0; // Bye bye
}


remove any space inside the key before trying to run the decipher on the above two blocks of ciphertext

---------- Post added at 03:13 AM ---------- Previous post was at 03:09 AM ----------

This is the code for the cipher256

#include "stdio.h"
#include "stdlib.h"
#include "time.h"

int readbyte;
int shift = 1;
int key_size = 256; // how many rounds will be made, can easily be made 128, 256, 512, 1024
int key_no = 0; // actually 1, but C++ starts from 0 ;-)
unsigned char keychain[256]; // will store the keys in reverse order, should be equal to key_size.
int key; // current key used for ciphering
int last_key; // last key lol

FILE *in, *out;


int main(int argc, char* argv[])
{
if(argc < 3)
{
printf("Usage:\n\tcipher256 input_file output_file\n");
return 0;
}

// Random key generator
srand((unsigned)time(NULL)); // random generator seeded. am a farmer lol

// Two approaches are possible. Either make the whole key first, and then cipher.
// or make one key and cipher and carry on.
// Choose the first method. lesser code implementation ;-) am lazy

do
{
key = rand()/1000;
if(key >=1 && key <= 26)
{
if(key_no != 0)
{
if(key != last_key)
{
keychain[key_size - 1 - key_no] = 64 + key;
key_no++;
last_key = key;
}
}
else
{
keychain[key_size - 1] = 64 + key;
key_no++;
last_key = key;
}
}
}
while(key_no < key_size);

// key generated, now we need to cipher ;-)

for(key_no = 0; key_no < key_size; key_no++)
{
if(key_no != 0 && key_no != key_size - 1)
{
if(key_no % 2 == 1)
{
if((in = fopen("odd.tmp", "r")) == NULL)
{
printf("Error::Can't open temporary files!\n");
return 0;
}

if((out = fopen("even.tmp", "w")) == NULL)
{
printf("Error::Can't create temporary files!\n");
fclose(in);
return 0;
}
}
else
{
if((in = fopen("even.tmp", "r")) == NULL)
{
printf("Error::Can't open temporary files!\n");
return 0;
}

if((out = fopen("odd.tmp", "w")) == NULL)
{
printf("Error::Can't create temporary files!\n");
fclose(in);
return 0;
}
}
}

if(key_no == 0)
{
if((in = fopen(argv[1], "r")) == NULL)
{
printf("Error::Can't open input file!\n");
return 0;
}

if((out = fopen("odd.tmp", "w")) == NULL)
{
printf("Error::Can't create temporary files!\n");
fclose(in);
return 0;
}
}

if(key_no == key_size - 1)
{
if((in = fopen("odd.tmp", "r")) == NULL)
{
printf("Error::Can't open temporary files!\n");
return 0;
}

if((out = fopen(argv[2], "w")) == NULL)
{
printf("Error::Can't create output file!\n");
fclose(in);
return 0;
}
}

while((readbyte = getc(in)) != EOF)
{
if(readbyte >= 'a' && readbyte <= 'z')
{
readbyte = readbyte + shift;
shift++;
if(readbyte > 'z')
readbyte = readbyte - 26;

if(shift > keychain[key_no] - 64)
shift = 1;
}
/*else
{
shift++;
if(shift > keychain[key_no] - 64) //including this snippet will make the cipher take whitespaces in the block.
shift = 1; //this snippet is for cipherw.exe and not for cipher.exe
}*/
putc(readbyte, out);
}

fclose(in);
fclose(out);
}

// cipher ended ;-)

// now write down the key

if((out = fopen("KEY", "w")) == NULL)
{
printf("Error::Can't create output file!\n");
return 0;
}

for(key_no = 0; key_no < key_size; key_no++)
putc(keychain[key_no], out);

fclose(out);

_unlink("odd.tmp"); // Cleanup temporary files
_unlink("even.tmp");

return 0; // Exit gracefully
}


---------- Post added at 03:16 AM ---------- Previous post was at 03:13 AM ----------

lol just realised i went open source

---------- Post added at 03:31 AM ---------- Previous post was at 03:16 AM ----------

a small bug is there in cipher256
key_size should be always even. a small code block would solve it. its already implemented in decipher
and decipher is not limited to a fixed key_size, it will decipher all key_size
 

proxyg33k

Smashed Buffer >>
lmao.......will read it...seems preety cool........

btw tron bro....can i knw .......wht profession ur in?????? student????

---------- Post added at 05:47 AM ---------- Previous post was at 05:41 AM ----------

doesn`t looks like the code is written by some noob......well done .......
 

The CyberShot

Broken In
Just finished CTC! I feel a lot better now :)
I was losing sleep over the 3-letter word, and Tron91 gave me a hint too,
but I tried bruteforce anyway and it worked!! :D
(there aren't a lot of 3-letter english words)

Thanks to *all* of you guys (and gals, if any) who helped others with the challenges.
This thread was really very helpful to me for getting by some levels.
Especially the one where we're asked to name something that's described as being narcissistic, happy, perfect and untouchable.

And I just *KNEW* the answer had to be women! or cats!
But no, apparently, it was not! I tried all kinds of synonyms like girls, girl, girlfriend, woman, females, felines, etc. but I got it all wrong, of course.
I even tried men! :D

Thanks to your Google It! hint Tron91, I was able to figure it out.



P.S. If anybody else had the same thoughts and are still stuck at that level, then trust me, it ain't gotta do *anything* with women, men or cats :p

---------- Post added at 06:34 AM ---------- Previous post was at 06:15 AM ----------

Niiice Tron91, you seem to be good with programming and stuff. And if you crave for more computer oriented challenges, you should give http://www.hackthisite.org/ a try

If anyone among you is interested in harder, more computer security oriented challenges, then you should register yourself at http://www.wechall.net/
It's a hacker world ranking site that has hackers and computer enthusiasts from all over the world trying out computer security challenges. You're ranked among all the hackers in the world! (at least the one's who registered at WeChall)
You'll learn a *lot* about computers too!
These sites teach you about all kinds of cool stuff like Steganography, Programming, Exploits, etc.


India is currently ranked 13 on the site
(http://www.wechall.net/countryranking.php?countryid=33)
and with geeks like you onboard, it can only get better! :D

My personal favorites are:

> http://www.net-force.nl/
> http://www.hackthisite.org/
> http://thisislegal.com/
> http://www.rankk.org/
> http://www.dareyourmind.net/
> http://www.brainquest.sk/
> http://www.black-zero.com/

And if you're into programming with C and C++, you can try out http://www.cstutoringcenter.com/ which also provides some basic C and C++ tutorials and a hell lot of C/C++ challs.

Trivia: 'chall' is short for challenge


Have fun! :D

---------- Post added at 07:27 AM ---------- Previous post was at 06:34 AM ----------

I just found out something and thought I'd share it with you guys.
The hex.exe file that we're supposed to fix in the level 'I put a hex on this'
doesn't work on a 64-bit Windows 7 system even if you've fixed it correctly.
I think it might not work on any 64-bit systems. I got around this by trying out the fixed file out on Windows XP that I'm running using VirtualBox. It works fine then.

Just thought you guys should know about this just in case someone with a 64-bit system out there is having problems
 

The CyberShot

Broken In
Oops, almost forgot to thank Team Digit for the awesome CTC.
It must've taken a lot of time and energy to create something so elaborate.
Kudos to the Cover Design team. They did a fine job!
(I'd like to learn some isometric art from them. How about a tutorial Digit?)

The sad thing is... CTC ends here. Although it was highly satisfying, I crave for more. And I'm sure many of you do too.

I'd like a CTC 2.0. A CTC that's harder and more convoluted than the original. So, I created this thread. There's a poll there that I'd be happy to see you guys to take. Who knows, if enough people voted for CTC 2.0, Team Digit might just machinate one! :D

You can also post your ideas on the kinds of challenges it could/should have.

Digit CTC 2.0 - Unofficial gossip and speculation thread

CTC Rocks!!!
2hwz9zm.png
 

Devrath_ND

Obsessed with Technology
Dont expect them to be conducting CTC again so early. It takes a lot of preparation and indeed take your time to prepare and test everything at once and not checkpoints. make at annual event and if possible bi-annual event.

Prepare from now!!!!!!!! Dont make us wait. :)
 

Tron91

In the zone
Dont expect them to be conducting CTC again so early. It takes a lot of preparation and indeed take your time to prepare and test everything at once and not checkpoints. make at annual event and if possible bi-annual event.

Prepare from now!!!!!!!! Dont make us wait. :)

I agree with you as well as disagree with you. Agree at the beta testing part so that there is no delays in between the competition which happened this time.

Disagree with the event being an annual or biennial. Its for me a learning avenue for the readers of Digit. So the more frequent it is, the better it is for the readers. I want it to be a monthly event which means a new CTC with every issue of Digit.

Just my two cents of thought. Its upon RAAABO and his team. Are they game enough to take CTC into a new level each month?
 

Devrath_ND

Obsessed with Technology
Disagree with the event being an annual or biennial. Its for me a learning avenue for the readers of Digit. So the more frequent it is, the better it is for the readers. I want it to be a monthly event which means a new CTC with every issue of Digit.

Thats not possible. They cannot commit every month for CTC. And if they make it regular it will lose its uniqueness and can become repetitive. To prepare such things it requires a lot of time and I don't think they will be able to make it an monthly event.
 

The CyberShot

Broken In
Thats not possible. They cannot commit every month for CTC. And if they make it regular it will lose its uniqueness and can become repetitive. To prepare such things it requires a lot of time and I don't think they will be able to make it an monthly event.

Hey guys why don't you try Net-Force or ThisIsLegal if all you need is some stimulation of the grey matter and a nice hard test of your computer know-how.

Net-Force has some very interesting challenges for the newbies and experienced hackers alike, but if you're new to all this hacking stuff, then you should steer clear of it... for the time being at least.

ThisIsLegal is a nice place to start if you're a newbie. The site's got an active forum and the admins are helpful and friendly to new users.

If you want even more advanced stuff, just check out the links I shared in my last post.
 
T

tryeee

Guest
hey , i m new 2 this forum , but too late 4 CTC .
it mght b that the CTC contst has finished.
but i did tried 2 solve ths CTC but i stuck at

thinkdigit.com/d/<name_pagenumber>

whn i typ
thinkdigit.com/d/<Defaced_6>
URL, a blank pag appears.
ny help will highly be appreciated.

i read many Starting posts but as soon as i kept reading forward ,
i found that very very few people hav stuck where i hav stuck ,
i m realy depressed with my situation.
Do help me......!!!! :meditate:
 

proxyg33k

Smashed Buffer >>
hey , i m new 2 this forum , but too late 4 CTC .
it mght b that the CTC contst has finished.
but i did tried 2 solve ths CTC but i stuck at

thinkdigit.com/d/<name_pagenumber>

whn i typ
thinkdigit.com/d/<Defaced_6>
URL, a blank pag appears.
ny help will highly be appreciated.

i read many Starting posts but as soon as i kept reading forward ,
i found that very very few people hav stuck where i hav stuck ,
i m realy depressed with my situation.
Do help me......!!!! :meditate:

thinkdigit.com/d/Defaced_6 <<<<< dont use "<>"
 
N

neotheone

Guest
Hey when I decrypted the atom smasher Image I got another decrypted text....please tell me how to decrypt that?
 
R

rahul142

Guest
Hey people......I know I'm too late for the challenge. But anyways, can someone please gimme a hint for the Binary to Decimal converting thing on page 56??

Thanks in advance!! :)
 

Achuth

In the zone
As i cant find the md5 of the file and ..@tron91 making me understand that CTC is a learning base..i m too not submittin the entry for WInners...yup ...
but plsss help me with findin the md5..
u wont see me among winners..for sure..please ........
 
As i cant find the md5 of the file and ..@tron91 making me understand that CTC is a learning base..i m too not submittin the entry for WInners...yup ...
but plsss help me with findin the md5..
u wont see me among winners..for sure..please ........

check ur pm !!
 
Status
Not open for further replies.
Top Bottom