10
2
Fork 0
has-writeup/aaaa/seeing-stars
Hazel Levine 0552264c78 fix seeing stars, fix fonts 2020-05-26 11:35:21 -04:00
..
README.md fix seeing stars, fix fonts 2020-05-26 11:35:21 -04:00
seeing-stars.py set up include filter correctly; fix issues 2020-05-26 06:33:02 -04:00

README.md

Seeing Stars

Category: Astronomy, Astrophysics, Astrometry, Astrodynamics, AAAA Points (final): 23 Solves: 213

Here is the output from a CCD Camera from a star tracker, identify as many stars as you can! (in image reference coordinates) Note: The camera prints pixels in the following order (x,y): (0,0), (1,0), (2,0)... (0,1), (1,1), (2,1)…

Note that top left corner is (0,0)

Write-up

by hazel (arcetera)

The CCD image given by the netcat is a 128x128 matrix of comma-separated values.

We read the data into a NumPy array, and pass that into OpenCV.

data = []
for line in rawdat.strip().split('\n'):
    data.append([int(x) for x in line.split(',')])

x = np.array(data, dtype='uint8').T

im = x

We then run a filter on the data, only grabbing values in [127, 255] to filter out data that is obviously not stars. We then run two dilates on the image post-filter, because otherwise we end up with a division by zero on centroid finding later for M["m00"]. Finally, we grabbed the contour of every object visible in the image.

ret, thresh = cv2.threshold(im.copy(), 127, 255, 0)
kernel = np.ones((5, 5), np.uint8)
dilated = cv2.dilate(thresh.copy(), kernel, iterations = 2)

cnts, hier = cv2.findContours(dilated.copy(), \
                              cv2.RETR_TREE, \
                              cv2.CHAIN_APPROX_NONE)

For each contour, we grabbed its centroid:

solve = ''
for c in cnts:
    M = cv2.moments(c)
    cX = int(M["m10"] / M["m00"])
    cY = int(M["m01"] / M["m00"])

    solve += (str(cX) + "," + str(cY)+'\n')
return solve

We then automated this entire process using pwnlib to connect to the server and read the data.

Full code

Run it, and the flag should be printed as a bytestring.

Resources and other writeups