8 Replies - 877 Views - Last Post: 18 June 2012 - 11:18 AM Rate Topic: -----

#1 Duckman5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-June 12

Decoding Task

Posted 18 June 2012 - 12:08 AM

A friend of mine gave me some code and he wanted me to figure out a value. How do I do this? I don't want you to tell me what it is I'd like to know the specifics of it. Thank you.

char l=0,i=(0x1<<4)-011,v[]= "qqe<|qmgcclo{&dih+";
char L(){
    l+=(v[l]?1:0);
    if(v[l])L();
}
char C(){
    v[i]^=l-i+++(3);
    if (i<l)C();
}

char main()
{
    ;
    L();
    C();
    }



The "qqe<|qmgcclo{&dih+" is what I'm trying to find.

Is This A Good Question/Topic? 0
  • +

Replies To: Decoding Task

#2 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1572
  • View blog
  • Posts: 2,993
  • Joined: 30-May 10

Re: Decoding Task

Posted 18 June 2012 - 03:01 AM

So have you got at far as compiling the code, running it, and seeing what it does?

Next, you could put something like
printf("L called\n");
at the start of the L() function, then run the code and see what happens.
Was This Post Helpful? 0
  • +
  • -

#3 Duckman5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-June 12

Re: Decoding Task

Posted 18 June 2012 - 03:18 AM

It compiles and runs just fine. When it runs it yields 18. When I tried adding the printf, it yielded the same value of 18 but there were several L calls. No compiling errors though.

Heres the code I used.
#include <stdio.h>

char l=0,i=(0x1<<4)-011,v[]= "qqe<|qmgcclo{&dih+";
char L(){
    printf("L called\n");
    l+=(v[l]?1:0);
    if(v[l])L();
}
char C(){
    v[i]^=l-i+++(3);
    if (i<l)C();
}

char main()
{
    ;
    L();
    C();
    }



Also he gave me another code just in case I couldn't figure out that one.

main(){
    char l=0,i=4|3|1,v[]= "qqe<|qmgcclo{&dih+";
o:
    if (v[l++]) goto o;
;
O:l--
;
_:
    v[i]^=l-i+++(1|2);
    if(i < l) goto _;
;
}

Was This Post Helpful? 0
  • +
  • -

#4 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1572
  • View blog
  • Posts: 2,993
  • Joined: 30-May 10

Re: Decoding Task

Posted 18 June 2012 - 04:06 AM

> printf("L called\n");
And if you now change it to
printf("L called, l=%d\n",l);

What do you see now?
Does it have anything to do with the length of the string perhaps?

Now do something similar in the C() function, printing the value of i (it's the variable being changed, it's going to be interesting).

> Also he gave me another code just in case I couldn't figure out that one.
I hope you're not seriously thinking you're going to actually learn C programming from these are you?

Mostly, these would be poor submissions to http://www.ioccc.org/
Was This Post Helpful? 0
  • +
  • -

#5 Duckman5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-June 12

Re: Decoding Task

Posted 18 June 2012 - 04:24 AM

#include <stdio.h>

char l=0,i=(0x1<<4)-011,v[]= "qqe<|qmgcclo{&dih+";
char L(){
    printf("L called, l=%d\n",l);
    l+=(v[l]?1:0);
    if(v[l])L();
}
char C(){
    printf("C called, i=%d\n",l);
    v[i]^=l-i+++(3);
    if (i<l)C();
}

char main()
{
    ;
    L();
    C();
    }



When I did it for both it did indeed yield the length of the string. I'm a bit confused and don't know where to go from here. Also I don't really intend to learn programming from this, it's just a test to see how I'm doing.
Was This Post Helpful? 0
  • +
  • -

#6 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1572
  • View blog
  • Posts: 2,993
  • Joined: 30-May 10

Re: Decoding Task

Posted 18 June 2012 - 06:29 AM

Maybe pay attention?
You say you're printing i, but you're still printing l

How about trying this?
printf("C called, i=%d, v=%s\n",i,v);

Like I said, the code is a pile of shit not worth understanding.

$ gcc -Wall foo.c
foo.c: In function ‘L’:
foo.c:11: warning: array subscript has type ‘char’
foo.c:12: warning: array subscript has type ‘char’
foo.c: In function ‘C’:
foo.c:16: warning: array subscript has type ‘char’
foo.c:16: warning: operation on ‘i’ may be undefined
foo.c:16: warning: operation on ‘i’ may be undefined
foo.c:18: warning: control reaches end of non-void function
foo.c: In function ‘L’:
foo.c:13: warning: control reaches end of non-void function

This means undefined behaviour (it's a term you will know well when you get really into C programming). It means the code WILL NOT give you the same answer on all machines.
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5951
  • View blog
  • Posts: 23,210
  • Joined: 23-August 08

Re: Decoding Task

Posted 18 June 2012 - 10:32 AM

Apparently the OP is trying to get with the l33t k1dz. They must have put that in there strictly to keep the scr1pt k1dd13z out, given how easy it is to get the result if you have the slightest idea what you're doing. ;)

And because I'm a giant tease...

Attached image(s)

  • Attached Image

Was This Post Helpful? 1
  • +
  • -

#8 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1572
  • View blog
  • Posts: 2,993
  • Joined: 30-May 10

Re: Decoding Task

Posted 18 June 2012 - 11:13 AM

In other words, by removing "http://" from the string, the decode was broken.

Anyway, I'm happy to piss on your parade by posting the link.
mod edit: spoil sport link removed

There - share and enjoy.

This post has been edited by modi123_1: 18 June 2012 - 11:18 AM

Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8365
  • View blog
  • Posts: 31,080
  • Joined: 12-June 08

Re: Decoding Task

Posted 18 June 2012 - 11:18 AM

It's probably too late, but let's not be a spoil sport and trash a potentially interesting way of learning some debugging.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1