FYI: My "UNIX only" solution. All you need is wget and ImageMagick.
Just want to ask how you solved this challenge. I think my way of "converting" the image is a bit unusual,
but I could not imagine a faster and shorter way (even with perl):
#!/usr/bin/env python
import Image
img = Image.open("stars.png")
width, height = img.size
print "".join([chr(int("".join(["1" if 200 < min(img.getpixel((x,y))) else "0" for x in xrange(7, width, 16)]), 2)) for y in xrange(7, height, 16)])
This is a good example of how to write dirty code in Python! I was told that this is impossible. Or did you just remove the indentation to confuse your audience?
I didn't know that Python supports reading (and probably writing) of image files...
I don't know how to convert the image into data which I need to use, so I just keep refreshing the page and wait for a short one, and type really fast, then copy and paste the answer...
@megabreit re PeterS: that last line is "valid", it didn't just have indentation removed. It just uses the functional paradigm of python. Once you use functional programming (usually from another language) you start to use it all the time in python
Public Class Form1
Private Sub Image_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Image.Click
Dim file_name As String = Application.ExecutablePath
file_name = "C:\Users\Craig\Desktop\Challenges\hackerorg\stars\stars.php.png"
Dim row As Integer
Dim col As Integer
Dim currentColor As Color
Dim binString As String = ""
Dim outputString As String = ""
' Load the picture into a Bitmap.
Dim bm As New Bitmap(file_name)
' Display the results.
picImage.Image = bm
PicImage.SizeMode = PictureBoxSizeMode.AutoSize
'start at 8, add 16 for each row down
'same from left
For row = 8 To bm.Height - 8 Step 16
For col = 8 To bm.Width - 8 Step 16
currentColor = bm.GetPixel(col, row)
If currentColor.ToArgb = -2125524 Then
binString = binString & 0
Else
binString = binString & 1
End If
Next
outputString = outputString & Chr(BinToInt(binString))
binString = ""
Next
Outbox.Text = outputString
End Sub
Function BinToInt(ByVal BinaryNumber As String)
Dim Length As Integer
Dim TempValue As Integer
'Get the length of the binary string
Length = Len(BinaryNumber)
'Convert each binary digit to its corresponding integer value
'and add the value to the previous sum
'The string is parsed from the right (LSB - Least Significant Bit)
'to the left (MSB - Most Significant Bit)
For x = 1 To Length
TempValue = TempValue + Val(Mid(BinaryNumber, Length - x + 1, 1)) * 2 ^ (x - 1)
Next
BinToInt = TempValue
End Function
End Class
I did it just like everyone else, I'm just wondering though, would it be possible to stop the timer?
I managed to extend and even stop the timer using javascript (just pasted javascript code right into the url using javascript:) but even if i solved it after the 20 seconds, it said it was too late. I'm guessing the php has a timer in it too, or how else would it know if I extended the time?
it wouldn't be a timer as such but a timestamp from the last time you requested the page or some part of the page (such as the image which appears to only change after requesting the challenge page), if the time you submitted your answer is greater than timestamp+20 then you get a rejection message, this method doesn't really offer itself up for exploitation unless your willing to wait until 03:14:07 19/01/2038 for the timestamp to overflow (guessing that there is no timestamp >=timestamp && timestamp <= timestamp + 20)