Link to home
Start Free TrialLog in
Avatar of doronb
doronb

asked on

Identify the Killers (Decoding Question)

Ok people, here's the newest encoded text-blocks.  The first one is the same as the first image I've posted in this question https://www.experts-exchange.com/questions/21314301/Who's-attacking-you-and-what-with.html:

qg{jqsg%{qO\_e{|Pft{qt***_{#qt5{q__kz8{a{q^+99W#Y4WWW00+3y+W6RR*4E47)e*E%e*tt~{b
q@lq~xq!'q^q^;zb>q`lMMMq5Vxq`:/VXxq2:qkqzq8a{q6===6R*$^^&{<q`qWnj32j<{qOn_W+8{"{
q^`&-{"{qt736Et-k{g%{q80^^R)j6j-j8j^R7=$Y9W)=3Rk{g%q8g8{qet7-55r0=44uu88-{Q{qR7=
^utQw`~{\q#q7h8q3?wq%<gzgZgWq)/Ig6qvq0fqzqJq@?()g"{q$t_9=7y2{v.Bml"mVq!Xq2LoSTJ[
F]|Fua[Jokt$)1e^+7*+@9^e$E~{gSL]XF"GJ']KGxaC]Hr8pwy6r&it0O8e=E0o@{qBg~qxg$qMg@q,
q>g2qxq?q,g4qvg%{qx.dpksGi;IkA\kIFs;P"IdsXtw-^Ej9j*j6j_6r&w4y(r0_#sXt{gp{q3^r*+$
$E0W4uu8-%{6{q8-%Etw4`~ew{GhqW35qrM<gzq4q%ugdg_g6qvq=X;Sq|qu()qnq3q^:Bq|,{qH9=7y
!{V?bNq@Zn:MCYK}DRAyhs}Ki\yAp2r&_`(!w0&r#8!(%{g|'Gl[x]'FS"|kFXSc[0E&O=TwE6&Rwp(W
&r_{qCg2q,g`qZg4qxg2qMqBg@qCq/qMg$qBg5{qZ]fo'aHSfUoGS"[doF|kZ8y5R8+WEt_{/{qt;Yuo
{gZ^cqlq?g8q^gHBq.3q0gTEgzgTCqOqzwq*vgRg:7_giqzTqUq]g;&gQg[qha*g"q>qO]Xq$g8q5cqK
gZgz-q^fZn'q0q-gJz9Xg)gfq}.qLgJqTgGqfqpgLq|X|grqDgflgEqAq4gUqbq1q1g^qCqb-qQ\{gd6
rX{}gP_gTgrg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9eacG`v|e\LaQCi@a0iQa/i2Ui#ahan7iWisaEa
)aZi%i`acPiuacW$i]lif?a7a-a7@iU*eaE3"Ae[aIaJi7iX&i(ziQiQaDziSvagiW{alihaj;r!+a%a
rirR?qiwa[N<rYeat\?]i*9yze;<%alaLitna8i[aYYa&~i'aHisi3iPzi=eah<ZH%q]@eilYiGa5i$h
ri#aJiRitiPasa\RZ'i:i=iCa0iQa#4a*abIIa`ji1CzamaDqiW&i-i0R}$$wiKi-aU$wafOYRioaLEi
Oa~iEi!Da8itasCioiL.iTiYHikaRiE6iwX1Ka6ila4a&@iAd;aIaham+w=i&9>i5ag5=Esei-*@Ieab
_iril[aIak)Fa\DEa<va}7ik[T{)saX*i]i#a}i[ijavViQaoiXaSa1a@i]ifa@a&iXi@a4sa%aki2ya
c=5,9oBauihti$ciIi:ilgayarTli0li(i:a*li(i:a*a}afisi|a?a*i'aOa4aE(IiEa>iRB2i0aliT
i:'ida%E}iYa$6fiZea+B7"Veti@Zi$i2RaE-iXSja#aySja#-aKaz

If you can show some source-code that would decode both of these text-blocks back into their correct images, you'd get the points :)
Avatar of qwaletee
qwaletee

This may as well have been titled "For Synque"

Well, I suppose I could use Synque's code as a starting point, assimilate the info you gave on why you change dthings, and have a crack at it.  But the kids are crying and the migration project is behind, so...

Lehitraot
Avatar of doronb

ASKER

Ok qwaletee, lehitraot, ve'be'hatz'la'kha ;)

Actually, to give a hint, synque's code is missing just one small part really :)
Shouldn't that be u'be'hatz... or maybe u've'hatz... well, I'll try reisntalling the encoder for the dikduk algorithm.  ;)
Avatar of doronb

ASKER

LOL :)

Where are you now anyway, in Israel?
New York. You?
Avatar of doronb

ASKER

North Bay, Ontario.  Ani Po Biglal Ishti, remember that play? ;)
Ken, mai'vin.

Now, how would that decoder change for an Israeli keyboard?  Answer: I don't thin you could, not enough non-Roman charcaters.
Avatar of doronb

ASKER

Actually, the decoder doesn't care about Hebrew or English or any other language since if there was a message to encode which would go beyond the English characters, I'd simply encode it as a byte-stream.

The idea behind this encoder is to be able to take any byte-stream -- basically, any value between 0 and 255 -- and encode it as printable characters in the normal ASCII/Keyboard range.

I know encoders like that exist, Base64 for instance, however, I wanted to:

1) Write one myself.
2) Write one that produced more compact results.
3) Write one that produced different results each time you encoded the same data.

I think I got all three "wants", the question of who needs this, now that's a different issue ;)
Understood... you just have an index of 256 characters that "happens" to be somewhat aligned with a standard keyboard (NA English).  If it was a Hebrew keyboard, your algorithm does not change, and you MIGHT have used a different set of characters and ordering in your table.  Put another way, if your table now begins ~1!, nothing prevents you from deciding that the order should be !1~ instead, or dropping the one in favor of some other chavater you don't currently use.  That's all I'm saying.
Avatar of doronb

ASKER

Yes, however, the idea was to encode a binary byte-stream as an all-ascii text-block, so I had to stick to conventional English characters...
Okay lemme try to decrypt it this weekend. It looks somewhat more random now. What I know so far is that you still use the same header and the repetitions are handled the same way. Groups of identical characters are also identical in the cipher text, and every plain text character seems to have at most 4 different encodings in the cipher text. My first guess would be that you stopped using the header characters only as a marker and began using their values as well. There's something about a factor of 4 as well ... dunno.
Avatar of doronb

ASKER

/me keeps his mouth shut this time!!!! >;)
Then you might have to wait more than 3 months this time, cause I have no idea at this moment (no one else seems to be interested). There are a lot of funny symmetries in the encrypted text. For example, if I look at every plain text characters and its encoding I get this:

(plain text character: positions of the encoded characters in your qwerty charset)  

0: 13 16 23 33
1: 12 17 22 32
2: 11 14 25 31
3: 10 15 24 30
4: 9 20 27 37
5: 8 21 26 36
6: 7 18 29 35
...

Weird, weird. Btw, you should think of it as a riddle. If you just want to encrypt data in a way _I_ couldn't decrypt anymore just XOR it by the output of a pseudo random number generator and store the seed somewhere in the encrypted text. If you keep posting small encoded blocks and hide the encoder on your harddisk no one here would get it, I think.
Avatar of doronb

ASKER

Waiting more than 3 months is fine by me >;)

The idea after all IS to make this encoding a little more than a simple substitute-algo...
I still think it's not enough data. Maybe you should at least post another encrypted version of the "old" jpeg.
Avatar of doronb

ASKER

Ok, here it is, the same JPEG image as the first one:

{`|m{O`@|{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sg.SjWqa"aqjPa&auj
(a6makj0gpcj*jqHa<[aya`aLjS;j}a8a4j)j-K_a7682,5_#*j(a`jpj*a:UjKjTaNjo>+ij'taDza}
apaRj-jDL6jlavaLfagjsa.j2aGj{_aAz7._#`a`q4afj!aVaglfRjGa8a$Dfa>\jljga"j;jIqa"aZa
!q`uaKjuaZPa|q_aZBfG@U_jyj*j8agnz]8jE[j*~aem_jxTP:_aoa]Sa(a~jz{p2GOjCaoaLnj'{j*a
8)@j:SG(j{FaAjUbjA]jqLaw/a%aQj-a&aJxjGj0j6}jCjk7[awa*mj~jqa!a]wj#dj"adzjAjXj"MPj
3$j]/_a6QtSkNY(_jejka@<a/askaga=j{xRawTa?Ja`j=a[\j7aWj'j+3aUj#E$_aY=F&_ju34\"jFj
'8v_jk5*p_YaYatjzjra=|_jre0t_LjSaGaP
Avatar of doronb

ASKER

Also, just to have some fun, here's the text "QwertyEncoding is better than Base64 any day!!", without the "" of course, repeated 10 times:

mfp$H9-.qrSX&5)v!~BvE"(lqq!12q&9XvY9>4B:2^4525#5@@

`cma\)$0)QI82^5$&@v$0L8@))#rK)6^8kt^(3<?K17)K@!)kk

lxe'h&`<=~RX&_~b1r:br/#K==W_#=82XvF2,$bN#^-w#4+w33

k`vug=04rqAw$8(W34.W+K)*rr3@<r$=wcT=#&.L<%&8<818,,

ynawo+2@^_u+q~@E_$lE5V!9^^%(>^3`+?[`2W/<>=`=>e&=..

pgtqT8*!2Ear(48=E`,=!Z-02213N2&)rnU)1)NlN*$^N03^nn

sfaxt*25#Ey-8$@*W~l*`"!W##!(/#7`-My`%-n</94=/_#=??

exv"A&(n*~aC3_9c%r.c-/0'**W21*8_C;F_N`bK12-&1~+&!!

rv`eu13=#8i69q@^W9K^1.!~##0('#R16mS1_=K,'0+q'_=q::

qor"t=_n@-fv9`-CR4mC1B8Z@@5`1@#(vN](N0?z18~%1)7%!!

Each line is its own text block.
Doron, is this an intellectual exercise?  Or does this have some real-world purpose?
Avatar of doronb

ASKER

Bit of both really.
That is the answer of a cipher.
Avatar of doronb

ASKER

LOL :)
Avatar of doronb

ASKER

So... any progress, or should I just close this question?
Well, I still want to work on it, but right now I can't.
Avatar of doronb

ASKER

Whenever you can is alright, just help me keep the question open :)
Avatar of doronb

ASKER

I would actually like to keep the question open so that synque or qwaletee can decrypt the text-blocks.
Yep, I'm still here as well. I think I'll try it again this weekend. Just didn't want to do the second challenge right after spending a couple of hours on the 'old' question. Can't promise a solution though :P
Avatar of doronb

ASKER

That's alright.. I just thought I'd stop "nagging" ;)
Avatar of Mark Brady
Keep it open I'll have a go over the next few days !


Mark
Avatar of doronb

ASKER

Basically, any comment posted will keep the question open until an answer's given :)
Avatar of doronb

ASKER

By the way, elvin66/Mark, I suggest you read through the previous question at [ https://www.experts-exchange.com/questions/21314301/Who's-attacking-you-and-what-with.html ] to catch up on what's been going on... :)
>>Basically, any comment posted will keep the question open until an answer's given :)
Not exactly.. if there is no new information for a while and just "Keep it open", the Cleanup Admin takes an action and just start the closings. This way ensuring that noone is just trying to keep a question too long and thus missusing the point ssystem.
Avatar of doronb

ASKER

I trust you understand, Venabili, that I'm not keeping this question open to spite anyone, or missuse the point system.
Noone said anything on this question - I was explaining practices :)
Avatar of doronb

ASKER

Ah... :o :)
Avatar of doronb

ASKER

So... have we lost all hope?
I just want confirmation for something ... I can decode the three versions of the first image, and the 10 versions of the text string, but when i decode the second image, i get a partly corrupted image : the top 1/3 of the image is fine, but after that, the colors get weird ... can you confirm this, or should i look for a bug in my decoder ?
My mistake ... it decodes fine :) Was a copy-paste problem lol
So, here's my code that breaks your encoding :) It's not very clean code, as it's the result of a lot of tweaking and changing along the way, and i can't be bothered to clean it up atm lol.

---- code block start ----

#include "stdio.h"

char enc[2048] = { 0 };
unsigned char dec[2048] = { 0 };

char alphabet[94 + 1] = "`~1!2@3#4$5%6^7&8*9(0)-_=+qQwWeErRtTyYuUiIoOpP[{]}\\|aAsSdDfFgGhHjJkKlL;:\'\"zZxXcCvVbBnNmM,<.>/?";

char alf[90 + 1];

int find_in_alf(char c) {
  int i;
  for (i = 0; i < 90; i++) {
    if (alf[i] == c)
      return i;
  }
  return -1;
}

int decode(int length) {
  int i = 0, j = 0, k = 0;
  char prev = '\0';
  int prev_base = 0;
 
  int base = 0;
  unsigned char block = 0;
 
  j = 0;
  for (i = 0; i < 94; i++) {
    if ((alphabet[i] != enc[0])&&(alphabet[i] != enc[1])&&(alphabet[i] != enc[2])&&(alphabet[i] != enc[3])) {
      alf[j++] = alphabet[i];
    }
  }
  alf[i] = '\0';

  j = 0;
  k = 0;
  prev = '\0';
  prev_base = 0;
  base = 0;
  block = 0;
  for (i = 4; i < length; i++) {
    if (enc[i] == enc[0]) {
      base = 90;
    }
    else if (enc[i] == enc[1]) {
      base = 180;
    }
    else if (enc[i] == enc[2]) {
      base = 0;
      block ^= 1;
      prev = '\0';
    }
    else if (enc[i] == enc[3]) {
      char number[16];
      int count;
      int l = 0;
      while (enc[++i] != enc[3])
        number[l++] = enc[i];
      number[l] = '\0';
      sscanf(number, "%x", &count);
      dec[k++] = (unsigned char) ((unsigned char) find_in_alf(enc[++i]) + base)^((unsigned char) enc[j]);
      j = (j + 1) % 4;
      prev = enc[i];
      //prev_base = base;
      for (; count > 1; count--, k++) {
        dec[k] = dec[k - 1];
      }
      if (!block) {
        base = 0;
      }
    }
    else {
      if ((enc[i] == prev) && (base == prev_base)) {
        dec[k] = dec[k - 1];
      }
      else {
        dec[k] = (unsigned char) ((unsigned char) find_in_alf(enc[i]) + base)^((unsigned char) enc[j]);
        j = (j + 1) % 4;
        prev = enc[i];
        prev_base = base;
      }
      if (!block) {
        base = 0;
      }
      k++;
    }
  }

  return k;
}

int main(int argc, char **argv) {
  FILE *in;
  FILE *out;
  int length = 0;

  if (argc != 3) {
    fprintf(stdout, "provide input and output files :\n  %s <inputfile> <outputfile>\n", argv[0]);
    return 1;
  }
  in = fopen(argv[1], "rb");
  length = fread(enc, 1, 2047, in);
  if (length <= 0) {
    fprintf(stderr, "ERROR : could not read from file\n");
    return 1;
  }
  fclose(in);
 
  length = decode(length);
  fprintf(stdout, "decoded %d bytes !\n", length);
 
  out = fopen(argv[2], "wb");
  if (fwrite(dec, 1, length, out) <= 0) {
    fprintf(stderr, "ERROR : could not write to file\n");
    return 1;
  }
  fclose(out);
  return 0;
}

---- code block end ----

It took me a few hours to break ... but that was largely because the original image (of the first text block) was available. That way i could easily work my way back to reverse-engineer your encryption scheme.

Anyway : if you have any further questions, just let me know :)
Avatar of doronb

ASKER

I wonder how long it'd've taken you if you had to start from scratch.  Anyway... I'm gonna close this question soon, after I ask someone to check your C code (I don't even have a C compiler on my machine.. sorry).
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doronb

ASKER

The image is the right one... but I can only get back to this after the 16th of August as I'm currently away from my computer and codebase and other dev-tools.
Take your time :)
Avatar of doronb

ASKER

I'm back in Canada now and will try to find the time to split the points fairly. :)
Avatar of doronb

ASKER

Thanks to everyone who participated and helped.  I gave full points to Infinity08 since the riddle was completely solved.

Qwaletee and Synque, sorry about not giving you guys anything this time.