Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Ulisse profile imageVaiTon
VaiTon forUlisse

Posted on • Originally published atctf.ulis.se

     

chicago

Challenge description

Keygenme...sort of

Author:akhbaar

The keygen

As usual, we start by trying to run the executable.

./chicago
Enter fullscreen modeExit fullscreen mode

but unfortunately, we get

... Bad lenght! ...
Enter fullscreen modeExit fullscreen mode

Opening the file with ghidra, we see that the file is a rust compiled executable, withA TON of functions (I suppose from the rust standard library). After some time we find themain, with an interesting portion of code:

if(local_1a8<10){FUN_00107480("Bad length ...
Enter fullscreen modeExit fullscreen mode

So the length of the input must be at least 10.
Also, after some analysis and variable renaming, we find that

actual_num=input[i]-0x30;// 0x30 is the ascii code for '0'
Enter fullscreen modeExit fullscreen mode

So every character of the input must be a digit.

if(((i&1)!=0)&&(actual_num=actual_num*2,L'4'<(uint)input[i])){actual_num=(uint)(byte)((char)(actual_num&0xff)+(char)((actual_num&0xff)/10)*-9);}
Enter fullscreen modeExit fullscreen mode

So if the index of the character is odd, we multiply it by 2.
Also, if the original number is greater than 4, we replace it with $x + x / 10 * -9$, where $x$ is the original number.

Then, at least that's what I thought, it gets compared to the first character of the input, and if it's equal we get the flag.

The real keygen

After spending much more time than I should have, and after writing a python script to bruteforce the flag, I was so surprised when the first number it tried checked all the conditions.

As you could have guessed, the first and most obvious string that my script tried was0000000000, and it worked 😭.

To get the flag, I then just had to run the program with./chicago 0000000000.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Read next

zhangwei42 profile image

Unveiling a New Era in Open Source Licensing

Zhang Wei -

laetitiaperraut profile image

Unveiling the Samba Public License: A Deep Dive into Fair Code Licensing

Laetitia Perraut -

ahmmrizv9 profile image

Engaging Exploration of the Open Invention Network License

Ahmend Riss -

rachellovestowrite profile image

Unveiling Open Data Commons Public Domain Dedication and License: A Deep Dive

Rachel Duncan -

More fromUlisse

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp