Qbasicnews.com

QbasicNews.Com => Challenges => Topic started by: Dio on July 30, 2006, 07:19:29 AM



Title: decrypt and win $100
Post by: Dio on July 30, 2006, 07:19:29 AM
i knew that would get your attention.


using my picture encryption thing  (http://forum.qbasicnews.com/viewtopic.php?t=11982) i scrambled a picture that had text in it.

here is the picture:

(http://fileanchor.com/48909-r.bmp)


i'm even giving you people the source code and i still think you can't do it. and putting 100 dollars on the line.*

* i may or may not send you 100 (hundred) dollars. you must post (PM) your source to qualify for receiving the 100 dollars. however even if you do meet the criteria to win the $100, i may not send you $100. based on how cool your entry is. my judgment is arbitrary and final. contest never ends unless otherwise noted my me. by posting an entry, you acknowledge the rules above. Please ignore spelling errors and what not. look, just don't sue me!


Title: decrypt and win $100
Post by: Anonymous on July 30, 2006, 11:57:06 AM
Ur code crashes out of the box. the one where u say "yay success i got it"

edit: needed "option dynamic" at top, those arrays on top are too large to fit into the stack (internal compiler changes in newer versions of fb.)


You realize this is an irreversible encryption, right =)

edit2: program still crashes.

edit3: making it dim shared, removing option dynamic and removing those other 2 arrays makes it work. looks klike that's an fb bug, i'll report that on fb forums asap.

and btw i saw the randomize timer, but now i see it in fact is reversible. i'll try cracking it...


Title: decrypt and win $100
Post by: Anonymous on July 30, 2006, 01:41:07 PM
btw, if you cut this image out of a larger image you encrypted using that algo it's irreversible, so, did you? =p (brutefocre cracking prog running in background)


Title: decrypt and win $100
Post by: Anonymous on July 30, 2006, 09:04:23 PM
Code:
option explicit
#include "crt.bi"
const as integer sz = 161 * 11 * 4


'sub dio_DeCrypt( srcImg as any ptr, dstPtr as any ptr, seed as integer )
#macro dio_DeCrypt( srcImg, dstPtr, seed )

'  if srcImg = 0 then exit sub
   
'  static as integer imgWidth, imgHeight, i, x, y, pa, pb, rx, ry, xo, yo
'  static as integer ptr pix, imgData2
 
'  imgWidth = cptr( ushort ptr, srcImg )[0] shr 3
'  imgHeight = cptr( ushort ptr, srcImg )[1]

 
  memcpy( dstPtr + 4, srcImg + 4, ( sz ) )
'  memcpy( dstPtr + 4, srcImg + 4, ( imgWidth * imgHeight ) * len( integer ) )

  imgData2 = cptr( any ptr, VarPtr( cptr( ushort ptr, dstPtr )[2] ) )
 
  randomize seed
 
'  dim as integer pic( sz * 8 )
 
  i = 0
  for y = 0 to 11 - 1

    for x = 0 to 161 - 1

      pic( i ) = int( rnd * ( 161 - 1 ) )
      i = i + 1

      pic( i ) = int( rnd * ( 11 - 1 ) )
      i = i + 1

    next  

  next
 
  pix = varptr( imgData2[(11 * 161) - 1] )
  for y = 11 - 1 to 0 step -1
   
'    yo = (y * imgWidth)
    for x = 161 - 1 to 0 step -1
 
      i = i - 1
      ry = pic(i)

      i = i - 1
      rx = pic(i)
     
      xo = (ry * 161)+ rx
     
     
'      pa = imgData2[yo + x]
      pa = *pix
      pb = imgData2[xo]

      imgData2[xo] = pa
      *pix = pb
'      imgData2[yo + x] = pb


      pix -= 1

    next    
   
  next
 
#endmacro
'end sub


#macro check_topline( __COLOR__ )
  if j then
  for l = 0 to 160
    if lc[l] <> __COLOR__ then
      j = 0
     
      exit for
    end if
  next
end if
#endmacro

#macro check_rightline( __COLOR__ )
  if j then
  for l = 0 to 10
    if lc[m + 160] <> __COLOR__ then
      j = 0
     
      exit for
    end if
    m += 161
  next
end if
#endmacro

#macro check_bottomline( __COLOR__ )
  if j then
  for l = 0 to 160
    if lc[l + 1600] <> __COLOR__ then
      j = 0
     
      exit for
    end if
  next
  end if
#endmacro

#macro check_leftline( __COLOR__ )
  if j then
  for l = 0 to 10
    if lc[m] <> __COLOR__ then
      j = 0
     
      exit for
    end if
    m += 161
  next
end if
#endmacro

#macro check_alllines( __COLOR__ )


  check_topline( __COLOR__ )
  check_rightline( __COLOR__ )
  check_bottomline( __COLOR__ )
  check_leftline( __COLOR__ )
 

#endmacro

screen 14, 32

dim as any ptr img1, img2
dim as integer ptr lc

img1 = imagecreate( 161, 11 )
img2 = imagecreate( 161, 11 )

bload "10dollarch.bmp", img1
'bload "newimg.bmp", img1

lc = cptr( any ptr, varptr( cptr( ushort ptr, img2 )[2] ) )
dim as uinteger iii, j, k, l, m, ddd

dim as integer imgWidth, imgHeight, i, x, y, pa, pb, rx, ry, xo, yo
dim as integer ptr pix, imgData2

dim as integer pic( sz * 8 )



if command( 1 ) <> "" then
ddd = val( command( 1 ) )

end if
 


'for iii = ( 2 ^ 32 ) - 1 to 0 step -1
'for iii = 170000 to ( 2 ^ 32 ) - 1
for iii = ddd to ( 2 ^ 32 ) - 1

  dio_DeCrypt( img1, img2, iii )
 
  j = -1
  k = lc[0]
  m = 0
 
'  check_alllines( rgb( 255, 255, 255 ) )
  check_topline( k )
  k = lc[160]
  m = 0
  check_rightline( k )
  k = lc[1600]
  m = 0
  check_bottomline( k )
  k = lc[0]
  m = 0
  check_leftline( k )


'  rgb( 255, 255, 255 )
'  for l = 0 to 10
'    if lc[m] <> rgb( 255, 255, 255 ) then
'      j = 0
'      
'      exit for
'    end if
'    m += 161
'  next
  skip:
  if j = -1 then
    ? "heh: " & iii
    bsave "dioresult.bmp", img2
    sleep
   
  end if
 
  if multikey( &h2F ) then
    put( 0, 0 ), img2, pset
    locate 20
    ? iii
   
  end if
  if multikey( 1 ) then
    end
   
  end if
 
     
 
next






verdict: after about 100 million iterations between a few computers, i think it probrbaly isn't brute force crackable =|


Title: decrypt and win $100
Post by: Dio on July 31, 2006, 07:36:14 AM
Quote from: "cha0s"
Ur code crashes out of the box. the one where u say "yay success i got it"

edit: needed "option dynamic" at top, those arrays on top are too large to fit into the stack (internal compiler changes in newer versions of fb.)


edit2: program still crashes.

edit3: making it dim shared, removing option dynamic and removing those other 2 arrays makes it work. looks klike that's an fb bug, i'll report that on fb forums asap.


ok. i admit. i suck at programming. Besides, i improved on the code since then.

Quote from: "cha0s"
btw, if you cut this image out of a larger image you encrypted using that algo it's irreversible, so, did you? =p (brutefocre cracking prog running in background)


don't worry. i did good   :^_^:

Quote from: "cha0s"

verdict: after about 100 million iterations between a few computers, i think it probrbaly isn't brute force crackable =|


and that image is 11X161. with plain white text. I figured you could make a program to search for letters. But can you imagine 1000X700 images that could be anything from B&W satellite photos to other shit you dont want grandma to see. And could you imagine 100 million iterations at 1000X700? And what if the FBI used the source code to try and decrypt it but I kept re-encrypting the same image a thousand times or a million times? Should they have their computer (super in orientation no doubt) go thru the same image and the same pass re-decrypting a million times to be sure? What if I changed the pass 500,000 iterations into it?


How ever, it may only work for BMPs though. JPEG compresses and screws with the pixels


Title: decrypt and win $100
Post by: NovaProgramming on July 31, 2006, 01:17:48 PM
So does that mean that you can decrypt that image into whatever it's supposed to be, but you're just waiting to see if we can do it?  Because that's pretty sweet  :wtnod2:


Title: decrypt and win $100
Post by: Dio on July 31, 2006, 03:09:23 PM
i guess.


Title: decrypt and win $100
Post by: NovaProgramming on July 31, 2006, 04:44:13 PM
hey all I know is that I couldn't program that cuz I stink at that kind of stuff.   That's why I didn't try to decrypt it.  my "skillz" are n00bish at best.  But I can still outprogram my brother who is a Computer Science major :).


Title: decrypt and win $100
Post by: Dio on July 31, 2006, 08:07:56 PM
Quote from: "NovaProgramming"
my "skillz" are n00bish at best.  But I can still outprogram my brother who is a Computer Science major :).


i would have an aneurysm trying to program "Ballsbreaker"   :wow:  :wow:  :wow:


Title: decrypt and win $100
Post by: NovaProgramming on August 01, 2006, 01:35:41 AM
lol Ballsbreaker *2* should be so much better if it ever cools down outside.   I use my laptop for programming and the best atmosphere I find is either in class, while I'm supposed to be listening, or I'm in my bed with the TV on, using my lap for the laptop (ingenius, I know).  But lately, as you all know (all of you in the U.S, at least), it has been extremely hot.  It was a record-breaker here, something like 93 with a heat index of around 106... and it's northern minnesota so it's supposed to be cold :(


Title: decrypt and win $100
Post by: na_th_an on August 01, 2006, 03:18:44 AM
Translate 51C to F :P That was the temperature yesterday at 2PM at my place.

At it doesn't go lower than 34C at night... This is like hell :P

EDIT: I'll do the conversions for you: 122F Max, 93.2F Min.


Title: decrypt and win $100
Post by: NovaProgramming on August 01, 2006, 04:12:19 AM
Yeah, but Mr. President George W. Bush says that there's no such thing as global warming!  And if you can't trust your president, then who the **** can you trust?


Title: decrypt and win $100
Post by: Zap on August 01, 2006, 05:24:15 PM
Our winter was a record-breaker for cold (3-4 months of hard-frozen snow, we usually get a few weeks of the shappy one), and now our summer is a record-breaker for heat  :shifty: Doesnt really get any more silly.

But then again, the "record-breaking" for heat (here) is only since 1975, so I'm not really worried...

EDIT:
Quote from: "nathan"
And it doesn't go lower than 34C at night...


Here we get 31.5C in the day and call it record-breaking  :laughing:


Title: decrypt and win $100
Post by: Deleter on August 01, 2006, 10:22:30 PM
Quote from: "NovaProgramming"
Yeah, but Mr. President George W. Bush says that there's no such thing as global warming!  And if you can't trust your president, then who the **** can you trust?


everyone else?


Title: decrypt and win $100
Post by: NovaProgramming on August 02, 2006, 01:30:50 AM
Quote from: "Deleter"
Quote from: "NovaProgramming"
Yeah, but Mr. President George W. Bush says that there's no such thing as global warming!  And if you can't trust your president, then who the **** can you trust?


everyone else?



I meant to say...

[sarcasm]"If you can't trust your president, then who the **** can you trust?" [/sarcasm]


Title: decrypt and win $100
Post by: Deleter on August 02, 2006, 01:37:33 AM
yeah I knew you werent serious, but I took adavantage of the fact you didn't say you weren't serious. ;)


Title: decrypt and win $100
Post by: NovaProgramming on August 02, 2006, 02:08:33 AM
BAH!  don't do that, you're confusing me again


Title: decrypt and win $100
Post by: Deleter on August 02, 2006, 02:27:23 AM
Quote from: "NovaProgramming"
BAH!  don't do that, you're confusing me again

But does the president trust you?


Title: decrypt and win $100
Post by: Dio on August 02, 2006, 03:39:21 AM
so i guess no one solved it.  :roll:


Title: decrypt and win $100
Post by: Zap on August 02, 2006, 07:03:34 PM
I guess no one cared to spend hours coding to maybe win $100 ;)


Title: decrypt and win $100
Post by: yetifoot on August 03, 2006, 03:46:10 AM
a few people were trying.  It was discussed a bit on the FB IRC channel.  

The technique being used, was a brute force, looking for a complete border around the image.  I used a slightly modified verion, looking for more patchy borders, prepared to take more false negatives.  

However, I, and i guess the others, got bored after i let it run for about 16 hours.  I actually recoded the inner loops of mine in ASM, and it was still very slow going.  I think i was trying about 5-15 thousand numbers per second, when it was at full speed, but most of the time, i couldn't run it this fast because i wanted to use the machine for other stuff.  

Considering though, it needed to try 4 billion combinations, it was going to take too long, and i could not be guarenteed that there would be a border as such to find.

I'd be interested to see the actual image, and know the number pass, to see if what i wrote, would actually have ever cracked it, given the time.

None of use expected you to pay if we did get it, and i don't think it took anyone longer than an hour to write their program.


Title: decrypt and win $100
Post by: Dio on August 03, 2006, 07:06:08 AM
wow. that's alot to process. (no pun intended) where did you say this was being discussed? link?  :D i seldom travel out of QBNF.

well the seed number i used to encrypted it was 10011100110111010001 (just convert to decimal)

immature: yes
arbitrary: you bet
retarded: It's my creed. (retardizm that is)
false: Proud to so say it is.


tell you what. if i post a harder pic, i will guarantee 100. (pesos)


Title: decrypt and win $100
Post by: NovaProgramming on August 03, 2006, 12:15:55 PM
Quote from: "Google.com"
100 Mexican pesos = 9.09901549 U.S. dollars


hmm...


Title: decrypt and win $100
Post by: Dio on August 03, 2006, 07:18:23 PM
10 bucks. better than nothing...


Title: decrypt and win $100
Post by: whitetiger0990 on August 03, 2006, 10:02:43 PM
/me decodes
DAMMIT

The far right side was solid. Cha0s code would have caught it but it didn't work with my version of fb and we thought we already eliminated the numbers below 1mil. *mumbles*


Title: decrypt and win $100
Post by: yetifoot on August 04, 2006, 06:57:19 AM
Have another look, the far right side is not solid, its a gradient, from

RGB(243, 0, 0) - RGB(250, 0, 0)

so the solid border technique won't catch it.

I might have nearly caught it, as i tried re-rendering the original image down to 16 colors, but that yielded too many false positives to check.

Well done dio, i doubt anyone could break it, without some kind of character recognition, which would have made it so slow, as to be near impossible, without a massive effort of many machines.


Title: decrypt and win $100
Post by: Dio on August 04, 2006, 07:21:40 AM
here was the image i croped it from.

SCREENRES 1024,768,32,2,1
r =255
FOR ww = 0 TO 1000 STEP 1
  r = r - 1
  CIRCLE (1024/2,768/2),ww,RGB(r,g,b)
  CIRCLE (1024/2+1,768/2+1),ww,RGB(r,g,b)
  CIRCLE (1024/2+2,768/2+1),ww,RGB(r,g,b)
NEXT
SLEEP

with the text being at the top left hand corner. (1,1)


Title: decrypt and win $100
Post by: Dio on August 05, 2006, 04:57:56 AM
Quote from: "yetifoot"
a few people were trying.  It was discussed a bit on the FB IRC channel.


Quote from: "Dio"
where did you say this was being discussed? link?


Title: decrypt and win $100
Post by: yetifoot on August 05, 2006, 06:18:38 AM
it was on the FB IRC channel, so all the text of conversations is gone....

the actual channel is

#freebasic

on

irc.freenode.net:6667


Title: decrypt and win $100
Post by: anarky on August 05, 2006, 08:50:54 AM
I didn't even bother.

As for temperature, think 14-20C daily, and overnight, bordering on zero or a bit below.

And it's perpetually always raining and I hate it.


Title: decrypt and win $100
Post by: Dio on August 06, 2006, 04:47:31 AM
Quote from: "yetifoot"
it was on the FB IRC channel, so all the text of conversations is gone....


dammit. i knew it. i even looked around for a chat room. i think i found it. but no one was there or somthin'.

completely unrelated: does anyone know a good tut for uploading BMP into fb? thanks


Title: decrypt and win $100
Post by: whitetiger0990 on August 06, 2006, 02:11:15 PM
Quote from: "Dio"
completely unrelated: does anyone know a good tut for uploading BMP into fb? thanks

BLOAD
http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgBload
Scroll down a bit.


Title: decrypt and win $100
Post by: Dio on August 07, 2006, 06:54:36 AM
thanks. but you must keep this in mind:

-------
-------
---o--- <- average
-------
-------
-------
-------
---o---  <- me
---o---  <- mongoloid.
--------


i'm not kidding you guys when i say i suck at programming!  :)
when i learn a new tid-bit of info i scourer away and fiddle around with it like some sort of mad scientist. ok so where do i start?

'Load a graphic to current work page
Screen 18, 32
Cls
Bload "picture.bmp" where do i keep the picture? what file? what if the picture came in a download?
'Load a 48x48 bitmap into an array
Screen 18, 32
Dim garray(4 * (48 * 48 ) + 4) As Byte why *4? and + 4? and why as byte?
Bload "picture.bmp", @garray(0) what's with the @ and the (0)
Put (10,10),garray(0)



see, the thing about these tuts is that the author just assumes that the reader has some prior knowledge and is not a dumbass.


Title: decrypt and win $100
Post by: red_Marvin on August 07, 2006, 09:12:20 AM
Explanation to 4*(w*h)+4:

"4*" is because in 32 bit, each pixel takes 4 bytes (rgba I guess) and
"+4" is to make room for storing w and h in the array so it get's read correctly. (I guess it's stored as two two byte integers)


Title: decrypt and win $100
Post by: yetifoot on August 07, 2006, 09:15:53 AM
Quote
Bload "picture.bmp" where do i keep the picture? what file? what if the picture came in a download?

This is similar to Open in QB, it looks for the file in the current directory, which will normally be the same as the program.

Quote
Dim garray(4 * (48 * 48 ) + 4) As Byte why *4? and + 4? and why as byte?


*4 Is because each pixel takes 4 bytes to store in a 32bit mode, as red, green, blue and alpha bytes.
+4 is because there is a header on GET/PUT arrays of 4 bytes, that stores the images width, height and bytes per pixel.

Quote
Bload "picture.bmp", @garray(0) what's with the @ and the (0)


@garray(0) means the address of garray(0), this is basically telling it to bload to the start of garray.


Title: decrypt and win $100
Post by: Dio on August 08, 2006, 12:59:16 AM
so the 4* and the +4 are always the same?

i tryed this:

Code:
Cls
Bload "picture.bmp"

'Load a 48x48 bitmap into an array
Screenres 1024,768,32,2,1
Dim garray(4 * (50 * 50) + 4) As Byte
Bload "picture.bmp", @garray(0)
Put (10,10),garray(0)
sleep


i put a picture called "picture.bmp" which is 50 * 50 into C:\FreeBASIC
all i got was a black screen.


Title: decrypt and win $100
Post by: Dio on August 08, 2006, 01:02:35 AM
n/m it worked. i renamed "picture.bmp" to "picture"

silly me.  :roll:


Title: decrypt and win $100
Post by: Dio on August 08, 2006, 04:36:49 AM
ok it's not working again. and all i did was save the bas of it

Code:
'Load a graphic to current work page
'Screenres 1024,768,32,2,1
Cls
Bload "picture.bmp"

'Load a 48x48 bitmap into an array
Screenres 1024,768,32,2,1
Dim garray(4 * (32 * 32) + 4) As Byte
Bload "picture.bmp", @garray(0)
Put (0,0),garray(0)
sleep
for y = 0 to 767
for x = 0 to 1023
  a = point(x,y)
  r = int(a/65536)
  a = a - r * 65536s
  g = int(a/256)
  a = a - g * 256
  b = a
  a = int((r+b+g)/3)
  pset (x,y),rgb(0,g,0)
next
next
sleep


i made sure and x & y were correct. and the picture was called "picture" and in C:\FreeBASIC

wtf happened?


Title: decrypt and win $100
Post by: Dio on August 08, 2006, 04:40:51 AM
n/m

(4 post in a row?)


Title: decrypt and win $100
Post by: anarky on August 08, 2006, 07:40:29 AM
On this, can I use the same loading technique to store two or more images in the same array such as follows:

BLOAD image.ext to array$(0)
BLOAD image2.ext to array$(4*(640*480)+4)

? possible?


Title: decrypt and win $100
Post by: Dio on August 09, 2006, 03:42:29 AM
how do i get a screen shot into fb? i'm making a screen saver (btw im gunna need to know how to do that) i want to try to avoid using clipboard.


Title: decrypt and win $100
Post by: whitetiger0990 on August 09, 2006, 02:34:53 PM
Quote from: "Dio"
how do i get a screen shot into fb? i'm making a screen saver (btw im gunna need to know how to do that) i want to try to avoid using clipboard.


http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgBsave


Title: decrypt and win $100
Post by: red_Marvin on August 09, 2006, 03:36:24 PM
I think he meant a screenshot of the desktop to use in the program...

Anyway the, "4*" is only valid on 32 bit modes but I think it's always "+4"...